diff --git a/src/resources/api/framework/users/user.js b/src/resources/api/framework/users/user.js index a93736171638de97912c1aee0b3f9e0c730dcd4a..ff966c90623b99edc03790eb9c40604ae1bed412 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 d95a0c11f7e40e3c7a18c825f50e68482d961400..937146940834378a3ee895b91c3c5090500a5d46 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'); @@ -633,10 +646,9 @@ export default { } this.formShow = true; let data = { - userUuid: id, - isRuleRole: false + userUuid: id }; - 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; @@ -674,34 +686,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 +718,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 +727,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 +754,6 @@ export default { }, //自定义初始化tabs getLabel(label, name) { - var _this = this; return h => { return h( 'div', @@ -770,7 +763,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 +865,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 +910,7 @@ export default {