|
@@ -194,10 +194,41 @@ const getDatas = async () => {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
const ret = await axios.get(modelValue.url);
|
|
const ret = await axios.get(modelValue.url);
|
|
- if (ret) {
|
|
|
|
- modelValue.devices = ret;
|
|
|
|
|
|
+ let flattenRet = flattenTree(ret);
|
|
|
|
+ if (flattenRet) {
|
|
|
|
+ modelValue.devices = flattenRet;
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
+//展开树
|
|
|
|
+const flattenTree = (root) =>{
|
|
|
|
+ if (!root) return []; // 空树返回空数组
|
|
|
|
+
|
|
|
|
+ const result = []; // 存储展开后的数组
|
|
|
|
+
|
|
|
|
+ // 递归遍历树
|
|
|
|
+ function dfs(node) {
|
|
|
|
+ result.push({
|
|
|
|
+ id: node.id,
|
|
|
|
+ label: node.label||node.name,
|
|
|
|
+ device: node.device||node.id,
|
|
|
|
+ type: node.type,
|
|
|
|
+ mock: node.mock,
|
|
|
|
+ // children: node.children,
|
|
|
|
+ }); // 将当前节点值添加到结果数组
|
|
|
|
+ // 遍历当前节点的子节点
|
|
|
|
+ if(node.children){
|
|
|
|
+ for (let child of node.children) {
|
|
|
|
+ dfs(child); // 递归调用DFS
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ root.forEach((item) => {
|
|
|
|
+ dfs(item);
|
|
|
|
+ });
|
|
|
|
+ // dfs(root); // 从根节点开始遍历
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+}
|
|
|
|
|
|
const importDataset = async () => {
|
|
const importDataset = async () => {
|
|
let columns: any = [
|
|
let columns: any = [
|