|
@@ -717,7 +717,7 @@ export default {
|
|
|
selectedMenuIds: [],
|
|
|
menuExpand: false,
|
|
|
menuNodeAll: false,
|
|
|
- menuCheckStrictly: true,
|
|
|
+ menuCheckStrictly: false, // 默认不联动
|
|
|
};
|
|
|
},
|
|
|
|
|
@@ -968,11 +968,6 @@ export default {
|
|
|
this.parentMenu = response.data;
|
|
|
});
|
|
|
},
|
|
|
- popoverHide(checkedIds, checkedData) {
|
|
|
- this.selectedMenuIds = checkedIds;
|
|
|
- this.defaultCheckedKeys = checkedIds;
|
|
|
- this.UpdateDataRelationParam.values = checkedIds;
|
|
|
- },
|
|
|
|
|
|
handleMenu(row) {
|
|
|
// 重置复选框状态
|
|
@@ -991,20 +986,30 @@ export default {
|
|
|
for (const key in nodes) {
|
|
|
nodes[key].expanded = false;
|
|
|
}
|
|
|
- // 重置选中状态和父子联动
|
|
|
+
|
|
|
+ // 设置初始状态
|
|
|
this.$refs.menuTree.store.defaultExpandAll = false;
|
|
|
this.$refs.menuTree.store.checkStrictly = !this.menuCheckStrictly;
|
|
|
+
|
|
|
+ // 如果有初始选中的菜单ID,设置选中状态
|
|
|
+ if (row.menuIds && row.menuIds !== "") {
|
|
|
+ const menuArr = row.menuIds.split(",").map((id) => Number(id));
|
|
|
+ this.selectedMenuIds = menuArr;
|
|
|
+ this.defaultCheckedKeys = menuArr;
|
|
|
+ this.UpdateDataRelationParam.values = menuArr;
|
|
|
+ // 确保在设置选中状态前已经切换到正确的联动模式
|
|
|
+ this.$refs.menuTree.setCheckedKeys(menuArr);
|
|
|
+ } else {
|
|
|
+ // 如果没有初始选中的菜单,清空选中状态
|
|
|
+ this.selectedMenuIds = [];
|
|
|
+ this.defaultCheckedKeys = [];
|
|
|
+ this.UpdateDataRelationParam.values = [];
|
|
|
+ this.$refs.menuTree.setCheckedKeys([]);
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
|
|
|
this.dataform.id = row.id;
|
|
|
- if (row.menuIds && row.menuIds !== "") {
|
|
|
- const menuArr = row.menuIds.split(",").map((id) => Number(id));
|
|
|
- this.selectedMenuIds = menuArr;
|
|
|
- this.defaultCheckedKeys = menuArr;
|
|
|
- this.UpdateDataRelationParam.values = menuArr;
|
|
|
- }
|
|
|
-
|
|
|
this.dialogMenuVisible = true;
|
|
|
},
|
|
|
close_update_menu_dialog() {
|
|
@@ -1943,6 +1948,7 @@ export default {
|
|
|
this.$refs.menuTree.setCheckedKeys([]);
|
|
|
this.selectedMenuIds = [];
|
|
|
}
|
|
|
+ // 更新相关数据
|
|
|
this.defaultCheckedKeys = this.selectedMenuIds;
|
|
|
this.UpdateDataRelationParam.values = this.selectedMenuIds;
|
|
|
}
|
|
@@ -1950,7 +1956,32 @@ export default {
|
|
|
handleCheckedTreeConnect(value) {
|
|
|
// 处理父子联动
|
|
|
if (this.$refs.menuTree) {
|
|
|
+ // 先获取当前选中的节点
|
|
|
+ const checkedKeys = this.$refs.menuTree.getCheckedKeys();
|
|
|
+ const halfCheckedKeys = this.$refs.menuTree.getHalfCheckedKeys();
|
|
|
+
|
|
|
+ // 更新父子联动状态
|
|
|
+ this.menuCheckStrictly = value;
|
|
|
this.$refs.menuTree.checkStrictly = !value;
|
|
|
+
|
|
|
+ // 重新设置选中状态
|
|
|
+ this.$nextTick(() => {
|
|
|
+ if (value) {
|
|
|
+ // 父子联动模式,合并完全选中和半选中的节点
|
|
|
+ const allCheckedKeys = [
|
|
|
+ ...new Set([...checkedKeys, ...halfCheckedKeys]),
|
|
|
+ ];
|
|
|
+ this.$refs.menuTree.setCheckedKeys(allCheckedKeys);
|
|
|
+ this.selectedMenuIds = allCheckedKeys;
|
|
|
+ } else {
|
|
|
+ // 严格模式,只保留完全选中的节点
|
|
|
+ this.$refs.menuTree.setCheckedKeys(checkedKeys);
|
|
|
+ this.selectedMenuIds = checkedKeys;
|
|
|
+ }
|
|
|
+ // 更新相关数据
|
|
|
+ this.defaultCheckedKeys = this.selectedMenuIds;
|
|
|
+ this.UpdateDataRelationParam.values = this.selectedMenuIds;
|
|
|
+ });
|
|
|
}
|
|
|
},
|
|
|
getAllMenuIds(menus) {
|
|
@@ -1964,15 +1995,26 @@ export default {
|
|
|
});
|
|
|
return ids;
|
|
|
},
|
|
|
- handleTreeCheck(data, checked) {
|
|
|
- // 获取当前选中的节点和半选中的节点
|
|
|
- const checkedNodes = this.$refs.menuTree.getCheckedNodes();
|
|
|
- const halfCheckedNodes = this.$refs.menuTree.getHalfCheckedNodes();
|
|
|
+ handleTreeCheck(data, checked, indeterminate) {
|
|
|
+ // 获取当前所有选中的节点
|
|
|
+ const checkedKeys = this.$refs.menuTree.getCheckedKeys();
|
|
|
+ const halfCheckedKeys = this.$refs.menuTree.getHalfCheckedKeys();
|
|
|
+ console.log("当前选中的节点:", checkedKeys, halfCheckedKeys);
|
|
|
+ // 更新选中状态
|
|
|
+ if (!this.menuCheckStrictly) {
|
|
|
+ // 父子联动模式:包含全选和半选节点
|
|
|
+ this.selectedMenuIds = [
|
|
|
+ ...new Set([...checkedKeys, ...halfCheckedKeys]),
|
|
|
+ ];
|
|
|
+ } else {
|
|
|
+ // 严格模式:只包含全选节点
|
|
|
+ this.selectedMenuIds = [...checkedKeys];
|
|
|
+ }
|
|
|
|
|
|
- // 合并所有选中的节点ID
|
|
|
- this.selectedMenuIds = [...checkedNodes, ...halfCheckedNodes].map(
|
|
|
- (node) => node.id
|
|
|
- );
|
|
|
+ console.log("当前选中的节点:", this.selectedMenuIds);
|
|
|
+
|
|
|
+ // 更新相关数据
|
|
|
+ this.defaultCheckedKeys = this.selectedMenuIds;
|
|
|
this.UpdateDataRelationParam.values = this.selectedMenuIds;
|
|
|
},
|
|
|
},
|