feat: refs #7553 added VnTable in Expedition, new field & minor changes in rest of section
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jon Elias 2024-07-26 09:55:24 +02:00
parent 2245552dfa
commit 2ab7d48b0c
9 changed files with 149 additions and 233 deletions

1
salix-front-mindshore Submodule

@ -0,0 +1 @@
Subproject commit 7432396ceafb7fe46b8ed8ac28fa7753df57efd2

View File

@ -1,41 +1,37 @@
<script setup> <script setup>
import { onMounted, ref, computed, onUnmounted, reactive, watch } from 'vue'; import { onMounted, ref, computed, onUnmounted, watch } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import FetchData from 'components/FetchData.vue';
import VnInput from 'src/components/common/VnInput.vue';
import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue'; import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
import TicketEditManaProxy from './TicketEditMana.vue';
import TableVisibleColumns from 'src/components/common/TableVisibleColumns.vue'; import TableVisibleColumns from 'src/components/common/TableVisibleColumns.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import ExpeditionNewTicket from './ExpeditionNewTicket.vue'; import ExpeditionNewTicket from './ExpeditionNewTicket.vue';
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue'; import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import { useStateStore } from 'stores/useStateStore'; import { useStateStore } from 'stores/useStateStore';
import { toCurrency, toPercentage } from 'src/filters';
import { useArrayData } from 'composables/useArrayData'; import { useArrayData } from 'composables/useArrayData';
import { useVnConfirm } from 'composables/useVnConfirm'; import { useVnConfirm } from 'composables/useVnConfirm';
import useNotify from 'src/composables/useNotify.js'; import useNotify from 'src/composables/useNotify.js';
import { toDateTimeFormat } from 'src/filters/date'; import { toDateTimeFormat } from 'src/filters/date';
import axios from 'axios'; import axios from 'axios';
import VnTable from 'src/components/VnTable/VnTable.vue';
const route = useRoute(); const route = useRoute();
const stateStore = useStateStore(); const stateStore = useStateStore();
const { t } = useI18n(); const { t } = useI18n();
const { notify } = useNotify(); const { notify } = useNotify();
const { openConfirmationModal } = useVnConfirm(); const { openConfirmationModal } = useVnConfirm();
const editPriceProxyRef = ref(null);
const newTicketDialogRef = ref(null); const newTicketDialogRef = ref(null);
const logsTableDialogRef = ref(null); const logsTableDialogRef = ref(null);
const tableRef = ref();
const expeditionsLogsData = ref([]); const expeditionsLogsData = ref([]);
const selectedExpeditions = ref([]); const selectedExpeditions = ref([]);
const allColumnNames = ref([]); const allColumnNames = ref([]);
const visibleColumns = ref([]); const visibleColumns = ref([]);
const newTicketWithRoute = ref(false); const newTicketWithRoute = ref(false);
const itemsOptions = ref([]); const selectedRows = ref([]);
const hasSelectedRows = computed(() => selectedRows.value.length > 0);
const exprBuilder = (param, value) => { const exprBuilder = (param, value) => {
switch (param) { switch (param) {
@ -56,8 +52,6 @@ const expeditionsArrayData = useArrayData('ticketExpeditions', {
filter: expeditionsFilter.value, filter: expeditionsFilter.value,
exprBuilder: exprBuilder, exprBuilder: exprBuilder,
}); });
const expeditionsStore = expeditionsArrayData.store;
const ticketExpeditions = computed(() => expeditionsStore.data);
const ticketArrayData = useArrayData('ticketData'); const ticketArrayData = useArrayData('ticketData');
const ticketStore = ticketArrayData.store; const ticketStore = ticketArrayData.store;
@ -75,127 +69,95 @@ watch(
{ immediate: true } { immediate: true }
); );
const params = reactive({});
const applyColumnFilter = async (col) => {
try {
const paramKey = col.columnFilter?.filterParamKey || col.field;
params[paramKey] = col.columnFilter.filterValue;
await expeditionsArrayData.addFilter({ filter: expeditionsFilter.value, params });
} catch (err) {
console.error('Error applying column filter', err);
}
};
const getInputEvents = (col) => {
return col.columnFilter.type === 'select'
? { 'update:modelValue': () => applyColumnFilter(col) }
: {
'keyup.enter': () => applyColumnFilter(col),
};
};
const columns = computed(() => [ const columns = computed(() => [
{ {
align: 'left',
label: t('expedition.id'), label: t('expedition.id'),
name: 'id', name: 'id',
field: 'id', chip: {
align: 'left', condition: () => true,
sortable: true,
columnFilter: {
component: VnInput,
type: 'text',
filterParamKey: 'expeditionFk',
filterValue: null,
event: getInputEvents,
attrs: {
dense: true,
}, },
isId: true,
columnFilter: {
inWhere: true,
}, },
}, },
{ {
label: t('expedition.item'), label: t('expedition.item'),
name: 'item', name: 'packagingItemFk',
align: 'left', align: 'left',
cardVisible: true,
columnFilter: { columnFilter: {
component: VnInput, inWhere: true,
type: 'text',
filterParamKey: 'packageItemName',
filterValue: null,
event: getInputEvents,
attrs: {
dense: true,
},
}, },
}, },
{ {
label: t('expedition.name'), label: t('expedition.name'),
name: 'name', name: 'packageItemName',
field: 'packageItemName',
align: 'left', align: 'left',
isTitle: true,
columnFilter: { columnFilter: {
component: VnSelect, inWhere: true,
type: 'select', // component: 'select',
filterValue: null, // attrs: {
event: getInputEvents, // url: 'Items',
attrs: { // useLike: false,
options: itemsOptions.value, // fields: ['id', 'name'],
'option-value': 'id', // optionLabel: 'name',
'option-label': 'name', // optionValue: 'id',
dense: true, // },
},
}, },
}, },
{ {
label: t('expedition.packageType'), label: t('expedition.packageType'),
name: 'packageType', name: 'freightItemName',
field: 'freightItemName',
align: 'left', align: 'left',
columnFilter: { columnFilter: {
component: VnInput, inWhere: true,
type: 'text',
// filterParamKey: 'expeditionFk',
filterValue: null,
event: getInputEvents,
attrs: {
dense: true,
},
}, },
}, },
{ {
label: t('expedition.counter'), label: t('expedition.counter'),
name: 'counter', name: 'counter',
field: 'counter',
align: 'left', align: 'left',
columnFilter: null, columnFilter: {
inWhere: true,
},
}, },
{ {
label: t('expedition.externalId'), label: t('expedition.externalId'),
name: 'externalId', name: 'externalId',
field: 'externalId',
align: 'left', align: 'left',
columnFilter: null, cardVisible: true,
columnFilter: {
inWhere: true,
},
}, },
{ {
label: t('expedition.created'), label: t('expedition.created'),
name: 'created', name: 'created',
field: 'created',
align: 'left', align: 'left',
columnFilter: null, cardVisible: true,
format: (value) => toDateTimeFormat(value), format: (row) => toDateTimeFormat(row.created),
}, },
{ {
label: t('expedition.state'), label: t('expedition.state'),
name: 'state', name: 'state',
field: 'state',
align: 'left', align: 'left',
columnFilter: null, cardVisible: true,
columnFilter: { inWhere: true },
}, },
{ {
label: '', align: 'right',
name: 'history', name: 'tableActions',
align: 'left', actions: [
columnFilter: null, {
title: t('expedition.historyAction'),
icon: 'history',
isPrimary: true,
action: (row) => showLog(row),
},
],
}, },
]); ]);
@ -204,23 +166,35 @@ const logTableColumns = computed(() => [
label: t('expedition.state'), label: t('expedition.state'),
name: 'state', name: 'state',
field: 'state', field: 'state',
align: 'left', align: 'center',
sortable: true, sortable: true,
}, },
{ {
label: t('expedition.name'), label: t('expedition.name'),
name: 'name', name: 'name',
align: 'name', field: 'name',
align: 'center',
columnFilter: null, columnFilter: null,
}, },
{ {
label: t('expedition.created'), label: t('expedition.created'),
name: 'created', name: 'created',
field: 'created', field: 'created',
align: 'left', align: 'center',
columnFilter: null, columnFilter: null,
format: (value) => toDateTimeFormat(value), format: (value) => toDateTimeFormat(value),
}, },
{
label: t('expedition.isScanned'),
name: 'isScanned',
field: 'isScanned',
align: 'center',
columnFilter: null,
format: (value) => {
if (value === true) return t('expedition.yes');
else return t('expedition.no');
},
},
]); ]);
const showNewTicketDialog = (withRoute = false) => { const showNewTicketDialog = (withRoute = false) => {
@ -255,10 +229,20 @@ const getExpeditionState = async (expedition) => {
order: ['created DESC'], order: ['created DESC'],
}; };
const { data } = await axios.get(`ExpeditionStates/filter`, { const { data: expeditionStates } = await axios.get(`ExpeditionStates/filter`, {
params: { filter: JSON.stringify(filter) }, params: { filter: JSON.stringify(filter) },
}); });
expeditionsLogsData.value = data; const { data: scannedStates } = await axios.get(`ExpeditionStates`, {
params: { filter: JSON.stringify(filter), fields: ['id', 'isScanned'] },
});
expeditionsLogsData.value = expeditionStates.map((state) => {
const scannedState = scannedStates.find((s) => s.id === state.id);
return {
...state,
isScanned: scannedState ? scannedState.isScanned : false,
};
});
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} }
@ -268,19 +252,12 @@ onMounted(async () => {
stateStore.rightDrawer = true; stateStore.rightDrawer = true;
const filteredColumns = columns.value.filter((col) => col.name !== 'history'); const filteredColumns = columns.value.filter((col) => col.name !== 'history');
allColumnNames.value = filteredColumns.map((col) => col.name); allColumnNames.value = filteredColumns.map((col) => col.name);
// await expeditionsArrayData.fetch({ append: false });
}); });
onUnmounted(() => (stateStore.rightDrawer = false)); onUnmounted(() => (stateStore.rightDrawer = false));
</script> </script>
<template> <template>
<FetchData
url="Items"
auto-load
:filter="{ fields: ['id', 'name'], order: 'name ASC' }"
@on-fetch="(data) => (itemsOptions = data)"
/>
<VnSubToolbar> <VnSubToolbar>
<template #st-data> <template #st-data>
<TableVisibleColumns <TableVisibleColumns
@ -296,7 +273,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
ref="btnDropdownRef" ref="btnDropdownRef"
color="primary" color="primary"
:label="t('expedition.move')" :label="t('expedition.move')"
:disable="!selectedExpeditions.length" :disable="!hasSelectedRows"
> >
<template #label> <template #label>
<QTooltip>{{ t('Select lines to see the options') }}</QTooltip> <QTooltip>{{ t('Select lines to see the options') }}</QTooltip>
@ -329,7 +306,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
</QList> </QList>
</QBtnDropdown> </QBtnDropdown>
<QBtn <QBtn
:disable="!selectedExpeditions.length" :disable="!hasSelectedRows"
icon="delete" icon="delete"
color="primary" color="primary"
@click=" @click="
@ -344,110 +321,27 @@ onUnmounted(() => (stateStore.rightDrawer = false));
</template> </template>
</VnSubToolbar> </VnSubToolbar>
<QTable <VnTable
:rows="ticketExpeditions" ref="tableRef"
data-key="TicketExpedition"
url="Expeditions/filter"
:columns="columns" :columns="columns"
row-key="id" :filter="expeditionsFilter"
:pagination="{ rowsPerPage: 0 }" v-model:selected="selectedRows"
class="full-width q-mt-md" :table="{
selection="multiple" 'row-key': 'id',
v-model:selected="selectedExpeditions" selection: 'multiple',
:visible-columns="visibleColumns" }"
:no-data-label="t('globals.noResults')" default-mode="table"
auto-load
> >
<template #top-row="{ cols }"> <template #column-packagingItemFk="{ row }">
<QTr> <span class="link" @click.stop>
<QTd /> {{ row.packagingItemFk }}
<QTd v-for="(col, index) in cols" :key="index" style="max-width: 100px">
<component
:is="col.columnFilter.component"
v-if="col.columnFilter"
v-model="col.columnFilter.filterValue"
v-bind="col.columnFilter.attrs"
v-on="col.columnFilter.event(col)"
dense
/>
</QTd>
</QTr>
</template>
<template #body-cell-item="{ row }">
<QTd auto-width @click.stop>
<QBtn flat color="primary">{{ row.packagingItemFk }}</QBtn>
<ItemDescriptorProxy :id="row.packagingItemFk" /> <ItemDescriptorProxy :id="row.packagingItemFk" />
</QTd> </span>
</template> </template>
<template #body-cell-available="{ row }"> </VnTable>
<QTd @click.stop>
<QBadge :color="row.available < 0 ? 'alert' : 'transparent'" dense>
{{ row.available }}
</QBadge>
</QTd>
</template>
<template #body-cell-price="{ row }">
<QTd>
<template v-if="isTicketEditable && row.id">
<QBtn flat color="primary" dense @click="onOpenEditPricePopover(row)">
{{ toCurrency(row.price) }}
</QBtn>
<TicketEditManaProxy
ref="editPriceProxyRef"
:mana="mana"
:new-price="getNewPrice"
@save="updatePrice(row)"
>
<VnInput
v-model.number="edit.price"
:label="t('ticketSale.price')"
type="number"
/>
</TicketEditManaProxy>
</template>
<span v-else>{{ toCurrency(row.price) }}</span>
</QTd>
</template>
<template #body-cell-discount="{ row }">
<QTd>
<template v-if="!isLocked && row.id">
<QBtn
flat
color="primary"
dense
@click="onOpenEditDiscountPopover(row)"
>
{{ toPercentage(row.discount / 100) }}
</QBtn>
<TicketEditManaProxy
:mana="mana"
:new-price="getNewPrice"
@save="changeDiscount(row)"
>
<VnInput
v-model.number="edit.discount"
:label="t('ticketSale.discount')"
type="number"
/>
</TicketEditManaProxy>
</template>
<span v-else>{{ toPercentage(row.discount / 100) }}</span>
</QTd>
</template>
<template #body-cell-history="{ row }">
<QTd>
<QBtn
@click.stop="showLog(row)"
color="primary"
icon="history"
size="md"
flat
>
<QTooltip class="text-no-wrap">
{{ t('expedition.historyAction') }}
</QTooltip>
</QBtn>
</QTd>
</template>
</QTable>
<QDialog ref="newTicketDialogRef" transition-show="scale" transition-hide="scale"> <QDialog ref="newTicketDialogRef" transition-show="scale" transition-hide="scale">
<ExpeditionNewTicket <ExpeditionNewTicket
:ticket="ticketData" :ticket="ticketData"
@ -461,12 +355,14 @@ onUnmounted(() => (stateStore.rightDrawer = false));
data-key="TicketExpeditionLog" data-key="TicketExpeditionLog"
:rows="expeditionsLogsData" :rows="expeditionsLogsData"
:columns="logTableColumns" :columns="logTableColumns"
class="q-pa-sm" class="q-pa-md full-width"
> >
<template #body-cell-name="{ row }"> <template #body-cell-name="{ row }">
<QTd auto-width> <QTd style="text-align: center">
<QBtn flat dense color="primary">{{ row.name }}</QBtn> <span class="link" @click.stop>
<QBtn flat dense>{{ row.name }}</QBtn>
<WorkerDescriptorProxy :id="row.workerFk" /> <WorkerDescriptorProxy :id="row.workerFk" />
</span>
</QTd> </QTd>
</template> </template>
</QTable> </QTable>

View File

@ -186,18 +186,22 @@ const openCreateModal = () => createTicketRequestDialogRef.value.show();
</template> </template>
<template #body-cell-requester="{ row }"> <template #body-cell-requester="{ row }">
<QTd @click.stop> <QTd @click.stop>
<QBtn flat color="primary"> <span class="link">
<QBtn flat>
{{ row.requester?.user?.nickname }} {{ row.requester?.user?.nickname }}
<WorkerDescriptorProxy :id="row.requesterFk" /> <WorkerDescriptorProxy :id="row.requesterFk" />
</QBtn> </QBtn>
</span>
</QTd> </QTd>
</template> </template>
<template #body-cell-atender="{ row }"> <template #body-cell-atender="{ row }">
<QTd @click.stop> <QTd @click.stop>
<QBtn flat color="primary"> <span class="link">
<QBtn flat>
{{ row.atender?.user?.nickname }} {{ row.atender?.user?.nickname }}
<WorkerDescriptorProxy :id="row.attenderFk" /> <WorkerDescriptorProxy :id="row.attenderFk" />
</QBtn> </QBtn>
</span>
</QTd> </QTd>
</template> </template>
<template #body-cell-quantity="{ row }"> <template #body-cell-quantity="{ row }">
@ -220,10 +224,12 @@ const openCreateModal = () => createTicketRequestDialogRef.value.show();
</template> </template>
<template #body-cell-saleFk="{ row }"> <template #body-cell-saleFk="{ row }">
<QTd @click.stop> <QTd @click.stop>
<QBtn v-if="row.saleFk" flat color="primary"> <span class="link">
<QBtn v-if="row.saleFk" flat>
{{ row.sale.itemFk }} {{ row.sale.itemFk }}
<ItemDescriptorProxy :id="row.sale.itemFk" /> <ItemDescriptorProxy :id="row.sale.itemFk" />
</QBtn> </QBtn>
</span>
</QTd> </QTd>
</template> </template>
<template #body-cell-actions="{ row }"> <template #body-cell-actions="{ row }">

View File

@ -11,7 +11,6 @@ import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
import TicketEditManaProxy from './TicketEditMana.vue'; import TicketEditManaProxy from './TicketEditMana.vue';
import VnImg from 'src/components/ui/VnImg.vue'; import VnImg from 'src/components/ui/VnImg.vue';
import RightMenu from 'src/components/common/RightMenu.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import TicketSaleMoreActions from './TicketSaleMoreActions.vue'; import TicketSaleMoreActions from './TicketSaleMoreActions.vue';
import TicketTransfer from './TicketTransfer.vue'; import TicketTransfer from './TicketTransfer.vue';
@ -620,10 +619,12 @@ onUnmounted(() => (stateStore.rightDrawer = false));
<template #body-cell-itemFk="{ row }"> <template #body-cell-itemFk="{ row }">
<QTd @click.stop> <QTd @click.stop>
<div v-if="row.id"> <div v-if="row.id">
<QBtn flat color="primary" dense> <span class="link">
<QBtn flat dense>
{{ row.itemFk }} {{ row.itemFk }}
</QBtn> </QBtn>
<ItemDescriptorProxy :id="row.itemFk" /> <ItemDescriptorProxy :id="row.itemFk" />
</span>
</div> </div>
<VnSelect <VnSelect
v-else v-else

View File

@ -406,10 +406,12 @@ const qCheckBoxController = (sale, action) => {
<template #body-cell-item="{ row }"> <template #body-cell-item="{ row }">
<QTd @click.stop> <QTd @click.stop>
<div> <div>
<QBtn flat color="primary"> <span class="link">
<QBtn flat>
{{ row.itemFk }} {{ row.itemFk }}
</QBtn> </QBtn>
<ItemDescriptorProxy :id="row.itemFk" /> <ItemDescriptorProxy :id="row.itemFk" />
</span>
</div> </div>
</QTd> </QTd>
</template> </template>

View File

@ -95,10 +95,12 @@ const openCreateModal = () => createTrackingDialogRef.value.show();
> >
<template #body-cell-worker="{ row }"> <template #body-cell-worker="{ row }">
<QTd @click.stop> <QTd @click.stop>
<QBtn flat color="primary"> <span class="link">
<QBtn flat>
{{ row.user?.name }} {{ row.user?.name }}
<WorkerDescriptorProxy :id="row.user?.worker?.id" /> <WorkerDescriptorProxy :id="row.user?.worker?.id" />
</QBtn> </QBtn>
</span>
</QTd> </QTd>
</template> </template>
</QTable> </QTable>

View File

@ -134,10 +134,12 @@ onUnmounted(() => (stateStore.rightDrawer = false));
> >
<template #body-cell-item="{ row }"> <template #body-cell-item="{ row }">
<QTd> <QTd>
<QBtn flat color="primary"> <span class="link">
<QBtn flat>
{{ row.itemFk }} {{ row.itemFk }}
<ItemDescriptorProxy :id="row.itemFk" /> <ItemDescriptorProxy :id="row.itemFk" />
</QBtn> </QBtn>
</span>
</QTd> </QTd>
</template> </template>
<template #body-cell-description="{ row }"> <template #body-cell-description="{ row }">

View File

@ -112,6 +112,9 @@ expedition:
removeExpeditionSubtitle: Are you sure you want to delete this expedition? removeExpeditionSubtitle: Are you sure you want to delete this expedition?
worker: Worker worker: Worker
move: Move move: Move
isScanned: Is scanned
yes: Yes
no: No
basicData: basicData:
next: Next next: Next
back: Back back: Back

View File

@ -201,6 +201,9 @@ expedition:
removeExpeditionSubtitle: ¿Está seguro de eliminar esta expedición? removeExpeditionSubtitle: ¿Está seguro de eliminar esta expedición?
worker: Trabajador worker: Trabajador
move: Mover move: Mover
isScanned: Escaneado
yes:
no: No
package: package:
package: Embalaje package: Embalaje
quantity: Cantidad quantity: Cantidad