0
0
Fork 0
This commit is contained in:
Carlos Satorres 2024-01-31 12:52:50 +01:00
parent f715c615d2
commit 78877556cf
1 changed files with 17 additions and 3 deletions

View File

@ -1,7 +1,8 @@
<script setup> <script setup>
import { ref } from 'vue'; import { ref,computed, } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { useState } from 'src/composables/useState';
import { useQuasar } from 'quasar'; import { useQuasar } from 'quasar';
import CreateDepartmentChild from '../CreateDepartmentChild.vue'; import CreateDepartmentChild from '../CreateDepartmentChild.vue';
@ -13,6 +14,7 @@ const quasar = useQuasar();
const { t } = useI18n(); const { t } = useI18n();
const router = useRouter(); const router = useRouter();
const { notify } = useNotify(); const { notify } = useNotify();
const state = useState();
const treeRef = ref(null); const treeRef = ref(null);
const showCreateNodeFormVal = ref(false); const showCreateNodeFormVal = ref(false);
@ -22,6 +24,7 @@ const expanded = ref([]);
const nodes = ref([{ id: null, name: t('Departments'), sons: true, children: [{}] }]); const nodes = ref([{ id: null, name: t('Departments'), sons: true, children: [{}] }]);
const fetchedChildrensSet = ref(new Set()); const fetchedChildrensSet = ref(new Set());
const formData = computed(() => state.get('Tree'));
const onNodeExpanded = (nodeKeysArray) => { const onNodeExpanded = (nodeKeysArray) => {
// Verificar si el nodo ya fue expandido // Verificar si el nodo ya fue expandido
@ -29,6 +32,7 @@ const onNodeExpanded = (nodeKeysArray) => {
fetchedChildrensSet.value.add(nodeKeysArray.at(-1)); fetchedChildrensSet.value.add(nodeKeysArray.at(-1));
fetchNodeLeaves(nodeKeysArray.at(-1)); // Llamar a la función para obtener los nodos hijos fetchNodeLeaves(nodeKeysArray.at(-1)); // Llamar a la función para obtener los nodos hijos
} }
state.set('Tree', nodeKeysArray.at(-1));
}; };
const fetchNodeLeaves = async (nodeKey) => { const fetchNodeLeaves = async (nodeKey) => {
@ -105,9 +109,12 @@ const redirectToDepartmentSummary = (id) => {
class="row justify-between full-width q-pr-md cursor-pointer" class="row justify-between full-width q-pr-md cursor-pointer"
@click.stop="redirectToDepartmentSummary(node.id)" @click.stop="redirectToDepartmentSummary(node.id)"
> >
<span class="text-uppercase"> <a
:href="`#/department/department/${node.id}/summary`"
color: inherit
>
{{ node.name }} {{ node.name }}
</span> </a>
<div class="row justify-between" style="max-width: max-content"> <div class="row justify-between" style="max-width: max-content">
<QIcon <QIcon
v-if="node.id" v-if="node.id"
@ -149,6 +156,12 @@ const redirectToDepartmentSummary = (id) => {
</QCard> </QCard>
</template> </template>
<style lang="scss" scoped>
a {
color: inherit;
text-decoration: none;
}
</style>
<i18n> <i18n>
es: es:
Departments: Departamentos Departments: Departamentos
@ -157,3 +170,4 @@ const redirectToDepartmentSummary = (id) => {
Are you sure you want to delete it?: ¿Seguro que quieres eliminarlo? Are you sure you want to delete it?: ¿Seguro que quieres eliminarlo?
Delete department: Eliminar departamento Delete department: Eliminar departamento
</i18n> </i18n>