<template>
  <basic-container>
    <el-drawer
      title="比对结果"
      append-to-body
      :visible.sync="drawer"
      size="65%"
      class="drawer"
    >
      <avue-crud
        :option="personListOption"
        :table-loading="loading"
        :data="data"
        :page.sync="page"
        ref="crud"
        :permission="permissionList"
        @search-change="searchChange"
        @search-reset="searchReset"
        @selection-change="selectionChange"
        @current-change="currentChange"
        @size-change="sizeChange"
        @refresh-change="refreshChange"
        class="customPage"
      >
        <!--/自定义按钮-->
        <template slot="menuRight">
          <el-button
            type="primary"
            size="small"
            @click="handleExport"
            >导出</el-button
          >
        </template>
        <template v-slot:idNumber="{row}">
          <span>{{idNumberDDesensitization(row.idNumber)}}</span>
        </template>
      </avue-crud>
    </el-drawer>
  </basic-container>
</template>

<script>
import {userLists,userListsExport} from "@/api/tenant/postzp";
// import Resume from "@/components/resume/index";
import { mapGetters } from "vuex";
import { idNumberDDesensitization } from "@/util/util";

export default {
  data () {
    return {
      isIndeterminate: false,
      checkAll: false,
      checked: false,
      missionId: "",
      missionTitle: "",
      stime: "",
      drawer: false,
      selectionList: [],
      loading: false,
      query: {},
      id:null,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      personListOption: {
        dialogWidth: "30%",
        align: "center",
        menuAlign: "center",
        rowKey: "id",
        tip: false,
        menu: false,
        addBtn: false,
        columnBtn: false,
        searchBtn: true,
        searchShow: true,
        searchMenuSpan: 6,
        searchLabelWidth: 45,
        menuPosition: "center",
        labelPosition: "right",
        border: true,
        index: true,
        indexLabel: "序号",
        viewBtn: false,
        dialogType: "dialog",
        dialogClickModal: false,
        column: [
          {
            label: "姓名",
            prop: "name",
            search: false,
          },
          {
            label: "性别",
            prop: "sex",
            search: false,
            width: 50,
          },
          {
            label: "年龄",
            prop: "age",
            search: false,
            width: 50,
          },
          {
            label: "身份证",
            prop: "idNumber",
            search: false,
            width: 150,
            slot: true
          },
          {
            label: "联系方式",
            prop: "telphone",
            search: false,
            width: 120,
          },
          {
            label: "工种",
            prop: "worktypeName",
            search: false,
          },
          {
            label: "人才库",
            prop: "groupName",
            search: false,
          },
          // {
          //   label: "操作",
          //   prop: "recommend",
          //   slot: true,
          // },
        ],
      },
      excelBox: false,
      data: [],
    };
  },
  components: {
    // Resume,
  },
  watch: {},
  computed: {
    ...mapGetters(["userInfo", "permission"]),
    ids () {
      let ids = [];
      this.selectionList.forEach((ele) => {
        ids.push(ele.userId);
      });
      return ids.join(",");
    },
  },
  methods: {
    idNumberDDesensitization,
      //导出
    handleExport(){
        window.open(userListsExport(this.missionId, this.id));
    },
    /*打开drawer*/
    openDialog (missionId,ids) {
        this.missionId = missionId;
        this.id = ids;
        this.ids = ids;
        this.onLoad(this.page, this.query);
        this.drawer = true;
    },
    /*批量选择*/
    // handleChoice () {
      
    // },
    searchReset () {
      this.query = {};
      this.onLoad(this.page);
    },
    searchChange (params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, this.query);
      done();
    },
    selectionChange (list) {
      this.selectionList = list;
    },
    selectionClear () {
      this.selectionList = [];
      this.$refs.crud.toggleSelection();
    },
    currentChange (currentPage) {
      this.page.currentPage = currentPage;
      this.onLoad(this.page);
    },
    sizeChange (pageSize) {
      this.page.currentPage = 1;
      this.page.pageSize = pageSize;
      this.onLoad(this.page);
    },
    refreshChange () {
      this.onLoad(this.page, this.query);
    },
    onLoad () {
      this.loading = true;
      userLists(this.missionId, this.id).then((res) => {
        const data = res.data.data;
        this.data = data;
        this.loading = false;
        this.selectionClear();
      });
    },
  },
};
</script>