<template>
  <app-container>
    <normal-table :data="list" :head="head" :query="listQuery" :total="total" :columns="columns" :list-loading="listLoading" @change="changePage">
      <template slot="btns">
        <el-button size="small" class="edit_btn">添加</el-button>
        <el-button size="small" class="edit_btn">修改</el-button>
        <el-button size="small" class="edit_btn">删除</el-button>
      </template>
      <template slot="columns">
        <el-table-column label="操作" align="center" width="160">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click.stop="goDetail(scope.row)">详情</el-button>
            <el-button type="text" size="small" @click.stop="edit(scope.row)">编辑</el-button>
            <el-button type="text" size="small" @click.stop="registerIris(scope.row)">采集</el-button>
          </template>
        </el-table-column>
      </template>
    </normal-table>
  </app-container>
</template>

<script>
import NormalTable from '@/components/NomalTable'
import AppContainer from '@/components/layout/AppContainer'
export default {
  name: 'TableExample',
  components: { AppContainer, NormalTable },
  data() {
    return {
      listQuery: {
        name: '', // 姓名
        sex: '', // 性别
        nation: '', // 民族
        collReason: '', // 采集原因
        cardType: '', // 证件类型
        idCardNo: '', // 证件号码
        personTag: '', // 人员标签
        startTime: '', // 创建开始时间
        endTime: '', // 创建结束时间
        offset: 1,
        limit: 20,
        sort: 'createTime',
        order: 'desc'
      }, // 筛选条件
      columns: [
        {
          text: '姓名',
          value: 'name',
          align: 'center'
        },
        {
          text: '性别',
          value: 'sexName',
          align: 'center',
          width: 60
        },
        {
          text: '民族',
          value: 'nationName',
          width: 50,
          align: 'center'
        },
        {
          text: '采集原因',
          value: 'collReasonName',
          align: 'center'
        },
        {
          text: '证件类型',
          value: 'cardTypeName',
          align: 'center',
          width: 80
        },
        {
          text: '证件号码',
          value: 'idCardNo',
          align: 'center'
        },
        {
          text: '户籍地址',
          value: 'residenceAddr',
          align: 'center'
        },
        {
          text: '创建时间',
          value: 'createTime',
          width: 120,
          align: 'center'
        }
      ], // 显示列
      list: [], // 列表数据
      total: 0, // 数据总数
      listLoading: true, // 列表加载动画
      head: {
        show: true,
        text: '数据列表'
      }
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      this.listLoading = true
      const that = this
      setTimeout(function() {
        that.list = [
          { name: '张三', sexName: '男', nationName: '汉族', collReasonName: '工作人员', cardTypeName: '身份证', idCardNo: '1101264987431551155', residenceAddr: '北京市' },
          { name: '张三', sexName: '男', nationName: '汉族', collReasonName: '工作人员', cardTypeName: '身份证', idCardNo: '1101264987431551155', residenceAddr: '北京市' },
          { name: '张三', sexName: '男', nationName: '汉族', collReasonName: '工作人员', cardTypeName: '身份证', idCardNo: '1101264987431551155', residenceAddr: '北京市' },
          { name: '张三', sexName: '男', nationName: '汉族', collReasonName: '工作人员', cardTypeName: '身份证', idCardNo: '1101264987431551155', residenceAddr: '北京市' },
          { name: '张三', sexName: '男', nationName: '汉族', collReasonName: '工作人员', cardTypeName: '身份证', idCardNo: '1101264987431551155', residenceAddr: '北京市' },
          { name: '张三', sexName: '男', nationName: '汉族', collReasonName: '工作人员', cardTypeName: '身份证', idCardNo: '1101264987431551155', residenceAddr: '北京市' },
          { name: '张三', sexName: '男', nationName: '汉族', collReasonName: '工作人员', cardTypeName: '身份证', idCardNo: '1101264987431551155', residenceAddr: '北京市' },
          { name: '张三', sexName: '男', nationName: '汉族', collReasonName: '工作人员', cardTypeName: '身份证', idCardNo: '1101264987431551155', residenceAddr: '北京市' },
          { name: '张三', sexName: '男', nationName: '汉族', collReasonName: '工作人员', cardTypeName: '身份证', idCardNo: '1101264987431551155', residenceAddr: '北京市' },
          { name: '张三', sexName: '男', nationName: '汉族', collReasonName: '工作人员', cardTypeName: '身份证', idCardNo: '1101264987431551155', residenceAddr: '北京市' },
          { name: '张三', sexName: '男', nationName: '汉族', collReasonName: '工作人员', cardTypeName: '身份证', idCardNo: '1101264987431551155', residenceAddr: '北京市' }
        ]
        that.total = 200
        that.listLoading = false
      }, 2000)
    },
    changePage(val) {
      if (val.size) {
        this.listQuery.limit = val.size
      }
      if (val.page) {
        this.listQuery.offset = val.page
      }
      this.fetchData()
    }
  }
}
</script>

<style scoped>

</style>
