From 21c7375b7b38ebf2c8a2ca8fbf6fe9fb4f28250f Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Wed, 12 Jan 2022 10:59:40 +0800
Subject: [PATCH] 新增公司注册机公司注册审核

---
 src/views/trainingRegistration/index.vue |  355 ++++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 233 insertions(+), 122 deletions(-)

diff --git a/src/views/trainingRegistration/index.vue b/src/views/trainingRegistration/index.vue
index 2630d6d..b7c5ae3 100644
--- a/src/views/trainingRegistration/index.vue
+++ b/src/views/trainingRegistration/index.vue
@@ -1,6 +1,9 @@
 <template>
-  <basic-container>
+  <basic-container
+    :class="[$store.state.control.windowWidth >= 1024 ? 'oneRowSearch' : '']"
+  >
     <avue-crud
+      v-if="visibles"
       :option="option"
       :table-loading="loading"
       :data="data"
@@ -50,6 +53,14 @@
           @click="handleImport"
           >批量导入
         </el-button>
+        <el-button
+          type="warning"
+          size="small"
+          plain
+          icon="el-icon-download"
+          @click="handleApplyInfoExport"
+          >报名信息导出
+        </el-button>
       </template>
       <template slot-scope="{ type, size, row }" slot="menu">
         <el-button
@@ -58,7 +69,7 @@
           :size="size"
           :type="type"
           v-if="permission.trainingRegistration_cancel"
-          :disabled="row.cancel==2"
+          :disabled="row.cancel == 2"
           >取消报名</el-button
         >
         <el-button
@@ -66,7 +77,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>
@@ -130,13 +141,21 @@
 } 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,75 +172,60 @@
         excelBtn: false,
         menuWidth: 380,
         dialogClickModal: false,
+        ...this.$store.state.control.clearOtherBut,
         column: [
+          {
+            label: "所选保安人数",
+            prop: "number",
+            span: 24,
+            value: 0,
+            disabled: true,
+            labelWidth: 110,
+          },
           // {
-          //   label: "考试人数",
-          //   prop: "number",
-          //   type: 'number',
+          //   label: "序号开始",
+          //   prop: "serialStart",
           //   span: 12,
-          //   precision:0,
-          //   step:50,
-          //   mock:{
-          //     type:'number',
-          //     max:1000,
-          //     min:0,
-          //     precision:0
+          //   value: 1,
+          //   mock: {
+          //     type: "number",
+          //     max: 1000,
+          //     min: 1,
+          //     precision: 0,
           //   },
+          //   minRows: 1,
+          //   maxRows: 1000,
+          //   type: "number",
           //   rules: [
           //     {
           //       required: true,
-          //       message: "请输入考试人数",
+          //       message: "请输入序号",
           //       trigger: "blur",
           //     },
           //   ],
-          //   minRows: 0,
-          //   maxRows: 1000,
-          //   value:50,
           // },
-          {
-            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: "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: "startTime",
@@ -248,7 +252,7 @@
               },
             ],
             span: 12,
-            labelWidth:110
+            labelWidth: 110,
           },
           {
             label: "考试开始截止时间",
@@ -276,7 +280,7 @@
               },
             ],
             span: 12,
-            labelWidth:140
+            labelWidth: 140,
           },
         ],
       },
@@ -311,24 +315,35 @@
         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,
         align: "center",
-        selection: false,
+        reserveSelection: true,
+        selection: true,
         column: column,
         delBtn: false,
         editBtn: false,
         addBtn: false,
+        ...this.$store.state.control.clearOtherBut,
       },
     };
   },
@@ -340,7 +355,7 @@
       });
       return ids.join(",");
     },
-    ...mapGetters(["userInfo", "permission"]),
+    ...mapGetters(["userInfo", "permission", "windowWidth"]),
     permissionList() {
       return {
         addBtn: this.vaildData(this.permission.notice_add, false),
@@ -349,13 +364,76 @@
         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;
+  },
+  watch: {
+    windowHeight() {
+      // console.log(this.windowHeight, "windowHeight");
+      this.option.height = this.windowHeight - 320;
+      this.visibles = false;
+      this.$nextTick(() => {
+        this.visibles = true;
+        this.refreshChange();
+      });
+    },
+  },
+  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("不刷新");
+    // }
   },
   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;
@@ -367,11 +445,11 @@
     },
     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;
@@ -493,7 +571,18 @@
         });
     },
     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) {
@@ -529,35 +618,34 @@
       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;
-            }
-            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.loading = false;
-            });
-        })
-      })
+          var roleAlias = res.data.data.roleAlias;
+          if (
+            roleAlias == "保安公司管理员" ||
+            roleAlias == "保安" ||
+            roleAlias == "分公司管理员"
+          ) {
+            //如果是保安公司管理员
+            params["deptId"] = that.userInfo.dept_id;
+          }
+          if (roleAlias == "培训公司管理员") {
+            //如果是培训公司管理员
+            params["trainingUnitId"] = that.userInfo.dept_id;
+          }
+          // 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.loading = false;
+          });
+        });
+      });
     },
     handleImport() {
       this.excelBox = true;
@@ -575,10 +663,19 @@
 
     //生成考试弹窗
     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) {
@@ -594,27 +691,40 @@
       //    return;
       // }
 
-      var s = new Date(row.startTime);
-      var e = new Date(row.endTime);
-      if(s>e){
-        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;
       }
 
-      row['number'] = (row.serialEnd-row.serialStart)+1;
-      //创建人
-      row['creator'] = this.userInfo.Id;
+      // 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 += ",";
+        }
+      }
+      row["ids"] = str;
       //提交申请
-      addExam(Object.assign(row, this.search)).then(
+      let overData = Object.assign(row);
+      console.log(overData, "overData");
+      // done();
+      // return;
+      addExam(overData).then(
         () => {
           this.onLoad(this.page);
           that.$refs.formExamApply.resetFields();
@@ -623,6 +733,7 @@
             type: "success",
             message: "操作成功",
           });
+          this.$refs.crud.toggleSelection();
           done();
         },
         (error) => {

--
Gitblit v1.9.3