0
0
Fork 0
This commit is contained in:
William Buezas 2024-07-01 08:43:15 -03:00
parent 86a016e375
commit e951894ac3
3 changed files with 52 additions and 28 deletions

View File

@ -17,6 +17,7 @@ const { t } = useI18n();
const paginateRef = ref(null); const paginateRef = ref(null);
const workersActiveOptions = ref([]); const workersActiveOptions = ref([]);
const clientsOptions = ref([]); const clientsOptions = ref([]);
const showHeaderFilters = ref(true);
const from = ref(Date.vnNew()); const from = ref(Date.vnNew());
const to = ref(Date.vnNew()); const to = ref(Date.vnNew());
@ -37,9 +38,11 @@ const filter = reactive({
}, },
}); });
const refetch = async () => await paginateRef.value.fetch();
watch(dateRange, (val) => { watch(dateRange, (val) => {
filter.where['v.stamp'].between = val; filter.where['v.stamp'].between = val;
paginateRef.value.fetch(); refetch();
}); });
function exprBuilder(param, value) { function exprBuilder(param, value) {
@ -166,6 +169,8 @@ const columns = computed(() => [
:no-data-label="t('globals.noResults')" :no-data-label="t('globals.noResults')"
> >
<template #top> <template #top>
<div class="full-width row justify-between">
<div class="row">
<VnInputDate <VnInputDate
:label="t('salesClientsTable.from')" :label="t('salesClientsTable.from')"
dense dense
@ -181,8 +186,18 @@ const columns = computed(() => [
v-model="to" v-model="to"
style="width: 150px" style="width: 150px"
/> />
</div>
<div class="row q-gutter-x-sm">
<QBtn
color="primary"
icon="search"
@click="showHeaderFilters = !showHeaderFilters"
/>
<QBtn color="primary" icon="replay" @click="refetch()" />
</div>
</div>
</template> </template>
<template #top-row="{ cols }"> <template v-if="showHeaderFilters" #top-row="{ cols }">
<QTr> <QTr>
<QTd <QTd
v-for="(col, index) in cols" v-for="(col, index) in cols"

View File

@ -50,7 +50,7 @@ const columns = computed(() => [
name: 'date', name: 'date',
field: 'dated', field: 'dated',
align: 'left', align: 'left',
columnFilter: null, sortable: true,
}, },
{ {
label: t('salesOrdersTable.client'), label: t('salesOrdersTable.client'),
@ -162,8 +162,7 @@ const redirectToOrderSummary = (orderId) => {
<QBadge <QBadge
:color="getBadgeColor(row.date_send)" :color="getBadgeColor(row.date_send)"
text-color="black" text-color="black"
class="q-ma-none q-mb-md" class="q-pa-sm q-mb-md"
dense
style="font-size: 14px" style="font-size: 14px"
> >
{{ toDateFormat(row.date_send) }} {{ toDateFormat(row.date_send) }}

View File

@ -315,7 +315,9 @@ const getBadgeAttrs = (date) => {
if (comparation < 0) return { color: 'success', 'text-color': 'black' }; if (comparation < 0) return { color: 'success', 'text-color': 'black' };
return { color: 'transparent', 'text-color': 'white' }; return { color: 'transparent', 'text-color': 'white' };
}; };
let refreshTimer = null; let refreshTimer = null;
const autoRefreshHandler = (value) => { const autoRefreshHandler = (value) => {
if (value) if (value)
refreshTimer = setInterval(() => paginateRef.value.fetch(), DEFAULT_AUTO_REFRESH); refreshTimer = setInterval(() => paginateRef.value.fetch(), DEFAULT_AUTO_REFRESH);
@ -324,8 +326,10 @@ const autoRefreshHandler = (value) => {
refreshTimer = null; refreshTimer = null;
} }
}; };
const redirectToTicketSummary = (id) => { const redirectToTicketSummary = (id) => {
router.push({ name: 'TicketSummary', params: { id } }); const url = `#/ticket/${id}/summary`;
window.open(url, '_blank');
}; };
const stateColors = { const stateColors = {
@ -348,6 +352,11 @@ const formatShippedDate = (date) => {
return toDateFormat(_date); return toDateFormat(_date);
}; };
const redirectToSales = (id) => {
const url = `#/ticket/${id}/sale`;
window.open(url, '_blank');
};
onMounted(async () => { onMounted(async () => {
const filteredColumns = columns.value.filter((col) => col.name !== 'rowActions'); const filteredColumns = columns.value.filter((col) => col.name !== 'rowActions');
allColumnNames.value = filteredColumns.map((col) => col.name); allColumnNames.value = filteredColumns.map((col) => col.name);
@ -517,8 +526,10 @@ onMounted(async () => {
</template> </template>
<template #body-cell-identifier="{ row }"> <template #body-cell-identifier="{ row }">
<QTd> <QTd>
<span class="link" @click.stop.prevent>{{ row.id }}</span> <span class="link" @click.stop.prevent>
{{ row.id }}
<TicketDescriptorProxy :id="row.id" /> <TicketDescriptorProxy :id="row.id" />
</span>
</QTd> </QTd>
</template> </template>
<template #body-cell-client="{ row }"> <template #body-cell-client="{ row }">
@ -537,8 +548,7 @@ onMounted(async () => {
<QTd> <QTd>
<QBadge <QBadge
v-bind="getBadgeAttrs(row.shippedDate)" v-bind="getBadgeAttrs(row.shippedDate)"
class="q-ma-none" class="q-pa-sm"
dense
style="font-size: 14px" style="font-size: 14px"
> >
{{ formatShippedDate(row.shippedDate) }} {{ formatShippedDate(row.shippedDate) }}
@ -555,7 +565,7 @@ onMounted(async () => {
v-else v-else
:color="stateColors[row.classColor] || 'transparent'" :color="stateColors[row.classColor] || 'transparent'"
:text-color="stateColors[row.classColor] ? 'black' : 'white'" :text-color="stateColors[row.classColor] ? 'black' : 'white'"
dense class="q-pa-sm"
style="font-size: 14px" style="font-size: 14px"
> >
{{ row.state }} {{ row.state }}
@ -585,7 +595,7 @@ onMounted(async () => {
<QBadge <QBadge
:color="totalPriceColor(row) || 'transparent'" :color="totalPriceColor(row) || 'transparent'"
:text-color="totalPriceColor(row) ? 'black' : 'white'" :text-color="totalPriceColor(row) ? 'black' : 'white'"
dense class="q-pa-sm"
style="font-size: 14px" style="font-size: 14px"
> >
{{ toCurrency(row.totalWithVat) }} {{ toCurrency(row.totalWithVat) }}
@ -601,7 +611,7 @@ onMounted(async () => {
class="q-mr-sm" class="q-mr-sm"
flat flat
dense dense
:to="{ name: 'TicketSale', params: { id: row.id } }" @click="redirectToSales(row.id)"
> >
<QTooltip>{{ t('salesTicketsTable.goToLines') }}</QTooltip> <QTooltip>{{ t('salesTicketsTable.goToLines') }}</QTooltip>
</QBtn> </QBtn>