<template>
    <div style="padding: 0 20px">
      <div ref="lxHeader">
        <lx-header icon="md-apps" text="访客区域设置" style="margin-bottom: 10px; border: 0px; margin-top: 15px">
          <slot>
            <div style="display: flex;align-items: center;">
              <div style="margin-right: 10px;">关键词</div>

              <el-input size="mini" placeholder="请输入关键词" v-model="select.keyword" style="width: 160px;margin-right: 10px;"></el-input>

              <el-button size="medium" type="primary" @click="$refs['addVisitor'].isShow = true,$refs['addVisitor'].type = 'add'" style="margin-left: 10px">新增</el-button>
            </div>
          </slot>
        </lx-header>
      </div>

    <xy-table
      :table-item="table"
      :list="data"
      :total="total"
      :auths="['edit','delete']"
      @pageSizeChange="e => {select.rows = e;select.page = 1;getList()}"
      @pageIndexChange="e => {select.page = e;getList()}"
      @delete="deleteRow"
      @editor="editorRow">
    </xy-table>
    <addVisitor ref="addVisitor" @refresh="getList"></addVisitor>
  </div>
</template>

<script>

import {getList,destroy} from '@/api/parameter/visitor.js'
import addVisitor from '@/views/parameter/component/addVisitor'
export default {
  components: {
    addVisitor
  },
  data() {
    return {
      select:{
        page:1,
        rows:10
      },
      total:0,
      data:[],
      table:[
        {
          label:'序号',
          type:"index"
        },
        {
          label:'区域名称',
          sortable:false,
          prop:'name'
        },
        // {
        //   label:'审核类型',
        //   sortable:false,
        //   prop:'end_time',
        // },
        // {
        //   label:'备注',
        //   sortable:false,
        //   prop:'end_time',
        // },
        {
          label:'创建时间',
          sortable:false,
          prop:'created_at',
          width:180
        },
        {
          label:'创建人',
          sortable:false,
          prop:'admin',
                   width:180
        }
      ]
    }
  },
  computed: {},
  mounted() {
    this.getList()
  },
  methods: {
    async getList(){
      let res = await getList(this.select)
      console.log(res)
      this.data = res.data
      this.total = res.total
    },
    deleteRow(row){
      destroy({id:row.id}).then(res => {
        this.$successMessage('destroy','访客区域')
        this.getList()
      })
    },
    editorRow(row){
      this.$refs['addVisitor'].id = row.id
      this.$refs['addVisitor'].type = 'editor'
      this.$refs['addVisitor'].isShow = true
    }
  },
}
</script>

<style scoped lang="scss">
//::v-deep .el-button + .el-button{
//  margin-left: 0 !important;
//}
::v-deep .el-button{
  padding: 5px 8px !important;
}
</style>
