0
0
Fork 0

Merge pull request 'Create ticket future filter' (!638) from hyervoni/salix-front-mindshore:feature/TicketFutureFilter into dev

Reviewed-on: verdnatura/salix-front#638
Reviewed-by: Javier Segarra <jsegarra@verdnatura.es>
This commit is contained in:
Javier Segarra 2024-08-23 11:28:46 +00:00
commit 6358fdb320
7 changed files with 271 additions and 12 deletions

View File

@ -202,7 +202,7 @@ function formatValue(value) {
function sanitizer(params) { function sanitizer(params) {
for (const [key, value] of Object.entries(params)) { for (const [key, value] of Object.entries(params)) {
if (typeof value == 'object') { if (value && typeof value === 'object') {
const param = Object.values(value)[0]; const param = Object.values(value)[0];
if (typeof param == 'string') params[key] = param.replaceAll('%', ''); if (typeof param == 'string') params[key] = param.replaceAll('%', '');
} }

View File

@ -448,7 +448,7 @@ const handleCloseProgressDialog = () => {
const handleCancelProgress = () => (cancelProgress.value = true); const handleCancelProgress = () => (cancelProgress.value = true);
onMounted(async () => { onMounted(async () => {
let today = Date.vnNew(); let today = Date.vnNew().toISOString();
const tomorrow = new Date(today); const tomorrow = new Date(today);
tomorrow.setDate(tomorrow.getDate() + 1); tomorrow.setDate(tomorrow.getDate() + 1);
userParams.dateFuture = tomorrow; userParams.dateFuture = tomorrow;

View File

@ -55,7 +55,7 @@ onMounted(async () => await getItemPackingTypes());
:data-key="props.dataKey" :data-key="props.dataKey"
:search-button="true" :search-button="true"
:hidden-tags="['search']" :hidden-tags="['search']"
:unremovable-params="['warehouseFk', 'dateFuture', 'dateToAdvance']" :un-removable-params="['warehouseFk', 'dateFuture', 'dateToAdvance']"
> >
<template #tags="{ tag, formatFn }"> <template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs"> <div class="q-gutter-x-xs">
@ -70,7 +70,6 @@ onMounted(async () => await getItemPackingTypes());
v-model="params.dateFuture" v-model="params.dateFuture"
:label="t('params.dateFuture')" :label="t('params.dateFuture')"
is-outlined is-outlined
@update:model-value="searchFn()"
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>
@ -80,7 +79,6 @@ onMounted(async () => await getItemPackingTypes());
v-model="params.dateToAdvance" v-model="params.dateToAdvance"
:label="t('params.dateToAdvance')" :label="t('params.dateToAdvance')"
is-outlined is-outlined
@update:model-value="searchFn()"
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>

View File

@ -8,6 +8,8 @@ import VnSelect from 'src/components/common/VnSelect.vue';
import TicketDescriptorProxy from 'src/pages/Ticket/Card/TicketDescriptorProxy.vue'; import TicketDescriptorProxy from 'src/pages/Ticket/Card/TicketDescriptorProxy.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import VnSearchbar from 'src/components/ui/VnSearchbar.vue'; import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
import RightMenu from 'src/components/common/RightMenu.vue';
import TicketFutureFilter from './TicketFutureFilter.vue';
import { dashIfEmpty, toCurrency } from 'src/filters'; import { dashIfEmpty, toCurrency } from 'src/filters';
import { useVnConfirm } from 'composables/useVnConfirm'; import { useVnConfirm } from 'composables/useVnConfirm';
@ -37,9 +39,9 @@ const exprBuilder = (param, value) => {
return { liters: value }; return { liters: value };
case 'lines': case 'lines':
return { lines: value }; return { lines: value };
case 'ipt': case 'iptColFilter':
return { ipt: { like: `%${value}%` } }; return { ipt: { like: `%${value}%` } };
case 'futureIpt': case 'futureIptColFilter':
return { futureIpt: { like: `%${value}%` } }; return { futureIpt: { like: `%${value}%` } };
case 'totalWithVat': case 'totalWithVat':
return { totalWithVat: value }; return { totalWithVat: value };
@ -47,8 +49,8 @@ const exprBuilder = (param, value) => {
}; };
const userParams = reactive({ const userParams = reactive({
futureDated: Date.vnNew(), futureDated: Date.vnNew().toISOString(),
originDated: Date.vnNew(), originDated: Date.vnNew().toISOString(),
warehouseFk: user.value.warehouseFk, warehouseFk: user.value.warehouseFk,
}); });
@ -83,6 +85,8 @@ const getInputEvents = (col) => {
}; };
}; };
const tickets = computed(() => store.data);
const ticketColumns = computed(() => [ const ticketColumns = computed(() => [
{ {
label: t('futureTickets.problems'), label: t('futureTickets.problems'),
@ -121,7 +125,7 @@ const ticketColumns = computed(() => [
sortable: true, sortable: true,
columnFilter: { columnFilter: {
component: VnSelect, component: VnSelect,
filterParamKey: 'ipt', filterParamKey: 'iptColFilter',
type: 'select', type: 'select',
filterValue: null, filterValue: null,
event: getInputEvents, event: getInputEvents,
@ -214,7 +218,7 @@ const ticketColumns = computed(() => [
sortable: true, sortable: true,
columnFilter: { columnFilter: {
component: VnSelect, component: VnSelect,
filterParamKey: 'futureIpt', filterParamKey: 'futureIptColFilter',
type: 'select', type: 'select',
filterValue: null, filterValue: null,
event: getInputEvents, event: getInputEvents,
@ -305,9 +309,14 @@ onMounted(async () => {
</QBtn> </QBtn>
</template> </template>
</VnSubToolbar> </VnSubToolbar>
<RightMenu>
<template #right-panel>
<TicketFutureFilter data-key="FutureTickets" />
</template>
</RightMenu>
<QPage class="column items-center q-pa-md"> <QPage class="column items-center q-pa-md">
<QTable <QTable
:rows="store.data" :rows="tickets"
:columns="ticketColumns" :columns="ticketColumns"
row-key="id" row-key="id"
selection="multiple" selection="multiple"

View File

@ -0,0 +1,242 @@
<script setup>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import FetchData from 'components/FetchData.vue';
import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
import VnSelect from 'components/common/VnSelect.vue';
import VnInputDate from 'src/components/common/VnInputDate.vue';
import VnInput from 'src/components/common/VnInput.vue';
import axios from 'axios';
import { onMounted } from 'vue';
const { t } = useI18n();
const props = defineProps({
dataKey: {
type: String,
required: true,
},
});
const warehousesOptions = ref([]);
const itemPackingTypes = ref([]);
const stateOptions = ref([]);
const getItemPackingTypes = async () => {
try {
const filter = {
where: { isActive: true },
};
const { data } = await axios.get('ItemPackingTypes', {
params: { filter: JSON.stringify(filter) },
});
itemPackingTypes.value = data.map((ipt) => ({
description: t(ipt.description),
code: ipt.code,
}));
} catch (error) {
console.error(error);
}
};
const getGroupedStates = async () => {
try {
const { data } = await axios.get('AlertLevels');
stateOptions.value = data.map((state) => ({
id: state.id,
name: t(`futureTickets.${state.code}`),
code: state.code,
}));
} catch (error) {
console.error(error);
}
};
onMounted(async () => {
getItemPackingTypes();
getGroupedStates();
});
</script>
<template>
<FetchData
url="Warehouses"
@on-fetch="(data) => (warehousesOptions = data)"
auto-load
/>
<VnFilterPanel
:data-key="props.dataKey"
:hidden-tags="['search']"
:un-removable-params="['warehouseFk', 'originDated', 'futureDated']"
>
<template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs">
<strong>{{ t(`params.${tag.label}`) }}: </strong>
<span>{{ formatFn(tag.value) }}</span>
</div>
</template>
<template #body="{ params, searchFn }">
<QItem class="q-my-sm">
<QItemSection>
<VnInputDate
v-model="params.originDated"
:label="t('params.originDated')"
is-outlined
/>
</QItemSection>
</QItem>
<QItem class="q-my-sm">
<QItemSection>
<VnInputDate
v-model="params.futureDated"
:label="t('params.futureDated')"
is-outlined
/>
</QItemSection>
</QItem>
<QItem class="q-my-sm">
<QItemSection>
<VnInput
:label="t('params.litersMax')"
v-model="params.litersMax"
is-outlined
/>
</QItemSection>
</QItem>
<QItem class="q-my-sm">
<QItemSection>
<VnInput
:label="t('params.linesMax')"
v-model="params.linesMax"
is-outlined
/>
</QItemSection>
</QItem>
<QItem>
<QItemSection>
<VnSelect
:label="t('params.ipt')"
v-model="params.ipt"
:options="itemPackingTypes"
option-value="code"
option-label="description"
:info="t('iptInfo')"
@update:model-value="searchFn()"
dense
outlined
rounded
>
</VnSelect>
</QItemSection>
</QItem>
<QItem>
<QItemSection>
<VnSelect
:label="t('params.futureIpt')"
v-model="params.futureIpt"
:options="itemPackingTypes"
option-value="code"
option-label="description"
:info="t('iptInfo')"
@update:model-value="searchFn()"
dense
outlined
rounded
>
</VnSelect>
</QItemSection>
</QItem>
<QItem>
<QItemSection>
<VnSelect
:label="t('params.state')"
v-model="params.state"
:options="stateOptions"
option-value="code"
option-label="name"
@update:model-value="searchFn()"
dense
outlined
rounded
>
</VnSelect>
</QItemSection>
</QItem>
<QItem>
<QItemSection>
<VnSelect
:label="t('params.futureState')"
v-model="params.futureState"
:options="stateOptions"
option-value="code"
option-label="name"
@update:model-value="searchFn()"
dense
outlined
rounded
>
</VnSelect>
</QItemSection>
</QItem>
<QItem>
<QItemSection>
<QCheckbox
:label="t('params.problems')"
v-model="params.problems"
:toggle-indeterminate="false"
@update:model-value="searchFn()"
/>
</QItemSection>
</QItem>
<QItem>
<QItemSection>
<VnSelect
:label="t('params.warehouseFk')"
v-model="params.warehouseFk"
:options="warehousesOptions"
option-value="id"
option-label="name"
@update:model-value="searchFn()"
dense
outlined
rounded
>
</VnSelect>
</QItemSection>
</QItem>
</template>
</VnFilterPanel>
</template>
<i18n>
en:
iptInfo: IPT
params:
originDated: Origin date
futureDated: Destination date
futureIpt: Destination IPT
ipt: Origin IPT
warehouseFk: Warehouse
litersMax: Max liters
linesMax: Max lines
state: Origin grouped state
futureState: Destination grouped state
problems: With problems
es:
Horizontal: Horizontal
Vertical: Vertical
iptInfo: Encajado
params:
originDated: Fecha origen
futureDated: Fecha destino
futureIpt: IPT destino
ipt: IPT Origen
warehouseFk: Almacén
litersMax: Litros máx.
linesMax: Líneas máx.
state: Estado agrupado origen
futureState: Estado agrupado destino
problems: Con problemas
</i18n>

View File

@ -93,6 +93,11 @@ futureTickets:
moveTicketSuccess: Tickets moved successfully! moveTicketSuccess: Tickets moved successfully!
searchInfo: Search future tickets by date searchInfo: Search future tickets by date
futureTicket: Future tickets futureTicket: Future tickets
FREE: Free
ON_PREVIOUS: ON_PREVIOUS
ON_PREPARATION: On preparation
PACKED: Packed
DELIVERED: Delivered
expedition: expedition:
id: Expedition id: Expedition
item: Item item: Item

View File

@ -140,6 +140,11 @@ futureTickets:
moveTicketSuccess: Tickets movidos correctamente moveTicketSuccess: Tickets movidos correctamente
searchInfo: Buscar tickets por fecha searchInfo: Buscar tickets por fecha
futureTicket: Tickets a futuro futureTicket: Tickets a futuro
FREE: Libre
ON_PREVIOUS: ON_PREVIOUS
ON_PREPARATION: En preparación
PACKED: Encajado
DELIVERED: Servido
ticketSale: ticketSale:
id: Id id: Id
visible: Visible visible: Visible