|
@@ -1272,6 +1272,9 @@ const onOkIot = () => {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
_iots.forEach((item)=>{item.checkable = false});
|
|
_iots.forEach((item)=>{item.checkable = false});
|
|
|
|
+ if(data.iotTree?.length){
|
|
|
|
+ _iots = simpleMergeTwoLevelTrees(data.iotTree,_iots);
|
|
|
|
+ }
|
|
data.iotTree = _iots;
|
|
data.iotTree = _iots;
|
|
if (!meta2d.store.data.iot) {
|
|
if (!meta2d.store.data.iot) {
|
|
meta2d.store.data.iot = {};
|
|
meta2d.store.data.iot = {};
|
|
@@ -1280,8 +1283,26 @@ const onOkIot = () => {
|
|
iotDialog.value.show = false;
|
|
iotDialog.value.show = false;
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+function simpleMergeTwoLevelTrees(tree1, tree2) {
|
|
|
|
+ const merged = [...tree1];
|
|
|
|
+ const idMap = new Map(tree1.map(node => [node.value, true]));
|
|
|
|
+
|
|
|
|
+ tree2.forEach(node => {
|
|
|
|
+ if (idMap.has(node.value)) {
|
|
|
|
+ // 覆盖相同ID的父节点
|
|
|
|
+ const index = merged.findIndex(n => n.value === node.value);
|
|
|
|
+ merged[index] = { ...merged[index], ...node };
|
|
|
|
+ } else {
|
|
|
|
+ // 添加新父节点
|
|
|
|
+ merged.push(node);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ return merged;
|
|
|
|
+}
|
|
|
|
+
|
|
const onShowIot = async () => {
|
|
const onShowIot = async () => {
|
|
// await getIotTree();
|
|
// await getIotTree();
|
|
|
|
+ checkedIots.value = [];
|
|
await getRootTree();
|
|
await getRootTree();
|
|
getCheckedIots();
|
|
getCheckedIots();
|
|
iotDialog.value.show = true;
|
|
iotDialog.value.show = true;
|
|
@@ -1415,7 +1436,7 @@ const getCheckedIots = ()=>{
|
|
meta2d.store.data?.iot?.tree.forEach((item)=>{
|
|
meta2d.store.data?.iot?.tree.forEach((item)=>{
|
|
arr.push(...item.children?.map((_item)=>_item.value));
|
|
arr.push(...item.children?.map((_item)=>_item.value));
|
|
});
|
|
});
|
|
- checkedIots.value = arr;
|
|
|
|
|
|
+ checkedIots.value = [...new Set([...checkedIots.value, ...arr])];
|
|
}
|
|
}
|
|
|
|
|
|
const iotSearch = ref('');
|
|
const iotSearch = ref('');
|