<template>
  <el-drawer title="报名详情" :visible.sync="visible" size="60%" append-to-body>
    <avue-crud
      :option="option"
      :table-loading="loading"
      :data="data"
      ref="crud"
      v-model="form"
      :permission="permissionList"
      :page.sync="page"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
    ></avue-crud>
  </el-drawer>
</template>

<script>
import { getZPView } from "@/api/workstation/post";
import { mapGetters } from "vuex";

export default {
  props: {},
  data() {
    return {
      missionNo: null,
      form: {},
      selectionList: [],
      query: {},
      loading: true,
      parentId: 0,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      visible: false,
      checkDialog: false,
      delayDialog: false,
      zpviewDialog: false,
      finishDialog: false,
      option: {
        height: "auto",
        tip: false,
        searchShow: true,
        searchMenuSpan: 6,
        border: true,
        index: false,
        selection: false,
        viewBtn: false,
        addBtn: false,
        menu: false,
        menuWidth: 300,
        dialogClickModal: false,
        dialogType: "drawer",
        dialogFullscreen: true,
        column: [
          {
            label: "姓名",
            prop: "realName",
            search: true,
            searchSpan: 7,
            searchLabelWidth: 50,
            display: false,
          },
          {
            label: "身份证号码",
            prop: "cardNumber",
            search: true,
            display: false,
            searchLabelWidth: 100,
            searchSpan: 7,
          },
          {
            type: "select",
            label: "报名详情",
            prop: "status",
            display: false,
            search: true,
            searchSpan: 7,
            dicData: [
              { label: "申请中", value: 1 },
              { label: "申请通过", value: 2 },
              { label: "申请未通过", value: 3 },
              { label: "已完成", value: 4 },
              { label: "申请无效（其他）", value: 9 },
            ],
          },
        ],
      },
      data: [],
    };
  },
  computed: {
    ...mapGetters(["userInfo", "permission"]),
    permissionList() {
      return {
        viewBtn: this.vaildData(
          this.permission.manage_station_mainList_view,
          false
        ),
      };
    },
    ids() {
      let ids = [];
      this.selectionList.forEach((ele) => {
        ids.push(ele.id);
      });
      return ids;
    },
  },
  methods: {
    initData() {
      this.onLoad(this.page, this.query);
    },
    open(missionNo) {
      this.missionNo = missionNo;
      this.initData();
      this.visible = true;
    },
    searchReset() {
      this.query = {};
      this.onLoad(this.page);
    },
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    selectionChange(list) {
      this.selectionList = list;
    },
    selectionClear() {
      this.selectionList = [];
      this.$refs.crud.toggleSelection();
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    onLoad(page, params = {}) {
      this.loading = true;
      getZPView(
        page.currentPage,
        page.pageSize,
        this.missionNo,
        Object.assign(this.query, params)
      ).then((res) => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        this.loading = false;
      });
    },
  },
};
</script>

<style>
</style>
