Merge branch 'master' into hotfix_termograph_filter
gitea/salix-front/pipeline/pr-master This commit looks good Details

This commit is contained in:
Javier Segarra 2024-11-14 14:56:30 +00:00
commit e6ba0c7c30
2 changed files with 17 additions and 13 deletions

View File

@ -23,7 +23,7 @@ function notIsLocations(ifIsFalse, ifIsTrue) {
:base-url="notIsLocations('Zones', undefined)" :base-url="notIsLocations('Zones', undefined)"
:descriptor="ZoneDescriptor" :descriptor="ZoneDescriptor"
:filter-panel="notIsLocations(ZoneFilterPanel, undefined)" :filter-panel="notIsLocations(ZoneFilterPanel, undefined)"
:search-data-key="notIsLocations('ZoneList', 'ZoneLocations')" :search-data-key="notIsLocations('ZoneList', undefined)"
:custom-url="`Zones/${route.params?.id}/getLeaves`" :custom-url="`Zones/${route.params?.id}/getLeaves`"
:searchbar-props="{ :searchbar-props="{
url: notIsLocations('Zones', 'ZoneLocations'), url: notIsLocations('Zones', 'ZoneLocations'),

View File

@ -5,6 +5,7 @@ import VnInput from 'src/components/common/VnInput.vue';
import { useState } from 'src/composables/useState'; import { useState } from 'src/composables/useState';
import axios from 'axios'; import axios from 'axios';
import { useArrayData } from 'composables/useArrayData'; import { useArrayData } from 'composables/useArrayData';
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
const props = defineProps({ const props = defineProps({
rootLabel: { rootLabel: {
@ -33,22 +34,23 @@ const state = useState();
const treeRef = ref(); const treeRef = ref();
const expanded = ref([]); const expanded = ref([]);
const arrayData = useArrayData('ZoneLocations', { const datakey = 'ZoneLocations';
url: `Zones/${route.params.id}/getLeaves`, const url = computed(() => `Zones/${route.params.id}/getLeaves`);
const arrayData = useArrayData(datakey, {
url: url.value,
}); });
const { store } = arrayData; const { store } = arrayData;
const storeData = computed(() => store.data); const storeData = computed(() => store.data);
const nodes = ref([ const defaultNode = {
{
id: null, id: null,
name: props.rootLabel, name: props.rootLabel,
sons: true, sons: true,
tickable: false, tickable: false,
noTick: true, noTick: true,
children: [{}], children: [{}],
}, };
]); const nodes = ref([defaultNode]);
const _tickedNodes = computed({ const _tickedNodes = computed({
get: () => props.tickedNodes, get: () => props.tickedNodes,
@ -128,6 +130,7 @@ function getNodeIds(node) {
watch(storeData, async (val) => { watch(storeData, async (val) => {
// 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
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]);
@ -193,6 +196,7 @@ onUnmounted(() => {
<QBtn color="primary" icon="search" dense flat @click="reFetch()" /> <QBtn color="primary" icon="search" dense flat @click="reFetch()" />
</template> </template>
</VnInput> </VnInput>
<VnSearchbar :data-key="datakey" :url="url" :redirect="false" />
<QTree <QTree
ref="treeRef" ref="treeRef"
:nodes="nodes" :nodes="nodes"