forked from verdnatura/salix-front
Ticket advance filter
This commit is contained in:
parent
53a75954d1
commit
0adbd3e6d2
|
@ -177,10 +177,20 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
|
||||||
delete store.userParams[param];
|
delete store.userParams[param];
|
||||||
delete params[param];
|
delete params[param];
|
||||||
if (store.filter?.where) {
|
if (store.filter?.where) {
|
||||||
const key = Object.keys(exprBuilder ? exprBuilder(param) : param);
|
let key;
|
||||||
if (key[0]) delete store.filter.where[key[0]];
|
if (exprBuilder) {
|
||||||
if (Object.keys(store.filter.where).length === 0) {
|
const result = exprBuilder(param);
|
||||||
delete store.filter.where;
|
if (result !== undefined && result !== null)
|
||||||
|
key = Object.keys(result);
|
||||||
|
} else {
|
||||||
|
if (typeof param === 'object' && param !== null)
|
||||||
|
key = Object.keys(param);
|
||||||
|
}
|
||||||
|
if (key && key[0]) {
|
||||||
|
delete store.filter.where[key[0]];
|
||||||
|
if (Object.keys(store.filter.where).length === 0) {
|
||||||
|
delete store.filter.where;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@ import TicketDescriptorProxy from 'src/pages/Ticket/Card/TicketDescriptorProxy.v
|
||||||
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 VnProgress from 'src/components/common/VnProgressModal.vue';
|
import VnProgress from 'src/components/common/VnProgressModal.vue';
|
||||||
|
import RightMenu from 'src/components/common/RightMenu.vue';
|
||||||
|
import TicketAdvanceFilter from './TicketAdvanceFilter.vue';
|
||||||
|
|
||||||
import { dashIfEmpty, toCurrency } from 'src/filters';
|
import { dashIfEmpty, toCurrency } from 'src/filters';
|
||||||
import { useVnConfirm } from 'composables/useVnConfirm';
|
import { useVnConfirm } from 'composables/useVnConfirm';
|
||||||
|
@ -42,9 +44,9 @@ const exprBuilder = (param, value) => {
|
||||||
case 'notMovableLines':
|
case 'notMovableLines':
|
||||||
case 'futureZoneFk':
|
case 'futureZoneFk':
|
||||||
return { [param]: value };
|
return { [param]: 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}%` } };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -55,6 +57,7 @@ const arrayData = useArrayData('AdvanceTickets', {
|
||||||
url: 'Tickets/getTicketsAdvance',
|
url: 'Tickets/getTicketsAdvance',
|
||||||
userParams: userParams,
|
userParams: userParams,
|
||||||
exprBuilder: exprBuilder,
|
exprBuilder: exprBuilder,
|
||||||
|
limit: 0,
|
||||||
});
|
});
|
||||||
const { store } = arrayData;
|
const { store } = arrayData;
|
||||||
const tickets = computed(() =>
|
const tickets = computed(() =>
|
||||||
|
@ -110,7 +113,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,
|
||||||
|
@ -194,7 +197,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,
|
||||||
|
@ -451,7 +454,8 @@ onMounted(async () => {
|
||||||
userParams.dateFuture = tomorrow;
|
userParams.dateFuture = tomorrow;
|
||||||
userParams.dateToAdvance = today;
|
userParams.dateToAdvance = today;
|
||||||
userParams.warehouseFk = user.value.warehouseFk;
|
userParams.warehouseFk = user.value.warehouseFk;
|
||||||
await arrayData.addFilter({ userParams });
|
const filter = { limit: 0 };
|
||||||
|
await arrayData.addFilter({ filter, userParams });
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -521,6 +525,11 @@ onMounted(async () => {
|
||||||
</QBtn>
|
</QBtn>
|
||||||
</template>
|
</template>
|
||||||
</VnSubToolbar>
|
</VnSubToolbar>
|
||||||
|
<RightMenu>
|
||||||
|
<template #right-panel>
|
||||||
|
<TicketAdvanceFilter data-key="AdvanceTickets" />
|
||||||
|
</template>
|
||||||
|
</RightMenu>
|
||||||
<QPage class="column items-center q-pa-md">
|
<QPage class="column items-center q-pa-md">
|
||||||
<QTable
|
<QTable
|
||||||
:rows="tickets"
|
:rows="tickets"
|
||||||
|
|
|
@ -0,0 +1,172 @@
|
||||||
|
<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 axios from 'axios';
|
||||||
|
import { onMounted } from 'vue';
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
const props = defineProps({
|
||||||
|
dataKey: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
exprBuilder: {
|
||||||
|
type: Function,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const warehousesOptions = ref([]);
|
||||||
|
const itemPackingTypes = 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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(async () => await getItemPackingTypes());
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<FetchData
|
||||||
|
url="Warehouses"
|
||||||
|
@on-fetch="(data) => (warehousesOptions = data)"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
|
<VnFilterPanel
|
||||||
|
:data-key="props.dataKey"
|
||||||
|
:search-button="true"
|
||||||
|
:hidden-tags="['search']"
|
||||||
|
:unremovable-params="['warehouseFk', 'dateFuture', 'dateToAdvance']"
|
||||||
|
>
|
||||||
|
<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.dateFuture"
|
||||||
|
:label="t('params.dateFuture')"
|
||||||
|
is-outlined
|
||||||
|
@update:model-value="searchFn()"
|
||||||
|
/>
|
||||||
|
</QItemSection>
|
||||||
|
</QItem>
|
||||||
|
<QItem class="q-my-sm">
|
||||||
|
<QItemSection>
|
||||||
|
<VnInputDate
|
||||||
|
v-model="params.dateToAdvance"
|
||||||
|
:label="t('params.dateToAdvance')"
|
||||||
|
is-outlined
|
||||||
|
@update:model-value="searchFn()"
|
||||||
|
/>
|
||||||
|
</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.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>
|
||||||
|
<QCheckbox
|
||||||
|
:label="t('params.itemPackingTypes')"
|
||||||
|
v-model="params.itemPackingTypes"
|
||||||
|
toggle-indeterminate
|
||||||
|
@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:
|
||||||
|
dateFuture: Origin date
|
||||||
|
dateToAdvance: Destination date
|
||||||
|
futureIpt: Origin IPT
|
||||||
|
ipt: Destination IPT
|
||||||
|
itemPackingTypes: 100% movable
|
||||||
|
warehouseFk: Warehouse
|
||||||
|
es:
|
||||||
|
Horizontal: Horizontal
|
||||||
|
Vertical: Vertical
|
||||||
|
iptInfo: Encajado
|
||||||
|
params:
|
||||||
|
dateFuture: Origin date
|
||||||
|
dateToAdvance: Destination date
|
||||||
|
futureIpt: Origin IPT
|
||||||
|
ipt: Destination IPT
|
||||||
|
itemPackingTypes: 100% movable
|
||||||
|
warehouseFk: Warehouse
|
||||||
|
</i18n>
|
Loading…
Reference in New Issue