fix: 1. Warehouse default

This commit is contained in:
Javier Segarra 2024-04-29 13:22:23 +02:00
parent 5425902918
commit 7108444a44
1 changed files with 34 additions and 5 deletions

View File

@ -5,7 +5,8 @@ import { useI18n } from 'vue-i18n';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue'; import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
const DEFAULT_WAREHOUSE = 'Algemesi';
const { t } = useI18n(); const { t } = useI18n();
const props = defineProps({ const props = defineProps({
dataKey: { dataKey: {
@ -17,12 +18,25 @@ const props = defineProps({
const to = Date.vnNew(); const to = Date.vnNew();
to.setDate(to.getDate() + 1); to.setDate(to.getDate() + 1);
const defaultParams = {
warehouse: null,
};
const warehouses = ref(); const warehouses = ref();
const handleWarehouses = async (data) => {
warehouses.value = data;
defaultParams.warehouse = data.find((w) => w.name === DEFAULT_WAREHOUSE).id;
};
</script> </script>
<template> <template>
<FetchData url="Warehouses" @on-fetch="(data) => (warehouses = data)" auto-load /> <FetchData url="Warehouses" @on-fetch="handleWarehouses" auto-load />
<VnFilterPanel :data-key="props.dataKey" :search-button="true"> <VnFilterPanel
:data-key="props.dataKey"
:params="defaultParams"
:search-button="true"
>
<template #tags="{ tag, formatFn }"> <template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs"> <div class="q-gutter-x-xs">
<strong>{{ t(`ticket.negative.${tag.label}`) }}: </strong> <strong>{{ t(`ticket.negative.${tag.label}`) }}: </strong>
@ -33,7 +47,12 @@ const warehouses = ref();
<QList dense class="q-gutter-y-sm q-mt-sm"> <QList dense class="q-gutter-y-sm q-mt-sm">
<QItem> <QItem>
<QItemSection> <QItemSection>
<VnInput v-model="params.id" :label="t('negative.id')" dense /> <VnInput
v-model="params.id"
:label="t('negative.id')"
dense
is-outlined
/>
</QItemSection> </QItemSection>
</QItem> </QItem>
<QItem> <QItem>
@ -42,6 +61,7 @@ const warehouses = ref();
v-model="params.producer" v-model="params.producer"
:label="t('negative.producer')" :label="t('negative.producer')"
dense dense
is-outlined
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>
@ -51,6 +71,7 @@ const warehouses = ref();
v-model="params.colour" v-model="params.colour"
:label="t('negative.colour')" :label="t('negative.colour')"
dense dense
is-outlined
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>
@ -60,6 +81,7 @@ const warehouses = ref();
v-model="params.size" v-model="params.size"
:label="t('negative.size')" :label="t('negative.size')"
dense dense
is-outlined
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>
@ -69,6 +91,7 @@ const warehouses = ref();
v-model="params.origen" v-model="params.origen"
:label="t('negative.origen')" :label="t('negative.origen')"
dense dense
is-outlined
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>
@ -78,12 +101,13 @@ const warehouses = ref();
v-model="params.lack" v-model="params.lack"
:label="t('negative.value')" :label="t('negative.value')"
dense dense
is-outlined
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>
<QItem v-if="warehouses"> <QItem v-if="warehouses">
<QItemSection> <QItemSection>
<QSelect <VnSelect
:label="t('Warehouse')" :label="t('Warehouse')"
v-model="params.warehouse" v-model="params.warehouse"
@update:model-value="searchFn()" @update:model-value="searchFn()"
@ -92,7 +116,12 @@ const warehouses = ref();
option-label="name" option-label="name"
emit-value emit-value
map-options map-options
use-input
hide-selected
dense dense
outlined
rounded
:input-debounce="0"
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>