From d8cb402b82f93279531be6babbb89400a50a178d Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Fri, 05 Nov 2021 10:40:08 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.105:10010/r/zhba_enterprises

---
 src/views/securityGuard/securityGuard.vue |  499 +++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 340 insertions(+), 159 deletions(-)

diff --git a/src/views/securityGuard/securityGuard.vue b/src/views/securityGuard/securityGuard.vue
index 5b04176..b00c5e1 100644
--- a/src/views/securityGuard/securityGuard.vue
+++ b/src/views/securityGuard/securityGuard.vue
@@ -46,7 +46,7 @@
               icon="el-icon-upload2"
               v-if="permission.securityGuard_import"
               @click="handleImport1"
-              >批量导入
+              >保安员批量导入
             </el-button>
             <el-button
               type="success"
@@ -57,6 +57,16 @@
               @click="handleImport2"
               >个人照片批量上传
             </el-button>
+            <el-button
+              type="primary"
+              size="small"
+              plain
+              v-if="permission.securityGuard_security_apply"
+              icon="el-icon-s-promotion"
+              @click="handleSecurityApply"
+              >制证申请
+            </el-button>
+
             <el-button
               type="danger"
               style="display: none"
@@ -131,7 +141,7 @@
               :size="size"
               :type="type"
               v-if="permission.securityGuard_delete && row.status != 2"
-              @click.stop="rowDel(row)"
+              @click.stop="rowStatus(row)"
               >离职登记
             </el-button>
             <el-button
@@ -284,7 +294,7 @@
     </el-col>
   </el-row>
 </template>
- 
+
 <script>
 import {
   getUser,
@@ -299,6 +309,7 @@
   getUserPractitionersInfo,
   saveOrUpdateUserPractitionersInfo,
 } from "@/api/system/user";
+import {securityApply} from '@/api/accreditationRecords/accreditationRecords'
 import { getList } from "@/api/securityGuard/securityGuard";
 import { getDeptLazyTree } from "@/api/system/dept";
 import { getRoleTree, getRoleDetail } from "@/api/system/role";
@@ -311,47 +322,88 @@
 
 export default {
   data() {
-    const validatePass = (rule, value, callback) => {
-      if (value === "") {
-        callback(new Error("请输入密码"));
-      } else {
-        callback();
-      }
-    };
-    const validatePass2 = (rule, value, callback) => {
-      if (value === "") {
-        callback(new Error("请再次输入密码"));
-      } else if (value !== this.form.password) {
-        callback(new Error("两次输入密码不一致!"));
-      } else {
-        callback();
-      }
-    };
-    const validatePassNumber = (rule, value, callback) => {
-      var test = /^[0-9]*$/gm;
-      if (!test.test(value)) {
-        callback(new Error("请输入数字"));
-      } else {
-        callback();
-      }
-    };
+    // const validatePass = (rule, value, callback) => {
+    //   if (value === "") {
+    //     callback(new Error("请输入密码"));
+    //   } else {
+    //     callback();
+    //   }
+    // };
+    // const validatePass2 = (rule, value, callback) => {
+    //   if (value === "") {
+    //     callback(new Error("请再次输入密码"));
+    //   } else if (value !== this.form.password) {
+    //     callback(new Error("两次输入密码不一致!"));
+    //   } else {
+    //     callback();
+    //   }
+    // };
+    // const validatePassNumber = (rule, value, callback) => {
+    //   var test = /^[0-9]*$/gm;
+    //   if (!test.test(value)) {
+    //     callback(new Error("请输入数字"));
+    //   } else {
+    //     callback();
+    //   }
+    // };
+    var date = new Date();
+    let year = date.getFullYear(),
+      mouth = date.getMonth() + 1,
+      day = date.getDate(),
+      oldy,
+      oldm,
+      oldd,
+      ok = false;
+
     const validatePassCardid = (rule, value, callback) => {
-      var test = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/g;
-      if (!test.test(value) && value.length < 17) {
+      // console.log(oldy, oldm, oldd, year - oldy, mouth, day);
+      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岁的
+        oldy = +value.slice(6, 10);
+        oldm = +value.slice(10, 12);
+        oldd = +value.slice(12, 14);
+        ok =
+          year - oldy < 18 || year - oldy > 60
+            ? false
+            : year - oldy == 18
+            ? mouth < oldm
+              ? false
+              : mouth > oldm
+              ? true
+              : day < oldd
+              ? false
+              : true
+            : year - oldy == 60
+            ? mouth < oldm
+              ? true
+              : mouth > oldm
+              ? false
+              : day <= oldd
+              ? false
+              : true
+            : true;
+        if (ok) {
+          callback();
+        } else {
+          // callback(new Error("根据国家要求,需在18岁至60岁"));
+          callback(new Error("年龄不符"));
+        }
       }
     };
     const validatePassPhone = (rule, value, callback) => {
-      var test =
-        /^(13[0-9]|14[5|7]|15[0|1|2|3|4|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$/g;
+      var test = /^(13[0-9]|14[0-9]|15[0-9]|17[0-9]|18[0-9]|19[0-9])\d{8}$/g;
       if (!test.test(value)) {
         callback(new Error("请输入正确手机号码"));
       } else {
         callback();
       }
     };
+    console.log(this.userInfo, 123);
+
     return {
       securityid: "",
       excelBox1: false,
@@ -373,7 +425,7 @@
               res: "data",
             },
             tip: "请上传 .xls,.xlsx 标准格式文件",
-            action: "/api/blade-user/import-user",
+            action: "/api/blade-user/import-user?deptId=" + this.deptIds,
           },
           {
             label: "模板下载",
@@ -398,12 +450,11 @@
             propsHttp: {
               res: "data",
             },
-            tip: "请上传 zip 压缩文件",
+            tip: "请上传 zip 压缩文件,照片文件名以身份证号码命名",
             action: "/api/blade-resource/oss/endpoint/put-file-zip",
           },
         ],
       },
-
       form: {},
       search: {},
       roleBox: false,
@@ -421,6 +472,7 @@
       },
       roleId: "1412226235153731586",
       deptId: "1413470343230877697",
+      deptIds: "",
       platformPage: {
         pageSize: 10,
         currentPage: 1,
@@ -464,22 +516,29 @@
           children: "children",
         },
       },
+      choiceList: [],
       option: {
         height: "auto",
         calcHeight: 80,
-        tip: false,
+        tip: true,
         searchShow: true,
-
+        reserveSelection:true,
+        selectable: (row) => {
+          if (row.hold!=="1") {
+            return false;
+          } else {
+            return true;
+          }
+        },
         indexWidth: 55,
         searchMenuSpan: 6,
         stripe: true,
         border: true,
-        delBtn: false,
-
+        delBtn: true,
         align: "center",
         index: true,
         delBtnText: "注销",
-        menuWidth: 271,
+        menuWidth: 327,
         selection: true,
         viewBtn: true,
         defaultExpandAll: true,
@@ -514,49 +573,6 @@
                 ],
               },
               {
-                label: "登录账号",
-                prop: "account",
-                editDisabled: true,
-                rules: [
-                  {
-                    required: true,
-                    message: "请输入登录账号",
-                    trigger: "blur",
-                  },
-                ],
-                // disabled: true,
-              },
-              {
-                label: "密码",
-                prop: "password",
-                type: "password",
-                hide: true,
-                editDisplay: false,
-                viewDisplay: false,
-                rules: [
-                  { required: true, validator: validatePass, trigger: "blur" },
-                ],
-              },
-              {
-                label: "确认密码",
-                prop: "password2",
-                type: "password",
-                hide: true,
-                editDisplay: false,
-                viewDisplay: false,
-                rules: [
-                  { required: true, validator: validatePass2, trigger: "blur" },
-                ],
-              },
-            ],
-          },
-          {
-            label: "详细信息",
-            prop: "detailInfo",
-            labelWidth: "110",
-            icon: "el-icon-s-order",
-            column: [
-              {
                 label: "姓名",
                 prop: "realName",
                 rules: [
@@ -572,68 +588,49 @@
                   },
                 ],
               },
-              {
-                label: "昵称",
-                prop: "name",
-              },
-              {
-                label: "个人照片",
-                type: "upload",
-                listType: "picture-img",
-                propsHttp: {
-                  res: "data",
-                  url: "url",
-                },
-                canvasOption: {
-                  text: " ",
-                  ratio: 0.1,
-                },
-                action: "/api/blade-resource/oss/endpoint/put-files",
-                tip: "只能上传jpg/png个人头像,且不超过500kb",
-                span: 10,
-                // row: true,
-                prop: "avatar",
-              },
-              {
-                label: "指纹信息",
-                type: "upload",
-                listType: "picture-img",
-                propsHttp: {
-                  res: "data",
-                  url: "url",
-                },
-                canvasOption: {
-                  text: " ",
-                  ratio: 0.1,
-                },
-                action: "/api/blade-resource/oss/endpoint/put-files",
-                tip: "只能上传jpg/png指纹信息,且不超过500kb",
-                span: 10,
-                // row: true,
-                prop: "fingerprint",
-              },
-              {
-                label: "是否持证",
-                prop: "hold",
-                dicUrl: "/api/blade-system/dict-biz/dictionary?code=equipage",
-                props: {
-                  label: "dictValue",
-                  value: "dictKey",
-                },
-                type: "select",
-                rules: [
-                  {
-                    required: true,
-                    message: "请选择",
-                    trigger: "blur",
-                  },
-                ],
-              },
-              {
-                label: "保安员证编号",
-                prop: "securitynumber",
-                hide: true,
-              },
+              // {
+              //   label: "登录账号",
+              //   prop: "account",
+              //   editDisabled: true,
+              //   rules: [
+              //     {
+              //       required: true,
+              //       message: "请输入登录账号",
+              //       trigger: "blur",
+              //     },
+              //   ],
+              //   // disabled: true,
+              // },
+              // {
+              //   label: "密码",
+              //   prop: "password",
+              //   type: "password",
+              //   hide: true,
+              //   editDisplay: false,
+              //   viewDisplay: false,
+              //   rules: [
+              //     { required: true, validator: validatePass, trigger: "blur" },
+              //   ],
+              // },
+              // {
+              //   label: "确认密码",
+              //   prop: "password2",
+              //   type: "password",
+              //   hide: true,
+              //   editDisplay: false,
+              //   viewDisplay: false,
+              //   rules: [
+              //     { required: true, validator: validatePass2, trigger: "blur" },
+              //   ],
+              // },
+            ],
+          },
+          {
+            label: "详细信息",
+            prop: "detailInfo",
+            labelWidth: "110",
+            icon: "el-icon-s-order",
+            column: [
               {
                 label: "身份证号",
                 prop: "cardid",
@@ -669,6 +666,90 @@
                   },
                 ],
               },
+              // {
+              //   label: "昵称",
+              //   prop: "name",
+              // },
+              {
+                label: "个人照片",
+                type: "upload",
+                listType: "picture-img",
+                propsHttp: {
+                  res: "data",
+                  url: "url",
+                },
+                canvasOption: {
+                  text: " ",
+                  ratio: 0.1,
+                },
+                action: "/api/blade-resource/oss/endpoint/put-files",
+                tip: "上传二代身份证一寸近期彩色正面免冠图象, (358像素(宽) × 441像素(高)、分辨率350dpi)且不超过500kb",
+                span: 12,
+                // row: true,
+                prop: "avatar",
+              },
+              {
+                label: "指纹信息",
+                type: "upload",
+                listType: "picture-img",
+                propsHttp: {
+                  res: "data",
+                  url: "url",
+                },
+                canvasOption: {
+                  text: " ",
+                  ratio: 0.1,
+                },
+                action: "/api/blade-resource/oss/endpoint/put-files",
+                tip: "只能上传jpg/png指纹信息,且不超过500kb",
+                span: 12,
+                // row: true,
+                prop: "fingerprint",
+              },
+              {
+                label: "是否持证",
+                prop: "hold",
+                // dicUrl: "/api/blade-system/dict-biz/dictionary?code=equipage",
+                // props: {
+                //   label: "dictValue",
+                //   value: "dictKey",
+                // },
+                type: "select",
+                dicData: [
+                  {
+                    label: "是",
+                    value: "1",
+                  },
+                  {
+                    label: "否",
+                    value: "2",
+                  },
+                  {
+                    label: "已吊销",
+                    value: "3",
+                  },
+                ],
+                rules: [
+                  {
+                    required: true,
+                    message: "请选择",
+                    trigger: "blur",
+                  },
+                ],
+              },
+              {
+                label: "保安员证编号",
+                prop: "securitynumber",
+                hide: true,
+              },
+              // {
+              //   label: "发证日期",
+              //   prop: "paperTime",
+              //   hide: true,
+              //   type: "date",
+              //   format: "yyyy-MM-dd",
+              //   valueFormat: "yyyy-MM-dd",
+              // },
               {
                 label: "电子邮箱",
                 prop: "email",
@@ -708,11 +789,18 @@
               },
               {
                 label: "联系地址",
-                prop: "address",
+                prop: "address"
               },
               {
-                label: "户口所在地",
+                label: "住址",
                 prop: "registered",
+                rules: [
+                  {
+                    required: true,
+                    message: "请输入住址",
+                    trigger: "click",
+                  },
+                ],
               },
               {
                 label: "所属辖区",
@@ -766,6 +854,13 @@
                   //   label: "未知",
                   //   value: 3,
                   // },
+                ],
+                rules: [
+                  {
+                    required: true,
+                    message: "请选择性别",
+                    trigger: "blur",
+                  },
                 ],
               },
               // {
@@ -962,6 +1057,7 @@
     }
     console.log(this.search, 111);
     this.search["status"] = 1;
+    this.deptIds = this.userInfo.dept_id;
   },
   methods: {
     handleImport1() {
@@ -1031,6 +1127,42 @@
         this.onLoad(this.page);
       });
     },
+    //制证申请
+    handleSecurityApply(){
+      if (this.choiceList.length === 0) {
+        this.$message.warning("请勾选至少一位持证保安员");
+        return;
+      }
+        this.$confirm("共选择制证申请人数"+this.choiceList.length+"人,确定申请制证?", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
+        .then(() => {
+          let cho = this.choiceList;
+          console.log(this.choiceList,14521);
+          let str = "";
+          for (let k in cho) {
+            str += cho[k].id;
+            if (k != cho.length - 1) {
+              str += ",";
+            }
+          }
+          console.log(str,1132);
+          const data = {
+            ids:str,
+            createUser:this.userInfo.user_id
+          }
+          return securityApply(data);
+        })
+        .then(() => {
+          // this.$refs.crud.toggleSelection();
+          this.$message({
+            type: "success",
+            message: "操作成功!",
+          });
+        });
+    },
     rowSave(row, done, loading) {
       if (row.deptId) {
         row.deptId = row.deptId;
@@ -1072,15 +1204,21 @@
           sex: row.sex,
         },
       };
+
       securitySave(userMap).then(
         () => {
           this.initFlag = false;
-          this.onLoad(this.page);
-          this.$message({
-            type: "success",
-            message: "操作成功!",
+          this.$alert("账号为身份证号码,密码为身份证后六位", "温馨提示", {
+            confirmButtonText: "确定",
+            callback: (action) => {
+              this.$message({
+                type: "success",
+                message: `操作成功`,
+              });
+              this.onLoad(this.page);
+              done();
+            },
           });
-          done();
         },
         (error) => {
           window.console.log(error);
@@ -1121,7 +1259,7 @@
         }
       );
     },
-    rowDel(row) {
+    rowStatus(row) {
       this.$prompt("离职原因", "提示", {
         confirmButtonText: "确定离职",
         cancelButtonText: "取消",
@@ -1142,6 +1280,23 @@
           this.refreshChange();
         })
         .catch(() => {});
+    },
+    rowDel(row) {
+      this.$confirm("确定注销当前用户?", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
+        .then(() => {
+          return remove(row.id);
+        })
+        .then(() => {
+          this.onLoad(this.page);
+          this.$message({
+            type: "success",
+            message: "操作成功!",
+          });
+        });
     },
     rowCheck(row) {
       this.$confirm("确定审查异常标记?", {
@@ -1173,11 +1328,17 @@
       done();
     },
     selectionChange(list) {
-      this.selectionList = list;
+      // this.selectionList = list;
+      this.choiceList = [];
+      for (let k in list) {
+        this.choiceList.push({
+          id: list[k].id,
+        });
+      }
     },
     selectionClear() {
-      this.selectionList = [];
-      this.$refs.crud.toggleSelection();
+      // this.selectionList = [];
+      // this.$refs.crud.toggleSelection();
     },
     handleDelete() {
       if (this.selectionList.length === 0) {
@@ -1340,6 +1501,14 @@
             that.isSecurity = false;
             //如果是保安公司管理员
             params["deptId"] = that.userInfo.dept_id;
+
+            //导入action 修改
+            const importColumn = that.findObject(
+              that.excelOption1.column,
+              "excelFile"
+            );
+            importColumn.action =
+              "/api/blade-user/import-user?deptId=" + this.deptIds;
           } else if (roleAlias == "公安管理员") {
             params["jurisdiction"] = that.userInfo.jurisdiction;
             var columnDept = that.findObject(that.option.column, "deptId");
@@ -1350,7 +1519,19 @@
             ColumnDeptUpdate.dicUrl =
               "/api/blade-system/dept/security_lazy-tree?parentId=1413470343230877697&jurisdiction=" +
               that.userInfo.jurisdiction;
-          } else {
+          } else if (roleAlias == "培训公司管理员") {
+              //如果是保安公司管理员
+              params["trainingUnitId"] = that.userInfo.dept_id;
+              var columnDept2 = that.findObject(that.option.column, "deptId");
+            columnDept2.dicUrl =
+              "/api/blade-system/dept/security_lazy-tree?parentId=1413470343230877697";
+            var ColumnDeptUpdate2 = that.findObject(
+              that.option.group,
+              "deptId"
+            );
+            ColumnDeptUpdate2.dicUrl =
+              "/api/blade-system/dept/security_lazy-tree?parentId=1413470343230877697";
+          }else {
             var columnDept1 = that.findObject(that.option.column, "deptId");
             columnDept1.dicUrl =
               "/api/blade-system/dept/security_lazy-tree?parentId=1413470343230877697";
@@ -1458,7 +1639,7 @@
   },
 };
 </script>
- 
+
 <style lang="scss" scoped>
 .box {
   height: 800px;
@@ -1476,4 +1657,4 @@
     cursor: pointer;
   }
 }
-</style>
\ No newline at end of file
+</style>

--
Gitblit v1.9.3