|
@@ -78,11 +78,46 @@ const treeKeys = reactive({
|
|
|
label: 'ChartClassifyName',
|
|
|
});
|
|
|
|
|
|
+const filterNodes = (arr) => {
|
|
|
+ arr.length && arr.forEach((item) => {
|
|
|
+ console.log(item);
|
|
|
+ props.allCheckedList.includes(item.ChartClassifyId) && (item.expanded = true);
|
|
|
+ item.Children&&item.Children.length && containsAnyValue(item.Children, props.allCheckedList) && (item.expanded = true);
|
|
|
+ item.Children&&item.Children.length && filterNodes(item.Children);
|
|
|
+ });
|
|
|
+ return arr;
|
|
|
+}
|
|
|
+
|
|
|
+const containsAnyValue = (multiDimArray, targetArray) => {
|
|
|
+ // 辅助函数,用于递归遍历数组
|
|
|
+ function recursiveCheck(subArray) {
|
|
|
+ for (let item of subArray) {
|
|
|
+ if (Array.isArray(item)) {
|
|
|
+ // 如果当前元素是数组,递归检查
|
|
|
+ if (recursiveCheck(item)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 检查当前元素是否在目标数组中
|
|
|
+ if (targetArray.includes(item.ChartClassifyId)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 如果没有找到任何匹配的值,返回false
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ // 从外层数组开始递归检查
|
|
|
+ return recursiveCheck(multiDimArray);
|
|
|
+}
|
|
|
+
|
|
|
// 监听renewalForm的变化
|
|
|
watch(
|
|
|
() => props.PermissionList,
|
|
|
(newValue) => {
|
|
|
- treeList.value = newValue;
|
|
|
+ console.log('newValue', newValue);
|
|
|
+ treeList.value = newValue.length !== 0 ? filterNodes(newValue) : [];
|
|
|
+
|
|
|
if (!props.isSearch) { // 如果不是搜索,则直接把后端返回的赋值为选中项
|
|
|
allChecked.value = props.allCheckedList;
|
|
|
actuallyAllChecked.value = props.allCheckedList;
|
|
@@ -92,6 +127,10 @@ watch(
|
|
|
},
|
|
|
{ immediate: true }
|
|
|
);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
watch(
|
|
|
() => props.currentStep,
|
|
|
(newValue) => {
|
|
@@ -114,7 +153,10 @@ watch(
|
|
|
|
|
|
// tree相关
|
|
|
const onChange = (checked, context) => {
|
|
|
- console.info('context:', tree.value.setItem());
|
|
|
+ // console.info('context:', );
|
|
|
+ // tree.value.setItem('12', {
|
|
|
+ // expanded: true,
|
|
|
+ // })
|
|
|
const { node } = context;
|
|
|
if (node.checked) {
|
|
|
if (node.data.Children.length) { // 如果当前节点有子节点,则把所有子节点的id都加上去
|