瀏覽代碼

Merge branch 'master' of http://120.26.64.82:3000/BFFE/Foshan4A4.0

zhaoke 3 年之前
父節點
當前提交
28ece3c617

+ 56 - 29
src/components/usergrouptree/index.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: zk
  * @Date: 2022-02-09 15:47:09
- * @LastEditTime: 2022-03-10 17:25:18
+ * @LastEditTime: 2022-03-11 16:42:20
  * @LastEditors: your name
  * @Description: 用户组树
  * @FilePath: \Foshan4A4.0\src\components\usergrouptree\index.vue
@@ -53,6 +53,10 @@ export default {
     checkDisabled: {
       type: Number,
       default: 0
+    },
+    singleNode: {
+      type: Number,
+      default: 0
     }
   },
   data () {
@@ -97,38 +101,61 @@ export default {
         PageSize: this.pageSize
       })
       const datas = result.returnData
-      const tree = translateDataToTreeAll(datas, 'GroupUpid', 'GroupId')
-      const setDisabled = (tree, key) => {
-        if (key) {
-          tree.find(node => {
-            if (node.GroupId === key) {
-              node.disabled = true
-              node.children?.length && setDisabled(node.children)
+      if (this.singleNode) {
+        if (this.singleNode === -1) {
+          const obj = {
+          AuthCount: 0,
+          GroupId: -1,
+          GroupName: '岗位',
+          GroupUpid: 0,
+          QueryTarget: 0,
+          Status: 0,
+          UserCount: 0,
+          disabled: true
+        }
+        this.data = [obj]
+        } else {
+          this.data = [datas.find(data => {
+            if (data.GroupId === this.singleNode) {
+              data.disabled = true
               return true
-            } else if (node.children?.length) {
-              setDisabled(node.children, key)
             }
-          })
-        } else {
-          tree.forEach(node => {
-            node.disabled = true
-            node.children?.length && setDisabled(node.children)
-          })
+          })]
         }
+      } else {
+        const tree = translateDataToTreeAll(datas, 'GroupUpid', 'GroupId')
+        const setDisabled = (tree, key) => {
+          if (key) {
+            tree.find(node => {
+              if (node.GroupId === key) {
+                node.disabled = true
+                node.children?.length && setDisabled(node.children)
+                return true
+              } else if (node.children?.length) {
+                setDisabled(node.children, key)
+              }
+            })
+          } else {
+            tree.forEach(node => {
+              node.disabled = true
+              node.children?.length && setDisabled(node.children)
+            })
+          }
+        }
+        this.checkDisabled && setDisabled(tree, this.checkDisabled)
+        const obj = {
+          AuthCount: 0,
+          GroupId: -1,
+          GroupName: '岗位',
+          GroupUpid: 0,
+          QueryTarget: 0,
+          Status: 0,
+          UserCount: 0,
+          disabled: true,
+          children: tree
+        }
+        this.data = [obj]
       }
-      this.checkDisabled && setDisabled(tree, this.checkDisabled)
-      const obj = {
-        AuthCount: 0,
-        GroupId: -1,
-        GroupName: '岗位',
-        GroupUpid: 0,
-        QueryTarget: 0,
-        Status: 0,
-        UserCount: 0,
-        disabled: true,
-        children: tree
-      }
-      this.data = [obj]
     }
   }
 }

+ 1 - 1
src/views/accountGroupManagement/components/accountGroupEdit.vue

@@ -53,7 +53,7 @@
             <AccountGroupTree
               title="上级岗位"
               nodekey="GroupId"
-              :check-disabled="GroupId"
+              :single-node="doesGroupExist ? GroupUpId : 0"
               :type="true"
               :default-props="defaultProps"
               :checked-keys="accountGroupTreeCheckedList"

+ 50 - 10
src/views/accountGroupManagement/components/accountGroupHome.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2022-01-08 09:27:43
- * @LastEditTime: 2022-03-10 21:34:47
+ * @LastEditTime: 2022-03-11 14:54:37
  * @LastEditors: your name
  * @Description: 用户组管理
  * @FilePath: \Foshan4A2.0\src\views\accountGroupManagement\components\home.vue
@@ -38,6 +38,7 @@
                 :filter-node-method="filterNode"
                 highlight-current
                 :default-expanded-keys="[currentKey]"
+                :expand-on-click-node="false"
                 @node-click="handleNodeClick"
               >
               </el-tree>
@@ -386,13 +387,13 @@ export default {
     renderMember(data) {
       this.$message.warning('功能开发中')
     },
-    // 关闭开启
+    // 切换状态
     renderChange(data) {
       const { GroupId, flag } = data
       const Status = flag ? 1 : 0
       this.handleChange(GroupId, Status)
     },
-    // 下级关闭
+    // 下级切换状态
     async childrenRenderChange(data, index) {
       const { GroupId, flag } = data
       const Status = flag ? 1 : 0
@@ -404,6 +405,24 @@ export default {
         if (res.code === 0) {
           this.$message.success(res.message)
           this.childrenData[index].Status = Status
+          if (flag) {
+            this.dataArr.find(data => {
+              if (data.GroupId === GroupId) {
+                data.Status = 1
+                data.flag = true
+                return true
+              }
+            })
+          } else {
+            this.dataArr.find(data => {
+              if (data.GroupId === GroupId) {
+                data.Status = 0
+                data.flag = false
+                return true
+              }
+            })
+            this.setChildrenDisabled(GroupId)
+          }
           // this.getOrganTree();
         } else {
           this.$message.error(res.message)
@@ -444,6 +463,16 @@ export default {
       }
       return arr
     },
+    // 更改下级状态
+    setChildrenDisabled(id) {
+      this.dataArr.forEach(data => {
+        if (data.GroupUpid === id) {
+          data.Status = 0
+          data.flag = false
+          this.setChildrenDisabled(data.GroupId)
+        }
+      })
+    },
     // -----------获取数据------------
     // 状态变更
     async handleChange(id, val) {
@@ -455,17 +484,28 @@ export default {
         if (res.code === 0) {
           this.$message.success(res.message)
           this.currDataArr[0].Status = val
-          if (!val) {
+          if (val) {
+            this.dataArr.find(data => {
+              if (data.GroupId === id) {
+                data.Status = 1
+                data.flag = true
+                return true
+              }
+            })
+          } else {
+            this.dataArr.find(data => {
+              if (data.GroupId === id) {
+                data.Status = 0
+                data.flag = false
+                return true
+              }
+            })
             this.childrenData.forEach(data => {
-              data.Status = '2'
+              data.Status = 0
               data.flag = false
             })
+            this.setChildrenDisabled(id)
           }
-          this.dataArr.forEach(data => {
-            if (data.GroupUpid === id) {
-              data.Status = '2'
-            }
-          })
         } else {
           this.$message.error(res.message)
           this.currDataArr[0].flag = !val