From e75feee9d0cbd99cf727b1ea9b8598fe4af0d8b0 Mon Sep 17 00:00:00 2001
From: liuyg <376836862@qq.com>
Date: Mon, 25 Oct 2021 16:24:04 +0800
Subject: [PATCH] 保安员新增年龄限制

---
 src/views/securityGuard/securityGuard.vue |   18 +++++++-
 src/views/exam/performance.vue            |   70 +++++++++++++++++++----------------
 2 files changed, 53 insertions(+), 35 deletions(-)

diff --git a/src/views/exam/performance.vue b/src/views/exam/performance.vue
index fad79a9..1e45f4f 100644
--- a/src/views/exam/performance.vue
+++ b/src/views/exam/performance.vue
@@ -1,8 +1,8 @@
 /*
  * @Author: Morpheus
  * @Date: 2021-07-05 16:31:54
- * @Last Modified by: Morpheus
- * @Last Modified time: 2021-07-18 19:44:47
+ * @Last Modified by: liu
+ * @Last Modified time: 2021-10-25 15:10:09
  * menu-name 成绩管理
  */
 <template>
@@ -38,7 +38,15 @@
               {{ row.allGrade == -1 ? "" : row.allGrade }}
             </template>
             <template slot-scope="{ row }" slot="qualified">
-              {{ row.qualified == -1 ? "" : row.qualified==0?"合格":row.qualified==1?"不合格":'' }}
+              {{
+                row.qualified == -1
+                  ? ""
+                  : row.qualified == 0
+                  ? "合格"
+                  : row.qualified == 1
+                  ? "不合格"
+                  : ""
+              }}
             </template>
 
             <!-- 自定义按钮 -->
@@ -73,7 +81,7 @@
                 icon="el-icon-collection"
                 class="start-kaoshi"
                 v-if="permission.performance_print"
-                :disabled="row.qualified==1"
+                :disabled="row.qualified == 1"
                 @click="securityPrint(row)"
                 >保安证打印
               </el-button>
@@ -84,7 +92,6 @@
             title="实操成绩导入"
             append-to-body
             :visible.sync="excelBox"
-            
             width="555px"
           >
             <avue-form
@@ -187,7 +194,7 @@
               },
             ],
             // overHidden: true,
-            width:230,
+            width: 230,
           },
           {
             label: "用户名",
@@ -214,7 +221,7 @@
                 trigger: "blur",
               },
             ],
-            width:160
+            width: 160,
           },
           {
             label: "所属公司",
@@ -246,7 +253,7 @@
                 trigger: "blur",
               },
             ],
-            width:250,
+            width: 250,
           },
           {
             label: "考试开始时间",
@@ -497,7 +504,7 @@
       },
     };
   },
-  computed:{
+  computed: {
     ...mapGetters(["userInfo", "permission"]),
     permissionList() {
       return {
@@ -519,31 +526,30 @@
       var roleIds = this.userInfo.role_id.split(",");
       roleIds.forEach((roleId) => {
         getRoleDetail(roleId).then((res) => {
-            var roleAlias = res.data.data.roleAlias;
-            if (
-              roleAlias == "保安公司管理员" ||
-              roleAlias == "保安" ||
-              roleAlias == "未持证保安"
-            ) {
-              //如果是保安公司管理员
-              params["deptId"] = that.userInfo.dept_id;
-            }
+          var roleAlias = res.data.data.roleAlias;
+          if (
+            roleAlias == "保安公司管理员" ||
+            roleAlias == "保安" ||
+            roleAlias == "未持证保安"
+          ) {
+            //如果是保安公司管理员
+            params["deptId"] = that.userInfo.dept_id;
+          }
+          that.questionBankLoading = false;
+          params["examType"] = 1;
+          getList(
+            page.currentPage,
+            page.pageSize,
+            Object.assign(params, this.query)
+          ).then((res) => {
+            const data = res.data.data;
+            that.questionBankPage.total = data.total;
+            that.questionBankData = data.records;
             that.questionBankLoading = false;
-            params["examType"] = 1;
-            getList(
-              page.currentPage,
-              page.pageSize,
-              Object.assign(params, this.query)
-            ).then((res) => {
-              const data = res.data.data;
-              that.questionBankPage.total = data.total;
-              that.questionBankData = data.records;
-              that.questionBankLoading = false;
-              that.questionBankSelectionClear();
-            });
-        })
+            that.questionBankSelectionClear();
+          });
+        });
       });
-      
     },
     questionBankSelectionClear() {
       this.questionBankSelectionList = [];
diff --git a/src/views/securityGuard/securityGuard.vue b/src/views/securityGuard/securityGuard.vue
index 3cf9e0d..43a6590 100644
--- a/src/views/securityGuard/securityGuard.vue
+++ b/src/views/securityGuard/securityGuard.vue
@@ -335,12 +335,24 @@
     //     callback();
     //   }
     // };
+    var date = new Date();
+    let year = date.getFullYear(),
+      oldyear;
+
     const validatePassCardid = (rule, value, callback) => {
-      var test = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/g;
-      if (!test.test(value) && value.length < 17) {
+      var test =
+        /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
+      if (!test.test(value)) {
         callback(new Error("请输入正确身份证号码"));
       } else {
-        callback();
+        //加入校验18岁到60岁的
+        oldyear = +value.slice(6, 10);
+        if (year - oldyear < 18 || year - oldyear > 60) {
+          // callback(new Error("根据国家要求,需在18岁至60岁"));
+          callback(new Error("年龄不符"));
+        } else {
+          callback();
+        }
       }
     };
     const validatePassPhone = (rule, value, callback) => {

--
Gitblit v1.9.3