فهرست منبع

修复修改用户,右上角不更新问题

shaogen1995 4 سال پیش
والد
کامیت
538b31ea2c
1فایلهای تغییر یافته به همراه15 افزوده شده و 1 حذف شده
  1. 15 1
      src/views/tab4/tab4_add.vue

+ 15 - 1
src/views/tab4/tab4_add.vue

@@ -108,6 +108,20 @@ export default {
       try {
         await this.$refs.ruleForm.validate()
         const res = await userSave(this.ruleForm)
+        // 如果是编辑用户--并且编辑的是自己
+        if (this.ruleForm.id) {
+          const temp = localStorage.getItem('SWKK_userInfo')
+          const userInfo = JSON.parse(temp)
+          if (userInfo.id === this.ruleForm.id) {
+            const userRes = await getUserDetailById(this.ruleForm.id)
+            localStorage.setItem('SWKK_userInfo', JSON.stringify(userRes.data))
+            this.$nextTick(() => {
+              setTimeout(() => {
+                location.reload(true)
+              }, 200)
+            })
+          }
+        }
         if (res.code === 0) {
           this.$message.success('操作成功')
           // 通知父组件更新
@@ -122,7 +136,7 @@ export default {
     async getUserDetailById (id) {
       const res = await getUserDetailById(id)
       this.ruleForm = res.data
-      // console.log(999, res)
+      // localStorage.setItem('SWKK_userInfo', JSON.stringify(res.data))
     }
   },
   // 生命周期 - 创建完成(可以访问当前this实例)