Commit 332717ba by 张晓玮

Merge branch 'feature/584/zxw' into 'SAAS+V5.8.4'

选择三级类目禁用规则修改

See merge request !875
2 parents aa9b5246 774ec1ed
......@@ -259,6 +259,28 @@ export default {
});
return list;
},
// 其他Tab已选节点所在的完整路径(用于判断父级是否需要禁用)
otherTabSelectedPathsWithLevel() {
return this.disabledGoodsTypeList.map((item) => {
let targetValue = null;
let level = 1; // 1: 一级, 2: 二级, 3: 三级
if (item.thirdLevelGoodsType) {
targetValue = item.thirdLevelGoodsType;
level = 3;
} else if (item.secondaryGoodsType) {
targetValue = item.secondaryGoodsType;
level = 2;
} else {
targetValue = item.goodsType;
level = 1;
}
if (targetValue) {
const path = this.findCompletePathByTargetValue(this.goodsList, targetValue);
return { path, level };
}
return null;
}).filter(Boolean);
},
// 带有 disabled 状态的树形数据(实时计算,确保响应式更新)
computedGoodsTypeTreeList() {
// 重新计算整个树,确保disabled状态实时更新
......@@ -272,6 +294,7 @@ export default {
// 收集当前Tab和其他Tab的选中路径
const currentPaths = this.currentTabSelectedPaths || [];
const otherPaths = this.otherTabSelectedPaths || [];
const otherPathsWithLevel = this.otherTabSelectedPathsWithLevel || [];
// 构建需要禁用的节点值集合
const shouldDisableValues = new Set();
......@@ -298,20 +321,14 @@ export default {
});
// 2. 处理其他Tab已选路径(跨Tab禁用规则)
otherPaths.forEach((path) => {
// 规则:只禁用节点本身(防止重复),父级、子级、兄弟级都可以选
otherPathsWithLevel.forEach(({ path, level }) => {
if (!path || !path.length) {
return;
}
// 其他Tab选中的节点本身也要禁用
path.forEach((value) => {
shouldDisableValues.add(value);
});
// 禁用该路径的所有祖先
for (let i = 0; i < path.length - 1; i++) {
shouldDisableValues.add(path[i]);
}
// 禁用该路径的所有后代
this.collectAllDescendantsByPath(tree, path, shouldDisableValues);
// 只禁用节点本身(防止重复选择)
shouldDisableValues.add(path[path.length - 1]);
});
// 设置disabled状态(排除当前Tab可取消勾选的节点)
......
......@@ -981,7 +981,6 @@ export default {
cascaderProps: {
multiple: true,
checkStrictly: true,
expandTrigger: "hover",
label: "categoryName",
value: "categoryType",
disabled: "disabled", // 显式配置 disabled 属性映射
......@@ -1167,6 +1166,28 @@ export default {
});
return list;
},
// 其他Tab已选节点所在的完整路径(用于判断父级是否需要禁用)
otherTabSelectedPathsWithLevel() {
return this.disabledGoodsTypeList.map((item) => {
let targetValue = null;
let level = 1; // 1: 一级, 2: 二级, 3: 三级
if (item.thirdLevelGoodsType) {
targetValue = item.thirdLevelGoodsType;
level = 3;
} else if (item.secondaryGoodsType) {
targetValue = item.secondaryGoodsType;
level = 2;
} else {
targetValue = item.goodsType;
level = 1;
}
if (targetValue) {
const path = this.findCompletePathByTargetValue(this.goodsList, targetValue);
return { path, level };
}
return null;
}).filter(Boolean);
},
// 带有 disabled 状态的树形数据(实时计算,确保响应式更新)
computedGoodsTypeTreeList() {
// 重新计算整个树,确保disabled状态实时更新
......@@ -1180,6 +1201,7 @@ export default {
// 收集当前Tab和其他Tab的选中路径
const currentPaths = this.currentTabSelectedPaths || [];
const otherPaths = this.otherTabSelectedPaths || [];
const otherPathsWithLevel = this.otherTabSelectedPathsWithLevel || [];
// 构建需要禁用的节点值集合
const shouldDisableValues = new Set();
......@@ -1206,20 +1228,14 @@ export default {
});
// 2. 处理其他Tab已选路径(跨Tab禁用规则)
otherPaths.forEach((path) => {
// 规则:只禁用节点本身(防止重复),父级、子级、兄弟级都可以选
otherPathsWithLevel.forEach(({ path, level }) => {
if (!path || !path.length) {
return;
}
// 其他Tab选中的节点本身也要禁用
path.forEach((value) => {
shouldDisableValues.add(value);
});
// 禁用该路径的所有祖先
for (let i = 0; i < path.length - 1; i++) {
shouldDisableValues.add(path[i]);
}
// 禁用该路径的所有后代
this.collectAllDescendantsByPath(tree, path, shouldDisableValues);
// 只禁用节点本身(防止重复选择)
shouldDisableValues.add(path[path.length - 1]);
});
// 设置disabled状态(排除当前Tab可取消勾选的节点)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!