|
|
@@ -124,7 +124,16 @@ const treeProps = {
|
|
|
// 权限树数据
|
|
|
const permissionTreeData = ref<any[]>([]);
|
|
|
|
|
|
-// 转换菜单数据为树形组件需要的格式
|
|
|
+// 递归设置节点及其子级的 disabled,并打标供 updateNodeDisabledState 保留
|
|
|
+const setStoreDecorateDisabledRecursive = (nodes: any[]) => {
|
|
|
+ nodes.forEach((n: any) => {
|
|
|
+ n.disabled = true;
|
|
|
+ n.disableByStoreDecorate = true;
|
|
|
+ if (n.children?.length) setStoreDecorateDisabledRecursive(n.children);
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+// 转换菜单数据为树形组件需要的格式;一级为「门店装修」时禁用该节点及所有子级
|
|
|
const transformMenuData = (menuList: MenuItem[]): any[] => {
|
|
|
return menuList.map(menu => {
|
|
|
const node: any = {
|
|
|
@@ -136,6 +145,15 @@ const transformMenuData = (menuList: MenuItem[]): any[] => {
|
|
|
if (menu.children && menu.children.length > 0) {
|
|
|
node.children = transformMenuData(menu.children);
|
|
|
}
|
|
|
+ // 判断是否是门店装修
|
|
|
+ if (localGet("storeTickets") == 0) {
|
|
|
+ if (menu.menuName === "门店装修") {
|
|
|
+ node.disabled = true;
|
|
|
+ node.disableByStoreDecorate = true;
|
|
|
+ if (node.children?.length) setStoreDecorateDisabledRecursive(node.children);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return node;
|
|
|
});
|
|
|
};
|
|
|
@@ -396,13 +414,18 @@ const hasCheckedChildrenInData = (nodeData: any, checkedKeys: number[]): boolean
|
|
|
const updateNodeDisabledState = (treeData: any[], checkedKeys: number[]) => {
|
|
|
const updateNode = (nodes: any[]): void => {
|
|
|
nodes.forEach((node: any) => {
|
|
|
+ // 一级为「门店装修」及其子级:始终保持禁用,不参与后续逻辑
|
|
|
+ if (node.disableByStoreDecorate) {
|
|
|
+ node.disabled = true;
|
|
|
+ if (node.children?.length) updateNode(node.children);
|
|
|
+ return;
|
|
|
+ }
|
|
|
// 如果是叶子节点,不禁用
|
|
|
if (!node.children || node.children.length === 0) {
|
|
|
node.disabled = false;
|
|
|
} else {
|
|
|
// 如果节点有子节点被选中,则禁用该节点
|
|
|
node.disabled = hasCheckedChildrenInData(node, checkedKeys);
|
|
|
- // 递归更新子节点
|
|
|
if (node.children && node.children.length > 0) {
|
|
|
updateNode(node.children);
|
|
|
}
|