From 70bc18350980382cecad0d1660f69841a8aaf85b Mon Sep 17 00:00:00 2001 From: pengyongcheng <pyc_1215@163.com> Date: Thu, 19 Dec 2024 09:19:09 +0800 Subject: [PATCH] 角色权限配置,默认不展开权限树 --- ant-design-vue-jeecg/src/views/system/modules/UserRoleModal.vue | 56 +++++++++++++++++++++++++++----------------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/ant-design-vue-jeecg/src/views/system/modules/UserRoleModal.vue b/ant-design-vue-jeecg/src/views/system/modules/UserRoleModal.vue index 5670b9e..f03d01a 100644 --- a/ant-design-vue-jeecg/src/views/system/modules/UserRoleModal.vue +++ b/ant-design-vue-jeecg/src/views/system/modules/UserRoleModal.vue @@ -40,7 +40,7 @@ </a-menu> <a-button> 树操作 - <a-icon type="up"/> + <a-icon type="up" /> </a-button> </a-dropdown> <a-popconfirm title="确定放弃编辑?" @confirm="close" okText="确定" cancelText="取消"> @@ -57,17 +57,17 @@ </template> <script> -import {queryTreeListForRole, queryRolePermission, saveRolePermission} from '@/api/api' +import { queryRolePermission, queryTreeListForRole, saveRolePermission } from '@/api/api' import RoleDataruleModal from './RoleDataruleModal.vue' export default { - name: "RoleModal", + name: 'RoleModal', components: { RoleDataruleModal }, data() { return { - roleId: "", + roleId: '', treeData: [], defaultCheckedKeys: [], checkedKeys: [], @@ -75,7 +75,7 @@ export default { allTreeKeys: [], autoExpandParent: true, checkStrictly: true, - title: "角色权限配置", + title: '角色权限配置', visible: false, loading: false, selectedKeys: [] @@ -90,22 +90,22 @@ export default { }, onCheck(o) { if (this.checkStrictly) { - this.checkedKeys = o.checked; + this.checkedKeys = o.checked } else { this.checkedKeys = o } }, show(roleId) { this.roleId = roleId - this.visible = true; + this.visible = true }, close() { this.reset() - this.$emit('close'); - this.visible = false; + this.$emit('close') + this.visible = false }, onExpand(expandedKeys) { - this.expandedKeysss = expandedKeys; + this.expandedKeysss = expandedKeys this.autoExpandParent = false }, reset() { @@ -128,9 +128,9 @@ export default { this.checkedKeys = [] }, switchCheckStrictly(v) { - if (v == 1) { + if (v === 1) { this.checkStrictly = false - } else if (v == 2) { + } else if (v === 2) { this.checkStrictly = true } }, @@ -138,40 +138,38 @@ export default { this.close() }, handleSubmit(exit) { - let that = this; + let that = this let params = { roleId: that.roleId, - permissionIds: that.checkedKeys.join(","), - lastpermissionIds: that.defaultCheckedKeys.join(","), - }; - that.loading = true; - console.log("请求参数:", params); + permissionIds: that.checkedKeys.join(','), + lastpermissionIds: that.defaultCheckedKeys.join(',') + } + that.loading = true saveRolePermission(params).then((res) => { if (res.success) { - that.$message.success(res.message); - that.loading = false; + that.$message.success(res.message) + that.loading = false if (exit) { that.close() } } else { - that.$message.error(res.message); - that.loading = false; + that.$message.error(res.message) + that.loading = false if (exit) { that.close() } } - this.loadData(); + this.loadData() }) }, loadData() { queryTreeListForRole().then((res) => { this.treeData = res.result.treeList this.allTreeKeys = res.result.ids - queryRolePermission({roleId: this.roleId}).then((res) => { - this.checkedKeys = [...res.result]; - this.defaultCheckedKeys = [...res.result]; - this.expandedKeysss = this.allTreeKeys; - console.log(this.defaultCheckedKeys) + queryRolePermission({ roleId: this.roleId }).then((res) => { + this.checkedKeys = [...res.result] + this.defaultCheckedKeys = [...res.result] + //this.expandedKeysss = this.allTreeKeys 注释为了加载数据后,控件不展开 }) }) } @@ -179,7 +177,7 @@ export default { watch: { visible() { if (this.visible) { - this.loadData(); + this.loadData() } } } -- libgit2 0.22.2