diff --git a/src/views/modules/Abnormal/AbnormalFeedBack.vue b/src/views/modules/Abnormal/AbnormalFeedBack.vue index 71e6c36..e759779 100644 --- a/src/views/modules/Abnormal/AbnormalFeedBack.vue +++ b/src/views/modules/Abnormal/AbnormalFeedBack.vue @@ -193,7 +193,7 @@ fixed="right" header-align="center" align="center" - width="360" + width="390" label="操作"> @@ -34,6 +35,7 @@ data () { return { visible: false, + dialogLoading: false, menuList: [], menuListTreeProps: { label: 'name', @@ -55,36 +57,53 @@ methods: { init (id) { this.dataForm.id = id || 0 - this.$http({ + this.dataForm.roleName = '' + this.dataForm.remark = '' + this.menuList = [] + this.visible = true + this.dialogLoading = true + this.$nextTick(() => { + if (this.$refs['dataForm']) { + this.$refs['dataForm'].clearValidate() + } + if (this.$refs.menuListTree) { + this.$refs.menuListTree.setCheckedKeys([]) + } + }) + const menuPromise = this.$http({ url: this.$http.adornUrl('/sys/menu/list'), method: 'get', params: this.$http.adornParams() - }).then(({data}) => { - this.menuList = treeDataTranslate(data, 'menuId') - }).then(() => { - this.visible = true - this.$nextTick(() => { - this.$refs['dataForm'].resetFields() - this.$refs.menuListTree.setCheckedKeys([]) + }) + const rolePromise = this.dataForm.id + ? this.$http({ + url: this.$http.adornUrl(`/sys/role/info/${this.dataForm.id}`), + method: 'get', + params: this.$http.adornParams() }) - }).then(() => { - if (this.dataForm.id) { - this.$http({ - url: this.$http.adornUrl(`/sys/role/info/${this.dataForm.id}`), - method: 'get', - params: this.$http.adornParams() - }).then(({data}) => { - if (data && data.code === 0) { - this.dataForm.roleName = data.role.roleName - this.dataForm.remark = data.role.remark - var idx = data.role.menuIdList.indexOf(this.tempKey) - if (idx !== -1) { - data.role.menuIdList.splice(idx, data.role.menuIdList.length - idx) - } - this.$refs.menuListTree.setCheckedKeys(data.role.menuIdList) - } - }) + : Promise.resolve({data: null}) + // 并行加载菜单与角色详情,减少弹窗等待时长 - rqrq + Promise.all([menuPromise, rolePromise]).then(([menuRes, roleRes]) => { + this.menuList = treeDataTranslate(menuRes.data || [], 'menuId') + let checkedMenuIds = [] + if (this.dataForm.id && roleRes.data && roleRes.data.code === 0) { + this.dataForm.roleName = roleRes.data.role.roleName + this.dataForm.remark = roleRes.data.role.remark + checkedMenuIds = (roleRes.data.role.menuIdList || []).slice() + const idx = checkedMenuIds.indexOf(this.tempKey) + if (idx !== -1) { + checkedMenuIds = checkedMenuIds.slice(0, idx) + } } + this.$nextTick(() => { + if (this.$refs.menuListTree) { + this.$refs.menuListTree.setCheckedKeys(checkedMenuIds) + } + }) + }).catch(() => { + this.$message.error('权限数据加载失败') + }).finally(() => { + this.dialogLoading = false }) }, // 表单提交