fix: fixed node fetching and adapted to back data
gitea/salix-front/pipeline/pr-master This commit is unstable
Details
gitea/salix-front/pipeline/pr-master This commit is unstable
Details
This commit is contained in:
parent
d1b92d0f26
commit
b9e5ed7346
|
@ -72,6 +72,7 @@ const onNodeExpanded = async (nodeKeysArray) => {
|
|||
const response = await axios.get(`Zones/${route.params.id}/getLeaves`, {
|
||||
params,
|
||||
});
|
||||
response.data = JSON.parse(response.data);
|
||||
if (response.data) {
|
||||
node.childs = response.data.map((n) => {
|
||||
if (n.sons > 0) n.childs = [{}];
|
||||
|
@ -125,14 +126,17 @@ watch(
|
|||
async (val) => {
|
||||
if (!val) return;
|
||||
// // Se triggerea cuando se actualiza el store.data, el cual es el resultado del fetch de la searchbar
|
||||
val = JSON.parse(val);
|
||||
if (!nodes.value[0]) nodes.value = [defaultNode];
|
||||
nodes.value[0].childs = [...val];
|
||||
const fetchedNodeKeys = val.flatMap(getNodeIds);
|
||||
state.set('Tree', [...fetchedNodeKeys]);
|
||||
expanded.value = [null, ...fetchedNodeKeys];
|
||||
const fetchs = [];
|
||||
for (let n of state.get('Tree')) {
|
||||
await fetchNodeLeaves(n);
|
||||
fetchs.push(fetchNodeLeaves(n));
|
||||
}
|
||||
await Promise.all(fetchs);
|
||||
previousExpandedNodes.value = new Set(expanded.value);
|
||||
},
|
||||
{ immediate: true }
|
||||
|
|
Loading…
Reference in New Issue