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`, {
|
const response = await axios.get(`Zones/${route.params.id}/getLeaves`, {
|
||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
|
response.data = JSON.parse(response.data);
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
node.childs = response.data.map((n) => {
|
node.childs = response.data.map((n) => {
|
||||||
if (n.sons > 0) n.childs = [{}];
|
if (n.sons > 0) n.childs = [{}];
|
||||||
|
@ -125,14 +126,17 @@ watch(
|
||||||
async (val) => {
|
async (val) => {
|
||||||
if (!val) return;
|
if (!val) return;
|
||||||
// // Se triggerea cuando se actualiza el store.data, el cual es el resultado del fetch de la searchbar
|
// // 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];
|
if (!nodes.value[0]) nodes.value = [defaultNode];
|
||||||
nodes.value[0].childs = [...val];
|
nodes.value[0].childs = [...val];
|
||||||
const fetchedNodeKeys = val.flatMap(getNodeIds);
|
const fetchedNodeKeys = val.flatMap(getNodeIds);
|
||||||
state.set('Tree', [...fetchedNodeKeys]);
|
state.set('Tree', [...fetchedNodeKeys]);
|
||||||
expanded.value = [null, ...fetchedNodeKeys];
|
expanded.value = [null, ...fetchedNodeKeys];
|
||||||
|
const fetchs = [];
|
||||||
for (let n of state.get('Tree')) {
|
for (let n of state.get('Tree')) {
|
||||||
await fetchNodeLeaves(n);
|
fetchs.push(fetchNodeLeaves(n));
|
||||||
}
|
}
|
||||||
|
await Promise.all(fetchs);
|
||||||
previousExpandedNodes.value = new Set(expanded.value);
|
previousExpandedNodes.value = new Set(expanded.value);
|
||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
|
|
Loading…
Reference in New Issue