From cb81eef3d9aabe280e506fc7971c539542cf13f7 Mon Sep 17 00:00:00 2001
From: liuyg <376836862@qq.com>
Date: Thu, 19 Aug 2021 15:12:01 +0800
Subject: [PATCH] 冲突

---
 src/views/securityGuard/securityGuard.vue |  386 +++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 274 insertions(+), 112 deletions(-)

diff --git a/src/views/securityGuard/securityGuard.vue b/src/views/securityGuard/securityGuard.vue
index 0eeaef8..097d2b8 100644
--- a/src/views/securityGuard/securityGuard.vue
+++ b/src/views/securityGuard/securityGuard.vue
@@ -1,5 +1,5 @@
 <template>
-  <el-row>
+  <el-row class="securityGuard">
     <el-col :span="0" style="display: none">
       <div class="box">
         <el-scrollbar>
@@ -38,6 +38,14 @@
           @on-load="onLoad"
         >
           <template slot="menuLeft">
+            <el-button
+              type="success"
+              size="small"
+              plain
+              icon="el-icon-upload2"
+              @click="handleImport1"
+              >批量导入
+            </el-button>
             <el-button
               type="danger"
               style="display: none"
@@ -99,7 +107,7 @@
               >导出
             </el-button>
           </template>
-
+ 
           <template slot-scope="{ type, size, row }" slot="menu">
             <!-- <el-button
                 style="display:none"
@@ -117,12 +125,12 @@
               >离职登记
             </el-button>
           </template>
-
+ 
           <template slot-scope="{ row }" slot="sex">
             <el-tag v-if="row.sex == 1">男</el-tag>
             <el-tag v-if="row.sex == 2">女</el-tag>
           </template>
-
+ 
           <template slot-scope="{ row }" slot="tenantName">
             <el-tag>{{ row.tenantName }}</el-tag>
           </template>
@@ -153,7 +161,7 @@
             :props="props"
           >
           </el-tree>
-
+ 
           <span slot="footer" class="dialog-footer">
             <el-button @click="roleBox = false">取 消</el-button>
             <el-button type="primary" @click="submitRole">确 定</el-button>
@@ -208,11 +216,29 @@
             </template>
           </avue-crud>
         </el-dialog>
+        <el-dialog
+          title="保安员导入"
+          append-to-body
+          :visible.sync="excelBox1"
+          width="555px"
+        >
+          <avue-form
+            :option="excelOption1"
+            v-model="excelForm1"
+            :upload-after="uploadAfter1"
+          >
+            <template slot="excelTemplate">
+              <el-button type="primary" @click="handleTemplate1">
+                点击下载<i class="el-icon-download el-icon--right"></i>
+              </el-button>
+            </template>
+          </avue-form>
+        </el-dialog>
       </basic-container>
     </el-col>
   </el-row>
 </template>
-
+ 
 <script>
 import {
   getUser,
@@ -221,6 +247,7 @@
   update,
   updatePlatform,
   add,
+  securitySave,
   grant,
   resetPassword,
   getUserPractitionersInfo,
@@ -228,13 +255,14 @@
 } from "@/api/system/user";
 import { getList } from "@/api/securityGuard/securityGuard";
 import { getDeptLazyTree } from "@/api/system/dept";
-import { getRoleTree } from "@/api/system/role";
+import { getRoleTree, getRoleDetail } from "@/api/system/role";
 import { getPostList } from "@/api/system/post";
 import { mapGetters } from "vuex";
 import website from "@/config/website";
 import { getToken } from "@/util/auth";
 import { securityFormPageColumn } from "./data";
-
+import { mapState } from "vuex";
+ 
 export default {
   data() {
     const validatePass = (rule, value, callback) => {
@@ -254,6 +282,36 @@
       }
     };
     return {
+      securityid: "",
+      excelBox1: false,
+      isSecurity: false,
+      excelForm1: {},
+      excelOption1: {
+        submitBtn: false,
+        emptyBtn: false,
+        column: [
+          {
+            label: "文件上传",
+            prop: "excelFile",
+            type: "upload",
+            drag: true,
+            loadText: "文件上传中,请稍等",
+            span: 24,
+            propsHttp: {
+              res: "data",
+            },
+            tip: "请上传 .xls,.xlsx 标准格式文件",
+            action: "/api/blade-user/import-user",
+          },
+          {
+            label: "模板下载",
+            prop: "excelTemplate",
+            formslot: true,
+            span: 24,
+          },
+        ],
+      },
+ 
       form: {},
       search: {},
       roleBox: false,
@@ -322,10 +380,12 @@
         searchMenuSpan: 6,
         border: false,
         stripe: true,
+        align: "center",
         index: true,
         delBtnText: "注销",
         selection: true,
         viewBtn: true,
+        defaultExpandAll: true,
         //dialogType: 'drawer',
         dialogClickModal: false,
         column: securityFormPageColumn,
@@ -340,15 +400,14 @@
                 label: "所属保安公司",
                 prop: "deptId",
                 type: "tree",
-                dicUrl:
-                  "/api/blade-system/dept/security_lazy-tree?parentId=1413470343230877697",
+                // dicUrl:
+                  // "/api/blade-system/dept/security_lazy-tree?parentId=1413470343230877697",
                 // dicUrl: "/api/blade-system/dept/lazy-tree?parentId=0",
                 props: {
                   label: "title",
                   value: "id",
                 },
                 // disabled: true,
-                span: 24,
                 rules: [
                   {
                     required: true,
@@ -406,15 +465,35 @@
                 ],
               },
               {
-                label: "编号",
-                prop: "code",
-              },
-              {
                 label: "昵称",
                 prop: "name",
               },
               {
-                label: "所属行政区",
+                label: "个人照片",
+                type: "upload",
+                listType: "picture-img",
+                propsHttp: {
+                  res: "data",
+                  url: "link",
+                },
+                canvasOption: {
+                  text: " ",
+                  ratio: 0.1,
+                },
+                action: "/api/blade-resource/oss/endpoint/put-file",
+                tip: "只能上传jpg/png个人头像,且不超过500kb",
+                span: 12,
+                row: true,
+                prop: "myPicture",
+              },
+ 
+              // {
+              //   label: "编号",
+              //   prop: "code",
+              // },
+ 
+              {
+                label: "所属辖区",
                 prop: "jurisdiction",
                 // multiple: true,
                 type: "tree",
@@ -427,49 +506,49 @@
                 slot: true,
                 rules: [
                   {
-                    required: true,
-                    message: "请选择所属行政区",
-                    trigger: "click",
-                  },
-                ],
-              },
-              {
-                label: "所属角色",
-                prop: "roleId",
-                multiple: true,
-                type: "tree",
-                dicData: [],
-                props: {
-                  label: "title",
-                },
-                checkStrictly: true,
-                slot: true,
-                rules: [
-                  {
-                    required: true,
-                    message: "请选择所属角色",
-                    trigger: "click",
-                  },
-                ],
-              },
-              {
-                label: "所属岗位",
-                prop: "postId",
-                type: "tree",
-                multiple: true,
-                dicData: [],
-                props: {
-                  label: "postName",
-                  value: "id",
-                },
-                rules: [
-                  {
                     required: false,
-                    message: "请选择所属岗位",
+                    message: "请选择所属辖区",
                     trigger: "click",
                   },
                 ],
               },
+              // {
+              //   label: "所属角色",
+              //   prop: "roleId",
+              //   multiple: true,
+              //   type: "tree",
+              //   dicData: [],
+              //   props: {
+              //     label: "title",
+              //   },
+              //   checkStrictly: true,
+              //   slot: true,
+              //   rules: [
+              //     {
+              //       required: true,
+              //       message: "请选择所属角色",
+              //       trigger: "click",
+              //     },
+              //   ],
+              // },
+              // {
+              //   label: "所属岗位",
+              //   prop: "postId",
+              //   type: "tree",
+              //   multiple: true,
+              //   dicData: [],
+              //   props: {
+              //     label: "postName",
+              //     value: "id",
+              //   },
+              //   rules: [
+              //     {
+              //       required: false,
+              //       message: "请选择所属岗位",
+              //       trigger: "click",
+              //     },
+              //   ],
+              // },
               {
                 label: "是否持证",
                 prop: "hold",
@@ -486,6 +565,11 @@
                     trigger: "blur",
                   },
                 ],
+              },
+              {
+                label: "保安员证编号",
+                prop: "securitynumber",
+                hide: true,
               },
               {
                 label: "手机号码",
@@ -584,6 +668,8 @@
                 label: "生日",
                 type: "date",
                 prop: "birthday",
+                format: "yyyy-MM-dd",
+                valueFormat: "yyyy-MM-dd",
               },
             ],
           },
@@ -836,14 +922,37 @@
       });
       return ids.join(",");
     },
+    ...mapState({
+      userInfo: (state) => state.user.userInfo,
+    }),
+  },
+  beforeCreate() {
+    
+  },
+  created() {
+ 
   },
   mounted() {
+    // this.option.column[0].hide = true
     // 非保安单位模式默认加载管理组数据
     if (!website.tenantMode) {
-      this.initData(website.tenantId);
-    }
+          this.initData(website.tenantId);
+        }
   },
   methods: {
+    handleImport1() {
+      this.excelBox1 = true;
+    },
+    uploadAfter1(res, done, loading, column) {
+      window.console.log(column);
+      this.excelBox1 = false;
+      // this.refreshChange();
+      done();
+    },
+    handleTemplate1() {
+      window.open(`/api/examSubjectChoices/export-template`);
+    },
+ 
     //行点击事件
     rowClick(row) {
       this.$router.push({
@@ -857,18 +966,18 @@
       this.onLoad(this.page);
     },
     initData(tenantId) {
-      getRoleTree(tenantId).then((res) => {
-        const column = this.findObject(this.option.group, "roleId");
-        column.dicData = res.data.data;
-      });
+      // getRoleTree(tenantId).then((res) => {
+      //   const column = this.findObject(this.option.group, "roleId");
+      //   column.dicData = res.data.data;
+      // });
       // getDeptTree(tenantId).then((res) => {
       //   const column = this.findObject(this.option.group, "deptId");
       //   column.dicData = res.data.data;
       // });
-      getPostList(tenantId).then((res) => {
-        const column = this.findObject(this.option.group, "postId");
-        column.dicData = res.data.data;
-      });
+      // getPostList(tenantId).then((res) => {
+      //   const column = this.findObject(this.option.group, "postId");
+      //   column.dicData = res.data.data;
+      // });
     },
     submitRole() {
       const roleList = this.$refs.treeRole.getCheckedKeys().join(",");
@@ -902,33 +1011,50 @@
             entryTime: item.entryTime,
             name: row.realName,
             leaving: item.leaving,
-            cardid: row.cardid,
+            securityid: row.id,
             post: item.post,
             responsibilities: item.responsibilities,
           };
           userPractitionersList.push(info);
         });
       }
-      var IdCardNo = row.cardid;
-      add(row).then(
+      const user = {
+        account: row.account,
+        address: row.address,
+        birthday: row.birthday,
+        cardid: row.cardid,
+        deptId: row.deptId,
+        education: row.education,
+        email: row.email,
+        height: row.height,
+        hold: row.hold,
+        jurisdiction: row.jurisdiction,
+        myPicture: row.myPicture,
+        name: row.name,
+        nation: row.nation,
+        nativeplace: row.nativeplace,
+        password: row.password,
+        password2: row.password2,
+        phone: row.phone,
+        politicaloutlook: row.politicaloutlook,
+        realName: row.realName,
+        registered: row.registered,
+        rtime: row.rtime,
+        securitynumber: row.securitynumber,
+        sex: row.sex,
+      };
+      const userMap = {
+        user: user,
+        userPractitionersInfo: userPractitionersList,
+      };
+      securitySave(userMap).then(
         () => {
-          const experience = {
-            cardid: IdCardNo,
-            userPractitionersInfo: userPractitionersList,
-          };
-          //新增从业信息
-          saveOrUpdateUserPractitionersInfo(experience).then(() => {
-            this.$message({
-              type: "success",
-              message: "操作成功!",
-            });
+          this.$message({
+            type: "success",
+            message: "操作成功!",
           });
           this.initFlag = false;
           this.onLoad(this.page);
-          // this.$message({
-          //   type: "success",
-          //   message: "操作成功!",
-          // });
           done();
         },
         (error) => {
@@ -952,20 +1078,20 @@
             entryTime: item.entryTime,
             name: row.realName,
             leaving: item.leaving,
-            cardid: row.cardid,
+            securityid: row.id,
             post: item.post,
             responsibilities: item.responsibilities,
           };
           userPractitionersList.push(info);
         });
       }
-      var IdCardNo = row.cardid;
+      var IdCardNo = row.id;
       //值替换,education 放在页面会卡死
       row.education = row.education1;
       update(row).then(
         () => {
           const experience = {
-            cardid: IdCardNo,
+            securityid: IdCardNo,
             userPractitionersInfo: userPractitionersList,
           };
           //更新从业信息
@@ -977,10 +1103,6 @@
           });
           this.initFlag = false;
           this.onLoad(this.page);
-          // this.$message({
-          //   type: "success",
-          //   message: "操作成功!",
-          // });
           done();
         },
         (error) => {
@@ -1140,7 +1262,7 @@
           }
           var userInfo = res.data.data;
           //获取用户从业信息
-          getUserPractitionersInfo(userInfo.cardid).then((res1) => {
+          getUserPractitionersInfo(userInfo.id).then((res1) => {
             that.form.UserPractitionersInfo = res1.data.data;
           });
         });
@@ -1158,25 +1280,65 @@
       this.onLoad(this.page, this.query);
     },
     onLoad(page, params = {}) {
-      let values = {
-        ...params,
-      };
-      values = {
-        ...params,
-        deptId: this.deptId,
-        roleId: this.roleId,
-        ...this.query,
-      };
-      this.loading = true;
-      getList(page.currentPage, page.pageSize, values, this.treeDeptId).then(
-        (res) => {
-          const data = res.data.data;
-          this.page.total = data.total;
-          this.data = data.records;
-          this.loading = false;
-          this.selectionClear();
-        }
-      );
+      var that = this;
+      //获取当前登录人员的角色信息
+      var roleIds = this.userInfo.role_id.split(",");
+      roleIds.forEach((roleId) => {
+        getRoleDetail(roleId).then((res) => {
+          var roleAlias = res.data.data.roleAlias;
+          if (
+            roleAlias == "保安公司管理员" ||
+            roleAlias == "保安" ||
+            roleAlias == "未持证保安"
+          ) {
+            //去除保安公司查询
+            const column = that.findObject(that.option.column, "deptId");
+            column.search = false;
+            const deptColumn = that.findObject(that.option.group, "deptId");
+            deptColumn.dicUrl = "/api/blade-system/dept/security_lazy-tree?parentId=1413470343230877697";
+            //禁止编辑
+            deptColumn.disabled = true;
+            deptColumn.value = that.userInfo.dept_id;
+            that.isSecurity = true;
+            //如果是保安公司管理员
+            params["deptId"] = that.userInfo.dept_id;
+          }else if (roleAlias == "公安管理员") {
+            params["jurisdiction"] = that.userInfo.jurisdiction;
+            var columnDept = that.findObject(that.option.column, "deptId");
+            columnDept.dicUrl = 
+                "/api/blade-system/dept/security_lazy-tree?parentId=1413470343230877697&jurisdiction="+that.userInfo.jurisdiction
+            var ColumnDeptUpdate = that.findObject(that.option.group, "deptId");
+            ColumnDeptUpdate.dicUrl = 
+                "/api/blade-system/dept/security_lazy-tree?parentId=1413470343230877697&jurisdiction="+that.userInfo.jurisdiction
+          }else{
+            var columnDept1 = that.findObject(that.option.column, "deptId");
+            columnDept1.dicUrl = "/api/blade-system/dept/security_lazy-tree?parentId=1413470343230877697";
+            var ColumnDeptUpdate1 = that.findObject(that.option.group, "deptId");
+            ColumnDeptUpdate1.dicUrl = "/api/blade-system/dept/security_lazy-tree?parentId=1413470343230877697";
+          }
+ 
+          let values = {
+            ...params,
+          };
+          values = {
+            ...params,
+            roleAlias: "111",
+            ...that.query,
+          };
+ 
+          that.loading = true;
+          getList(page.currentPage, page.pageSize, values).then((res) => {
+            const data = res.data.data;
+            that.page.total = data.total;
+            that.data = data.records;
+            that.loading = false;
+            that.selectionClear();
+          });
+        });
+      });
+      
+ 
+      
     },
     platformRowUpdate(row, index, done, loading) {
       updatePlatform(row.id, row.userType, row.userExt).then(
@@ -1246,17 +1408,17 @@
   },
 };
 </script>
-
+ 
 <style>
 .box {
   height: 800px;
 }
-
+ 
 .el-scrollbar {
   height: 100%;
 }
-
+ 
 .box .el-scrollbar__wrap {
   overflow: scroll;
 }
-</style>
+</style>
\ No newline at end of file

--
Gitblit v1.9.3