Explorar o código

卡片状态切换修改

zhongxiaoyu %!s(int64=3) %!d(string=hai) anos
pai
achega
8e2d972654

+ 29 - 41
src/views/accountGroupManagement/components/accountGroupHome.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2022-01-08 09:27:43
- * @LastEditTime: 2022-03-18 11:37:15
+ * @LastEditTime: 2022-03-18 16:00:11
  * @LastEditors: your name
  * @Description: 用户组管理
  * @FilePath: \Foshan4A2.0\src\views\accountGroupManagement\components\home.vue
@@ -38,7 +38,6 @@
                 :filter-node-method="filterNode"
                 highlight-current
                 :default-expanded-keys="[currentKey]"
-                :expand-on-click-node="false"
                 @node-click="handleNodeClick"
               >
               </el-tree>
@@ -390,15 +389,13 @@ export default {
     // 切换状态
     renderChange(data) {
       const { GroupId, flag } = data
-      const Status = flag ? 1 : 0
-      this.handleChange(GroupId, Status)
+      this.handleChange(GroupId, flag)
     },
     // 下级切换状态
     async childrenRenderChange(data, index) {
       const { GroupId, flag } = data
-      const Status = flag ? 1 : 0
       const isChildren = true
-      this.handleChange(GroupId, Status, index, isChildren)
+      this.handleChange(GroupId, flag, index, isChildren)
       // try {
       //   const res = await ChangeGroupStatus({
       //     GroupId: GroupId,
@@ -423,7 +420,7 @@ export default {
       //           return true
       //         }
       //       })
-      //       this.setChildrenDisabled(GroupId)
+      //       this.setChildrenStatus(GroupId)
       //     }
       //     // this.getOrganTree();
       //   } else {
@@ -472,68 +469,59 @@ export default {
       return arr
     },
     // 更改下级状态
-    setChildrenDisabled(id) {
+    setChildrenStatus(id, flag) {
       this.dataArr.forEach(data => {
         if (data.GroupUpid === id) {
-          data.Status = 0
-          data.flag = false
-          this.setChildrenDisabled(data.GroupId)
+          data.Status = flag ? 1 : 0
+          data.flag = flag
+          this.setChildrenStatus(data.GroupId, flag)
         }
       })
     },
     // -----------获取数据------------
     // 状态变更
-    async handleChange(id, val, index, isChildren = false) {
+    async handleChange(id, flag, index, isChildren = false) {
+      const Status = flag ? 1 : 0
       try {
         const res = await ChangeGroupStatus({
           GroupId: id,
-          Status: val
+          Status: Status
         })
         if (res.code === 0) {
           this.$message.success(res.message)
           if (!isChildren) {
-            this.currDataArr[0].Status = val
+            this.currDataArr[0].Status = Status
           } else {
-            this.childrenData[index].Status = val
+            this.childrenData[index].Status = Status
           }
-          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
-              }
-            })
-            if (!isChildren) {
-              this.childrenData.forEach(data => {
-                data.Status = 0
-                data.flag = false
-              })
+          this.dataArr.find(data => {
+            if (data.GroupId === id) {
+              data.Status = Status
+              data.flag = flag
+              return true
             }
-            this.setChildrenDisabled(id)
+          })
+          if (!isChildren) {
+            this.childrenData.forEach(data => {
+              data.Status = Status
+              data.flag = flag
+            })
           }
+          this.setChildrenStatus(id, flag)
         } else {
           this.$message.error(res.message)
           if (!isChildren) {
-            this.currDataArr[0].flag = !val
+            this.currDataArr[0].flag = !flag
           } else {
-            this.childrenData[index].flag = !val
+            this.childrenData[index].flag = !flag
           }
         }
       } catch (error) {
         console.log('出错了', error)
         if (!isChildren) {
-            this.currDataArr[0].flag = !val
+            this.currDataArr[0].flag = !flag
           } else {
-            this.childrenData[index].flag = !val
+            this.childrenData[index].flag = !flag
           }
       }
     },

+ 31 - 42
src/views/authorityManagement/components/authorityHome.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2021-11-29 09:27:43
- * @LastEditTime: 2022-03-18 11:29:32
+ * @LastEditTime: 2022-03-18 16:02:57
  * @LastEditors: your name
  * @Description: 权限管理
  * @FilePath: \Foshan4A2.0\src\views\authorityManagement\components\home.vue
@@ -229,9 +229,8 @@ export default {
     //下级切换状态
     childrenRenderChange (data, index) {
       const { AuthId, flag, Type } = data
-      const Status = flag ? 1 : 0
       const isChildren = true
-      this.handleChange(AuthId, Status, Type, index, isChildren)
+      this.handleChange(AuthId, flag, Type, index, isChildren)
     },
     filterNode (value, data) {
       if (!value) return true;
@@ -256,8 +255,7 @@ export default {
     // 关闭开启
     renderChange (data, index) {
       const { AuthId, flag, Type } = data
-      const Status = flag ? 1 : 0
-      this.handleChange(AuthId, Status, Type, index)
+      this.handleChange(AuthId, flag, Type, index)
     },
     //删除
     remove () {
@@ -301,12 +299,12 @@ export default {
       return arr
     },
     // 更改下级状态
-    setChildrenDisabled(id) {
+    setChildrenStatus(id, flag) {
       this.dataArr.forEach(data => {
         if (data.UpAuthId === id) {
-          data.Status = 0
-          data.flag = false
-          this.setChildrenDisabled(data.AuthId)
+          data.Status = flag ? 1 : 0
+          data.flag = flag
+          this.setChildrenStatus(data.AuthId, flag)
         }
       })
     },
@@ -344,68 +342,59 @@ export default {
     // },
     //-----------获取数据------------
     //应用状态变更
-    async handleChange (id, val, type, index, isChildren = false) {
+    async handleChange (id, flag, type, index, isChildren = false) {
+      const Status = flag ? 1 : 0
       try {
         let res = null
         if (type === 1) {
           res = await UpdateAppStatus({
             AppId: id,
-            Status: val
+            Status: Status
           })
         } else {
           res = await UpdateAuthStatus({
             AuthId: id,
-            AuthStatus: val
+            AuthStatus: Status
           })
         }
         if (res.code === 0) {
           this.$message.success(res.message)
           if (!isChildren) {
-            this.currDataArr[0].Status = val
+            this.currDataArr[0].Status = Status
           } else {
-            this.childrenData[index].Status = val
+            this.childrenData[index].Status = Status
           }
-          if (val) {
-            this.dataArr.find(data => {
-              if (data.AuthId === id) {
-                data.Status = 1
-                data.flag = true
-                return true
-              }
-            })
-          } else {
-            this.dataArr.find(data => {
-              if (data.AuthId === id) {
-                data.Status = 0
-                data.flag = false
-                return true
-              }
-            })
-            if (type === 2) {
-              if (!isChildren) {
-                this.childrenData.forEach(data => {
-                  data.Status = 0
-                  data.flag = false
-                })
-              }
-              this.setChildrenDisabled(id)
+          this.dataArr.find(data => {
+            if (data.AuthId === id) {
+              data.Status = Status
+              data.flag = flag
+              return true
+            }
+          })
+          if (type !== 1) {
+            if (!isChildren) {
+              this.childrenData.forEach(data => {
+                data.Status = Status
+                data.flag = flag
+              })
             }
+            this.setChildrenStatus(id, flag)
           }
           //this.getAuthTree()
         } else {
           this.$message.error(res.message)
           if (!isChildren) {
-            this.currDataArr[0].flag = !val;
+            this.currDataArr[0].flag = !flag;
           } else {
-            this.childrenData[index].flag = !val;
+            this.childrenData[index].flag = !flag;
           }
         }
       } catch (error) {
         console.log('出错了', error)
         if (!isChildren) {
-          this.currDataArr[0].flag = !val;
+          this.currDataArr[0].flag = !flag;
         } else {
-          this.childrenData[index].flag = !val;
+          this.childrenData[index].flag = !flag;
         }
       }
     },

+ 6 - 7
src/views/organizationManagement/components/organizationHome.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2021-11-29 09:27:43
- * @LastEditTime: 2022-03-18 11:36:50
+ * @LastEditTime: 2022-03-18 15:54:39
  * @LastEditors: your name
  * @Description: 权限管理
  * @FilePath: \Foshan4A2.0\src\views\authorityManagement\components\home.vue
@@ -287,14 +287,13 @@ export default {
     // 关闭开启
     renderChange (data) {
       const { OrganId, flag } = data;
-      const Status = flag ? 1 : 0;
-      this.handleChange(OrganId, Status);
+      this.handleChange(OrganId, flag);
     },
     //下级关闭
     childrenRenderChange (data, index) {
+      const { OrganId, flag } = data;
+      const Status = flag ? 1 : 0;
       try {
-        const { OrganId, flag } = data;
-        const Status = flag ? 1 : 0;
         tissueTreeStart({
           OrganId: OrganId,
           Status: Status,
@@ -353,11 +352,11 @@ export default {
 
     //-----------获取数据------------
     //应用状态变更
-    async handleChange (id, val) {
+    async handleChange (id, flag) {
       try {
         const res = await tissueTreeStart({
           OrganId: id,
-          Status: val,
+          Status: flag ? 1 : 0,
         });
         if (res.code === 0) {
           this.$message.success(res.message);