From 0a6f6cb7fc49847542595dcf545800886e865397 Mon Sep 17 00:00:00 2001 From: yaojn Date: Wed, 14 May 2025 16:59:07 +0800 Subject: [PATCH 1/2] =?UTF-8?q?-=20[=E4=BF=AE=E5=A4=8D]=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=8E=88=E6=9D=83=E9=A1=B5=E6=9D=83=E9=99=90=E5=9B=9E=E6=98=BE?= =?UTF-8?q?=E4=B8=8D=E6=AD=A3=E7=A1=AE=20=20=20=20-=20[=E5=85=B3=E8=81=94]?= =?UTF-8?q?#[1417283535077376]=E7=94=A8=E6=88=B7=E6=8E=88=E6=9D=83?= =?UTF-8?q?=E9=A1=B5=E6=9D=83=E9=99=90=E5=9B=9E=E6=98=BE=E4=B8=8D=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=20http://192.168.0.96:8090/demo/rdm.html#/bug-detail/?= =?UTF-8?q?939050947543040/939050947543057/1417283535077376?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/resources/api/framework/users/user.js | 4 + .../pages/framework/users/user-addview.vue | 214 ++++++++---------- 2 files changed, 96 insertions(+), 122 deletions(-) diff --git a/src/resources/api/framework/users/user.js b/src/resources/api/framework/users/user.js index a93736171..ff966c906 100644 --- a/src/resources/api/framework/users/user.js +++ b/src/resources/api/framework/users/user.js @@ -98,5 +98,9 @@ export default { }, clearUserSessionCache() { //删除用户会话缓存 return axios.post('/api/rest/user/session/cache/clear'); + }, + getUserForEdit(params) { + // 获取用户信息(编辑页面回显专用) + return axios.post('api/rest/user/get/foredit', params); } }; diff --git a/src/views/pages/framework/users/user-addview.vue b/src/views/pages/framework/users/user-addview.vue index d95a0c11f..62dc8ccf4 100644 --- a/src/views/pages/framework/users/user-addview.vue +++ b/src/views/pages/framework/users/user-addview.vue @@ -15,7 +15,7 @@
-
+
-
+
- - + @@ -77,17 +73,17 @@ type="primary" :loading="isLoading" @click="submit()" - >{{ $t('dialog.title.createtarget', {target: $t('page.user')}) }} + >{{ $t('dialog.title.createtarget', { target: $t('page.user') }) }}
- +
@@ -136,7 +132,7 @@ >{{ $t('page.save') }}
- +
v.name === 'teamRoleList'); - if (newConfig) { - newConfig.isHidden = false; - } - } - this.label1 = this.getLabel(this.$t('page.basicinfo'), 'user'); - this.label2 = this.getLabel(this.$t('page.auth'), 'auth'); - this.getRoleList(); - this.getAuthList(); - this.getProfile(); + this.initData(); }, - beforeMount() {}, - mounted() {}, - beforeUpdate() {}, - updated() {}, - activated() {}, - deactivated() {}, - beforeDestroy() {}, - destroyed() {}, - methods: { + initData() { + let { uuid = null, userId = null, key = null, readonly = false } = this.$route.query; + this.uuid = uuid; + this.userId = userId; + this.tabsName = key; + this.readonly = readonly; + this.handleDataByUuid(); + this.handleReadonly(); + this.basicInfoTabLabelName = this.getLabel(this.$t('page.basicinfo'), 'user'); + this.authTabLabelName = this.getLabel(this.$t('page.auth'), 'auth'); + this.getAuthList(); + this.getProfile(); + }, + handleDataByUuid() { + if (!this.$utils.isEmpty(this.uuid)) { + this.getUserDetail(this.uuid); + this.getAuthSelect(this.uuid); + this.getUserToken(this.uuid); + } + }, + handleReadonly() { + if (this.readonly) { + this.formData.forEach(item => { + item.disabled = true; + }); + this.formData + .filter(d => d.name == 'roleUuidList' || d.name == 'teamUuidList') + .forEach(item => { + item.readonly = true; + }); + } else { + this.formData.forEach(item => { + if (this.uuid && item.name == 'userId') { + item.disabled = true; + } else if (item.name != 'uuid') { + item.disabled = false; + item.readonly = false; + } + }); + } + if (this.readonly && this.uuid) { + let findTeamRoleItem = this.formData.find(v => v.name === 'teamRoleList'); + if (findTeamRoleItem) { + findTeamRoleItem.isHidden = false; + } + } + }, //密码框改变 psdChange: function(val) { if (this.userId != null) { @@ -500,7 +515,6 @@ export default { }, //下一步 next() { - let _this = this; let data = this.$refs.userForm.getFormValue(); if (!this.$refs.userForm.valid()) { this.stepStatus = 'error'; @@ -590,7 +604,7 @@ export default { .then(res => { if (res.Status == 'OK') { this.$Message.success(this.$t('message.savesuccess')); - this.userTabsDataList = this.$refs.userForm ? this.$refs.userForm.getFormValue() : null; + this.defaultUserDataTab = this.$refs.userForm ? this.$refs.userForm.getFormValue() : null; this.userData = this.getData(); } }) @@ -618,7 +632,6 @@ export default { }, //获取当前用户信息 getUserDetail(id) { - let _this = this; let obj_name = this.formData.find(d => d.name === 'userId'); let psd = this.formData.find(d => d.name === 'password'); let newpwd = this.formData.find(d => d.name === 'confirmpwd'); @@ -636,7 +649,7 @@ export default { userUuid: id, isRuleRole: false }; - this.$api.common.getUser(data).then(res => { + this.$api.framework.user.getUserForEdit(data).then(res => { if (res.Status == 'OK') { let row = res.Return; this.userDetail = row; @@ -648,6 +661,19 @@ export default { }); } this.teamRoleList = row.teamRoleList; + // 用户组角色主要用户回显,删除id,后端是动态生成的,为了处理下榻页面返回时,数据对比的问题 + // this.teamRoleList.forEach((v) => { + // if (v.id) { + // delete v.id; + // } + // if (v && v.teamList && v.teamList.length > 0) { + // v.teamList.forEach((team) => { + // if (team.id) { + // delete team.id; + // } + // }); + // } + // }); let obj = this.formData.find(d => d.name === 'teamUuidList'); if (obj) { obj.value = row.teamUuidList; @@ -674,34 +700,16 @@ export default { //获取所有权限列表 getAuthList: function() { let data = {}; - let _this = this; - this.$api.common - .getAuthGrouplist(data) - .then(res => { - if (res.Status == 'OK') { - _this.authList = res.Return.authGroupList; - _this.$nextTick(() => { - setTimeout(() => { - _this.userData = _this.getData(); - _this.userTabsDataList = _this.$refs.userForm.getFormValue(); - _this.userTabsAuthList = JSON.parse(JSON.stringify(_this.$refs.commonAuth.authSelectList)); - }, 500); - }); - } - }); - }, - //获取角色列表 - getRoleList: function() { - let data = { - needPage: false - }; - this.$api.framework.role.roleList(data).then(res => { + this.$api.common.getAuthGrouplist(data).then(res => { if (res.Status == 'OK') { - let list = res.Return.tbodyList; - let newConfig = this.formData.find(d => d.name == 'roleUuidList'); - if (newConfig) { - newConfig.dataList = list; - } + this.authList = res.Return.authGroupList; + this.$nextTick(() => { + setTimeout(() => { + this.userData = this.getData(); + this.defaultUserDataTab = this.$refs.userForm?.getFormValue(); + this.userTabsAuthList = JSON.parse(JSON.stringify(this.$refs.commonAuth.authSelectList)); + }, 500); + }); } }); }, @@ -724,7 +732,7 @@ export default { if (this.tabsName != name) { if (name == 'auth') { let newData = this.$refs.userForm.getFormValue(); - if (JSON.stringify(newData) == JSON.stringify(this.userTabsDataList)) { + if (this.$utils.isSame(newData, this.defaultUserDataTab)) { this.tabSaveTip = false; //可以跳转 } else { this.tabSaveTip = true; @@ -733,7 +741,7 @@ export default { } if (name == 'user') { let newData = this.$refs.commonAuth.authSelectList; - if (JSON.stringify(newData) == JSON.stringify(this.userTabsAuthList)) { + if (this.$utils.isSame(newData, this.userTabsAuthList)) { this.tabSaveTip = false; //可以跳转 } else { this.tabSaveTip = true; @@ -760,7 +768,6 @@ export default { }, //自定义初始化tabs getLabel(label, name) { - var _this = this; return h => { return h( 'div', @@ -770,7 +777,7 @@ export default { }, on: { click: e => { - var tip = _this.tabClick(name); // 判断条件是否满足 + const tip = this.tabClick(name); // 判断条件是否满足 if (tip) { e.stopPropagation(); // 不满足条件则阻止事件冒泡 本质是不让触发tab的on-click事件 } @@ -872,46 +879,9 @@ export default { }); } }, - filter: {}, - computed: {}, - watch: { - uuid() { - if (this.uuid != undefined) { - let uuid = this.uuid; - this.getUserDetail(uuid); - this.getAuthSelect(uuid); - this.getUserToken(uuid); - } - }, - // userId: function () { - // if (this.userId != undefined) { - // let userId = this.userId; - // } - // }, - readonly: function(newVal) { - if (newVal) { - this.formData.forEach(item => { - item.disabled = true; - }); - this.formData - .filter(d => d.name == 'roleUuidList' || d.name == 'teamUuidList') - .forEach(item => { - item.readonly = true; - }); - } else { - this.formData.forEach(item => { - if (this.uuid && item.name == 'userId') { - item.disabled = true; - } else if (item.name != 'uuid') { - item.disabled = false; - item.readonly = false; - } - }); - } - } }, //路由离开之前 beforeRouteLeave(to, from, next, url) { @@ -954,7 +924,7 @@ export default {