APP菜单权限及租户权限

This commit is contained in:
liuyusheng 2024-11-06 15:18:50 +08:00
parent a16c5a44f3
commit af585ecb17
3 changed files with 47 additions and 2 deletions

View File

View File

@ -71,6 +71,12 @@
<el-tree class="tree-border" :data="menuOptions" show-checkbox ref="menu" node-key="id"
:check-strictly="menuCheckStrictly" empty-text="加载中,请稍后" :props="defaultProps"></el-tree>
</el-form-item>
<el-form-item label="APP菜单权限">
<el-checkbox v-model="APPmenuExpand" @change="handleCheckedAPPTreeExpand($event)">展开/折叠</el-checkbox>
<el-checkbox v-model="APPmenuNodeAll" @change="handleCheckedAPPTreeNodeAll($event)">全选/全不选</el-checkbox>
<el-tree class="tree-border" :data="APPmenuOptions" show-checkbox ref="APPmenu" node-key="id"
:check-strictly="APPmenuCheckStrictly" empty-text="加载中,请稍后" :props="APPdefaultProps"></el-tree>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-radio-group v-model="form.status">
<el-radio v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)"
@ -93,6 +99,7 @@
import { createTenantPackage, updateTenantPackage, deleteTenantPackage, getTenantPackage, getTenantPackagePage} from "@/api/system/tenantPackage";
import {CommonStatusEnum} from "@/utils/constants";
import {listSimpleMenus} from "@/api/system/menu";
import {listSimpleAPPMenus} from "@/api/system/appMenu";
export default {
name: "SystemTenantPackage",
@ -124,13 +131,21 @@ export default {
//
form: {},
menuExpand: false,
APPmenuExpand: false,
menuNodeAll: false,
APPmenuNodeAll: false,
menuCheckStrictly: true,
APPmenuCheckStrictly: true,
defaultProps: {
label: "name",
children: "children"
},
APPdefaultProps: {
label: "name",
children: "children"
},
menuOptions: [], //
APPmenuOptions: [], //
//
rules: {
name: [{ required: true, message: "套餐名不能为空", trigger: "blur" }],
@ -165,9 +180,15 @@ export default {
if (this.$refs.menu !== undefined) {
this.$refs.menu.setCheckedKeys([]);
}
if (this.$refs.APPmenu !== undefined) {
this.$refs.APPmenu.setCheckedKeys([]);
}
this.menuExpand = false;
this.APPmenuExpand = false;
this.menuNodeAll = false;
this.APPmenuNodeAll = false;
this.menuCheckStrictly = true;
this.APPmenuCheckStrictly = true;
//
this.form = {
id: undefined,
@ -175,6 +196,7 @@ export default {
status: CommonStatusEnum.ENABLE,
remark: undefined,
menuIds: undefined,
appMenuIds: undefined,
};
this.resetForm("form");
},
@ -196,6 +218,7 @@ export default {
this.title = "添加租户套餐";
// 使
this.menuCheckStrictly = false;
this.APPmenuCheckStrictly = false;
},
/** 修改按钮操作 */
handleUpdate(row) {
@ -209,10 +232,13 @@ export default {
//
//
this.menuCheckStrictly = true
this.APPmenuCheckStrictly = true
//
this.$refs.menu.setCheckedKeys(response.data.menuIds);
this.$refs.APPmenu.setCheckedKeys(response.data.appMenuIds);
// 使
this.menuCheckStrictly = false
this.APPmenuCheckStrictly = false
});
},
/** 获得菜单 */
@ -223,6 +249,12 @@ export default {
//
this.menuOptions.push(...this.handleTree(response.data, "id"));
});
listSimpleAPPMenus().then(response => {
// APPmenuOptions
this.APPmenuOptions = [];
//
this.APPmenuOptions.push(...this.handleTree(response.data, "id"));
});
},
/** 提交按钮 */
submitForm() {
@ -234,7 +266,8 @@ export default {
if (this.form.id != null) {
updateTenantPackage({
...this.form,
menuIds: [...this.$refs.menu.getCheckedKeys(), ...this.$refs.menu.getHalfCheckedKeys()]
menuIds: [...this.$refs.menu.getCheckedKeys(), ...this.$refs.menu.getHalfCheckedKeys()],
appMenuIds: [...this.$refs.APPmenu.getCheckedKeys(), ...this.$refs.APPmenu.getHalfCheckedKeys()]
}).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
@ -245,7 +278,8 @@ export default {
//
createTenantPackage({
...this.form,
menuIds: [...this.$refs.menu.getCheckedKeys(), ...this.$refs.menu.getHalfCheckedKeys()]
menuIds: [...this.$refs.menu.getCheckedKeys(), ...this.$refs.menu.getHalfCheckedKeys()],
appMenuIds: [...this.$refs.APPmenu.getCheckedKeys(), ...this.$refs.APPmenu.getHalfCheckedKeys()]
}).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
@ -274,6 +308,17 @@ export default {
handleCheckedTreeNodeAll(value) {
this.$refs.menu.setCheckedNodes(value ? this.menuOptions: []);
},
// /
handleCheckedAPPTreeExpand(value, type) {
let treeList = this.APPmenuOptions;
for (let i = 0; i < treeList.length; i++) {
this.$refs.APPmenu.store.nodesMap[treeList[i].id].expanded = value;
}
},
// /
handleCheckedAPPTreeNodeAll(value) {
this.$refs.APPmenu.setCheckedNodes(value ? this.APPmenuOptions: []);
},
//
handleCheckedTreeConnect(value) {
this.form.menuCheckStrictly = value;