Administrator
2022-04-11 79d9fc857559982b00b68b2d709807bdc4cd286f
src/views/trainApply/index.vue
@@ -1,677 +1,969 @@
/*
 * @Author: Morpheus
 * @Date: 2021-07-05 16:31:54
 * @Last Modified by: Morpheus
 * @Last Modified time: 2021-07-19 19:39:45
 * @Last Modified by: liu
 * @Last Modified time: 2021-11-30 10:23:40
 * menu-name 报名考试
 */
<template>
    <el-row class="morpheus-box-apply-exam-1">
        <el-col :span="24" class="hasButOne">
            <el-card>
                <div class="exam-card-body">
  <!-- class="exam-card-body" -->
  <basic-container
    :class="[
      $store.state.control.screenSize == 1366 ? 'smallSize' : 'normalSize',
      $store.state.control.windowWidth >= 1024 ? 'tooRowSearch1' : '',
    ]"
  >
    <avue-crud
      v-model="obj"
      class="company-box tablesss"
      :option="questionBankOption"
      :search.sync="questionBankSearch"
      :table-loading="questionBankLoading"
      :data="questionBankData"
      ref="questionBankCrud"
      :page.sync="questionBankPage"
      @on-load="questionBankOnLoad"
      @selection-change="questionBankSelectionChange"
      @search-change="questionBankSearchChange"
      @search-reset="questionBankSearchReset"
      @current-change="questionBankCurrentChange"
      @size-change="questionBankSizeChange"
      @row-save="questionBankRowSave"
      @row-del="questionBankRowDel"
      :row-style="rowStyle"
    >
      <!-- 自定义按钮 -->
      <template slot="menuLeft">
        <el-button
          style="display: none"
          type="warning"
          size="small"
          plain
          icon="el-icon-download"
          @click="handleExport"
          >导出
        </el-button>
        <el-button
          type="warning"
          size="small"
          plain
          icon="el-icon-receiving"
          @click="handleExport"
          >清册打印
        </el-button>
        <el-button
          type="success"
          size="small"
          plain
          v-if="false"
          icon="el-icon-download"
          @click="handleImport"
          >清册导入
        </el-button>
        <el-button
          type="warning"
          size="small"
          plain
          icon="el-icon-download"
          @click="handleApplyInfoExport"
          >报名清册信息导出
        </el-button>
      </template>
                    <avue-crud v-model="obj"
                               class="company-box"
                               :option="questionBankOption"
                               :search.sync="questionBankSearch"
                               :table-loading="questionBankLoading"
                               :data="questionBankData"
                               ref="questionBankCrud"
                               :page.sync="questionBankPage"
                               @on-load="questionBankOnLoad"
                               @selection-change="questionBankSelectionChange"
                               @search-change="questionBankSearchChange"
                               @search-reset="questionBankSearchReset"
                               @current-change="questionBankCurrentChange"
                               @size-change="questionBankSizeChange"
                               @row-save="questionBankRowSave"
                               @row-del="questionBankRowDel">
      <template slot-scope="{ type, row }" slot="menu">
        <el-button
          :type="type"
          size="small"
          icon="el-icon-receiving"
          :disabled="
            row.candidateNo == '' || row.cancel == 2 || row.auditStatus == 2
          "
          @click="handlePrint(row)"
          >准考证打印
        </el-button>
        <el-button
          :type="type"
          size="small"
          icon="el-icon-refresh-left"
          :disabled="row.cancel == 2 || row.isExam == 2 || row.isExam == 3"
          @click="revoke(row)"
          >取消报名
        </el-button>
        <el-button
          style="display: none"
          :type="type"
          size="small"
          icon="el-icon-circle-check"
          :disabled="row.auditStatus == 1"
          @click="auditSucess(row)"
          >审核通过
        </el-button>
        <el-button
          v-if="row.vipStatus != 1 && permission.exam_vip"
          icon="el-icon-folder-checked"
          @click="usesVipConfirm(row)"
          :size="size"
          :type="type"
          >缴费确认</el-button
        >
      </template>
    </avue-crud>
                        <!-- 自定义按钮 -->
                        <template slot="menuLeft">
                            <el-button
                                style="display:none"
                                type="warning"
                                size="small"
                                plain
                                icon="el-icon-download"
                                @click="handleExport"
                                >导出
                            </el-button>
                            <el-button
                                 style="display:none"
                                type="success"
                                size="small"
                                plain
                                icon="el-icon-upload2"
                                @click="handleImport"
                                >导入
                            </el-button>
                            <el-button
                                type="warning"
                                size="small"
                                plain
                                icon="el-icon-download"
                                @click="handleExport"
                                >清册打印
                            </el-button>
                        </template>
                        <template slot-scope="{ type,row }" slot="menu">
                            <el-button
                            :type="type"
                            size="small"
                            icon="el-icon-receiving"
                            :disabled="row.cancel==2"
                            @click="handlePrint(row)"
                            >准考证打印
                            </el-button>
                        </template>
                    </avue-crud>
                     <el-dialog
                        title="清册数据导入"
                        append-to-body
                        :visible.sync="excelBox"
                        width="555px"
                        >
                        <avue-form
                            :option="excelOption"
                            v-model="excelForm"
                            :upload-after="uploadAfter"
                        >
                            <template slot="excelTemplate">
                            <el-button type="primary" @click="handleTemplate">
                                点击下载<i class="el-icon-download el-icon--right"></i>
                            </el-button>
                            </template>
                        </avue-form>
                    </el-dialog>
                </div>
            </el-card>
        </el-col>
    </el-row>
    <el-dialog
      title="清册数据导入"
      append-to-body
      :visible.sync="excelBox"
      width="555px"
    >
      <avue-form
        :option="excelOption"
        v-model="excelForm"
        :upload-after="uploadAfter"
      >
        <template slot="excelTemplate">
          <el-button type="primary" @click="handleTemplate">
            点击下载<i class="el-icon-download el-icon--right"></i>
          </el-button>
        </template>
      </avue-form>
    </el-dialog>
  </basic-container>
</template>
<script>
import {getdata,adddata,remove} from "@/api/trainingRegistration/trainingRegistration";
import { mapState } from 'vuex'
import {
  getdata,
  adddata,
  cancelTrainAudit,
  cancelTrain,
  auditSucess,
  remove,
  vipSign,
} from "@/api/trainingRegistration/trainingRegistration";
import Qs from "qs";
import { getToken } from "@/util/auth";
import { mapState } from "vuex";
import { mapGetters } from "vuex";
var DIC = {
    cancel: [{
        label: '已报名',
        value: 1
    }, {
        label: '已取消',
        value: 2
    }]
}
  cancel: [
    {
      label: "已报名",
      value: 1,
    },
    {
      label: "已取消",
      value: 2,
    },
  ],
};
export default {
    data () {
  data() {
    var examId = this.$route.query.id;
    return {
      excelBox: false,
      questionBankOption: {
        // 操作栏多余按钮去除
        delBtn: false,
        editBtn: false,
        addBtn: false,
        selection: true,
        menu: true,
        // 导出按钮
        // excelBtn: true,
        viewBtn: false,
        return {
            excelBox: false,
            questionBankOption: {
                // 操作栏多余按钮去除
                delBtn: false,
                editBtn: false,
                addBtn: false,
                selection: true,
                menu: true,
                // 导出按钮
                // excelBtn: true,
                viewBtn: false,
        // title: '题库',
                // title: '题库',
        align: "center",
        height: "auto",
        calcHeight: 80,
        tip: false,
        searchShow: true,
        searchMenuSpan: 4,
        index: true,
        indexLabel: "序号",
        //dialogType: 'drawer',
        dialogClickModal: false,
        // 操作栏宽度
        menuWidth: 280,
        ...this.$store.state.control.clearOtherBut,
        column: [
          {
            label: "保安姓名",
            prop: "userId",
            type: "tree",
            dicUrl: "",
                align: 'center',
                height: 'auto',
                calcHeight: 80,
                tip: false,
                searchShow: true,
                searchMenuSpan: 4,
                index: true,
                indexLabel: '序号',
                //dialogType: 'drawer',
                dialogClickModal: false,
                // 操作栏宽度
                menuWidth: 200,
                column: [
                    {
                        label: "保安姓名",
                        prop: "userId",
                        type: 'tree',
                        dicUrl: '',
                        hide:true,
                        slot: true,
                        // 表单新增时是否禁止
                        addDisabled: false,
                        // 表单新增时是否可见
                        addDisplay: true,
                        // 表单新增时是否为查看模式
                        addDetail: false,
                        // 表单编辑时是否禁止
                        editDisabled: true,
                        // 表单编辑时是否可见
                        editDisplay: true,
                        // 表单编辑时是否为查看模式
                        editDetail: false,
                        props: {
                            label: "title",
                            value: "id",
                        },
                        rules: [{
                            required: true,
                            message: "请选择保安姓名",
                            trigger: "blur"
                        }]
                    },
                    {
                        label: "保安姓名",
                        prop: "realName",
                        // 表单新增时是否禁止
                        addDisabled: false,
                        // 表单新增时是否可见
                        addDisplay: false,
                        search: true,
                        // 表单新增时是否为查看模式
                        addDetail: false,
                        // 表单编辑时是否禁止
                        editDisabled: false,
                        // 表单编辑时是否可见
                        editDisplay: false,
                        // 表单编辑时是否为查看模式
                        editDetail: false,
                        viewDisplay:true,
                        props: {
                            label: "title",
                            value: "id",
                        },
                        rules: [{
                            required: true,
                            message: "请选择保安姓名",
                            trigger: "blur"
                        }]
                    },
                    {
                        label: "考试名称",
                        prop: "trainExamName",
                        type: 'tree',
                        dicUrl: '/api/exampaper/page-tree',
                        // search: true,
                        slot: true,
                        // 表单新增时是否禁止
                        addDisabled: false,
                        // 表单新增时是否可见
                        addDisplay: true,
                        // 表单新增时是否为查看模式
                        addDetail: false,
                        // 表单编辑时是否禁止
                        editDisabled: true,
                        // 表单编辑时是否可见
                        editDisplay: true,
                        // 表单编辑时是否为查看模式
                        editDetail: false,
                        props: {
                            label: "examName",
                            value: "id",
                        },
                        rules: [{
                            required: true,
                            message: "请选择试卷名称",
                            trigger: "blur"
                        }],
                        width: 220
                    },
                    {
                        label: "所属公司",
                        prop: "deptName",
                        search: true,
                        slot: true,
                        // 表单新增时是否禁止
                        addDisabled: false,
                        // 表单新增时是否可见
                        addDisplay: false,
                        // 表单新增时是否为查看模式
                        addDetail: false,
                        // 表单编辑时是否禁止
                        editDisabled: true,
                        // 表单编辑时是否可见
                        editDisplay: true,
                        // 表单编辑时是否为查看模式
                        editDetail: false,
                        rules: [{
                            required: true,
                            message: "请选择所属公司",
                            trigger: "blur"
                        }],
                        width: 220
                    },
                    {
                        label: "准考证号",
                        prop: "candidateNo",
                        slot: true,
                        // 表单新增时是否禁止
                        addDisabled: false,
                        // 表单新增时是否可见
                        addDisplay: false,
                        // 表单新增时是否为查看模式
                        addDetail: false,
                        // 表单编辑时是否禁止
                        editDisabled: false,
                        // 表单编辑时是否可见
                        editDisplay: true,
                        // 表单编辑时是否为查看模式
                        editDetail: false,
                        rules: [{
                            required: true,
                            message: "请选择准考证号",
                            trigger: "blur"
                        }],
                        width:100,
                    },
                    {
                        label: "身份证号",
                        prop: "idCardNo",
                        slot: true,
                        // 表单新增时是否禁止
                        addDisabled: false,
                        // 表单新增时是否可见
                        addDisplay: false,
                        // 表单新增时是否为查看模式
                        addDetail: false,
                        // 表单编辑时是否禁止
                        editDisabled: false,
                        // 表单编辑时是否可见
                        editDisplay: true,
                        // 表单编辑时是否为查看模式
                        editDetail: false,
                        rules: [{
                            required: true,
                            message: "请选择准考证号",
                            trigger: "blur"
                        }],
                        width: 200
                    },
                    {
                        label: "报考证件",
                        prop: "applyCard",
                        slot: true,
                        // 表单新增时是否禁止
                        addDisabled: false,
                        // 表单新增时是否可见
                        addDisplay: false,
                        // 表单新增时是否为查看模式
                        addDetail: false,
                        // 表单编辑时是否禁止
                        editDisabled: false,
                        // 表单编辑时是否可见
                        editDisplay: true,
                        // 表单编辑时是否为查看模式
                        editDetail: false,
                        rules: [{
                            required: true,
                            message: "请选择准考证号",
                            trigger: "blur"
                        }],
                    },
                    // {
                    //     label: "试卷分数",
                    //     prop: "paperScore",
                    //     slot: true,
                    //     // 表单新增时是否禁止
                    //     addDisabled: false,
                    //     // 表单新增时是否可见
                    //     addDisplay: false,
                    //     // 表单新增时是否为查看模式
                    //     addDetail: false,
                    //     // 表单编辑时是否禁止
                    //     editDisabled: true,
                    //     // 表单编辑时是否可见
                    //     editDisplay: true,
                    //     // 表单编辑时是否为查看模式
                    //     editDetail: false
                    // },
                    {
                        label: "报名时间",
                        prop: "trainingTime",
                        type: "datetime",
                        // span: 24,
                        format: 'yyyy-MM-dd HH:mm:ss',
                        valueFormat: 'yyyy-MM-dd HH:mm:ss',
                        // 表单新增时是否禁止
                        addDisabled: true,
                        // 表单新增时是否可见
                        addDisplay: true,
                        // 表单新增时是否为查看模式
                        addDetail: false,
                        // 表单编辑时是否禁止
                        editDisabled: true,
                        // 表单编辑时是否可见
                        editDisplay: true,
                        // 表单编辑时是否为查看模式
                        editDetail: false,
                        value: (new Date().getFullYear() + '-' + (new Date().getMonth() + 1 < 10
                            ? "0" + (new Date().getMonth() + 1)
                            : new Date().getMonth() + 1) + '-' + (new Date().getDate() < 10
                                ? "0" + new Date().getDate()
                                : new Date().getDate()) + ' ' + (new Date().getHours() < 10
                                    ? "0" + new Date().getHours()
                                    : new Date().getHours()) + ':' + (new Date().getMinutes() < 10
                                        ? "0" + new Date().getMinutes()
                                        : new Date().getMinutes()) + ':' + (new Date().getSeconds() < 10
                                            ? "0" + new Date().getSeconds()
                                            : new Date().getSeconds())),
                        width: 160
                    },
                    {
                        label: "考试时间",
                        prop: "trainExamTime",
                        type: "datetime",
                        // span: 24,
                        format: 'yyyy-MM-dd HH:mm:ss',
                        valueFormat: 'yyyy-MM-dd HH:mm:ss',
                        // 表单新增时是否禁止
                        addDisabled: false,
                        // 表单新增时是否可见
                        addDisplay: false,
                        // 表单新增时是否为查看模式
                        addDetail: false,
                        // 表单编辑时是否禁止
                        editDisabled: false,
                        // 表单编辑时是否可见
                        editDisplay: true,
                        // 表单编辑时是否为查看模式
                        editDetail: false,
                        width: 160
                    },
                    // {
                    //     label: "报名状态",
                    //     prop: "cancel",
                    //     slot: true,
                    //     // 表单新增时是否禁止
                    //     addDisabled: false,
                    //     // 表单新增时是否可见
                    //     addDisplay: false,
                    //     // 表单新增时是否为查看模式
                    //     addDetail: false,
                    //     // 表单编辑时是否禁止
                    //     editDisabled: false,
                    //     // 表单编辑时是否可见
                    //     editDisplay: true,
                    //     // 表单编辑时是否为查看模式
                    //     editDetail: false,
                    //     dicData:DIC.cancel,
                    //     search:true,
                    //     type:"select"
                    // },
                ]
            hide: true,
            slot: true,
            // 表单新增时是否禁止
            addDisabled: false,
            // 表单新增时是否可见
            addDisplay: true,
            // 表单新增时是否为查看模式
            addDetail: false,
            // 表单编辑时是否禁止
            editDisabled: true,
            // 表单编辑时是否可见
            editDisplay: true,
            // 表单编辑时是否为查看模式
            editDetail: false,
            props: {
              label: "title",
              value: "id",
            },
            questionBankSearch: {},
            questionBankLoading: true,
            questionBankData: [
            rules: [
              {
                required: true,
                message: "请选择保安姓名",
                trigger: "blur",
              },
            ],
            questionBankPage: {
                pageSize: 10,
                currentPage: 1,
                total: 16
          },
          {
            label: "保安姓名",
            prop: "realName",
            // 表单新增时是否禁止
            addDisabled: false,
            // 表单新增时是否可见
            addDisplay: false,
            search: true,
            searchSpan: 3,
            // 表单新增时是否为查看模式
            addDetail: false,
            // 表单编辑时是否禁止
            editDisabled: false,
            // 表单编辑时是否可见
            editDisplay: false,
            // 表单编辑时是否为查看模式
            editDetail: false,
            viewDisplay: true,
            props: {
              label: "title",
              value: "id",
            },
            questionBankQuery: {},
            questionBankSelectionList: [],
            excelForm: {},
            excelOption: {
                submitBtn: false,
                emptyBtn: false,
                column: [
                {
                    label: "模板上传",
                    prop: "excelFile",
                    type: "upload",
                    drag: true,
                    loadText: "模板上传中,请稍等",
                    span: 24,
                    propsHttp: {
                    res: "data",
                    },
                    tip: "请上传 .xls,.xlsx 标准格式文件",
                    action: "/api/trainingRegistration/import-trainingRegistration",
                },
                {
                    label: "模板下载",
                    prop: "excelTemplate",
                    formslot: true,
                    span: 24,
                },
                ],
            rules: [
              {
                required: true,
                message: "请选择保安姓名",
                trigger: "blur",
              },
            ],
          },
          {
            label: "考试名称",
            prop: "trainExamName",
            type: "tree",
            dicUrl: "/api/exampaper/page-tree",
            // search: true,
            slot: true,
            // 表单新增时是否禁止
            addDisabled: false,
            // 表单新增时是否可见
            addDisplay: true,
            // 表单新增时是否为查看模式
            addDetail: false,
            // 表单编辑时是否禁止
            editDisabled: true,
            // 表单编辑时是否可见
            editDisplay: true,
            // 表单编辑时是否为查看模式
            editDetail: false,
            props: {
              label: "examName",
              value: "id",
            },
        }
    },
            rules: [
              {
                required: true,
                message: "请选择试卷名称",
                trigger: "blur",
              },
            ],
            width: 180,
            overHidden: true,
          },
          {
            label: "所属企业",
            prop: "deptName",
            search: true,
            searchSpan: 5,
            slot: true,
            // 表单新增时是否禁止
            addDisabled: false,
            // 表单新增时是否可见
            addDisplay: false,
            // 表单新增时是否为查看模式
            addDetail: false,
            // 表单编辑时是否禁止
            editDisabled: true,
            // 表单编辑时是否可见
            editDisplay: true,
            // 表单编辑时是否为查看模式
            editDetail: false,
            rules: [
              {
                required: true,
                message: "请选择所属企业",
                trigger: "blur",
              },
            ],
            width: 200,
            overHidden: true,
          },
          {
            label: "报名状态",
            prop: "cancel",
            type: "select",
            search: true,
            hide: true,
            searchSpan: 4,
            dicData: [
              {
                label: "全部",
                value: 0,
              },
              {
                label: "已报名",
                value: 1,
              },
              {
                label: "已取消",
                value: 2,
              },
            ],
          },
          {
            label: "准考证号",
            prop: "candidateNo",
            slot: true,
            // 表单新增时是否禁止
            addDisabled: false,
            // 表单新增时是否可见
            addDisplay: false,
            // 表单新增时是否为查看模式
            addDetail: false,
            // 表单编辑时是否禁止
            editDisabled: false,
            // 表单编辑时是否可见
            editDisplay: true,
            // 表单编辑时是否为查看模式
            editDetail: false,
            rules: [
              {
                required: true,
                message: "请选择准考证号",
                trigger: "blur",
              },
            ],
            width: 100,
          },
          {
            label: "身份证号",
            prop: "idCardNo",
            slot: true,
            // 表单新增时是否禁止
            addDisabled: false,
            // 表单新增时是否可见
            addDisplay: false,
            // 表单新增时是否为查看模式
            addDetail: false,
            // 表单编辑时是否禁止
            editDisabled: false,
            // 表单编辑时是否可见
            editDisplay: true,
            // 表单编辑时是否为查看模式
            editDetail: false,
            rules: [
              {
                required: true,
                message: "请选择准考证号",
                trigger: "blur",
              },
            ],
            width: 150,
          },
          {
            label: "报考证件",
            prop: "applyCard",
            slot: true,
            // 表单新增时是否禁止
            addDisabled: false,
            // 表单新增时是否可见
            addDisplay: false,
            // 表单新增时是否为查看模式
            addDetail: false,
            // 表单编辑时是否禁止
            editDisabled: false,
            // 表单编辑时是否可见
            editDisplay: true,
            // 表单编辑时是否为查看模式
            editDetail: false,
            rules: [
              {
                required: true,
                message: "请选择准考证号",
                trigger: "blur",
              },
            ],
          },
          // {
          //     label: "试卷分数",
          //     prop: "paperScore",
          //     slot: true,
          //     // 表单新增时是否禁止
          //     addDisabled: false,
          //     // 表单新增时是否可见
          //     addDisplay: false,
          //     // 表单新增时是否为查看模式
          //     addDetail: false,
          //     // 表单编辑时是否禁止
          //     editDisabled: true,
          //     // 表单编辑时是否可见
          //     editDisplay: true,
          //     // 表单编辑时是否为查看模式
          //     editDetail: false
          // },
          {
            label: "报名时间",
            prop: "trainingTime",
            type: "datetime",
            // span: 24,
            format: "yyyy-MM-dd HH:mm:ss",
            valueFormat: "yyyy-MM-dd HH:mm:ss",
            // 表单新增时是否禁止
            addDisabled: true,
            // 表单新增时是否可见
            addDisplay: true,
            // 表单新增时是否为查看模式
            addDetail: false,
            // 表单编辑时是否禁止
            editDisabled: true,
            // 表单编辑时是否可见
            editDisplay: true,
            // 表单编辑时是否为查看模式
            editDetail: false,
            value:
              new Date().getFullYear() +
              "-" +
              (new Date().getMonth() + 1 < 10
                ? "0" + (new Date().getMonth() + 1)
                : new Date().getMonth() + 1) +
              "-" +
              (new Date().getDate() < 10
                ? "0" + new Date().getDate()
                : new Date().getDate()) +
              " " +
              (new Date().getHours() < 10
                ? "0" + new Date().getHours()
                : new Date().getHours()) +
              ":" +
              (new Date().getMinutes() < 10
                ? "0" + new Date().getMinutes()
                : new Date().getMinutes()) +
              ":" +
              (new Date().getSeconds() < 10
                ? "0" + new Date().getSeconds()
                : new Date().getSeconds()),
    watch: {
        "form.examname": {
            // form是表单或者表格绑定的数据集,v-model='form'
            handler (val) {
                if (val) {
                    //地址截取,从县/区开始截取,并且取从县区第一个出现的位置开始
                    var address = val.formattedAddress.toString();
                    if (address.search("县") != -1) {
                        this.form.address = address.substring(
                            address.indexOf("县") + 1,
                            address.length
                        );
                    }
                    if (address.search("区") != -1) {
                        this.form.address = address.substring(
                            address.indexOf("区") + 1,
                            address.length
                        );
                    }
                }
            width: 150,
          },
          {
            label: "考试时间",
            prop: "trainExamTime",
            type: "datetime",
            // span: 24,
            format: "yyyy-MM-dd HH:mm:ss",
            valueFormat: "yyyy-MM-dd HH:mm:ss",
            // 表单新增时是否禁止
            addDisabled: false,
            // 表单新增时是否可见
            addDisplay: false,
            // 表单新增时是否为查看模式
            addDetail: false,
            // 表单编辑时是否禁止
            editDisabled: false,
            // 表单编辑时是否可见
            editDisplay: true,
            // 表单编辑时是否为查看模式
            editDetail: false,
            width: 150,
          },
          {
            label: "审核状态",
            search: true,
            searchLabelWidth: 110,
            type: "select",
            searchSpan: 4,
            prop: "auditStatus",
            dicData: [
              {
                label: "全部",
                value: 0,
              },
              {
                label: "审核通过",
                value: 1,
              },
              {
                label: "审核不通过",
                value: 2,
              },
              {
                label: "已提交审核",
                value: 3,
              },
              {
                label: "未提交审核",
                value: 4,
              },
            ],
            props: {
              label: "label",
              value: "value",
            },
            immediate: true,
        },
    },
    created () {
            editDisplay: false,
            addDisplay: false,
            width: 100,
          },
          {
            label: "考试状态",
            search: true,
            type: "select",
            searchSpan: 4,
            prop: "isExam",
            dicData: [
              {
                label: "全部",
                value: 0,
              },
              {
                label: "未考试",
                value: 1,
              },
              {
                label: "考试结束",
                value: 2,
              },
              {
                label: "考试中",
                value: 3,
              },
              {
                label: "缺考",
                value: 4,
              },
            ],
            props: {
              label: "label",
              value: "value",
            },
            editDisplay: false,
            addDisplay: false,
            width: 100,
          },
          //   {
          //     label: "缴费状态",
          //     search: true,
          //     type: "select",
          //     searchSpan: 4,
          //     prop: "vipStatus",
          //     dicData: [
          //         {
          //             label: '全部',
          //             value: 0,
          //         },
          //         {
          //             label: '已缴费',
          //             value: 1,
          //         },
          //         {
          //             label: '未缴费',
          //             value: 2,
          //         }
          //     ],
          //     props: {
          //         label: "label",
          //         value: "value"
          //     },
          //     editDisplay: false,
          //     addDisplay: false,
          //     width: 100,
          //   },
        ],
      },
      questionBankSearch: {},
      questionBankLoading: true,
      questionBankData: [],
      questionBankPage: {
        pageSize: 10,
        currentPage: 1,
        total: 16,
        ...this.$store.state.control.changePageSize,
      },
      questionBankQuery: {},
      questionBankSelectionList: [],
      excelForm: {},
      excelOption: {
        submitBtn: false,
        emptyBtn: false,
        column: [
          {
            label: "模板上传",
            prop: "excelFile",
            type: "upload",
            drag: true,
            loadText: "模板上传中,请稍等",
            span: 24,
            propsHttp: {
              res: "data",
            },
            tip: "请上传 .xls,.xlsx 标准格式文件",
            action:
              "/api/trainingRegistration/import-trainingRegistration?examId=" +
              examId,
          },
          {
            label: "模板下载",
            prop: "excelTemplate",
            formslot: true,
            span: 24,
          },
        ],
      },
    };
  },
      console.log(this.userInfo)
      if (this.userInfo.role_name.indexOf('ksxtadmin') != -1) {
        this.questionBankOption.column[0].dicUrl = "/api/blade-system/dept/lazy-tree-user?parentId="
      } else {
        this.questionBankOption.column[0].dicUrl = "/api/blade-system/dept/lazy-tree-user?parentId=" + this.userInfo.dept_id
      }
    },
    mounted() {
        var flag = false,
        i = 0,
        ind = null;
        this.$store.state.tags.tagList.forEach((item, index) => {
        if (item.label == "报名清册") {
            if (flag == false) {
            ind = index;
            flag = true;
            }
            i++;
        }
        });
        if (i > 1) {
        this.$store.state.tags.tagList.splice(ind, 1);
        }
    },
    computed: {
        ...mapState({
            userInfo: state => state.user.userInfo
        }),
        ids () {
            let ids = [];
            this.questionBankSelectionList.forEach(ele => {
                ids.push(ele.id);
            });
            return ids.join(",");
        },
    },
    methods: {
        //准考证查看
        handlePrint(row) {
            var obj = row;
            obj["name"] = "准考证信息";
            this.$router.push({
                path: `/applyexam/papers`,
                query: obj,
            });
        },
        questionBankOnLoad (page, params = {}) {
            // debugger;
            params['examId'] = this.$route.query.id;
            this.questionBankLoading = false;
            getdata(page.currentPage, page.pageSize, Object.assign(params, this.questionBankQuery)).then(res => {
                const data = res.data.data;
                this.questionBankPage.total = data.total;
                this.questionBankData = data.records;
                this.questionBankLoading = false;
                this.questionBankSelectionClear();
            });
        },
        questionBankSelectionClear () {
            this.questionBankSelectionList = [];
            this.$refs.questionBankCrud.toggleSelection();
        },
        questionBankSelectionChange (list) {
            this.questionBankSelectionList = list;
        },
        questionBankSearchChange (params, done) {
            this.questionBankQuery = params;
            this.questionBankPage.currentPage = 1;
            this.questionBankOnLoad(this.questionBankPage, params);
            done();
        },
        questionBankSearchReset () {
            this.questionBankQuery = {};
            this.questionBankOnLoad(this.questionBankPage);
        },
        questionBankCurrentChange (currentPage) {
            this.questionBankPage.currentPage = currentPage;
        },
        questionBankSizeChange (pageSize) {
            this.questionBankPage.pageSize = pageSize;
        },
        // 新增
        questionBankRowSave (row, done, loading) {
            adddata({ userId: row.name, examId: row.examName, applyTime: row.applyTime }).then(() => {
                this.questionBankOnLoad(this.questionBankPage);
                this.$message({
                    type: "success",
                    message: "操作成功!"
                });
                done();
            }, error => {
                window.console.log(error);
                loading();
            });
        },
        questionBankRowDel (row) {
            this.$confirm("确定将选择数据删除?", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            })
                .then(() => {
                    return remove(row.id);
                })
                .then(() => {
                    this.questionBankOnLoad(this.questionBankPage);
                    this.$message({
                        type: "success",
                        message: "操作成功!"
                    });
                });
        },
        questionBankHandleDelete () {
            if (this.questionBankSelectionList.length === 0) {
                this.$message.warning("请选择至少一条数据");
                return;
            }
            this.$confirm("确定将选择数据删除?", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            })
                .then(() => {
                    return remove(this.ids);
                })
                .then(() => {
                    this.questionBankOnLoad(this.questionBankPage);
                    this.$message({
                        type: "success",
                        message: "操作成功!"
                    });
                    this.$refs.questionBankCrud.toggleSelection();
                });
        },
        //清册生成
        handleExport() {
            var obj ={};
            obj["name"] = "报名清册信息";
            obj["examId"] = this.$route.query.id;
            this.$router.push({
                path: `/applydetailed/papers`,
                query: obj,
            });
        },
        //导出数据
        // handleExport() {
        //     this.$confirm("是否导出清册数据?", "提示", {
        //         confirmButtonText: "确定",
        //         cancelButtonText: "取消",
        //         type: "warning",
        //     }).then(() => {
        //         window.open(`/api/trainingRegistration/export-apply?examId=${this.$route.query.id}`);
        //     });
        // },
        handleImport() {
            this.excelBox = true;
        },
        handleTemplate() {
            window.open(
                `/api/apply/export-template`
  watch: {
    "form.examname": {
      // form是表单或者表格绑定的数据集,v-model='form'
      handler(val) {
        if (val) {
          //地址截取,从县/区开始截取,并且取从县区第一个出现的位置开始
          var address = val.formattedAddress.toString();
          if (address.search("县") != -1) {
            this.form.address = address.substring(
              address.indexOf("县") + 1,
              address.length
            );
        },
        uploadAfter(res, done, loading, column) {
            window.console.log(column);
            this.excelBox = false;
            this.refreshChange();
            done();
        },
        refreshChange() {
            this.questionBankOnLoad(this.page, this.query);
        },
          }
          if (address.search("区") != -1) {
            this.form.address = address.substring(
              address.indexOf("区") + 1,
              address.length
            );
          }
        }
      },
      immediate: true,
    },
  },
  created() {
    console.log(this.userInfo);
    if (this.userInfo.role_name.indexOf("ksxtadmin") != -1) {
      this.questionBankOption.column[0].dicUrl =
        "/api/blade-system/dept/lazy-tree-user?parentId=";
    } else {
      this.questionBankOption.column[0].dicUrl =
        "/api/blade-system/dept/lazy-tree-user?parentId=" +
        this.userInfo.dept_id;
    }
}
    // this.questionBankSearch["cancel"] = 1;
    // this.questionBankSearch["auditStatus"] = 0;
    // this.questionBankSearch["isExam"] = 1;
  },
  mounted() {
    var flag = false,
      i = 0,
      ind = null;
    this.$store.state.tags.tagList.forEach((item, index) => {
      if (item.label == "报名清册") {
        if (flag == false) {
          ind = index;
          flag = true;
        }
        i++;
      }
    });
    if (i > 1) {
      this.$store.state.tags.tagList.splice(ind, 1);
    }
    this.$store.commit("setWindowSizeHeightAdd");
  },
  computed: {
    ...mapState({
      userInfo: (state) => state.user.userInfo,
    }),
    ids() {
      let ids = [];
      this.questionBankSelectionList.forEach((ele) => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
    ...mapGetters(["userInfo", "permission"]),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permission.notice_add, false),
        viewBtn: this.vaildData(this.permission.notice_view, false),
        delBtn: this.vaildData(this.permission.notice_delete, false),
        editBtn: this.vaildData(this.permission.notice_edit, false),
      };
    },
  },
  methods: {
    //报名信息导出
    handleApplyInfoExport() {
      this.$confirm("是否导出考试报名信息数据?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        //获取查询条件
        // const { releaseTimeRange } = this.questionBankSearch;
        // if (releaseTimeRange) {
        //   this.questionBankSearch["startTime"] = releaseTimeRange[0];
        //   this.questionBankSearch["endTime"] = releaseTimeRange[1];
        // }
        var data = {
          cancel: this.questionBankSearch.cancel,
          auditStatus: this.questionBankSearch.auditStatus,
          deptName: this.questionBankSearch.deptName,
          isExam: this.questionBankSearch.isExam,
          realName: this.questionBankSearch.realName,
        };
        data["examId"] = this.$route.query.id;
        //序列号url形式,用&拼接
        data = Qs.stringify(data);
        window.open(
          `/api/trainingRegistration/export-apply-info?${
            this.website.tokenHeader
          }=${getToken()}&` + data
        );
      });
    },
    //行样式调整
    rowStyle({ row, column, rowIndex }) {
      if (row.auditStatus == "2") {
        return {
          color: "#ff2727",
        };
      }
    },
    //准考证查看
    handlePrint(row) {
      var obj = row;
      obj["name"] = "准考证信息";
      obj["token"] = getToken();
      // var data = Qs.stringify(obj);
      this.$router.push({
        path: `/applyexam/papers`,
        query: obj,
      });
    },
    questionBankOnLoad(page, params = {}) {
      params = this.questionBankSearch;
      params["examId"] = this.$route.query.id;
      this.questionBankLoading = false;
      getdata(
        page.currentPage,
        page.pageSize,
        Object.assign(params, this.questionBankQuery)
      ).then((res) => {
        const data = res.data.data;
        this.questionBankPage.total = data.total;
        this.questionBankData = data.records;
        this.questionBankLoading = false;
        this.questionBankSelectionClear();
        this.$store.commit("setWindowSizeHeightAdd");
      });
    },
    questionBankSelectionClear() {
      this.questionBankSelectionList = [];
      this.$refs.questionBankCrud.toggleSelection();
    },
    questionBankSelectionChange(list) {
      this.questionBankSelectionList = list;
    },
    questionBankSearchChange(params, done) {
      this.questionBankQuery = params;
      this.questionBankPage.currentPage = 1;
      this.questionBankOnLoad(this.questionBankPage, params);
      done();
    },
    questionBankSearchReset() {
      this.questionBankQuery = {};
      this.questionBankOnLoad(this.questionBankPage);
    },
    questionBankCurrentChange(currentPage) {
      this.questionBankPage.currentPage = currentPage;
    },
    questionBankSizeChange(pageSize) {
      this.questionBankPage.pageSize = pageSize;
    },
    //取消报名
    revoke(row, done, loading) {
      this.$confirm("确定取消报名?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        row.cancel = 2;
        cancelTrain(row).then(
          () => {
            this.onLoad(this.page);
            this.$message({
              type: "success",
              message: "取消报名成功!",
            });
            done();
          },
          (error) => {
            window.console.log(error);
            loading();
          }
        );
      });
    },
    //审核通过
    auditSucess(row, done, loading) {
      this.$confirm("确定审核通过?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        row.cancel = 1;
        auditSucess(row).then(
          () => {
            this.onLoad(this.page);
            this.$message({
              type: "success",
              message: "操作成功!",
            });
            done();
          },
          (error) => {
            window.console.log(error);
            loading();
          }
        );
      });
    },
    usesVipConfirm(row) {
      this.$confirm("确定将选择当前人员确认已缴费?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          var data = {
            id: row.id,
            userId: row.userId,
            vipStatus: 1,
          };
          return vipSign(data);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
        });
    },
    // 新增
    questionBankRowSave(row, done, loading) {
      adddata({
        userId: row.name,
        examId: row.examName,
        applyTime: row.applyTime,
      }).then(
        () => {
          this.questionBankOnLoad(this.questionBankPage);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          done();
        },
        (error) => {
          window.console.log(error);
          loading();
        }
      );
    },
    questionBankRowDel(row) {
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          return remove(row.id);
        })
        .then(() => {
          this.questionBankOnLoad(this.questionBankPage);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
        });
    },
    questionBankHandleDelete() {
      if (this.questionBankSelectionList.length === 0) {
        this.$message.warning("请选择至少一条数据");
        return;
      }
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          return remove(this.ids);
        })
        .then(() => {
          this.questionBankOnLoad(this.questionBankPage);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          this.$refs.questionBankCrud.toggleSelection();
        });
    },
    //清册生成
    handleExport() {
      var obj = {};
      obj["name"] = "报名清册信息";
      obj["examId"] = this.$route.query.id;
      obj["token"] = getToken();
      this.$router.push({
        path: `/applydetailed/papers`,
        query: obj,
      });
    },
    handleImport() {
      this.excelBox = true;
    },
    handleTemplate() {
      window.open(`/api/trainingRegistration/export-template`);
    },
    uploadAfter(res, done, loading, column) {
      window.console.log(column);
      this.excelBox = false;
      this.refreshChange();
      done();
    },
    refreshChange() {
      this.questionBankOnLoad(this.page, this.query);
    },
  },
};
</script>
<style lang="scss" scoped>