diff --git a/nezha-fronted/src/components/common/rightBox/accountBox.vue b/nezha-fronted/src/components/common/rightBox/accountBox.vue index 064a8ac88..92b0f519d 100644 --- a/nezha-fronted/src/components/common/rightBox/accountBox.vue +++ b/nezha-fronted/src/components/common/rightBox/accountBox.vue @@ -40,7 +40,7 @@ - + @@ -136,8 +136,10 @@ save() { this.$refs.accountForm.validate(valid => { if (valid) { + let editUser = JSON.parse(JSON.stringify(this.editUser)) + editUser.roleIds = [editUser.roleIds] if (this.editUser.userId) { - this.$put('sys/user/update', this.editUser).then(response => { + this.$put('sys/user/update',editUser).then(response => { if (response.code === 200) { this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")}); this.esc(true); @@ -146,7 +148,7 @@ } }); } else { - this.$post('sys/user/save', this.editUser).then(response => { + this.$post('sys/user/save', editUser).then(response => { if (response.code === 200) { this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")}); this.esc(true); @@ -220,6 +222,9 @@ this.$get("sys/role").then(response=>{ if (response.code == 200){ this.roles = response.data.list; + if(!this.editUser.userId){ + this.editUser.roleIds = this.roles.find(t=>t.name == 'common').id; + } }else{ this.$message.error("load roles faild") } @@ -251,8 +256,7 @@ deep: true, handler(n) { this.editUser = JSON.parse(JSON.stringify(n)); - this.editUser.roleIds=n.roles&&n.roles.map(t=>t.id) - console.log(this.editUser) + this.editUser.roleIds=n.roles&&n.roles.map(t=>t.id)[0] } }, "editUser.notifications": { @@ -262,13 +266,6 @@ this.getSelectableScripts(); } }, - editUser:{ - deep:true, - immediate:true, - handler(n,o){ - console.log('editUser',n) - } - } }, } diff --git a/nezha-fronted/src/components/page/config/account.vue b/nezha-fronted/src/components/page/config/account.vue index 6d9b17e79..4289dce0c 100644 --- a/nezha-fronted/src/components/page/config/account.vue +++ b/nezha-fronted/src/components/page/config/account.vue @@ -192,7 +192,7 @@ status: '1', createTime: '', receiver: [], - roleIds:[], + roleIds:0, roles:[], lang: '', notifications: []