<template>
  <div id="index">
    <el-row>
      <el-col :span="24" class="main">
        <el-col :span="24" class="one">
          <el-col :span="24" class="one_1"> 保安员信息维护查询 </el-col>
          <el-col :span="24" class="one_2">
            <el-form ref="searchFrom" :model="searchFrom" label-width="100px">
              <el-col :span="24" class="one_2txt">
                <el-col :span="8">
                  <el-form-item label="姓名">
                    <el-input v-model="searchFrom.name"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="公民身份号码">
                    <el-input v-model="searchFrom.card"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="考试等级">
                    <el-select v-model="searchFrom.grade" clearable placeholder="请选择">
                      <el-option v-for="(item, index) in exam_gradeList" :key="index" :label="item" :value="item"></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-col>
              <el-col :span="24" class="one_2txt">
                <el-col :span="8">
                  <el-form-item label="出生日期">
                    <el-date-picker
                      v-model="searchFrom['start@birth']"
                      placeholder="请选择"
                      value-format="yyyy-MM-dd"
                      format="yyyy-MM-dd"
                      type="date"
                      style="width: 100%"
                    >
                    </el-date-picker>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="至">
                    <el-date-picker
                      v-model="searchFrom['end@birth']"
                      placeholder="请选择"
                      value-format="yyyy-MM-dd"
                      format="yyyy-MM-dd"
                      type="date"
                      style="width: 100%"
                    >
                    </el-date-picker>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="审核状态">
                    <el-select v-model="searchFrom.status" clearable placeholder="请选择">
                      <el-option v-for="(item, index) in statusList" :key="index" :label="item.label" :value="item.value"></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
              </el-col>
              <el-col :span="24" class="one_2txt">
                <el-col :span="24" class="btn">
                  <el-button type="primary" size="mini" @click="search()">查询</el-button>
                </el-col>
              </el-col>
            </el-form>
          </el-col>
        </el-col>
        <el-col :span="24" class="two">
          <data-table @query="search" :fields="fields" :opera="opera" :data="list" :total="total" @edit="toEdit" @view="toView"> </data-table>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
const { exam_grade } = require('@common/src/layout/deploy/dict');
import { mapState, createNamespacedHelpers } from 'vuex';
const { mapActions: security_guard_base } = createNamespacedHelpers('security_guard_base');
export default {
  name: 'index',
  props: {},
  components: {},
  data: function () {
    return {
      // 查询
      searchFrom: {},
      // 列表
      fields: [
        { label: '姓名', model: 'name' },
        { label: '公民身份号码', model: 'card' },
        { label: '性别', model: 'gender' },
        { label: '保安员等级', model: 'grade' },
        { label: '采集指纹', model: 'collect_fingerprint' },
        { label: '采集照片', model: 'collect_photo' },
        { label: '审核结果', model: 'examine_status' },
        { label: '审批结果', model: 'approve_status' },
        { label: '受理时间', model: 'acceptance_date' },
        { label: '受理公安机关', model: 'acceptance_police' },
      ],
      opera: [
        { label: '维护', method: 'edit' },
        { label: '详情', method: 'view' },
      ],
      list: [],
      total: 0,
      // 考试等级
      exam_gradeList: exam_grade,
      // 审核状态
      statusList: [
        { label: '报名', value: 'null' },
        { label: '资料政审', value: '0' },
        { label: '信息采集', value: '1' },
        { label: '报名资格审核', value: '2' },
        { label: '报名资格审核未通过', value: '-3' },
        { label: '资格审批', value: '3' },
        { label: '资格审批未通过', value: '-4' },
        { label: '资格审批通过', value: '4' },
        { label: '考试合格', value: '7' },
        { label: '资料备案', value: '10' },
        { label: '已发保安员证', value: '11' },
        { label: '已入职企业', value: '12' },
      ],
    };
  },
  created() {
    this.search();
  },
  methods: {
    ...security_guard_base(['query']),
    async search({ skip = 1, limit = 10, ...info } = {}) {
      const condition = _.cloneDeep(this.searchFrom);
      let res = await this.query({ skip, limit, ...condition, ...info });
      if (this.$checkRes(res)) {
        this.$set(this, `list`, res.data);
        this.$set(this, `total`, res.total);
      }
    },
    // 维护
    toEdit({ data }) {
      this.$router.push({ path: '/adminPolice/information/bayxxwh/edit', query: { id: data.id } });
    },
    // 详情
    toView({ data }) {
      this.$router.push({ path: '/adminPolice/information/bayxxwh/info', query: { id: data.id } });
    },
  },
  computed: {
    ...mapState(['user']),
  },
  metaInfo() {
    return { title: this.$route.meta.title };
  },
  watch: {
    test: {
      deep: true,
      immediate: true,
      handler(val) {},
    },
  },
};
</script>

<style lang="less" scoped>
.main {
  .one {
    .one_1 {
      height: 40px;
      line-height: 40px;
      border-bottom: 1px solid #ccc;
      margin: 0 0 10px 0;
      font-size: 18px;
      font-weight: bold;
    }
    .one_2 {
      .one_2txt {
        border: 1px solid #ccc;
        /deep/.el-form-item {
          margin: 0;
        }
        /deep/.el-date-editor.el-input,
        .el-date-editor.el-input__inner {
          width: 100%;
        }
        /deep/.el-select {
          width: 100%;
        }
        .other {
          padding: 10px;
        }
        .btn {
          text-align: right;
          padding: 5px 5px;
        }
      }
    }
  }
}
</style>
