Browse Source

权限管理状态切换bug

zhongxiaoyu 3 years ago
parent
commit
1cf4549e9c

+ 61 - 45
src/views/accountGroupManagement/components/accountGroupHome.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2022-01-08 09:27:43
- * @LastEditTime: 2022-03-14 10:50:41
+ * @LastEditTime: 2022-03-16 11:57:19
  * @LastEditors: your name
  * @Description: 用户组管理
  * @FilePath: \Foshan4A2.0\src\views\accountGroupManagement\components\home.vue
@@ -298,7 +298,7 @@
     <!--删除弹框-->
     <Dialog :flag="flag">
       <div class="airportInfoDialog">
-        <div class="title">删除{{ title }}</div>
+        <div class="title">删除{{ accountGroupType }}</div>
         <div class="content">是否确认删除{{ title }}?</div>
         <div class="foot right t30">
           <el-button
@@ -397,41 +397,43 @@ export default {
     async childrenRenderChange(data, index) {
       const { GroupId, flag } = data
       const Status = flag ? 1 : 0
-      try {
-        const res = await ChangeGroupStatus({
-          GroupId: GroupId,
-          Status: Status
-        })
-        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)
-          this.childrenData[index].flag = !flag
-        }
-      } catch (error) {
-        console.log('出错了', error)
-        this.childrenData[index].flag = !flag
-      }
+      const isChildren = true
+      this.handleChange(GroupId, Status, isChildren, index)
+      // try {
+      //   const res = await ChangeGroupStatus({
+      //     GroupId: GroupId,
+      //     Status: Status
+      //   })
+      //   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)
+      //     this.childrenData[index].flag = !flag
+      //   }
+      // } catch (error) {
+      //   console.log('出错了', error)
+      //   this.childrenData[index].flag = !flag
+      // }
     },
     // 删除组织
     remove() {
@@ -475,7 +477,7 @@ export default {
     },
     // -----------获取数据------------
     // 状态变更
-    async handleChange(id, val) {
+    async handleChange(id, val, isChildren = false, index) {
       try {
         const res = await ChangeGroupStatus({
           GroupId: id,
@@ -483,7 +485,11 @@ export default {
         })
         if (res.code === 0) {
           this.$message.success(res.message)
-          this.currDataArr[0].Status = val
+          if (!isChildren) {
+            this.currDataArr[0].Status = val
+          } else {
+            this.childrenData[index].Status = val
+          }
           if (val) {
             this.dataArr.find(data => {
               if (data.GroupId === id) {
@@ -500,19 +506,29 @@ export default {
                 return true
               }
             })
-            this.childrenData.forEach(data => {
-              data.Status = 0
-              data.flag = false
-            })
+            if (!isChildren) {
+              this.childrenData.forEach(data => {
+                data.Status = 0
+                data.flag = false
+              })
+            }
             this.setChildrenDisabled(id)
           }
         } else {
           this.$message.error(res.message)
-          this.currDataArr[0].flag = !val
+          if (!isChildren) {
+            this.currDataArr[0].flag = !val
+          } else {
+            this.childrenData[index].flag = !val
+          }
         }
       } catch (error) {
         console.log('出错了', error)
-        this.currDataArr[0].flag = !val
+        if (!isChildren) {
+            this.currDataArr[0].flag = !val
+          } else {
+            this.childrenData[index].flag = !val
+          }
       }
     },
     // 删除

+ 43 - 59
src/views/authorityManagement/components/authorityHome.vue

@@ -1,8 +1,8 @@
 <!--
  * @Author: your name
  * @Date: 2021-11-29 09:27:43
- * @LastEditTime: 2022-03-01 10:30:44
- * @LastEditors: Please set LastEditors
+ * @LastEditTime: 2022-03-16 12:01:30
+ * @LastEditors: your name
  * @Description: 权限管理
  * @FilePath: \Foshan4A2.0\src\views\authorityManagement\components\home.vue
 -->
@@ -119,7 +119,7 @@
                           <div v-if="data.Type > 0" class="flex details">
                             <div class="details-msg">状态:<span :class="data.Status === 1 ? 'success' : 'error'">{{data.Status === 1 ? '启用' : '禁用'}}</span></div>
                             <div v-is="['authtree_btn_state_swatch']" class="details-info">
-                              <el-switch v-model="data.flag" @click.stop.native @change="renderChange(data,index)" active-color="#6F81BC">
+                              <el-switch v-model="data.flag" @click.stop.native @change="childrenRenderChange(data,index)" active-color="#6F81BC">
                               </el-switch>
                             </div>
                           </div>
@@ -148,7 +148,7 @@
     <!--删除弹框-->
     <Dialog :flag="flag">
       <div class="airportInfoDialog">
-        <div class="title">删除{{ title }}</div>
+        <div class="title">删除{{ type === 1 ? '应用' : '权限' }}</div>
         <div class="content">是否确认删除{{ title }}?</div>
         <div class="foot right t30">
           <el-button size="medium" class="r24" @click="remove" type="danger">删除</el-button>
@@ -228,26 +228,10 @@ export default {
     },
     //下级关闭
     childrenRenderChange (data, index) {
-      try {
-        const { OrganId, flag } = data;
-        const Status = flag ? 1 : 0;
-        tissueTreeStart({
-          OrganId: OrganId,
-          Status: Status,
-        }).then((res) => {
-          if (res.code === 0) {
-            this.$message.success(res.message);
-            this.childrenData[index].Status = Status;
-            // this.getOrganTree();
-          } else {
-            this.$message.error(res.message);
-            this.childrenData[index].flag = !flag;
-          }
-        });
-      } catch (error) {
-        console.log("出错了", error);
-        this.childrenData[index].flag = !flag;
-      }
+      const { AuthId, flag, Type } = data
+      const Status = flag ? 1 : 0
+      const isChildren = true
+      this.handleChange(AuthId, Status, Type, index, isChildren)
     },
     filterNode (value, data) {
       if (!value) return true;
@@ -311,40 +295,40 @@ export default {
       return arr
     },
     //渲染节点
-    renderContent (h, data) {
-      return (
-        <div class="account-left-content-teams">
-          <div class="team">
-            <div class={[data.Type <= 1 ? 'status1' : 'status2', 'bg']}></div>
-            <div class={[data.QueryTarget == 1 ? 'activeStatus' : '', 'list']}>
-              <div class="flex info">
-                <div class="name">{data.AuthName}</div>
-                <div class="icon">
-                  <span v-show={data.Type === 0} onClick={() => this.renderAdd()} class="cap cap-plus"></span>
-                  <span v-show={data.Type === 1} onClick={() => this.renderEdit(data)} class="cap cap-edit"></span>
-                  <span v-show={data.Type === 2} onClick={() => this.renderSub(data)} class="cap cap-sub"></span>
-                  <span v-show={data.Type > 2} onClick={() => this.renderEdit(data)} class="cap cap-edit"></span>
-                  <span v-show={data.Type > 2} onClick={() => this.renderSub(data)} class="cap cap-sub"></span>
-                </div>
-              </div>
-              <div v-show={data.Type > 0} class="flex details">
-                <div class="details-msg">状态:<span class={[data.Status === 1 ? 'success' : 'error']}>{data.Status === 1 ? '启用' : '禁用'}</span></div>
-                <div class="details-info">
-                  <el-switch v-model={data.flag} onChange={() => this.renderChange(data)} active-color="#6F81BC">
-                  </el-switch>
-                </div>
-              </div>
-            </div>
-          </div>
-          <div v-show={data.Type !== 0 && data.Type !== 2} onClick={() => this.onNodeClick(data)} class="info-close">
-            <i class={[data.Type === 1 ? 'close1' : data.Type > 2 ? 'close2' : '', 'icon', 'el-icon-close']}></i>
-          </div>
-        </div>
-      )
-    },
+    // renderContent (h, data) {
+    //   return (
+    //     <div class="account-left-content-teams">
+    //       <div class="team">
+    //         <div class={[data.Type <= 1 ? 'status1' : 'status2', 'bg']}></div>
+    //         <div class={[data.QueryTarget == 1 ? 'activeStatus' : '', 'list']}>
+    //           <div class="flex info">
+    //             <div class="name">{data.AuthName}</div>
+    //             <div class="icon">
+    //               <span v-show={data.Type === 0} onClick={() => this.renderAdd()} class="cap cap-plus"></span>
+    //               <span v-show={data.Type === 1} onClick={() => this.renderEdit(data)} class="cap cap-edit"></span>
+    //               <span v-show={data.Type === 2} onClick={() => this.renderSub(data)} class="cap cap-sub"></span>
+    //               <span v-show={data.Type > 2} onClick={() => this.renderEdit(data)} class="cap cap-edit"></span>
+    //               <span v-show={data.Type > 2} onClick={() => this.renderSub(data)} class="cap cap-sub"></span>
+    //             </div>
+    //           </div>
+    //           <div v-show={data.Type > 0} class="flex details">
+    //             <div class="details-msg">状态:<span class={[data.Status === 1 ? 'success' : 'error']}>{data.Status === 1 ? '启用' : '禁用'}</span></div>
+    //             <div class="details-info">
+    //               <el-switch v-model={data.flag} onChange={() => this.renderChange(data)} active-color="#6F81BC">
+    //               </el-switch>
+    //             </div>
+    //           </div>
+    //         </div>
+    //       </div>
+    //       <div v-show={data.Type !== 0 && data.Type !== 2} onClick={() => this.onNodeClick(data)} class="info-close">
+    //         <i class={[data.Type === 1 ? 'close1' : data.Type > 2 ? 'close2' : '', 'icon', 'el-icon-close']}></i>
+    //       </div>
+    //     </div>
+    //   )
+    // },
     //-----------获取数据------------
     //应用状态变更
-    async handleChange (id, val, type, index) {
+    async handleChange (id, val, type, index, isChildren = false) {
       try {
         let res = null
         if (type === 1) {
@@ -360,7 +344,7 @@ export default {
         }
         if (res.code === 0) {
           this.$message.success(res.message)
-          if (type === 1) {
+          if (!isChildren) {
             this.currDataArr[0].Status = val
           } else {
             this.childrenData[index].Status = val
@@ -368,7 +352,7 @@ export default {
           //this.getAuthTree()
         } else {
           this.$message.error(res.message)
-          if (type === 1) {
+          if (!isChildren) {
             this.currDataArr[0].flag = !flag;
           } else {
             this.childrenData[index].flag = !flag;
@@ -376,7 +360,7 @@ export default {
         }
       } catch (error) {
         console.log('出错了', error)
-        if (type === 1) {
+        if (!isChildren) {
           this.currDataArr[0].flag = !flag;
         } else {
           this.childrenData[index].flag = !flag;

+ 2 - 2
src/views/organizationManagement/components/organizationHome.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2021-11-29 09:27:43
- * @LastEditTime: 2022-03-14 11:04:03
+ * @LastEditTime: 2022-03-16 12:02:46
  * @LastEditors: your name
  * @Description: 权限管理
  * @FilePath: \Foshan4A2.0\src\views\authorityManagement\components\home.vue
@@ -187,7 +187,7 @@
     <!--删除弹框-->
     <Dialog :flag="flag">
       <div class="airportInfoDialog">
-        <div class="title">删除{{ title }}</div>
+        <div class="title">删除组织</div>
         <div class="content">是否确认删除{{ title }}?</div>
         <div class="foot right t30">
           <el-button size="medium" class="r24" @click="remove" type="danger">删除</el-button>