From 6db53ef580927d11e9d9c0059ce8cada692142d5 Mon Sep 17 00:00:00 2001
From: liuyg <376836862@qq.com>
Date: Tue, 07 Sep 2021 17:13:05 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.105:10010/r/zhba_enterprises

---
 src/views/trainingRegistration/index.vue |   93 ++++++++++++++++++++++++++++------------------
 1 files changed, 57 insertions(+), 36 deletions(-)

diff --git a/src/views/trainingRegistration/index.vue b/src/views/trainingRegistration/index.vue
index c02e989..372c962 100644
--- a/src/views/trainingRegistration/index.vue
+++ b/src/views/trainingRegistration/index.vue
@@ -5,6 +5,7 @@
       :table-loading="loading"
       :data="data"
       :page.sync="page"
+      :search.sync="search"
       ref="crud"
       @row-del="rowDel"
       v-model="form"
@@ -57,6 +58,7 @@
           :size="size"
           :type="type"
           v-if="permission.trainingRegistration_cancel"
+          :disabled="row.cancel==2"
           >取消报名</el-button
         >
         <el-button
@@ -64,7 +66,7 @@
           size="small"
           icon="el-icon-receiving"
           v-if="permission.trainingRegistration_print"
-          :disabled="row.candidateNo == ''"
+          :disabled="row.candidateNo == '' || row.cancel==2"
           @click="handlePrint(row)"
           >准考证打印
         </el-button>
@@ -127,12 +129,14 @@
   addExam,
 } from "@/api/trainingRegistration/trainingRegistration";
 import { mapGetters } from "vuex";
+import { getRoleDetail } from "@/api/system/role";
 export default {
   data() {
     return {
       loading: true,
       excelBox: false,
       dialogExamFormVisible: false,
+      search:{},
       optionExamApply: {
         height: "auto",
         filterBtn: true,
@@ -343,6 +347,11 @@
         editBtn: this.vaildData(this.permission.notice_edit, false),
       };
     },
+   
+  },
+  created(){
+    this.search['cancel'] = 1;
+    this.search['auditStatus'] = 4;
   },
   methods: {
     //准考证查看
@@ -355,15 +364,12 @@
       });
     },
     sizeChange(val) {
-      this.page1.currentPage = 1;
-      this.page1.pageSize = val;
+      this.page.pageSize = val;
       this.getData();
-      //   this.$message.success("行数" + val);
     },
     currentChange(val) {
-      this.page1.currentPage = val;
+      this.page.currentPage = val;
       this.getData();
-      //   this.$message.success("页码" + val);
     },
     rowSave(form, done, loading) {
       var that = this;
@@ -405,8 +411,6 @@
       this.onLoad(this.page);
     },
     rowUpdate(row, index, done, loading) {
-      // console.log(row);
-
       update(row).then(
         () => {
           this.onLoad(this.page);
@@ -515,20 +519,42 @@
       this.onLoad(this.page, this.query);
     },
     onLoad(page, params = {}) {
-      // params['cancel'] = 111;
       this.loading = true;
-      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 that = this;
+      //获取当前登录人员的角色信息
+      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;
+            });
+        })
+      })
     },
     handleImport() {
       this.excelBox = true;
@@ -554,19 +580,19 @@
     //生成考试
     submitExamApply(row, done, loading) {
       var that = this;
-      var startTime = row.startTime + ":00";
-      var endTime = row.endTime + ":00";
+      row.startTime = row.startTime + ":00";
+      row.endTime = row.endTime + ":00";
       if(row.number!=((row.serialEnd-row.serialStart)+1)){
           this.$message({
             type: "error",
-            message: "考试人数也序号不匹配!",
+            message: "考试人数与序号不匹配!",
           });
          done();
          return;
       }
 
-      var s = new Date(startTime);
-      var e = new Date(endTime);
+      var s = new Date(row.startTime);
+      var e = new Date(row.endTime);
       if(s>e){
         this.$message({
             type: "error",
@@ -576,12 +602,15 @@
          return;
       }
       
-      addExam(this.ids, null, startTime,row.number, endTime,row.serialStart,row.serialEnd).then(
+      addExam(Object.assign(row, this.search)).then(
         () => {
           this.onLoad(this.page);
-          
           that.$refs.formExamApply.resetFields();
           that.dialogExamFormVisible = false;
+          this.$message({
+            type: "success",
+            message: "操作成功",
+          });
           done();
         },
         (error) => {
@@ -594,14 +623,6 @@
     closeDialog() {
       this.$refs.formExamApply.resetFields();
     },
-  },
-  mounted() {
-    // this.Ourdata = data;
-    // this.getData();
-    // this.onLoad(this.page);
-    // var dept_id = JSON.parse(
-    //   window.localStorage.getItem("saber-userInfo")
-    // ).content.dept_id;
   },
 };
 </script>

--
Gitblit v1.9.3