fix: refs #6900 improve logic

This commit is contained in:
Jorge Penadés 2024-08-14 14:27:54 +02:00
parent de24a3efdb
commit 6dd9029871
1 changed files with 15 additions and 10 deletions

View File

@ -1,11 +1,11 @@
<script setup>
import { ref, computed, onBeforeMount } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import axios from 'axios';
import VnTable from 'src/components/VnTable/VnTable.vue';
import RightMenu from 'src/components/common/RightMenu.vue';
import InvoiceInSerialFilter from './InvoiceInSerialFilter.vue';
import { useArrayData } from 'src/composables/useArrayData';
const { t } = useI18n();
@ -30,15 +30,18 @@ const cols = computed(() => [
},
]);
const arrayData = useArrayData('InvoiceInSerial');
const table = ref();
onBeforeMount(async () => {
const { data } = await axios.get('InvoiceInConfigs/findOne', {
params: { filter: { fields: ['daysAgo'] } },
});
const daysAgo = ref(0);
arrayData.store.userParams.daysAgo = data.daysAgo;
await table.value.reload();
onBeforeMount(async () => {
const tableParam = useRoute().query.table;
if (tableParam) daysAgo.value = JSON.parse(tableParam).daysAgo;
else
daysAgo.value = (
await axios.get('InvoiceInConfigs/findOne', {
params: { filter: { fields: ['daysAgo'] } },
})
).data?.daysAgo;
});
</script>
<template>
@ -48,12 +51,14 @@ onBeforeMount(async () => {
</template>
</RightMenu>
<VnTable
ref="table"
v-if="daysAgo"
data-key="InvoiceInSerial"
url="InvoiceIns/getSerial"
:columns="cols"
:right-search="false"
:user-params="{ daysAgo }"
:disable-option="{ card: true }"
auto-load
/>
</template>
<i18n>