From f3768ee389adcf28bcbcec234f78b31216d3641b Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期五, 04 八月 2023 11:03:47 +0800
Subject: [PATCH] 1.角色权限优化75%

---
 src/views/basicSettings/roleList.vue |   64 +++++++++++++++++---------------
 src/router/index.js                  |    8 ++--
 2 files changed, 38 insertions(+), 34 deletions(-)

diff --git a/src/router/index.js b/src/router/index.js
index c5019d7..2750c21 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -143,7 +143,7 @@
     redirect: '/workOrder/workOrderList',
     name: '宸ュ崟绠$悊',
     code: '1002',
-    meta: { code: '1002', title: '宸ュ崟绠$悊', icon: 'quality' },
+    meta: { code: '1002', title: '宸ュ崟绠$悊', icon: 'bbgl' },
     alwaysShow: true, // 褰揷hildren鍙湁涓�涓椂锛屼篃鏄剧ず鐖惰彍鍗�
     children: [
       {
@@ -156,13 +156,13 @@
       {
         path: 'workOrderSend',
         name: 'workOrderSendCancel',
-        code: '1011',
+        code: '1021',
         component: () => import('@/views/workOrder/workOrderSend'),
         meta: { code: '1021', title: '宸ュ崟娲惧彂', icon: '', keepAlive: true }
       }, {
         path: 'workOrderClose',
         name: 'workOrderCloseCancel',
-        code: '1012',
+        code: '1022',
         component: () => import('@/views/workOrder/workOrderClose'),
         meta: { code: '1022', title: '宸ュ崟鍏抽棴', icon: '', keepAlive: true }
       }
@@ -207,7 +207,7 @@
     redirect: '/statistic/reportList',
     name: '缁熻鎶ヨ〃',
     code: '1004',
-    meta: { code: '1004', title: '缁熻鎶ヨ〃', icon: 'bbgl' },
+    meta: { code: '1004', title: '缁熻鎶ヨ〃', icon: 'quality' },
     alwaysShow: true, // 褰揷hildren鍙湁涓�涓椂锛屼篃鏄剧ず鐖惰彍鍗�
     children: [
       {
diff --git a/src/views/basicSettings/roleList.vue b/src/views/basicSettings/roleList.vue
index 70a0542..5d48668 100644
--- a/src/views/basicSettings/roleList.vue
+++ b/src/views/basicSettings/roleList.vue
@@ -111,7 +111,7 @@
 
                 <div
                   ref="scrollCenter"
-                  style="border-right: 1px solid rgba(0,0,0,0.2);width: 600px;padding-left: 10px;overflow-y: auto"
+                  style="border-right: 1px solid rgba(0,0,0,0.2);width: 660px;padding-left: 10px;overflow-y: auto"
                   :style="{height:(tableHeight-40)+'px'}"
                   @scroll="scrollCenterScroll()"
                   @mouseover="isScroll='center'"
@@ -140,7 +140,7 @@
                         v-if="item.expanded"
                         :key="it.menucode"
                         v-model="it.buttonChecked"
-                        style="margin-left: 40px;height:26px;display: flex"
+                        style="margin-left: 40px;height:26px;display: flex;"
                         @change="val=>handleCheckedButtonChange(val,it.menucode)"
                       >
 
@@ -148,7 +148,7 @@
                           v-for="i in it.buttoncodelist"
                           :key="i"
                           :label="i"
-                          style="display:flex;align-items: center"
+                          style="display:flex;align-items: center;"
                         />
                       </el-checkbox-group>
 
@@ -280,11 +280,12 @@
   },
 
   created() {
-    this.getRolePermissionSearchRole()
   },
   mounted() {
     window.addEventListener('resize', this.getHeight)
     this.getHeight()
+
+    this.getRolePermissionSearchRole()
   },
   methods: {
 
@@ -347,7 +348,6 @@
 
               let temp = this.allButtonData.filter(j => j.menucode === it.menucode).length > 0 ? this.allButtonData.filter(j => j.menucode === it.menucode)[0].buttoncode : []
               temp = temp.length > 0 ? temp.split(',') : []
-              console.log(temp, 7)
 
               it.buttonChecked = [] // 鏁版嵁鍥炴樉
               it.buttoncodelist.forEach(j => {
@@ -442,10 +442,6 @@
     },
     // 鍗曚釜鎸夐挳鏀瑰彉
     handleCheckedButtonChange(value, code, flag) {
-      // console.log(value, code, flag, 1)
-
-      // console.log(JSON.parse(JSON.stringify(this.treeCenter[0])), 2)
-
       // 鍒ゆ柇鏄惁鍖呭惈鍦ㄥ唴
       if (!flag) {
         if (!this.menuCheckedCodeArr.includes(code) && value.length === 1) { // 鍚�
@@ -469,7 +465,6 @@
             if (it.buttoncodelist.length) {
               childrenLength++
             }
-            console.log(count, childrenLength)
           })
         }
       })
@@ -479,8 +474,6 @@
     },
     // 鑾峰彇鏍戝舰鑺傜偣node
     getLeftTreeNode(data, Node, VueComponent) {
-      // console.log(data, Node, VueComponent, 2221)
-      // console.log(Node.expanded)
       this.treeCenter[0].children.forEach(item => {
         if (item.menucode === data.menucode) {
           item.expanded = Node.expanded
@@ -510,7 +503,6 @@
     // 澶勭悊涓棿鏍戝舰閫変腑鍊兼敼鍙�
     handleTreeCenterCheckChange(obj, selfChecked, selfChildrenTreeCheck) {
       // console.log(obj, selfChecked, selfChildrenTreeCheck, '鐜嬭�佸悏')
-      obj.flag = selfChecked ? 'Y' : 'N'
       if (!selfChildrenTreeCheck) {
         if (!selfChecked) {
           this.treeCenter[0].children.forEach(item => {
@@ -541,16 +533,17 @@
       this.treeCenter[0].children.forEach(item => {
         if (item.children && item.children.length) {
           item.children.forEach(it => {
-            if (it.dataChecked.length > 0) {
+            if (it.dataChecked.length > 0 && it.datacodelist.length > 0) {
               count++
             }
+            // console.log(it.dataChecked, 234)
             if (it.datacodelist.length > 0) {
               childrenLength++
             }
           })
         }
       })
-      // console.log(count, childrenLength, 9)
+      // console.log(count, childrenLength, 123)
       this.dataIsChecked = count === childrenLength
       this.$forceUpdate()
     },
@@ -590,31 +583,34 @@
 
     // 椤甸潰鍕鹃�夊ソ淇濆瓨浜嬩欢
     async saveClick() {
-      // [{"menucode":"1010","buttoncode":"Add,Update","datacode":"ALL"},]
+      const menuKeyArr = this.$refs.treeCenterRef.getCheckedKeys()
       const arr = []
       this.treeCenter[0].children.forEach(item => {
         if (item.children && item.children.length) {
           item.children.forEach(it => {
-            if (it.dataChecked && it.dataChecked.toString().length > 0) { // 鏁版嵁鏉冮檺宸插嬀閫�
-              it.dataChecked = this.dataKeyValue.find(i => i.dataname === it.dataChecked).datacode
-            }
+            if (menuKeyArr.includes(it.menucode)) {
+              if (it.dataChecked && it.dataChecked.toString().length > 0) { // 鏁版嵁鏉冮檺宸插嬀閫�
+                it.dataChecked = this.dataKeyValue.find(i => i.dataname === it.dataChecked).datacode
+              }
 
-            if (it.buttonChecked && it.buttonChecked.length > 0) { // 宸查�夎彍鍗�
-              it.buttonChecked = this.$ButtonData.filter(i =>
-                it.buttonChecked.includes(i.buttonname)
-              ).map(i => i.buttoncode)
+              if (it.buttonChecked && it.buttonChecked.length > 0) { // 宸查�夎彍鍗�
+                it.buttonChecked = this.$ButtonData.filter(i =>
+                  it.buttonChecked.includes(i.buttonname)
+                ).map(i => i.buttoncode)
+              }
+              arr.push({
+                menucode: it.menucode,
+                datacode: it.dataChecked,
+                buttoncode: it.buttonChecked ? it.buttonChecked.join(',') : ''
+              })
             }
-            arr.push({
-              menucode: it.menucode,
-              datacode: it.dataChecked,
-              buttoncode: it.buttonChecked ? it.buttonChecked.join(',') : ''
-            })
           })
         }
       })
 
+      // console.log(this.$refs.treeCenterRef.getCheckedKeys(), 7)
+      console.log(arr, 'arr')
       const rolecode = this.$refs.treeLeftRef.getCurrentKey()
-      // console.log(JSON.stringify(arr).toString())
       const res = await RolePermissionSava(JSON.stringify(arr), rolecode, this.activeName)
       if (res.code === '200') {
         const rolename = this.treeLeft[0].roles.find(i => i.code === rolecode).name
@@ -622,7 +618,7 @@
         await this.getRolePermissionSearchRoleMenuButton(rolecode)
         await this.getRolePermissionSearchRoleMenu(rolecode)
       }
-      this.$forceUpdate()
+      // this.$forceUpdate()
     },
     // 鑾峰彇椤甸潰楂樺害
     getHeight() {
@@ -655,4 +651,12 @@
   font-size: 14px;
   padding-right: 8px;
 }
+
+::v-deep .el-checkbox__label {
+  width: 55px;
+}
+
+.el-icon-plus:hover,.el-icon-edit:hover,.el-icon-delete:hover{
+  color: #000 !important;
+}
 </style>

--
Gitblit v1.9.3