refactor: refs #8197 adapt Ticket to VnCardMain
gitea/salix-front/pipeline/pr-beta This commit looks good Details

This commit is contained in:
Alex Moreno 2024-12-18 14:22:19 +01:00
parent 84ac4dd210
commit a940eb9861
3 changed files with 413 additions and 417 deletions

View File

@ -1,23 +1,7 @@
<script setup>
import { useI18n } from 'vue-i18n';
import VnCard from 'components/common/VnCard.vue';
import VnCardBeta from 'components/common/VnCardBeta.vue';
import TicketDescriptor from './TicketDescriptor.vue';
import TicketFilter from '../TicketFilter.vue';
const { t } = useI18n();
</script>
<template>
<VnCard
data-key="Ticket"
base-url="Tickets"
:filter-panel="TicketFilter"
:descriptor="TicketDescriptor"
search-data-key="TicketList"
:searchbar-props="{
url: 'Tickets/filter',
label: t('card.search'),
info: t('card.searchInfo'),
}"
/>
<VnCardBeta data-key="Ticket" base-url="Tickets" :descriptor="TicketDescriptor" />
</template>

View File

@ -8,13 +8,11 @@ import { useQuasar } from 'quasar';
import { toDate, toCurrency, dashIfEmpty } from 'src/filters/index';
import useNotify from 'src/composables/useNotify';
import TicketSummary from './Card/TicketSummary.vue';
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
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';
import RightMenu from 'src/components/common/RightMenu.vue';
import TicketFilter from './TicketFilter.vue';
import VnInput from 'src/components/common/VnInput.vue';
import FetchData from 'src/components/FetchData.vue';
@ -23,6 +21,7 @@ import ZoneDescriptorProxy from 'src/pages/Zone/Card/ZoneDescriptorProxy.vue';
import { toTimeFormat } from 'src/filters/date';
import InvoiceOutDescriptorProxy from 'src/pages/InvoiceOut/Card/InvoiceOutDescriptorProxy.vue';
import TicketProblems from 'src/components/TicketProblems.vue';
import VnSection from 'src/components/common/VnSection.vue';
const route = useRoute();
const router = useRouter();
@ -66,6 +65,7 @@ const dialogData = ref();
const companiesOptions = ref([]);
const accountingOptions = ref([]);
const amountToReturn = ref();
const dataKey = 'TicketList';
const columns = computed(() => [
{
@ -452,223 +452,228 @@ function setReference(data) {
@on-fetch="(data) => (accountingOptions = data)"
auto-load
/>
<VnSearchbar
data-key="TicketList"
:label="t('Search ticket')"
:info="t('You can search by ticket id or alias')"
data-cy="ticketListSearchBar"
/>
<RightMenu>
<template #right-panel>
<VnSection
:data-key="dataKey"
:columns="columns"
prefix="card"
:array-data-props="{
url: 'Tickets/filter',
order: ['shippedDate DESC', 'shippedHour ASC', 'zoneLanding ASC', 'id'],
exprBuilder,
}"
>
<template #rightMenu>
<TicketFilter data-key="TicketList" />
</template>
</RightMenu>
<VnTable
ref="tableRef"
data-key="TicketList"
url="Tickets/filter"
:create="{
urlCreate: 'Tickets/new',
title: t('ticketList.createTicket'),
onDataSaved: ({ id }) => tableRef.redirect(id),
formInitialData: { clientId: null },
}"
default-mode="table"
:order="['shippedDate DESC', 'shippedHour ASC', 'zoneLanding ASC', 'id']"
:columns="columns"
:user-params="userParams"
:right-search="false"
redirect="ticket"
v-model:selected="selectedRows"
:table="{
'row-key': 'id',
selection: 'multiple',
}"
data-cy="ticketListTable"
>
<template #column-statusIcons="{ row }">
<TicketProblems :row="row" />
</template>
<template #column-salesPersonFk="{ row }">
<span class="link" @click.stop>
{{ dashIfEmpty(row.userName) }}
<CustomerDescriptorProxy :id="row.salesPersonFk" />
</span>
</template>
<template #column-shippedDate="{ row }">
<span v-if="getDateColor(row.shipped)">
<QChip :class="getDateColor(row.shipped)" dense square>
{{ toDate(row.shippedDate) }}
</QChip>
</span>
</template>
<template #column-nickname="{ row }">
<span class="link" @click.stop>
{{ row.nickname }}
<CustomerDescriptorProxy :id="row.clientFk" />
</span>
</template>
<template #column-addressNickname="{ row }">
<span class="link" @click.stop>
{{ row.addressNickname }}
<CustomerDescriptorProxy :id="row.clientFk" />
</span>
</template>
<template #column-stateFk="{ row }">
<span v-if="row.refFk">
<span class="link" @click.stop>
{{ row.refFk }}
<InvoiceOutDescriptorProxy :id="row.invoiceOutId" />
</span>
</span>
<span v-else-if="getColor(row)">
<QChip :class="getColor(row)" dense square>
{{ row.state }}
</QChip>
</span>
<span v-else>
{{ row.state }}
</span>
</template>
<template #column-zoneFk="{ row }">
<span class="link" @click.stop>
{{ dashIfEmpty(row.zoneName) }}
<ZoneDescriptorProxy :id="row.zoneFk" />
</span>
</template>
<template #column-totalWithVat="{ row }">
<QChip
v-if="row.totalWithVat > 0 && row.totalWithVat < 50"
class="bg-warning"
dense
square
<template #body>
<VnTable
ref="tableRef"
:data-key="dataKey"
:create="{
urlCreate: 'Tickets/new',
title: t('ticketList.createTicket'),
onDataSaved: ({ id }) => tableRef.redirect(id),
formInitialData: { clientId: null },
}"
default-mode="table"
:columns="columns"
:user-params="userParams"
:right-search="false"
redirect="ticket"
v-model:selected="selectedRows"
:table="{
'row-key': 'id',
selection: 'multiple',
}"
data-cy="ticketListTable"
>
{{ row.totalWithVat }}
</QChip>
</template>
<template #more-create-dialog="{ data }">
<VnRow>
<VnSelect
url="Clients"
:fields="['id', 'name']"
:label="t('ticketList.client')"
v-model="data.clientId"
:options="clientsOptions"
option-value="id"
option-label="name"
hide-selected
required
@update:model-value="(client) => onClientSelected(data)"
:sort-by="'id ASC'"
>
<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
:label="t('basicData.address')"
v-model="data.addressId"
:options="addressesOptions"
option-value="id"
option-label="nickname"
hide-selected
map-options
required
:disable="!data.clientId"
:sort-by="'isActive DESC'"
@update:model-value="() => fetchAvailableAgencies(data)"
>
<template #option="scope">
<QItem
v-bind="scope.itemProps"
:class="{ disabled: !scope.opt.isActive }"
<template #column-statusIcons="{ row }">
<TicketProblems :row="row" />
</template>
<template #column-salesPersonFk="{ row }">
<span class="link" @click.stop>
{{ dashIfEmpty(row.userName) }}
<CustomerDescriptorProxy :id="row.salesPersonFk" />
</span>
</template>
<template #column-shippedDate="{ row }">
<span v-if="getDateColor(row.shipped)">
<QChip :class="getDateColor(row.shipped)" dense square>
{{ toDate(row.shippedDate) }}
</QChip>
</span>
</template>
<template #column-nickname="{ row }">
<span class="link" @click.stop>
{{ row.nickname }}
<CustomerDescriptorProxy :id="row.clientFk" />
</span>
</template>
<template #column-addressNickname="{ row }">
<span class="link" @click.stop>
{{ row.addressNickname }}
<CustomerDescriptorProxy :id="row.clientFk" />
</span>
</template>
<template #column-stateFk="{ row }">
<span v-if="row.refFk">
<span class="link" @click.stop>
{{ row.refFk }}
<InvoiceOutDescriptorProxy :id="row.invoiceOutId" />
</span>
</span>
<span v-else-if="getColor(row)">
<QChip :class="getColor(row)" dense square>
{{ row.state }}
</QChip>
</span>
<span v-else>
{{ row.state }}
</span>
</template>
<template #column-zoneFk="{ row }">
<span class="link" @click.stop>
{{ dashIfEmpty(row.zoneName) }}
<ZoneDescriptorProxy :id="row.zoneFk" />
</span>
</template>
<template #column-totalWithVat="{ row }">
<QChip
v-if="row.totalWithVat > 0 && row.totalWithVat < 50"
class="bg-warning"
dense
square
>
{{ row.totalWithVat }}
</QChip>
</template>
<template #more-create-dialog="{ data }">
<VnRow>
<VnSelect
url="Clients"
:fields="['id', 'name']"
:label="t('ticketList.client')"
v-model="data.clientId"
:options="clientsOptions"
option-value="id"
option-label="name"
hide-selected
required
@update:model-value="(client) => onClientSelected(data)"
:sort-by="'id ASC'"
>
<QItemSection style="min-width: min-content" avatar>
<QIcon
v-if="
scope.opt.isActive &&
selectedClient?.defaultAddressFk === scope.opt.id
"
size="sm"
color="grey"
name="star"
class="fill-icon"
/>
</QItemSection>
<QItemSection>
<QItemLabel
:class="{
'color-vn-label': !scope.opt?.isActive,
}"
<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
:label="t('basicData.address')"
v-model="data.addressId"
:options="addressesOptions"
option-value="id"
option-label="nickname"
hide-selected
map-options
required
:disable="!data.clientId"
:sort-by="'isActive DESC'"
@update:model-value="() => fetchAvailableAgencies(data)"
>
<template #option="scope">
<QItem
v-bind="scope.itemProps"
:class="{ disabled: !scope.opt.isActive }"
>
{{
`${
!scope.opt?.isActive
? t('basicData.inactive')
: ''
} `
}}
<span>
{{ scope.opt?.nickname }}:
{{ scope.opt?.street }}, {{ scope.opt?.city }}
</span>
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
</VnRow>
<VnRow>
<div class="col">
<VnInputDate
placeholder="dd-mm-aaa"
:label="t('globals.landed')"
v-model="data.landed"
@update:model-value="() => fetchAvailableAgencies(data)"
/>
</div>
</VnRow>
<VnRow>
<div class="col">
<VnSelect
url="Warehouses"
:sort-by="['name']"
:label="t('globals.warehouse')"
v-model="data.warehouseId"
:options="warehousesOptions"
option-value="id"
option-label="name"
hide-selected
required
@update:model-value="() => fetchAvailableAgencies(data)"
/>
</div>
</VnRow>
<VnRow>
<div class="col">
<VnSelect
:label="t('globals.agency')"
v-model="data.agencyModeId"
:options="agenciesOptions"
option-value="agencyModeFk"
option-label="agencyMode"
hide-selected
/>
</div>
</VnRow>
<QItemSection style="min-width: min-content" avatar>
<QIcon
v-if="
scope.opt.isActive &&
selectedClient?.defaultAddressFk ===
scope.opt.id
"
size="sm"
color="grey"
name="star"
class="fill-icon"
/>
</QItemSection>
<QItemSection>
<QItemLabel
:class="{
'color-vn-label': !scope.opt?.isActive,
}"
>
{{
`${
!scope.opt?.isActive
? t('basicData.inactive')
: ''
} `
}}
<span>
{{ scope.opt?.nickname }}:
{{ scope.opt?.street }},
{{ scope.opt?.city }}
</span>
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
</VnRow>
<VnRow>
<div class="col">
<VnInputDate
placeholder="dd-mm-aaa"
:label="t('globals.landed')"
v-model="data.landed"
@update:model-value="() => fetchAvailableAgencies(data)"
/>
</div>
</VnRow>
<VnRow>
<div class="col">
<VnSelect
url="Warehouses"
:sort-by="['name']"
:label="t('globals.warehouse')"
v-model="data.warehouseId"
:options="warehousesOptions"
option-value="id"
option-label="name"
hide-selected
required
@update:model-value="() => fetchAvailableAgencies(data)"
/>
</div>
</VnRow>
<VnRow>
<div class="col">
<VnSelect
:label="t('globals.agency')"
v-model="data.agencyModeId"
:options="agenciesOptions"
option-value="agencyModeFk"
option-label="agencyMode"
hide-selected
/>
</div>
</VnRow>
</template>
</VnTable>
</template>
</VnTable>
</VnSection>
<QPageSticky :offset="[20, 80]" style="z-index: 2">
<QBtn
v-if="hasSelectedRows"

View File

@ -1,19 +1,12 @@
import { RouterView } from 'vue-router';
export default {
name: 'Ticket',
path: '/ticket',
const ticketCard = {
name: 'TicketCard',
path: ':id',
component: () => import('src/pages/Ticket/Card/TicketCard.vue'),
redirect: { name: 'TicketSummary' },
meta: {
title: 'tickets',
icon: 'vn:ticket',
moduleName: 'Ticket',
keyBinding: 't',
},
component: RouterView,
redirect: { name: 'TicketMain' },
menus: {
main: ['TicketList', 'TicketAdvance', 'TicketWeekly', 'TicketFuture'],
card: [
menu: [
'TicketBasicData',
'TicketSale',
'TicketLog',
@ -32,21 +25,200 @@ export default {
'TicketSms',
],
},
children: [
{
path: 'summary',
name: 'TicketSummary',
meta: {
title: 'summary',
icon: 'launch',
},
component: () => import('src/pages/Ticket/Card/TicketSummary.vue'),
},
{
path: 'basic-data',
name: 'TicketBasicData',
meta: {
title: 'basicData',
icon: 'vn:settings',
},
component: () =>
import('src/pages/Ticket/Card/BasicData/TicketBasicDataView.vue'),
},
{
path: 'sale',
name: 'TicketSale',
meta: {
title: 'sale',
icon: 'vn:lines',
},
component: () => import('src/pages/Ticket/Card/TicketSale.vue'),
},
{
path: 'request',
name: 'TicketPurchaseRequest',
meta: {
title: 'purchaseRequest',
icon: 'vn:buyrequest',
},
component: () => import('src/pages/Ticket/Card/TicketPurchaseRequest.vue'),
},
{
path: 'tracking',
name: 'TicketTracking',
meta: {
title: 'tracking',
icon: 'vn:eye',
},
component: () => import('src/pages/Ticket/Card/TicketTracking.vue'),
},
{
path: 'log',
name: 'TicketLog',
meta: {
title: 'log',
icon: 'history',
},
component: () => import('src/pages/Ticket/Card/TicketLog.vue'),
},
{
path: 'observation',
name: 'TicketNotes',
meta: {
title: 'notes',
icon: 'vn:notes',
},
component: () => import('src/pages/Ticket/Card/TicketNotes.vue'),
},
{
path: 'picture',
name: 'TicketPicture',
meta: {
title: 'pictures',
icon: 'vn:photo',
},
component: () => import('src/pages/Ticket/Card/TicketPicture.vue'),
},
{
path: 'volume',
name: 'TicketVolume',
meta: {
title: 'volume',
icon: 'vn:volume',
},
component: () => import('src/pages/Ticket/Card/TicketVolume.vue'),
},
{
path: 'expedition',
name: 'TicketExpedition',
meta: {
title: 'expedition',
icon: 'vn:package',
},
component: () => import('src/pages/Ticket/Card/TicketExpedition.vue'),
},
{
path: 'service',
name: 'TicketService',
meta: {
title: 'services',
icon: 'vn:services',
},
component: () => import('src/pages/Ticket/Card/TicketService.vue'),
},
{
path: 'package',
name: 'TicketPackage',
meta: {
title: 'packages',
icon: 'vn:bucket',
},
component: () => import('src/pages/Ticket/Card/TicketPackage.vue'),
},
{
path: 'components',
name: 'TicketComponents',
meta: {
title: 'components',
icon: 'vn:components',
},
component: () => import('src/pages/Ticket/Card/TicketComponents.vue'),
},
{
path: 'sale-tracking',
name: 'TicketSaleTracking',
meta: {
title: 'saleTracking',
icon: 'assignment',
},
component: () => import('src/pages/Ticket/Card/TicketSaleTracking.vue'),
},
{
path: 'dms',
name: 'TicketDms',
meta: {
title: 'dms',
icon: 'cloud_upload',
},
component: () => import('src/pages/Ticket/Card/TicketDms.vue'),
},
{
path: 'boxing',
name: 'TicketBoxing',
meta: {
title: 'boxing',
icon: 'science',
},
component: () => import('src/pages/Ticket/Card/TicketBoxing.vue'),
},
{
path: 'sms',
name: 'TicketSms',
meta: {
title: 'sms',
icon: 'sms',
},
component: () => import('src/pages/Ticket/Card/TicketSms.vue'),
},
],
};
export default {
name: 'Ticket',
path: '/ticket',
meta: {
title: 'tickets',
icon: 'vn:ticket',
moduleName: 'Ticket',
keyBinding: 't',
menu: ['TicketList', 'TicketAdvance', 'TicketWeekly', 'TicketFuture'],
},
component: RouterView,
redirect: { name: 'TicketMain' },
children: [
{
name: 'TicketMain',
path: '',
component: () => import('src/components/common/VnSectionMain.vue'),
redirect: { name: 'TicketList' },
component: () => import('src/components/common/VnModule.vue'),
redirect: { name: 'TicketIndexMain' },
children: [
{
path: 'list',
name: 'TicketList',
meta: {
title: 'list',
icon: 'view_list',
},
path: '',
name: 'TicketIndexMain',
redirect: { name: 'TicketList' },
component: () => import('src/pages/Ticket/TicketList.vue'),
children: [
{
name: 'TicketList',
path: 'list',
meta: {
title: 'list',
icon: 'view_list',
},
},
ticketCard,
],
},
{
path: 'create',
@ -86,170 +258,5 @@ export default {
},
],
},
{
name: 'TicketCard',
path: ':id',
component: () => import('src/pages/Ticket/Card/TicketCard.vue'),
redirect: { name: 'TicketSummary' },
children: [
{
path: 'summary',
name: 'TicketSummary',
meta: {
title: 'summary',
icon: 'launch',
},
component: () => import('src/pages/Ticket/Card/TicketSummary.vue'),
},
{
path: 'basic-data',
name: 'TicketBasicData',
meta: {
title: 'basicData',
icon: 'vn:settings',
},
component: () =>
import('src/pages/Ticket/Card/BasicData/TicketBasicDataView.vue'),
},
{
path: 'sale',
name: 'TicketSale',
meta: {
title: 'sale',
icon: 'vn:lines',
},
component: () => import('src/pages/Ticket/Card/TicketSale.vue'),
},
{
path: 'request',
name: 'TicketPurchaseRequest',
meta: {
title: 'purchaseRequest',
icon: 'vn:buyrequest',
},
component: () =>
import('src/pages/Ticket/Card/TicketPurchaseRequest.vue'),
},
{
path: 'tracking',
name: 'TicketTracking',
meta: {
title: 'tracking',
icon: 'vn:eye',
},
component: () => import('src/pages/Ticket/Card/TicketTracking.vue'),
},
{
path: 'log',
name: 'TicketLog',
meta: {
title: 'log',
icon: 'history',
},
component: () => import('src/pages/Ticket/Card/TicketLog.vue'),
},
{
path: 'observation',
name: 'TicketNotes',
meta: {
title: 'notes',
icon: 'vn:notes',
},
component: () => import('src/pages/Ticket/Card/TicketNotes.vue'),
},
{
path: 'picture',
name: 'TicketPicture',
meta: {
title: 'pictures',
icon: 'vn:photo',
},
component: () => import('src/pages/Ticket/Card/TicketPicture.vue'),
},
{
path: 'volume',
name: 'TicketVolume',
meta: {
title: 'volume',
icon: 'vn:volume',
},
component: () => import('src/pages/Ticket/Card/TicketVolume.vue'),
},
{
path: 'expedition',
name: 'TicketExpedition',
meta: {
title: 'expedition',
icon: 'vn:package',
},
component: () => import('src/pages/Ticket/Card/TicketExpedition.vue'),
},
{
path: 'service',
name: 'TicketService',
meta: {
title: 'services',
icon: 'vn:services',
},
component: () => import('src/pages/Ticket/Card/TicketService.vue'),
},
{
path: 'package',
name: 'TicketPackage',
meta: {
title: 'packages',
icon: 'vn:bucket',
},
component: () => import('src/pages/Ticket/Card/TicketPackage.vue'),
},
{
path: 'components',
name: 'TicketComponents',
meta: {
title: 'components',
icon: 'vn:components',
},
component: () => import('src/pages/Ticket/Card/TicketComponents.vue'),
},
{
path: 'sale-tracking',
name: 'TicketSaleTracking',
meta: {
title: 'saleTracking',
icon: 'assignment',
},
component: () =>
import('src/pages/Ticket/Card/TicketSaleTracking.vue'),
},
{
path: 'dms',
name: 'TicketDms',
meta: {
title: 'dms',
icon: 'cloud_upload',
},
component: () => import('src/pages/Ticket/Card/TicketDms.vue'),
},
{
path: 'boxing',
name: 'TicketBoxing',
meta: {
title: 'boxing',
icon: 'science',
},
component: () => import('src/pages/Ticket/Card/TicketBoxing.vue'),
},
{
path: 'sms',
name: 'TicketSms',
meta: {
title: 'sms',
icon: 'sms',
},
component: () => import('src/pages/Ticket/Card/TicketSms.vue'),
},
],
},
],
};