feat: refs #7356 list & weekly to VnTable and style fixes
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
a0b6455b4c
commit
cb610608df
|
@ -11,18 +11,14 @@ const { t } = useI18n();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
const routeName = computed(() => route.name);
|
const routeName = computed(() => route.name);
|
||||||
const searchBarDataKeys = {
|
|
||||||
TicketSummary: 'TicketSummary',
|
|
||||||
TicketSale: 'TicketSale',
|
|
||||||
TicketPurchaseRequest: 'TicketPurchaseRequest',
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<VnCard
|
<VnCard
|
||||||
data-key="Ticket"
|
data-key="Ticket"
|
||||||
|
base-url="Tickets"
|
||||||
:filter-panel="TicketFilter"
|
:filter-panel="TicketFilter"
|
||||||
:descriptor="TicketDescriptor"
|
:descriptor="TicketDescriptor"
|
||||||
:search-data-key="searchBarDataKeys[routeName]"
|
search-data-key="TicketList"
|
||||||
:search-custom-route-redirect="routeName"
|
:search-custom-route-redirect="routeName"
|
||||||
:searchbar-label="t('card.search')"
|
:searchbar-label="t('card.search')"
|
||||||
:searchbar-info="t('card.searchInfo')"
|
:searchbar-info="t('card.searchInfo')"
|
||||||
|
|
|
@ -626,7 +626,7 @@ onMounted(async () => {
|
||||||
</template>
|
</template>
|
||||||
<template #body-cell-ticketId="{ row }">
|
<template #body-cell-ticketId="{ row }">
|
||||||
<QTd>
|
<QTd>
|
||||||
<QBtn flat color="primary">
|
<QBtn flat class="link">
|
||||||
{{ row.id }}
|
{{ row.id }}
|
||||||
<TicketDescriptorProxy :id="row.id" />
|
<TicketDescriptorProxy :id="row.id" />
|
||||||
</QBtn>
|
</QBtn>
|
||||||
|
@ -658,7 +658,7 @@ onMounted(async () => {
|
||||||
</template>
|
</template>
|
||||||
<template #body-cell-futureId="{ row }">
|
<template #body-cell-futureId="{ row }">
|
||||||
<QTd class="vertical-separator">
|
<QTd class="vertical-separator">
|
||||||
<QBtn flat color="primary" dense>
|
<QBtn flat class="link" dense>
|
||||||
{{ row.futureId }}
|
{{ row.futureId }}
|
||||||
<TicketDescriptorProxy :id="row.futureId" />
|
<TicketDescriptorProxy :id="row.futureId" />
|
||||||
</QBtn>
|
</QBtn>
|
||||||
|
|
|
@ -15,11 +15,11 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const workers = ref();
|
const workers = ref([]);
|
||||||
const provinces = ref();
|
const provinces = ref([]);
|
||||||
const states = ref();
|
const states = ref([]);
|
||||||
const agencies = ref();
|
const agencies = ref([]);
|
||||||
const warehouses = ref();
|
const warehouses = ref([]);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -33,7 +33,7 @@ const warehouses = ref();
|
||||||
@on-fetch="(data) => (workers = data)"
|
@on-fetch="(data) => (workers = data)"
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
<VnFilterPanel :data-key="props.dataKey" :search-button="true">
|
<VnFilterPanel :data-key="props.dataKey" :search-button="true" search-url="table">
|
||||||
<template #tags="{ tag, formatFn }">
|
<template #tags="{ tag, formatFn }">
|
||||||
<div class="q-gutter-x-xs">
|
<div class="q-gutter-x-xs">
|
||||||
<strong>{{ t(`params.${tag.label}`) }}: </strong>
|
<strong>{{ t(`params.${tag.label}`) }}: </strong>
|
||||||
|
|
|
@ -442,7 +442,7 @@ onMounted(async () => {
|
||||||
</template>
|
</template>
|
||||||
<template #body-cell-ticketId="{ row }">
|
<template #body-cell-ticketId="{ row }">
|
||||||
<QTd>
|
<QTd>
|
||||||
<QBtn flat color="primary">
|
<QBtn flat class="link">
|
||||||
{{ row.id }}
|
{{ row.id }}
|
||||||
<TicketDescriptorProxy :id="row.id" />
|
<TicketDescriptorProxy :id="row.id" />
|
||||||
</QBtn>
|
</QBtn>
|
||||||
|
@ -489,7 +489,7 @@ onMounted(async () => {
|
||||||
</template>
|
</template>
|
||||||
<template #body-cell-futureId="{ row }">
|
<template #body-cell-futureId="{ row }">
|
||||||
<QTd class="vertical-separator">
|
<QTd class="vertical-separator">
|
||||||
<QBtn flat color="primary" dense>
|
<QBtn flat class="link" dense>
|
||||||
{{ row.futureId }}
|
{{ row.futureId }}
|
||||||
<TicketDescriptorProxy :id="row.futureId" />
|
<TicketDescriptorProxy :id="row.futureId" />
|
||||||
</QBtn>
|
</QBtn>
|
||||||
|
|
|
@ -1,118 +1,312 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, onUnmounted } from 'vue';
|
import axios from 'axios';
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRouter } from 'vue-router';
|
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
|
||||||
import { toDate, toCurrency } from 'src/filters/index';
|
import { toDate, toCurrency } from 'src/filters/index';
|
||||||
import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
|
||||||
import TicketSummary from './Card/TicketSummary.vue';
|
import TicketSummary from './Card/TicketSummary.vue';
|
||||||
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
|
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
|
||||||
import TicketFilter from './TicketFilter.vue';
|
|
||||||
import VnLv from 'src/components/ui/VnLv.vue';
|
|
||||||
import CardList from 'src/components/ui/CardList.vue';
|
|
||||||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||||
import RightMenu from 'src/components/common/RightMenu.vue';
|
import VnTable from 'src/components/VnTable/VnTable.vue';
|
||||||
|
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
|
import VnInputDate from 'src/components/common/VnInputDate.vue';
|
||||||
|
import VnRow from 'src/components/ui/VnRow.vue';
|
||||||
|
|
||||||
const router = useRouter();
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const stateStore = useStateStore();
|
|
||||||
const { viewSummary } = useSummaryDialog();
|
const { viewSummary } = useSummaryDialog();
|
||||||
|
const tableRef = ref();
|
||||||
|
const clientsOptions = ref([]);
|
||||||
|
const addressesOptions = ref([]);
|
||||||
|
const agenciesOptions = ref([]);
|
||||||
|
const selectedClient = ref();
|
||||||
|
|
||||||
onMounted(() => (stateStore.rightDrawer = true));
|
const columns = computed(() => [
|
||||||
onUnmounted(() => (stateStore.rightDrawer = false));
|
{
|
||||||
|
align: 'left',
|
||||||
|
name: 'id',
|
||||||
|
label: t('ticketList.id'),
|
||||||
|
chip: {
|
||||||
|
condition: () => true,
|
||||||
|
},
|
||||||
|
isId: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align: 'left',
|
||||||
|
name: 'nickname',
|
||||||
|
label: t('ticketList.nickname'),
|
||||||
|
isTitle: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align: 'left',
|
||||||
|
name: 'state',
|
||||||
|
label: t('ticketList.state'),
|
||||||
|
cardVisible: true,
|
||||||
|
chip: {
|
||||||
|
condition: () => true,
|
||||||
|
color: (row) => {
|
||||||
|
return row?.classColor ? `bg-${row.classColor}` : 'bg-orange';
|
||||||
|
},
|
||||||
|
},
|
||||||
|
columnFilter: {
|
||||||
|
name: 'stateFk',
|
||||||
|
component: 'select',
|
||||||
|
attrs: {
|
||||||
|
url: 'States',
|
||||||
|
fields: ['id', 'name'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
columnField: {
|
||||||
|
component: null,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align: 'left',
|
||||||
|
name: 'shipped',
|
||||||
|
cardVisible: true,
|
||||||
|
label: t('ticketList.shipped'),
|
||||||
|
columnFilter: {
|
||||||
|
component: 'date',
|
||||||
|
alias: 't',
|
||||||
|
inWhere: true,
|
||||||
|
},
|
||||||
|
format: ({ shipped }) => toDate(shipped),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align: 'left',
|
||||||
|
name: 'zoneFk',
|
||||||
|
label: t('ticketList.zone'),
|
||||||
|
columnFilter: {
|
||||||
|
component: 'select',
|
||||||
|
attrs: {
|
||||||
|
url: 'Zones',
|
||||||
|
fields: ['id', 'name'],
|
||||||
|
},
|
||||||
|
alias: 't',
|
||||||
|
inWhere: true,
|
||||||
|
},
|
||||||
|
format: (row, dashIfEmpty) => dashIfEmpty(row.zoneName),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align: 'left',
|
||||||
|
label: t('ticketList.salesPerson'),
|
||||||
|
name: 'salesPersonFk',
|
||||||
|
component: 'select',
|
||||||
|
attrs: {
|
||||||
|
url: 'Workers/activeWithInheritedRole',
|
||||||
|
fields: ['id', 'name'],
|
||||||
|
where: { role: 'salesPerson' },
|
||||||
|
optionFilter: 'firstName',
|
||||||
|
useLike: false,
|
||||||
|
},
|
||||||
|
columnField: {
|
||||||
|
component: null,
|
||||||
|
},
|
||||||
|
format: (row, dashIfEmpty) => dashIfEmpty(row.salesPerson),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align: 'left',
|
||||||
|
name: 'totalWithVat',
|
||||||
|
label: t('ticketList.totalWithVat'),
|
||||||
|
cardVisible: true,
|
||||||
|
columnFilter: {
|
||||||
|
component: 'number',
|
||||||
|
inWhere: true,
|
||||||
|
},
|
||||||
|
format: (row) => toCurrency(row.totalWithVat),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align: 'right',
|
||||||
|
name: 'tableActions',
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
title: t('ticketList.summary'),
|
||||||
|
icon: 'preview',
|
||||||
|
action: (row) => viewSummary(row.id, TicketSummary),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
const from = Date.vnNew();
|
const onClientSelected = async (formData) => {
|
||||||
const to = Date.vnNew();
|
await fetchClient(formData);
|
||||||
to.setDate(to.getDate() + 1);
|
await fetchAddresses(formData);
|
||||||
|
|
||||||
const userParams = {
|
|
||||||
from: from.toISOString(),
|
|
||||||
to: to.toISOString(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function navigate(id) {
|
const fetchAvailableAgencies = async (formData) => {
|
||||||
router.push({ path: `/ticket/${id}` });
|
if (!formData.warehouseId || !formData.addressId || !formData.landed) return;
|
||||||
}
|
let params = {
|
||||||
|
warehouseFk: formData.warehouseId,
|
||||||
|
addressFk: formData.addressId,
|
||||||
|
landed: formData.landed,
|
||||||
|
};
|
||||||
|
|
||||||
|
const { data } = await axios.get('Agencies/getAgenciesWithWarehouse', { params });
|
||||||
|
|
||||||
|
agenciesOptions.value = data;
|
||||||
|
|
||||||
|
const defaultAgency = agenciesOptions.value.find(
|
||||||
|
(agency) =>
|
||||||
|
agency.agencyModeFk === selectedClient.value.defaultAddress.agencyModeFk
|
||||||
|
);
|
||||||
|
|
||||||
|
if (defaultAgency) formData.agencyModeId = defaultAgency.agencyModeFk;
|
||||||
|
};
|
||||||
|
|
||||||
|
const fetchClient = async (formData) => {
|
||||||
|
try {
|
||||||
|
const filter = {
|
||||||
|
include: {
|
||||||
|
relation: 'defaultAddress',
|
||||||
|
scope: {
|
||||||
|
fields: ['id', 'agencyModeFk'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
where: { id: formData.clientId },
|
||||||
|
};
|
||||||
|
const params = { filter: JSON.stringify(filter) };
|
||||||
|
const { data } = await axios.get('Clients', { params });
|
||||||
|
const [client] = data;
|
||||||
|
selectedClient.value = client;
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error fetching client');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const fetchAddresses = async (formData) => {
|
||||||
|
try {
|
||||||
|
if (!formData.clientId) return;
|
||||||
|
|
||||||
|
const filter = {
|
||||||
|
fields: ['nickname', 'street', 'city', 'id'],
|
||||||
|
where: { isActive: true },
|
||||||
|
order: 'nickname ASC',
|
||||||
|
};
|
||||||
|
const params = { filter: JSON.stringify(filter) };
|
||||||
|
const { data } = await axios.get(`Clients/${formData.clientId}/addresses`, {
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
addressesOptions.value = data;
|
||||||
|
|
||||||
|
const { defaultAddress } = selectedClient.value;
|
||||||
|
formData.addressId = defaultAddress.id;
|
||||||
|
} catch (err) {
|
||||||
|
console.error(`Error fetching addresses`, err);
|
||||||
|
return err.response;
|
||||||
|
}
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VnSearchbar
|
<VnSearchbar
|
||||||
data-key="TicketList"
|
data-key="Tickets"
|
||||||
:label="t('Search ticket')"
|
:label="t('Search ticket')"
|
||||||
:info="t('You can search by ticket id or alias')"
|
:info="t('You can search by ticket id or alias')"
|
||||||
/>
|
/>
|
||||||
<RightMenu>
|
<VnTable
|
||||||
<template #right-panel>
|
ref="tableRef"
|
||||||
<TicketFilter data-key="TicketList" />
|
data-key="Tickets"
|
||||||
|
url="Tickets/filter"
|
||||||
|
:create="{
|
||||||
|
urlCreate: 'Tickets/new',
|
||||||
|
title: t('ticketList.createTicket'),
|
||||||
|
onDataSaved: ({ id }) => tableRef.redirect(id),
|
||||||
|
formInitialData: {},
|
||||||
|
}"
|
||||||
|
default-mode="table"
|
||||||
|
:columns="columns"
|
||||||
|
redirect="ticket"
|
||||||
|
auto-load
|
||||||
|
>
|
||||||
|
<template #more-create-dialog="{ data }">
|
||||||
|
<VnRow>
|
||||||
|
<VnSelect
|
||||||
|
url="Clients"
|
||||||
|
:label="t('ticketList.client')"
|
||||||
|
v-model="data.clientId"
|
||||||
|
:options="clientsOptions"
|
||||||
|
option-value="id"
|
||||||
|
option-label="name"
|
||||||
|
hide-selected
|
||||||
|
@update:model-value="(client) => onClientSelected(data)"
|
||||||
|
>
|
||||||
|
<template #option="scope">
|
||||||
|
<QItem v-bind="scope.itemProps">
|
||||||
|
<QItemSection>
|
||||||
|
<QItemLabel>
|
||||||
|
{{ scope.opt.name }}
|
||||||
|
</QItemLabel>
|
||||||
|
<QItemLabel caption>
|
||||||
|
{{ `#${scope.opt.id}` }}
|
||||||
|
</QItemLabel>
|
||||||
|
</QItemSection>
|
||||||
|
</QItem>
|
||||||
|
</template>
|
||||||
|
</VnSelect>
|
||||||
|
</VnRow>
|
||||||
|
<VnRow>
|
||||||
|
<VnSelect
|
||||||
|
url="Addresses"
|
||||||
|
:label="t('ticket.create.address')"
|
||||||
|
v-model="data.addressId"
|
||||||
|
:options="addressesOptions"
|
||||||
|
option-value="id"
|
||||||
|
option-label="nickname"
|
||||||
|
hide-selected
|
||||||
|
:disable="!data.clientId"
|
||||||
|
@update:model-value="() => fetchAvailableAgencies(data)"
|
||||||
|
>
|
||||||
|
<template #option="scope">
|
||||||
|
<QItem v-bind="scope.itemProps">
|
||||||
|
<QItemSection>
|
||||||
|
<QItemLabel>
|
||||||
|
{{ scope.opt.nickname }}
|
||||||
|
</QItemLabel>
|
||||||
|
<QItemLabel caption>
|
||||||
|
{{ `${scope.opt.street}, ${scope.opt.city}` }}
|
||||||
|
</QItemLabel>
|
||||||
|
</QItemSection>
|
||||||
|
</QItem>
|
||||||
|
</template>
|
||||||
|
</VnSelect>
|
||||||
|
</VnRow>
|
||||||
|
<VnRow class="row q-gutter-md q-mb-md">
|
||||||
|
<div class="col">
|
||||||
|
<VnInputDate
|
||||||
|
placeholder="dd-mm-aaa"
|
||||||
|
:label="t('ticket.create.landed')"
|
||||||
|
v-model="data.landed"
|
||||||
|
@update:model-value="() => fetchAvailableAgencies(data)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</VnRow>
|
||||||
|
<VnRow class="row q-gutter-md q-mb-md">
|
||||||
|
<div class="col">
|
||||||
|
<VnSelect
|
||||||
|
url="Warehouses"
|
||||||
|
:label="t('ticket.create.warehouse')"
|
||||||
|
v-model="data.warehouseId"
|
||||||
|
:options="warehousesOptions"
|
||||||
|
option-value="id"
|
||||||
|
option-label="name"
|
||||||
|
hide-selected
|
||||||
|
@update:model-value="() => fetchAvailableAgencies(data)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</VnRow>
|
||||||
|
<VnRow class="row q-gutter-md q-mb-md">
|
||||||
|
<div class="col">
|
||||||
|
<VnSelect
|
||||||
|
:label="t('ticket.create.agency')"
|
||||||
|
v-model="data.agencyModeId"
|
||||||
|
:options="agenciesOptions"
|
||||||
|
option-value="agencyModeFk"
|
||||||
|
option-label="agencyMode"
|
||||||
|
hide-selected
|
||||||
|
:disable="!data.clientId || !data.landed || !data.warehouseId"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</VnRow>
|
||||||
</template>
|
</template>
|
||||||
</RightMenu>
|
</VnTable>
|
||||||
<QPage class="column items-center q-pa-md">
|
|
||||||
<div class="vn-card-list">
|
|
||||||
<VnPaginate
|
|
||||||
data-key="TicketList"
|
|
||||||
url="Tickets/filter"
|
|
||||||
:user-params="userParams"
|
|
||||||
order="id DESC"
|
|
||||||
auto-load
|
|
||||||
>
|
|
||||||
<template #body="{ rows }">
|
|
||||||
<CardList
|
|
||||||
v-for="row of rows"
|
|
||||||
:key="row.id"
|
|
||||||
:id="row.id"
|
|
||||||
:title="`${row.nickname}`"
|
|
||||||
@click="navigate(row.id)"
|
|
||||||
>
|
|
||||||
<template #list-items>
|
|
||||||
<VnLv
|
|
||||||
:label="t('ticket.list.nickname')"
|
|
||||||
:value="row.nickname"
|
|
||||||
/>
|
|
||||||
<VnLv :label="t('ticket.list.state')">
|
|
||||||
<template #value>
|
|
||||||
<QBadge
|
|
||||||
text-color="black"
|
|
||||||
:color="row.classColor ?? 'orange'"
|
|
||||||
class="q-ma-none"
|
|
||||||
dense
|
|
||||||
>
|
|
||||||
{{ row.state }}
|
|
||||||
</QBadge>
|
|
||||||
</template>
|
|
||||||
</VnLv>
|
|
||||||
<VnLv
|
|
||||||
:label="t('ticket.list.shipped')"
|
|
||||||
:value="toDate(row.shipped)"
|
|
||||||
/>
|
|
||||||
<VnLv :label="t('Zone')" :value="row.zoneName" />
|
|
||||||
<VnLv
|
|
||||||
:label="t('ticket.list.salesPerson')"
|
|
||||||
:value="row.salesPerson"
|
|
||||||
/>
|
|
||||||
<VnLv
|
|
||||||
:label="t('ticket.list.total')"
|
|
||||||
:value="toCurrency(row.totalWithVat)"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<template #actions>
|
|
||||||
<QBtn
|
|
||||||
:label="t('components.smartCard.openSummary')"
|
|
||||||
@click.stop="viewSummary(row.id, TicketSummary)"
|
|
||||||
color="primary"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</CardList>
|
|
||||||
</template>
|
|
||||||
</VnPaginate>
|
|
||||||
</div>
|
|
||||||
<QPageSticky :offset="[20, 20]">
|
|
||||||
<QBtn :to="{ name: 'TicketCreate' }" fab icon="add" color="primary">
|
|
||||||
<QTooltip>
|
|
||||||
{{ t('New ticket') }}
|
|
||||||
</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
</QPageSticky>
|
|
||||||
</QPage>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<i18n>
|
<i18n>
|
||||||
|
|
|
@ -1,40 +1,28 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, ref, computed, reactive, onUnmounted } from 'vue';
|
import { onMounted, ref, computed, onUnmounted } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRouter } from 'vue-router';
|
|
||||||
|
|
||||||
import FetchData from 'components/FetchData.vue';
|
|
||||||
import TableVisibleColumns from 'src/components/common/TableVisibleColumns.vue';
|
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
import CustomerDescriptorProxy from 'src/pages/Customer/Card/CustomerDescriptorProxy.vue';
|
import CustomerDescriptorProxy from 'src/pages/Customer/Card/CustomerDescriptorProxy.vue';
|
||||||
import TicketDescriptorProxy from 'src/pages/Ticket/Card/TicketDescriptorProxy.vue';
|
import TicketDescriptorProxy from 'src/pages/Ticket/Card/TicketDescriptorProxy.vue';
|
||||||
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
|
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
|
||||||
import VnPaginate from 'components/ui/VnPaginate.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 { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
import { dashIfEmpty } from 'src/filters';
|
|
||||||
import { useVnConfirm } from 'composables/useVnConfirm';
|
import { useVnConfirm } from 'composables/useVnConfirm';
|
||||||
import { useArrayData } from 'composables/useArrayData';
|
import { useArrayData } from 'composables/useArrayData';
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import VnTable from 'src/components/VnTable/VnTable.vue';
|
||||||
|
|
||||||
const router = useRouter();
|
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { openConfirmationModal } = useVnConfirm();
|
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
|
const { openConfirmationModal } = useVnConfirm();
|
||||||
const paginateRef = ref(null);
|
|
||||||
const agencyModesOptions = ref([]);
|
const agencyModesOptions = ref([]);
|
||||||
const visibleColumns = ref([]);
|
|
||||||
const allColumnNames = ref([]);
|
const allColumnNames = ref([]);
|
||||||
|
|
||||||
const arrayData = useArrayData('WeeklyTickets');
|
const arrayData = useArrayData('WeeklyTickets');
|
||||||
const { store } = arrayData;
|
const { store } = arrayData;
|
||||||
|
const tableRef = ref();
|
||||||
const weekdays = [
|
const weekdays = [
|
||||||
{ id: 0, name: t('weekdays.mon') },
|
{ id: 0, name: t('weekdays.mon') },
|
||||||
{ id: 1, name: t('weekdays.tue') },
|
{ id: 1, name: t('weekdays.tue') },
|
||||||
|
@ -45,113 +33,131 @@ const weekdays = [
|
||||||
{ id: 6, name: t('weekdays.sun') },
|
{ id: 6, name: t('weekdays.sun') },
|
||||||
];
|
];
|
||||||
|
|
||||||
const exprBuilder = (param, value) => {
|
|
||||||
switch (param) {
|
|
||||||
case 'clientName':
|
|
||||||
return { 'c.name': value };
|
|
||||||
case 'nickName':
|
|
||||||
return { 'u.name': value };
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const params = reactive({});
|
|
||||||
|
|
||||||
const applyColumnFilter = async (col) => {
|
|
||||||
try {
|
|
||||||
const paramKey = col.columnFilter?.filterParamKey || col.field;
|
|
||||||
params[paramKey] = col.columnFilter.filterValue;
|
|
||||||
await paginateRef.value.addFilter(null, params);
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error applying column filter', err);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const getInputEvents = (col) => ({ 'keyup.enter': () => applyColumnFilter(col) });
|
|
||||||
|
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
{
|
{
|
||||||
|
align: 'left',
|
||||||
|
name: 'ticketFk',
|
||||||
label: t('weeklyTickets.id'),
|
label: t('weeklyTickets.id'),
|
||||||
name: 'id',
|
chip: {
|
||||||
field: 'ticketFk',
|
condition: () => true,
|
||||||
align: 'left',
|
},
|
||||||
sortable: true,
|
isId: true,
|
||||||
columnFilter: null,
|
cardVisible: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
align: 'left',
|
||||||
|
name: 'clientFk',
|
||||||
label: t('weeklyTickets.client'),
|
label: t('weeklyTickets.client'),
|
||||||
name: 'client',
|
isTitle: true,
|
||||||
field: 'clientName',
|
cardVisible: true,
|
||||||
align: 'left',
|
component: 'select',
|
||||||
sortable: true,
|
attrs: {
|
||||||
columnFilter: {
|
url: 'Clients',
|
||||||
component: VnInput,
|
optionLabel: 'name',
|
||||||
type: 'text',
|
optionValue: 'id',
|
||||||
filterValue: null,
|
isWhere: true,
|
||||||
event: getInputEvents,
|
|
||||||
attrs: {
|
|
||||||
dense: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
format: (val) => dashIfEmpty(val),
|
columnField: {
|
||||||
|
component: null,
|
||||||
|
},
|
||||||
|
format: (row) => row.clientName,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
align: 'left',
|
||||||
|
name: 'weekDay',
|
||||||
label: t('weeklyTickets.shipment'),
|
label: t('weeklyTickets.shipment'),
|
||||||
name: 'shipment',
|
cardVisible: true,
|
||||||
field: 'weekDay',
|
|
||||||
align: 'left',
|
|
||||||
sortable: true,
|
|
||||||
columnFilter: null,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('weeklyTickets.agency'),
|
|
||||||
name: 'agency',
|
|
||||||
field: 'agencyModeFk',
|
|
||||||
align: 'left',
|
|
||||||
sortable: true,
|
|
||||||
columnFilter: null,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('weeklyTickets.warehouse'),
|
|
||||||
name: 'warehouse',
|
|
||||||
field: 'warehouseName',
|
|
||||||
align: 'left',
|
|
||||||
sortable: true,
|
|
||||||
columnFilter: null,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('weeklyTickets.salesperson'),
|
|
||||||
field: 'salesperson',
|
|
||||||
name: 'salesperson',
|
|
||||||
align: 'left',
|
|
||||||
sortable: true,
|
|
||||||
columnFilter: {
|
columnFilter: {
|
||||||
component: VnInput,
|
component: 'input',
|
||||||
type: 'text',
|
optionLabel: weekdays.name,
|
||||||
filterValue: null,
|
optionValue: weekdays.id,
|
||||||
event: getInputEvents,
|
inWhere: true,
|
||||||
filterParamKey: 'nickName',
|
|
||||||
attrs: {
|
|
||||||
dense: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '',
|
|
||||||
name: 'actions',
|
|
||||||
align: 'left',
|
align: 'left',
|
||||||
columnFilter: null,
|
label: t('weeklyTickets.agency'),
|
||||||
|
name: 'agencyModeFk',
|
||||||
|
cardVisible: true,
|
||||||
|
columnFilter: {
|
||||||
|
component: 'select',
|
||||||
|
attrs: {
|
||||||
|
url: 'AgencyModes',
|
||||||
|
fields: ['id', 'name'],
|
||||||
|
},
|
||||||
|
inWhere: true,
|
||||||
|
},
|
||||||
|
columnField: {
|
||||||
|
component: null,
|
||||||
|
},
|
||||||
|
format: (row, dashIfEmpty) => dashIfEmpty(row?.agencyMode?.name),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align: 'left',
|
||||||
|
name: 'warehouseFk',
|
||||||
|
label: t('weeklyTickets.warehouse'),
|
||||||
|
cardVisible: true,
|
||||||
|
columnFilter: {
|
||||||
|
component: 'select',
|
||||||
|
attrs: {
|
||||||
|
url: 'Warehouses',
|
||||||
|
fields: ['id', 'name'],
|
||||||
|
},
|
||||||
|
inWhere: true,
|
||||||
|
},
|
||||||
|
columnField: {
|
||||||
|
component: null,
|
||||||
|
},
|
||||||
|
format: (row, dashIfEmpty) => dashIfEmpty(row.warehouseName),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align: 'left',
|
||||||
|
name: 'workerFk',
|
||||||
|
label: t('weeklyTickets.salesperson'),
|
||||||
|
columnFilter: {
|
||||||
|
component: 'select',
|
||||||
|
attrs: {
|
||||||
|
url: 'Workers/activeWithInheritedRole',
|
||||||
|
fields: ['id', 'name'],
|
||||||
|
where: { role: 'salesperson' },
|
||||||
|
},
|
||||||
|
inWhere: true,
|
||||||
|
},
|
||||||
|
columnField: {
|
||||||
|
component: null,
|
||||||
|
},
|
||||||
|
cardVisible: true,
|
||||||
|
format: (row) => row.userName,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align: 'right',
|
||||||
|
label: '',
|
||||||
|
name: 'tableActions',
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
title: t('ticketWeekly.delete'),
|
||||||
|
icon: 'delete',
|
||||||
|
action: (row) =>
|
||||||
|
openConfirmationModal(
|
||||||
|
t('You are going to delete this weekly ticket'),
|
||||||
|
t(
|
||||||
|
'This ticket will be removed from weekly tickets! Continue anyway?'
|
||||||
|
),
|
||||||
|
() => deleteWeekly(row.ticketFk)
|
||||||
|
),
|
||||||
|
isPrimary: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const redirectToTicketSummary = (ticketFk) =>
|
|
||||||
router.push({ name: 'TicketSummary', params: { id: ticketFk } });
|
|
||||||
|
|
||||||
const deleteWeekly = async (ticketFk) => {
|
const deleteWeekly = async (ticketFk) => {
|
||||||
try {
|
try {
|
||||||
await axios.delete(`TicketWeeklies/${ticketFk}`);
|
await axios.delete(`TicketWeeklies/${ticketFk}`);
|
||||||
notify(t('globals.dataSaved'), 'positive');
|
notify(t('globals.dataSaved'), 'positive');
|
||||||
const ticketIndex = store.data.findIndex((e) => e.ticketFk == ticketFk);
|
const ticketIndex = store.data.findIndex((e) => e.ticketFk == ticketFk);
|
||||||
store.data.splice(ticketIndex, 1);
|
store.data.splice(ticketIndex, 1);
|
||||||
|
location.reload();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error deleting weekly', err);
|
console.error('Error deleting weekly', err);
|
||||||
}
|
}
|
||||||
|
@ -176,147 +182,61 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
|
||||||
url="AgencyModes/isActive"
|
|
||||||
:filter="{ fields: ['id', 'name'], order: 'name' }"
|
|
||||||
auto-load
|
|
||||||
@on-fetch="(data) => (agencyModesOptions = data)"
|
|
||||||
/>
|
|
||||||
<VnSearchbar
|
<VnSearchbar
|
||||||
data-key="WeeklyTickets"
|
data-key="WeeklyTickets"
|
||||||
:label="t('weeklyTickets.search')"
|
:label="t('weeklyTickets.search')"
|
||||||
:info="t('weeklyTickets.searchInfo')"
|
:info="t('weeklyTickets.searchInfo')"
|
||||||
/>
|
/>
|
||||||
<VnSubToolbar>
|
<VnTable
|
||||||
<template #st-data>
|
ref="tableRef"
|
||||||
<TableVisibleColumns
|
data-key="WeeklyTickets"
|
||||||
:all-columns="allColumnNames"
|
url="TicketWeeklies/filter"
|
||||||
table-code="itemsIndex"
|
:columns="columns"
|
||||||
labels-traductions-path="weeklyTickets"
|
default-mode="table"
|
||||||
@on-config-saved="visibleColumns = [...$event, 'actions']"
|
:use-model="true"
|
||||||
|
:disable-option="{ card: true }"
|
||||||
|
auto-load
|
||||||
|
>
|
||||||
|
<template #column-ticketFk="{ row }">
|
||||||
|
<span class="link" @click.stop>
|
||||||
|
{{ row.ticketFk }}
|
||||||
|
<TicketDescriptorProxy :id="row.ticketFk" />
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
<template #column-weekDay="{ row }">
|
||||||
|
<VnSelect
|
||||||
|
:options="weekdays"
|
||||||
|
hide-selected
|
||||||
|
option-label="name"
|
||||||
|
option-value="id"
|
||||||
|
v-model="row.weekDay"
|
||||||
|
@update:model-value="onUpdate(row.ticketFk, 'weekDay', $event)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</VnSubToolbar>
|
<template #column-agencyModeFk="{ row }">
|
||||||
<QPage class="column items-center q-pa-md">
|
<VnSelect
|
||||||
<VnPaginate
|
url="AgencyModes/isActive"
|
||||||
ref="paginateRef"
|
:options="agencyModesOptions"
|
||||||
data-key="WeeklyTickets"
|
hide-selected
|
||||||
url="TicketWeeklies/filter"
|
option-label="name"
|
||||||
:order="['weekDay', 'ticketFk']"
|
option-value="id"
|
||||||
:limit="20"
|
v-model="row.agencyModeFk"
|
||||||
:expr-builder="exprBuilder"
|
@update:model-value="onUpdate(row.ticketFk, 'agencyModeFk', $event)"
|
||||||
:user-params="params"
|
/>
|
||||||
:offset="50"
|
</template>
|
||||||
auto-load
|
<template #column-clientFk="{ row }">
|
||||||
>
|
<span class="link" @click.stop>
|
||||||
<template #body="{ rows }">
|
{{ row.clientName }}
|
||||||
<QTable
|
<CustomerDescriptorProxy :id="row.clientFk" />
|
||||||
:rows="rows"
|
</span>
|
||||||
:columns="columns"
|
</template>
|
||||||
row-key="id"
|
<template #column-workerFk="{ row }">
|
||||||
:pagination="{ rowsPerPage: 0 }"
|
<span class="link" @click.stop>
|
||||||
class="full-width q-mt-md"
|
{{ row.userName }}
|
||||||
:visible-columns="visibleColumns"
|
<WorkerDescriptorProxy :id="row.workerFk" />
|
||||||
:no-data-label="t('globals.noResults')"
|
</span>
|
||||||
@row-click="(_, row) => redirectToTicketSummary(row.ticketFk)"
|
</template>
|
||||||
>
|
</VnTable>
|
||||||
<template #top-row="{ cols }">
|
|
||||||
<QTr>
|
|
||||||
<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-id="{ row }">
|
|
||||||
<QTd @click.stop>
|
|
||||||
<QBtn flat color="primary">
|
|
||||||
{{ row.ticketFk }}
|
|
||||||
<TicketDescriptorProxy :id="row.ticketFk" />
|
|
||||||
</QBtn>
|
|
||||||
</QTd>
|
|
||||||
</template>
|
|
||||||
<template #body-cell-salesperson="{ row }">
|
|
||||||
<QTd @click.stop>
|
|
||||||
<QBtn flat color="primary">
|
|
||||||
{{ row.userName }}
|
|
||||||
<WorkerDescriptorProxy :id="row.workerFk" />
|
|
||||||
</QBtn>
|
|
||||||
</QTd>
|
|
||||||
</template>
|
|
||||||
<template #body-cell-client="{ row }">
|
|
||||||
<QTd @click.stop>
|
|
||||||
<QBtn flat color="primary" dense>
|
|
||||||
{{ row.clientName }}
|
|
||||||
<CustomerDescriptorProxy :id="row.clientFk" />
|
|
||||||
</QBtn>
|
|
||||||
</QTd>
|
|
||||||
</template>
|
|
||||||
<template #body-cell-shipment="{ row }">
|
|
||||||
<QTd @click.stop>
|
|
||||||
<VnSelect
|
|
||||||
:options="weekdays"
|
|
||||||
hide-selected
|
|
||||||
option-label="name"
|
|
||||||
option-value="id"
|
|
||||||
v-model="row.weekDay"
|
|
||||||
@update:model-value="
|
|
||||||
onUpdate(row.ticketFk, 'weekDay', $event)
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
</QTd>
|
|
||||||
</template>
|
|
||||||
<template #body-cell-agency="{ row }">
|
|
||||||
<QTd @click.stop>
|
|
||||||
<VnSelect
|
|
||||||
:options="agencyModesOptions"
|
|
||||||
hide-selected
|
|
||||||
option-label="name"
|
|
||||||
option-value="id"
|
|
||||||
v-model="row.agencyModeFk"
|
|
||||||
@update:model-value="
|
|
||||||
onUpdate(row.ticketFk, 'agencyModeFk', $event)
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
</QTd>
|
|
||||||
</template>
|
|
||||||
<template #body-cell-actions="{ row }">
|
|
||||||
<QTd>
|
|
||||||
<QIcon
|
|
||||||
@click.stop="
|
|
||||||
openConfirmationModal(
|
|
||||||
t('You are going to delete this weekly ticket'),
|
|
||||||
t(
|
|
||||||
'This ticket will be removed from weekly tickets! Continue anyway?'
|
|
||||||
),
|
|
||||||
() => deleteWeekly(row.ticketFk)
|
|
||||||
)
|
|
||||||
"
|
|
||||||
class="q-ml-sm cursor-pointer"
|
|
||||||
color="primary"
|
|
||||||
name="delete"
|
|
||||||
size="sm"
|
|
||||||
>
|
|
||||||
<QTooltip>
|
|
||||||
{{ t('globals.delete') }}
|
|
||||||
</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
</QTd>
|
|
||||||
</template>
|
|
||||||
</QTable>
|
|
||||||
</template>
|
|
||||||
</VnPaginate>
|
|
||||||
</QPage>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<i18n>
|
<i18n>
|
||||||
|
|
|
@ -225,3 +225,14 @@ package:
|
||||||
added: Added
|
added: Added
|
||||||
addPackage: Add package
|
addPackage: Add package
|
||||||
removePackage: Remove package
|
removePackage: Remove package
|
||||||
|
ticketList:
|
||||||
|
id: Id
|
||||||
|
nickname: Nickname
|
||||||
|
state: State
|
||||||
|
shipped: Shipped
|
||||||
|
zone: Zone
|
||||||
|
salesPerson: Sales person
|
||||||
|
totalWithVat: Total with VAT
|
||||||
|
summary: Summary
|
||||||
|
client: Customer
|
||||||
|
createTicket: Create ticket
|
||||||
|
|
|
@ -228,3 +228,14 @@ ticketSaleTracking:
|
||||||
Search ticket: Buscar tickets
|
Search ticket: Buscar tickets
|
||||||
You can search by ticket id or alias: Puedes buscar por id o alias del ticket
|
You can search by ticket id or alias: Puedes buscar por id o alias del ticket
|
||||||
Select lines to see the options: Selecciona líneas para ver las opciones
|
Select lines to see the options: Selecciona líneas para ver las opciones
|
||||||
|
ticketList:
|
||||||
|
id: Id
|
||||||
|
nickname: Alias
|
||||||
|
state: Estado
|
||||||
|
shipped: F. Envío
|
||||||
|
zone: Zona
|
||||||
|
salesPerson: Comercial
|
||||||
|
totalWithVat: Total con IVA
|
||||||
|
summary: Resumen
|
||||||
|
client: Cliente
|
||||||
|
createTicket: Crear ticket
|
||||||
|
|
Loading…
Reference in New Issue