From 8c6cf205affbbc8ada74f00a7ca25ebca867e9ed Mon Sep 17 00:00:00 2001
From: liuyg <376836862@qq.com>
Date: Mon, 27 Sep 2021 11:44:44 +0800
Subject: [PATCH] 图表颜色

---
 src/views/system/user.vue |  191 ++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 145 insertions(+), 46 deletions(-)

diff --git a/src/views/system/user.vue b/src/views/system/user.vue
index a94be80..468169c 100644
--- a/src/views/system/user.vue
+++ b/src/views/system/user.vue
@@ -1,6 +1,6 @@
 <template>
   <el-row class="user">
-    <el-col :span="5">
+    <el-col :span="sizes[0]">
       <div class="box">
         <el-scrollbar>
           <basic-container>
@@ -13,7 +13,7 @@
         </el-scrollbar>
       </div>
     </el-col>
-    <el-col :span="19">
+    <el-col :span="sizes[1]">
       <basic-container>
         <avue-crud
           :option="option"
@@ -50,7 +50,7 @@
               type="info"
               size="small"
               plain
-              v-if="permission.user_role"
+              v-if="permission.user_role && isguanli"
               icon="el-icon-user"
               @click="handleGrant"
               >角色配置
@@ -99,7 +99,7 @@
             <el-tag>{{ row.roleName }}</el-tag>
           </template>
           <template slot-scope="{ row }" slot="deptName">
-            <el-tag>{{ row.deptName }}</el-tag>
+            <el-tag>{{ row.deptName.split(",").join(" ,") }}</el-tag>
           </template>
           <template slot-scope="{ row }" slot="userTypeName">
             <el-tag>{{ row.userTypeName }}</el-tag>
@@ -193,6 +193,7 @@
   add,
   grant,
   resetPassword,
+  getJurisdiction,
 } from "@/api/system/user";
 import { getDeptTree, getDeptLazyTree } from "@/api/system/dept";
 import { getRoleTree } from "@/api/system/role";
@@ -219,9 +220,14 @@
         callback();
       }
     };
+
     return {
-      form: {
-      },
+      isguanli: true,
+
+      sizes: [5, 19],
+      deptids: null,
+
+      form: {},
       search: {},
       roleBox: false,
       excelBox: false,
@@ -256,19 +262,22 @@
       treeOption: {
         nodeKey: "id",
         lazy: true,
-        treeLoad: function (node, resolve) {
-          const parentId = node.level === 0 ? 0 : node.data.id;
-          getDeptLazyTree(parentId).then((res) => {
-            resolve(
-              res.data.data.map((item) => {
-                return {
-                  ...item,
-                  leaf: !item.hasChildren,
-                };
-              })
-            );
-          });
-        },
+        treeLoad: "", //处理权限  在created中
+        //  function (node, resolve) {
+        //   const parentId = node.level === 0 ? 0 : node.data.id;
+        //   //公安局进入
+
+        //   getDeptLazyTree(parentId, jurisdiction).then((res) => {
+        //     resolve(
+        //       res.data.data.map((item) => {
+        //         return {
+        //           ...item,
+        //           leaf: !item.hasChildren,
+        //         };
+        //       })
+        //     );
+        //   });
+        // },
         addBtn: false,
         menu: false,
         size: "small",
@@ -297,24 +306,28 @@
             label: "登录账号",
             prop: "account",
             search: true,
+            width: 190,
             display: false,
           },
           {
             label: "所属组织机构",
             prop: "deptName",
             slot: true,
+            overHidden: true,
             display: false,
           },
           {
             label: "用户姓名",
             prop: "realName",
             search: true,
+            width: 90,
             display: false,
           },
           {
             label: "所属角色",
             prop: "roleName",
             slot: true,
+            width: 130,
             display: false,
           },
           // {
@@ -415,7 +428,7 @@
               {
                 label: "密码",
                 prop: "password",
-                type:'password',
+                type: "password",
                 hide: true,
                 editDisplay: false,
                 viewDisplay: false,
@@ -426,7 +439,7 @@
               {
                 label: "确认密码",
                 prop: "password2",
-                type:'password',
+                type: "password",
                 hide: true,
                 editDisplay: false,
                 viewDisplay: false,
@@ -494,12 +507,19 @@
                     label: "女",
                     value: 2,
                   },
-                  {
-                    label: "未知",
-                    value: 3,
-                  },
+                  // {
+                  //   label: "未知",
+                  //   value: 3,
+                  // },
                 ],
                 hide: true,
+                rules: [
+                  {
+                    required: true,
+                    message: "请选择性别",
+                    trigger: "blur",
+                  },
+                ],
               },
               {
                 label: "用户生日",
@@ -714,11 +734,11 @@
   watch: {
     "form.tenantId"() {
       if (this.form.tenantId !== "" && this.initFlag) {
-        this.initData(this.form.tenantId);
+        this.initData(this.form.tenantId, this.userInfo.role_name);
       }
     },
     "form.deptId"() {
-      this.initData(this.form.tenantId);
+      this.initData(this.form.tenantId, this.userInfo.role_name);
     },
     "excelForm.isCovered"() {
       if (this.excelForm.isCovered !== "") {
@@ -753,10 +773,57 @@
       return ids.join(",");
     },
   },
+  created() {
+    console.log(this.userInfo.role_name);
+    if (this.userInfo.role_name == "保安公司管理员") {
+      this.deptids = this.userInfo.dept_id;
+      this.sizes = [0, 24];
+      this.isguanli = false;
+      this.option.group[0].column[0]["value"] = this.userInfo.dept_id;
+      this.option.group[0].column[0]["disabled"] = true;
+      // this.option.group[2].column[1]["disabled"] = true;
+    } else {
+      this.deptids = null;
+      this.sizes = [5, 19];
+    }
+
+    //公安局进入
+    var jurisdiction = "";
+    if (this.userInfo.role_name == "公安管理员") {
+      jurisdiction = this.userInfo.jurisdiction;
+      this.treeOption.treeLoad = function (node, resolve) {
+        const parentId = node.level === 0 ? 0 : node.data.id;
+        getDeptLazyTree(parentId, jurisdiction).then((res) => {
+          resolve(
+            res.data.data.map((item) => {
+              return {
+                ...item,
+                leaf: !item.hasChildren,
+              };
+            })
+          );
+        });
+      };
+    } else {
+      this.treeOption.treeLoad = function (node, resolve) {
+        const parentId = node.level === 0 ? 0 : node.data.id;
+        getDeptLazyTree(parentId).then((res) => {
+          resolve(
+            res.data.data.map((item) => {
+              return {
+                ...item,
+                leaf: !item.hasChildren,
+              };
+            })
+          );
+        });
+      };
+    }
+  },
   mounted() {
     // 非保安单位模式默认加载管理组数据
     if (!website.tenantMode) {
-      this.initData(website.tenantId);
+      this.initData(website.tenantId, this.userInfo.role_name);
     }
   },
   methods: {
@@ -765,10 +832,22 @@
       this.page.currentPage = 1;
       this.onLoad(this.page);
     },
-    initData(tenantId) {
+    initData(tenantId, d) {
       getRoleTree(tenantId).then((res) => {
         const column = this.findObject(this.option.group, "roleId");
-        column.dicData = res.data.data;
+        var k = res.data.data;
+        var b = [];
+        if (d == "保安公司管理员") {
+          console.log(k);
+          for (var n in k) {
+            if (k[n].title == "保安" || k[n].title == "保安公司管理员") {
+              b.push(k[n]);
+            }
+          }
+          column.dicData = b;
+        } else {
+          column.dicData = k;
+        }
       });
       getDeptTree(tenantId).then((res) => {
         const column = this.findObject(this.option.group, "deptId");
@@ -794,21 +873,35 @@
       row.deptId = row.deptId;
       row.roleId = row.roleId.join(",");
       row.postId = row.postId.join(",");
-      add(row).then(
-        () => {
-          this.initFlag = false;
-          this.onLoad(this.page);
-          this.$message({
-            type: "success",
-            message: "操作成功!",
-          });
-          done();
-        },
-        (error) => {
-          window.console.log(error);
-          loading();
+      console.log(row, "row");
+      var params = {
+        deptname: row.$deptId,
+      };
+      getJurisdiction(params).then((res) => {
+        // console.log(res.data.data);
+        // return;
+        if (res.data.msg != "暂无承载数据") {
+          row.jurisdiction = res.data.data;
+        } else {
+          row.jurisdiction = "";
         }
-      );
+        add(row).then(
+          () => {
+            this.initFlag = false;
+            this.onLoad(this.page);
+            this.$message({
+              type: "success",
+              message: "操作成功!",
+            });
+            done();
+          },
+          (error) => {
+            window.console.log(error);
+            loading();
+          }
+        );
+      });
+      // return;
     },
     rowUpdate(row, index, done, loading) {
       row.deptId = row.deptId;
@@ -985,12 +1078,17 @@
     },
     onLoad(page, params = {}) {
       this.loading = true;
+      var deptid = this.deptids == null ? this.treeDeptId : this.deptids;
+      //公安局进入
+      if (this.userInfo.role_name == "公安管理员") {
+        params["jurisdiction"] = this.userInfo.jurisdiction;
+      }
       params['status'] = 1;
       getList(
         page.currentPage,
         page.pageSize,
         Object.assign(params, this.query),
-        this.treeDeptId
+        deptid
       ).then((res) => {
         const data = res.data.data;
         this.page.total = data.total;
@@ -1051,11 +1149,12 @@
     },
     platformOnLoad(page, params = {}) {
       this.platformLoading = true;
+      var deptid = this.deptids == null ? this.treeDeptId : this.deptids;
       getList(
         page.currentPage,
         page.pageSize,
         Object.assign(params, this.query),
-        this.treeDeptId
+        deptid
       ).then((res) => {
         const data = res.data.data;
         this.platformPage.total = data.total;

--
Gitblit v1.9.3