Browse Source

账号状态修改bug

zhongxiaoyu 3 years ago
parent
commit
6a0bbb323f

+ 8 - 3
src/views/accountGroupManagement/components/accountGroupEdit.vue

@@ -157,7 +157,7 @@ export default {
     return {
       doesGroupExist: this.$route.meta.doesGroupExist, // 控制账号组新增/编辑
       GroupId: 0,
-      GroupUpId: this.$route.query.GroupUpId,
+      GroupUpId: Number(this.$route.query.GroupUpId),
       // dialogVisible: false,
       openRole: 0,
       accountGroupTreeCheckedList: [], // 账号组树初始勾选项
@@ -193,6 +193,7 @@ export default {
     }
   },
   created() {
+    console.log(typeof this.GroupUpId)
     let obj
     if (typeof this.systemSet === 'string') {
       obj = JSON.parse(this.systemSet)
@@ -206,7 +207,7 @@ export default {
     this.accountGroupTreeCheckedTemp = [this.GroupUpId]
   },
   mounted() {
-    this.roleType = 'roleByUpId'
+    this.roleType = this.GroupUpId === -1 ? 'onlyRole' : 'roleByUpId'
     this.accountGroupTreeCheckedList = [this.GroupUpId]
     if (this.doesGroupExist) {
       this.GroupId = this.$route.query.GroupId
@@ -266,10 +267,12 @@ export default {
     getAccountGroupChecked(arr) {
       if (arr && arr.length && arr[0] !== -1) {
         this.queryType = 'group'
+        this.roleType = 'roleByUpId'
         const GroupUpId = arr[0].GroupId
         this.accountGroupTreeCheckedTemp = [GroupUpId]
       } else {
         this.queryType = 'all'
+        this.roleType = 'onlyRole'
         this.accountGroupTreeCheckedTemp = [-1]
       }
     },
@@ -350,6 +353,7 @@ export default {
         if (res.code === 0) {
           this.$message.success(res.message)
           setTimeout(() => {
+            this.$store.dispatch('tagsView/delView', this.$route)
             this.$router.push('/accountGroup')
           }, 2000)
         } else {
@@ -365,8 +369,9 @@ export default {
         if (res.code === 0) {
           this.$message.success(res.message)
           setTimeout(() => {
+            this.$store.dispatch('tagsView/delView', this.$route)
             this.$router.push('/accountGroup')
-          }, 2000)
+          }, 1000)
         } else {
           this.$message.error(res.message)
         }

+ 9 - 6
src/views/accountManagement/components/accountEdit.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: Badguy
  * @Date: 2022-02-15 11:37:42
- * @LastEditTime: 2022-02-21 18:27:18
+ * @LastEditTime: 2022-02-22 10:47:56
  * @LastEditors: your name
  * @Description: 编辑账号
  * have a nice day!
@@ -362,7 +362,7 @@ export default {
     this.pwdLengthBegin = PwdLengthBegin
     this.pwdLengthEnd = PwdLengthEnd
     this.openRole && (this.roleType = this.openGroup ? 'roleByUpId' : 'onlyRole')
-    this.queryType = this.openRole ? 'group' : 'all'
+    this.queryType = this.openGroup ? 'group' : 'all'
     if (this.doesAccountExist) {
       this.userId = this.$route.query.userId
       this.getAccountInfo()
@@ -378,7 +378,7 @@ export default {
           UserId: this.userId
         })
         if (res.code === 0) {
-          console.log(res.returnData)
+          // console.log(res.returnData)
           const { UserDesc, UserName, GroupList, TacList, AuthList, RoleList, Status } = res.returnData
           this.accountForm.name = UserName
           this.accountForm.desc = UserDesc
@@ -391,12 +391,13 @@ export default {
               this.permissionTreeChckedTemp.push(auth)
             })
 
+          this.accountGroupTreeCheckedTemp = []
           GroupList &&
             GroupList.length &&
             GroupList.forEach(group => {
               this.accountGroupTreeCheckedList.push(group.GroupId)
+              this.accountGroupTreeCheckedTemp.push(group.GroupId)
             })
-          this.accountGroupTreeCheckedTemp = this.accountGroupTreeCheckedList
 
           RoleList &&
             RoleList.length &&
@@ -507,8 +508,9 @@ export default {
         if (res.code === 0) {
           this.$message.success(res.message)
           setTimeout(() => {
+            this.$store.dispatch('tagsView/delView', this.$route)
             this.$router.push('/account')
-          })
+          }, 1000)
         } else {
           this.$message.error(res.message)
         }
@@ -523,8 +525,9 @@ export default {
         if (res.code === 0) {
           this.$message.success(res.message)
           setTimeout(() => {
+            this.$store.dispatch('tagsView/delView', this.$route)
             this.$router.push('/account')
-          })
+          }, 1000)
         } else {
           this.$message.error(res.message)
         }

+ 20 - 9
src/views/accountManagement/components/accountHome.vue

@@ -92,7 +92,7 @@
                       :inactive-value="false"
                       active-color="#6F81BC"
                       inactive-color="#CFD6E2"
-                      @change="userActiveToggle(account.Flag, account.UserId)"
+                      @change="userActiveToggle(account)"
                     />
                   </el-col>
                 </el-row>
@@ -194,14 +194,20 @@ export default {
       this.pageInit()
     },
     // 修改状态
-    async userActiveToggle(flag, userId) {
+    async userActiveToggle({ Flag, Status, UserId }) {
+      Status = Flag ? 2 : 3
       try {
         const result = await ChangeUserStatus({
-          flag,
-          userId
+          Flag,
+          Status,
+          UserId
         })
         if (result.code === 0) {
-          this.pageInit()
+          this.accountArr.forEach(account => {
+            if (account.UserId === UserId) {
+              account.Status = Status
+            }
+          })
           this.$message.success(result.message)
         } else {
           this.$message.error(result.$message)
@@ -215,8 +221,8 @@ export default {
       this.deleteUserId = user.UserId
       this.deleteUserName = user.UserName
     },
-    toEdit(userid) {
-      this.userId = userid
+    toEdit(userId) {
+      this.userId = userId
       this.$router.push({
         path: '/account/accountEdit',
         query: { userId: this.userId }
@@ -380,10 +386,15 @@ export default {
       }
 
       .del {
+        padding: 10px;
         position: absolute;
-        right: 24px;
-        top: 32px;
+        right: 14px;
+        top: 22px;
         cursor: pointer;
+
+        &:hover {
+          color: #f25555;
+        }
       }
       .nameBox {
         display: flex;