<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 @click="getList" slot="reference" size="medium" type="primary" style="margin-left: 10px">查询</el-button>
              <el-button @click="visible=false,$refs['addLong'].isShow = true,$refs['addLong'].type = 'add'" size="medium" type="primary" style="margin-left: 10px">新增</el-button>


            </div>
          </slot>
        </lx-header>
      </div>

    <xy-table
      :table-item="table"
      :list="data"
      :total="total"
      @pageSizeChange="e => {select.rows = e;select.page = 1;getList()}"
      @pageIndexChange="e => {select.page = e;getList()}"
      @delete="deleteStudy"
      @editor="editorStudy">
    </xy-table>
    <addLong ref="addLong" @refresh="getList"></addLong>
  </div>
</template>

<script>

import {getList} from '@/api/visit/record.js'
import addLong from '@/views/visit/component/addLong'
export default {
  components: {
    addLong
  },
  data() {
    return {
      select:{
        page:1,
        rows:10,
        keyword:""
      },
      total:0,
      data:[],
      table:[
        {
          label:'姓名',
          sortable:false,
          prop:'start_time',
          fixed:"left",
          align:"left"
        },
        {
          label:'证件类型',
          sortable:false,
          prop:'end_time',
        },
        {
          label:'证件号',
          sortable:false,
          prop:'end_time',
        },
        {
          label:'状态',
          sortable:false,
          prop:'end_time',
        },
        {
          label:'单位名称',
          sortable:false,
          prop:'end_time',
        },
        {
          label:'手机号',
          sortable:false,
          prop:'end_time',
        },
        {
          label:'开始时间',
          sortable:false,
          prop:'end_time',
        },
        {
          label:'结束时间',
          sortable:false,
          prop:'end_time',
        },
        {
          label:'创建时间',
          sortable:false,
          prop:'end_time',
        },
        {
          label:'创建人',
          sortable:false,
          prop:'end_time',
        }
      ]
    }
  },
  computed: {},
  mounted() {
    // this.getList()
  },
  methods: {
    async getList(){
      let res = await getList(this.select)
      console.log(res)
      this.data = res.data
      this.total = res.total
    },
    deleteStudy(row){
      destroy({id:row.id}).then(res => {
        this.$successMessage('destroy','长期访客')
        this.getList()
      })
    },
    editorStudy(row){
      this.$refs['addLong'].id = row.id
      this.$refs['addLong'].type = 'editor'
      this.$refs['addLong'].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>
