Administrator
2022-04-11 79d9fc857559982b00b68b2d709807bdc4cd286f
src/views/trainingRegistration/index.vue
@@ -1,6 +1,13 @@
<template>
  <basic-container>
  <basic-container
    :class="[
      $store.state.control.screenSize == 1366 ? 'smallSize' : 'normalSize',
      $store.state.control.windowWidth >= 1024 ? 'tooRowSearch1' : ''
    ]"
  >
    <avue-crud
      class="tablesss"
      v-if="visibles"
      :option="option"
      :table-loading="loading"
      :data="data"
@@ -50,6 +57,23 @@
          @click="handleImport"
          >批量导入
        </el-button>
        <el-button
          type="warning"
          size="small"
          plain
          icon="el-icon-download"
          @click="handleApplyInfoExport"
          >报名信息导出
        </el-button>
        <el-button
          type="primary"
          size="small"
          plain
          icon="el-icon-checked"
          v-if="permission.batch_vip"
          @click="usesVipConfirmBatch"
          >批量缴费
        </el-button>
      </template>
      <template slot-scope="{ type, size, row }" slot="menu">
        <el-button
@@ -58,7 +82,7 @@
          :size="size"
          :type="type"
          v-if="permission.trainingRegistration_cancel"
          :disabled="row.cancel==2"
          :disabled="row.cancel == 2"
          >取消报名</el-button
        >
        <el-button
@@ -66,7 +90,7 @@
          size="small"
          icon="el-icon-receiving"
          v-if="permission.trainingRegistration_print"
          :disabled="row.candidateNo == '' || row.cancel==2"
          :disabled="row.candidateNo == '' || row.cancel == 2"
          @click="handlePrint(row)"
          >准考证打印
        </el-button>
@@ -77,6 +101,14 @@
          :size="size"
          :type="type"
          >确认报名</el-button
        >
        <el-button
          v-if="row.vipStatus!=1 && permission.trainingRegistration_vip"
          icon="el-icon-folder-checked"
          @click="usesVipConfirm(row)"
          :size="size"
          :type="type"
          >缴费确认</el-button
        >
      </template>
    </avue-crud>
@@ -127,16 +159,26 @@
  remove,
  cancelTrain,
  addExam,
  vipSign,
  vipSignBatch
} from "@/api/trainingRegistration/trainingRegistration";
import { mapGetters } from "vuex";
import { getRoleDetail } from "@/api/system/role";
import Qs from "qs";
import { getToken } from "@/util/auth";
export default {
  data() {
    return {
      visibles: true,
      choiceName: [],
      loading: true,
      excelBox: false,
      dialogExamFormVisible: false,
      search:{},
      search: {},
      examApply: {
        number: 0
      },
      optionExamApply: {
        height: "auto",
        filterBtn: true,
@@ -153,77 +195,62 @@
        excelBtn: false,
        menuWidth: 380,
        dialogClickModal: false,
        ...this.$store.state.control.clearOtherBut,
        column: [
          {
            label: "考试人数",
            label: "所选保安人数",
            prop: "number",
            type: 'number',
            span: 12,
            precision:0,
            step:50,
            mock:{
              type:'number',
              max:1000,
              min:0,
              precision:0
            },
            rules: [
              {
                required: true,
                message: "请输入考试人数",
                trigger: "blur",
              },
            ],
            minRows: 0,
            maxRows: 1000,
            value:50,
            span: 24,
            value: 0,
            disabled: true,
            labelWidth: 110
          },
          // {
          //   label: "序号开始",
          //   prop: "serialStart",
          //   span: 12,
          //   value: 1,
          //   mock: {
          //     type: "number",
          //     max: 1000,
          //     min: 1,
          //     precision: 0,
          //   },
          //   minRows: 1,
          //   maxRows: 1000,
          //   type: "number",
          //   rules: [
          //     {
          //       required: true,
          //       message: "请输入序号",
          //       trigger: "blur",
          //     },
          //   ],
          // },
          // {
          //   label: "序号结束",
          //   prop: "serialEnd",
          //   span: 12,
          //   value: 50,
          //   mock: {
          //     type: "number",
          //     max: 1000,
          //     min: 1,
          //     precision: 0,
          //   },
          //   minRows: 1,
          //   maxRows: 1000,
          //   type: "number",
          //   rules: [
          //     {
          //       required: true,
          //       message: "请输入序号",
          //       trigger: "blur",
          //     },
          //   ],
          // },
          {
            label: "序号开始",
            prop: "serialStart",
            span: 6,
            value:1,
            mock:{
              type:'number',
              max:1000,
              min:1,
              precision:0
            },
            minRows: 1,
            maxRows: 1000,
            type:"number",
            rules: [
              {
                required: true,
                message: "请输入序号",
                trigger: "blur",
              },
            ],
          },
          {
            label: "序号结束",
            prop: "serialEnd",
            span: 6,
            value:50,
            mock:{
              type:'number',
              max:1000,
              min:1,
              precision:0
            },
            minRows: 1,
            maxRows: 1000,
            type:"number",
            rules: [
              {
                required: true,
                message: "请输入序号",
                trigger: "blur",
              },
            ],
          },
          {
            label: "考试时间",
            label: "考试开始时间",
            prop: "startTime",
            type: "datetime",
            format: "yyyy-MM-dd HH:mm",
@@ -244,13 +271,14 @@
              {
                required: true,
                message: "请选择考试时间",
                trigger: "blur",
              },
                trigger: "blur"
              }
            ],
            span: 12,
            labelWidth: 110
          },
          {
            label: "截止时间",
            label: "考试开始截止时间",
            prop: "endTime",
            type: "datetime",
            format: "yyyy-MM-dd HH:mm",
@@ -271,12 +299,13 @@
              {
                required: true,
                message: "请选择考试时间",
                trigger: "blur",
              },
                trigger: "blur"
              }
            ],
            span: 12,
          },
        ],
            labelWidth: 140
          }
        ]
      },
      excelForm: {},
      excelOption: {
@@ -291,110 +320,175 @@
            loadText: "模板上传中,请稍等",
            span: 24,
            propsHttp: {
              res: "data",
              res: "data"
            },
            tip: "请上传 .xls,.xlsx 标准格式文件",
            action: "/api/trainingRegistration/import-trainingRegistration",
            action: "/api/trainingRegistration/import-trainingRegistration"
          },
          {
            label: "模板下载",
            prop: "excelTemplate",
            formslot: true,
            span: 24,
          },
        ],
            span: 24
          }
        ]
      },
      selectionList: [],
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
        ...this.$store.state.control.changePageSize
      },
      query: {},
      data: [],
      option: {
        // card: true,
        tip: false,
        // tip: false,
        // searchSize: "mini",
        searchMenuSpan: 6,
        height: 583,
        index: true,
        height: "auto",
        index: false,
        selectable: (row, index) => {
          // console.log(row, index);
          if (row.auditStatus == 4 && row.cancel == 1) {
            return true;
          } else {
            return false;
          }
        },
        labelWidth: "120",
        menuWidth: 200,
        menuWidth: 280,
        align: "center",
        selection: false,
        reserveSelection: true,
        selection: true,
        column: column,
        delBtn: false,
        editBtn: false,
        addBtn: false,
      },
        ...this.$store.state.control.clearOtherBut
      }
    };
  },
  computed: {
    ids() {
      let ids = [];
      this.selectionList.forEach((ele) => {
      this.selectionList.forEach(ele => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
    ...mapGetters(["userInfo", "permission"]),
    ...mapGetters(["userInfo", "permission", "windowWidth"]),
    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),
        editBtn: this.vaildData(this.permission.notice_edit, false)
      };
    },
    }
  },
  created(){
    this.search['cancel'] = 1;
    this.search['auditStatus'] = 4;
  created() {
    this.search["cancel"] = 1;
    this.search["auditStatus"] = 4;
    this.search["isExam"] = 1;
  },
  mounted() {
    // if (window.name == "baoming") {
    //   let old = JSON.parse(window.localStorage.getItem("baoming"));
    //   this.choiceName = old;
    //   console.log(old);
    //   console.log("刷新");
    // } else {
    //   window.name = "baoming";
    //   console.log("不刷新");
    // }
    this.$store.commit("setWindowSizeHeightAdd");
  },
  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.search.cancel,
          auditStatus: this.search.auditStatus,
          deptName: this.search.deptName,
          isExam: this.search.isExam,
          realName: this.search.realName
        };
        if (
          this.userInfo.role_name == "保安公司管理员" ||
          this.userInfo.role_name == "保安" ||
          this.userInfo.role_name == "分公司管理员"
        ) {
          //如果是保安公司管理员
          data["deptId"] = this.userInfo.dept_id;
        }
        if (this.userInfo.role_name == "培训公司管理员") {
          //如果是培训公司管理员
          data["trainingUnitId"] = this.userInfo.dept_id;
        }
        //序列号url形式,用&拼接
        data = Qs.stringify(data);
        window.open(
          `/api/trainingRegistration/export-apply-info?${
            this.website.tokenHeader
          }=${getToken()}&` + data
        );
      });
    },
    //准考证查看
    handlePrint(row) {
      var obj = row;
      obj["name"] = "准考证信息";
      this.$router.push({
        path: `/applyexam/papers`,
        query: obj,
        query: obj
      });
    },
    sizeChange(val) {
      this.page.pageSize = val;
      this.getData();
      // this.getData();
    },
    currentChange(val) {
      this.page.currentPage = val;
      this.getData();
      // this.getData();
    },
    rowSave(form, done, loading) {
      var that = this;
      adddata(form).then(
        (res) => {
        res => {
          this.onLoad(this.page);
          if (res.data.data == 201) {
            this.$message({
              type: "warning",
              message: "已报名,不能重复报名",
              message: "已报名,不能重复报名"
            });
          } else if (res.data.data == 201) {
            this.$message({
              type: "warning",
              message: "报名失败",
              message: "报名失败"
            });
          } else {
            this.$message({
              type: "success",
              message: "报名成功",
              message: "报名成功"
            });
          }
          done();
        },
        (error) => {
        error => {
          window.console.log(error);
          loading();
        }
@@ -416,11 +510,11 @@
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
            message: "操作成功!"
          });
          done();
        },
        (error) => {
        error => {
          window.console.log(error);
          loading();
        }
@@ -431,7 +525,7 @@
      this.$confirm("确认报名?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        type: "warning"
      }).then(() => {
        row.cancel = 3;
        update(row).then(
@@ -439,11 +533,11 @@
            this.onLoad(this.page);
            this.$message({
              type: "success",
              message: "确认报名成功!",
              message: "确认报名成功!"
            });
            done();
          },
          (error) => {
          error => {
            window.console.log(error);
            loading();
          }
@@ -454,7 +548,7 @@
      this.$confirm("确定取消报名?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        type: "warning"
      }).then(() => {
        row.cancel = 2;
        cancelTrain(row).then(
@@ -462,11 +556,11 @@
            this.onLoad(this.page);
            this.$message({
              type: "success",
              message: "取消报名成功!",
              message: "取消报名成功!"
            });
            done();
          },
          (error) => {
          error => {
            window.console.log(error);
            loading();
          }
@@ -477,7 +571,7 @@
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        type: "warning"
      })
        .then(() => {
          return remove(row.id);
@@ -486,12 +580,67 @@
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
            message: "操作成功!"
          });
        });
    },
    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: "操作成功!"
          });
        });
    },
    usesVipConfirmBatch(){
        this.$confirm("确定已缴费?", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
      })
        .then(() => {
          var data = {
            cancel : 1,
            isExam: 1,
            vipStatus :2
          }
          return vipSignBatch(data);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
        });
    },
    selectionChange(list) {
      this.selectionList = list;
      // this.selectionList = list;
      this.choiceName = [];
      // console.log(window.name);
      for (let k in list) {
        this.choiceName.push({
          label: list[k].realName,
          value: list[k].id
        });
      }
      // window.localStorage.setItem("baoming", JSON.stringify(this.choiceName));
      // console.log(this.choiceName);
    },
    handleDelete() {
      if (this.selectionList.length === 0) {
@@ -501,7 +650,7 @@
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        type: "warning"
      })
        .then(() => {
          return remove(this.ids);
@@ -510,7 +659,7 @@
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
            message: "操作成功!"
          });
          this.$refs.crudrec.toggleSelection();
        });
@@ -525,36 +674,41 @@
      //获取当前登录人员的角色信息
      var roleIds = this.userInfo.role_id.split(",");
      params = this.search;
      roleIds.forEach((roleId) => {
        getRoleDetail(roleId).then((res) => {
            var roleAlias = res.data.data.roleAlias;
            if (
              roleAlias == "保安公司管理员" ||
              roleAlias == "保安"
            ) {
              //如果是保安公司管理员
              params["deptId"] = that.userInfo.dept_id;
            }
            if (
              roleAlias == "培训公司管理员"
            ) {
              //如果是培训公司管理员
              params["trainingUnitId"] = that.userInfo.dept_id;
            }
            getdata(
              page.currentPage,
              page.pageSize,
              Object.assign(params, this.query)
            ).then((res) => {
              // console.log(res);
              const data = res.data.data;
              this.page.total = data.total;
              this.data = data.records;
              console.log(this.data);
              this.loading = false;
            });
        })
      })
      roleIds.forEach(roleId => {
        getRoleDetail(roleId).then(res => {
          var roleAlias = res.data.data.roleAlias;
          if (
            roleAlias == "保安公司管理员" ||
            roleAlias == "保安" ||
            roleAlias == "分公司管理员"
          ) {
            //如果是保安公司管理员
            params["deptId"] = that.userInfo.dept_id;
          }
          if (roleAlias == "培训公司管理员") {
            //如果是培训公司管理员
            params["trainingUnitId"] = that.userInfo.dept_id;
          }
          if (roleAlias == "公安管理员" || roleAlias == "民警") {
            //如果公安
            params["jurisdiction"] = that.userInfo.jurisdiction;
          }
          // params["isExam"] = 1;
          getdata(
            page.currentPage,
            page.pageSize,
            Object.assign(params, this.query)
          ).then(res => {
            // console.log(res);
            const data = res.data.data;
            this.page.total = data.total;
            this.data = data.records;
            // console.log(this.data);
            this.$store.commit("setWindowSizeHeightAdd");
            this.loading = false;
          });
        });
      });
    },
    handleImport() {
      this.excelBox = true;
@@ -572,48 +726,80 @@
    //生成考试弹窗
    handleBatchExam() {
      this.dialogExamFormVisible = true;
      if (this.selectionList.length === 0) {
        this.ids = "";
      if (this.choiceName.length == 0) {
        this.$message({
          message: "未选择保安员",
          type: "warning"
        });
        return;
      }
      this.dialogExamFormVisible = true;
      this.examApply.number = this.choiceName.length;
      // if (this.selectionList.length === 0) {
      //   this.ids = "";
      // }
    },
    //生成考试
    submitExamApply(row, done, loading) {
      var that = this;
      row.startTime = row.startTime + ":00";
      row.endTime = row.endTime + ":00";
      if(row.number!=((row.serialEnd-row.serialStart)+1)){
          this.$message({
            type: "error",
            message: "考试人数也序号不匹配!",
          });
         done();
         return;
      // if(row.number!=((row.serialEnd-row.serialStart)+1)){
      //     this.$message({
      //       type: "error",
      //       message: "考试人数与序号不匹配!",
      //     });
      //    done();
      //    return;
      // }
      // var s = new Date(row.startTime);
      // var e = new Date(row.endTime);
      // if (s > e) {
      //   this.$message({
      //     type: "error",
      //     message: "考试开始截止时间不能早于考试考试开始时间!",
      //   });
      //   done();
      //   return;
      // }
      if (that.userInfo.role_name == "培训公司管理员") {
        //如果是培训公司管理员
        row["trainingUnitId"] = that.userInfo.dept_id;
      }
      var s = new Date(row.startTime);
      var e = new Date(row.endTime);
      if(s>e){
        this.$message({
            type: "error",
            message: "截止时间不能早于考试考试开始时间!",
          });
         done();
         return;
      // row["number"] = row.serialEnd - row.serialStart + 1;
      // //创建人
      row["creator"] = this.userInfo.Id;
      let cho = this.choiceName;
      let str = "";
      for (let k in cho) {
        str += cho[k].value;
        if (k != cho.length - 1) {
          str += ",";
        }
      }
      addExam(Object.assign(row, this.search)).then(
      row["ids"] = str;
      //提交申请
      let overData = Object.assign(row);
      console.log(overData, "overData");
      // done();
      // return;
      addExam(overData).then(
        () => {
          this.onLoad(this.page);
          that.$refs.formExamApply.resetFields();
          that.dialogExamFormVisible = false;
          this.$message({
            type: "success",
            message: "操作成功",
            message: "操作成功"
          });
          this.$refs.crud.toggleSelection();
          done();
        },
        (error) => {
        error => {
          window.console.log(error);
          loading();
        }
@@ -622,10 +808,9 @@
    //关闭窗口清除数据
    closeDialog() {
      this.$refs.formExamApply.resetFields();
    },
  },
    }
  }
};
</script>
<style>
</style>
<style></style>