forked from verdnatura/salix-front
Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix-front into 6943-fixCustomer
This commit is contained in:
commit
3fe566796b
|
@ -8,15 +8,29 @@ const $props = defineProps({
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
find: {
|
find: {
|
||||||
type: String,
|
type: [String, Array],
|
||||||
default: null,
|
default: null,
|
||||||
|
description: 'search in row to add default options',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const options = ref([]);
|
const options = ref([]);
|
||||||
onBeforeMount(async () => {
|
onBeforeMount(async () => {
|
||||||
const { url } = useAttrs();
|
const { url, optionValue, optionLabel } = useAttrs();
|
||||||
const findBy = $props.find ?? url?.charAt(0)?.toLocaleLowerCase() + url?.slice(1, -1);
|
const findBy = $props.find ?? url?.charAt(0)?.toLocaleLowerCase() + url?.slice(1, -1);
|
||||||
if (findBy) options.value = [$props.row[findBy]];
|
if (!findBy || !$props.row) return;
|
||||||
|
// is array
|
||||||
|
if (Array.isArray(findBy)) {
|
||||||
|
const [id, name] = findBy;
|
||||||
|
if (!$props.row[id] || !$props.row[name]) return;
|
||||||
|
return (options.value = [
|
||||||
|
{
|
||||||
|
[optionValue ?? 'id']: $props.row[id],
|
||||||
|
[optionLabel ?? 'name']: $props.row[name],
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
// is string
|
||||||
|
if ($props.row[findBy]) options.value = [$props.row[findBy]];
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -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,311 @@
|
||||||
<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: 'stateFk',
|
||||||
|
label: t('ticketList.state'),
|
||||||
|
columnFilter: {
|
||||||
|
name: 'stateFk',
|
||||||
|
component: 'select',
|
||||||
|
attrs: {
|
||||||
|
url: 'States',
|
||||||
|
fields: ['id', 'name'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align: 'left',
|
||||||
|
name: 'id',
|
||||||
|
label: t('ticketList.id'),
|
||||||
|
chip: {
|
||||||
|
condition: () => true,
|
||||||
|
},
|
||||||
|
isId: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
align: 'left',
|
||||||
|
name: 'nickname',
|
||||||
|
label: t('ticketList.nickname'),
|
||||||
|
isTitle: true,
|
||||||
|
},
|
||||||
|
|
||||||
const from = Date.vnNew();
|
{
|
||||||
const to = Date.vnNew();
|
align: 'left',
|
||||||
to.setDate(to.getDate() + 1);
|
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 userParams = {
|
const onClientSelected = async (formData) => {
|
||||||
from: from.toISOString(),
|
await fetchClient(formData);
|
||||||
to: to.toISOString(),
|
await fetchAddresses(formData);
|
||||||
};
|
};
|
||||||
|
|
||||||
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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const getColor = (row) => {
|
||||||
|
return row?.classColor ? `bg-${row.classColor}` : 'bg-orange';
|
||||||
|
};
|
||||||
</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"
|
||||||
</template>
|
|
||||||
</RightMenu>
|
|
||||||
<QPage class="column items-center q-pa-md">
|
|
||||||
<div class="vn-card-list">
|
|
||||||
<VnPaginate
|
|
||||||
data-key="TicketList"
|
|
||||||
url="Tickets/filter"
|
url="Tickets/filter"
|
||||||
:user-params="userParams"
|
:create="{
|
||||||
order="id DESC"
|
urlCreate: 'Tickets/new',
|
||||||
|
title: t('ticketList.createTicket'),
|
||||||
|
onDataSaved: ({ id }) => tableRef.redirect(id),
|
||||||
|
formInitialData: {},
|
||||||
|
}"
|
||||||
|
default-mode="table"
|
||||||
|
:columns="columns"
|
||||||
|
redirect="ticket"
|
||||||
auto-load
|
auto-load
|
||||||
>
|
>
|
||||||
<template #body="{ rows }">
|
<template #more-create-dialog="{ data }">
|
||||||
<CardList
|
<VnRow>
|
||||||
v-for="row of rows"
|
<VnSelect
|
||||||
:key="row.id"
|
url="Clients"
|
||||||
:id="row.id"
|
:label="t('ticketList.client')"
|
||||||
:title="`${row.nickname}`"
|
v-model="data.clientId"
|
||||||
@click="navigate(row.id)"
|
:options="clientsOptions"
|
||||||
|
option-value="id"
|
||||||
|
option-label="name"
|
||||||
|
hide-selected
|
||||||
|
@update:model-value="(client) => onClientSelected(data)"
|
||||||
>
|
>
|
||||||
<template #list-items>
|
<template #option="scope">
|
||||||
<VnLv
|
<QItem v-bind="scope.itemProps">
|
||||||
:label="t('ticket.list.nickname')"
|
<QItemSection>
|
||||||
:value="row.nickname"
|
<QItemLabel>
|
||||||
/>
|
{{ scope.opt.name }}
|
||||||
<VnLv :label="t('ticket.list.state')">
|
</QItemLabel>
|
||||||
<template #value>
|
<QItemLabel caption>
|
||||||
<QBadge
|
{{ `#${scope.opt.id}` }}
|
||||||
text-color="black"
|
</QItemLabel>
|
||||||
:color="row.classColor ?? 'orange'"
|
</QItemSection>
|
||||||
class="q-ma-none"
|
</QItem>
|
||||||
dense
|
</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)"
|
||||||
>
|
>
|
||||||
{{ row.state }}
|
<template #option="scope">
|
||||||
</QBadge>
|
<QItem v-bind="scope.itemProps">
|
||||||
|
<QItemSection>
|
||||||
|
<QItemLabel>
|
||||||
|
{{ scope.opt.nickname }}
|
||||||
|
</QItemLabel>
|
||||||
|
<QItemLabel caption>
|
||||||
|
{{ `${scope.opt.street}, ${scope.opt.city}` }}
|
||||||
|
</QItemLabel>
|
||||||
|
</QItemSection>
|
||||||
|
</QItem>
|
||||||
</template>
|
</template>
|
||||||
</VnLv>
|
</VnSelect>
|
||||||
<VnLv
|
</VnRow>
|
||||||
:label="t('ticket.list.shipped')"
|
<VnRow class="row q-gutter-md q-mb-md">
|
||||||
:value="toDate(row.shipped)"
|
<div class="col">
|
||||||
|
<VnInputDate
|
||||||
|
placeholder="dd-mm-aaa"
|
||||||
|
:label="t('ticket.create.landed')"
|
||||||
|
v-model="data.landed"
|
||||||
|
@update:model-value="() => fetchAvailableAgencies(data)"
|
||||||
/>
|
/>
|
||||||
<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>
|
</div>
|
||||||
<QPageSticky :offset="[20, 20]">
|
</VnRow>
|
||||||
<QBtn :to="{ name: 'TicketCreate' }" fab icon="add" color="primary">
|
<VnRow class="row q-gutter-md q-mb-md">
|
||||||
<QTooltip>
|
<div class="col">
|
||||||
{{ t('New ticket') }}
|
<VnSelect
|
||||||
</QTooltip>
|
url="Warehouses"
|
||||||
</QBtn>
|
:label="t('ticket.create.warehouse')"
|
||||||
</QPageSticky>
|
v-model="data.warehouseId"
|
||||||
</QPage>
|
: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 #column-stateFk="{ row }">
|
||||||
|
<QChip :class="getColor(row)" dense square>
|
||||||
|
{{ row.state }}
|
||||||
|
</QChip>
|
||||||
|
</template>
|
||||||
|
</VnTable>
|
||||||
</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 VnSelectCache from 'src/components/common/VnSelectCache.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 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,132 @@ 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,
|
|
||||||
columnFilter: {
|
|
||||||
component: VnInput,
|
|
||||||
type: 'text',
|
|
||||||
filterValue: null,
|
|
||||||
event: getInputEvents,
|
|
||||||
attrs: {
|
attrs: {
|
||||||
dense: true,
|
url: 'Clients',
|
||||||
|
optionLabel: 'name',
|
||||||
|
optionValue: 'id',
|
||||||
|
isWhere: true,
|
||||||
},
|
},
|
||||||
|
columnField: {
|
||||||
|
component: null,
|
||||||
},
|
},
|
||||||
format: (val) => dashIfEmpty(val),
|
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: 'select',
|
||||||
type: 'text',
|
|
||||||
filterValue: null,
|
|
||||||
event: getInputEvents,
|
|
||||||
filterParamKey: 'nickName',
|
|
||||||
attrs: {
|
attrs: {
|
||||||
dense: true,
|
options: weekdays,
|
||||||
|
optionLabel: weekdays.name,
|
||||||
|
optionValue: weekdays.id,
|
||||||
},
|
},
|
||||||
|
inWhere: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '',
|
|
||||||
name: 'actions',
|
|
||||||
align: 'left',
|
align: 'left',
|
||||||
columnFilter: null,
|
label: t('weeklyTickets.agency'),
|
||||||
|
name: 'agencyModeFk',
|
||||||
|
cardVisible: true,
|
||||||
|
columnFilter: {
|
||||||
|
component: 'select',
|
||||||
|
alias: 'tw',
|
||||||
|
attrs: {
|
||||||
|
url: 'AgencyModes',
|
||||||
|
fields: ['id', 'name'],
|
||||||
|
},
|
||||||
|
inWhere: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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: 'id',
|
||||||
|
label: t('weeklyTickets.salesperson'),
|
||||||
|
columnFilter: {
|
||||||
|
component: 'select',
|
||||||
|
alias: 'u',
|
||||||
|
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 +183,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
|
|
||||||
:all-columns="allColumnNames"
|
|
||||||
table-code="itemsIndex"
|
|
||||||
labels-traductions-path="weeklyTickets"
|
|
||||||
@on-config-saved="visibleColumns = [...$event, 'actions']"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</VnSubToolbar>
|
|
||||||
<QPage class="column items-center q-pa-md">
|
|
||||||
<VnPaginate
|
|
||||||
ref="paginateRef"
|
|
||||||
data-key="WeeklyTickets"
|
data-key="WeeklyTickets"
|
||||||
url="TicketWeeklies/filter"
|
url="TicketWeeklies/filter"
|
||||||
:order="['weekDay', 'ticketFk']"
|
:columns="columns"
|
||||||
:limit="20"
|
default-mode="table"
|
||||||
:expr-builder="exprBuilder"
|
:use-model="true"
|
||||||
:user-params="params"
|
:disable-option="{ card: true }"
|
||||||
:offset="50"
|
|
||||||
auto-load
|
auto-load
|
||||||
>
|
>
|
||||||
<template #body="{ rows }">
|
<template #column-ticketFk="{ row }">
|
||||||
<QTable
|
<span class="link" @click.stop>
|
||||||
:rows="rows"
|
|
||||||
:columns="columns"
|
|
||||||
row-key="id"
|
|
||||||
:pagination="{ rowsPerPage: 0 }"
|
|
||||||
class="full-width q-mt-md"
|
|
||||||
:visible-columns="visibleColumns"
|
|
||||||
:no-data-label="t('globals.noResults')"
|
|
||||||
@row-click="(_, row) => redirectToTicketSummary(row.ticketFk)"
|
|
||||||
>
|
|
||||||
<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 }}
|
{{ row.ticketFk }}
|
||||||
<TicketDescriptorProxy :id="row.ticketFk" />
|
<TicketDescriptorProxy :id="row.ticketFk" />
|
||||||
</QBtn>
|
</span>
|
||||||
</QTd>
|
|
||||||
</template>
|
</template>
|
||||||
<template #body-cell-salesperson="{ row }">
|
<template #column-weekDay="{ 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
|
<VnSelect
|
||||||
:options="weekdays"
|
:options="weekdays"
|
||||||
hide-selected
|
hide-selected
|
||||||
option-label="name"
|
option-label="name"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
v-model="row.weekDay"
|
v-model="row.weekDay"
|
||||||
@update:model-value="
|
@update:model-value="onUpdate(row.ticketFk, 'weekDay', $event)"
|
||||||
onUpdate(row.ticketFk, 'weekDay', $event)
|
|
||||||
"
|
|
||||||
/>
|
/>
|
||||||
</QTd>
|
|
||||||
</template>
|
</template>
|
||||||
<template #body-cell-agency="{ row }">
|
<template #column-agencyModeFk="{ row }">
|
||||||
<QTd @click.stop>
|
<VnSelectCache
|
||||||
<VnSelect
|
url="AgencyModes/isActive"
|
||||||
:options="agencyModesOptions"
|
:row="row"
|
||||||
hide-selected
|
:find="['agencyModeFk', 'agencyModeName']"
|
||||||
option-label="name"
|
|
||||||
option-value="id"
|
|
||||||
v-model="row.agencyModeFk"
|
v-model="row.agencyModeFk"
|
||||||
@update:model-value="
|
@update:model-value="onUpdate(row.ticketFk, 'agencyModeFk', $event)"
|
||||||
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>
|
{{ console.log('row: ', row) }}
|
||||||
{{ t('globals.delete') }}
|
</VnSelectCache>
|
||||||
</QTooltip>
|
|
||||||
</QIcon>
|
|
||||||
</QTd>
|
|
||||||
</template>
|
</template>
|
||||||
</QTable>
|
<template #column-clientFk="{ row }">
|
||||||
|
<span class="link" @click.stop>
|
||||||
|
{{ row.clientName }}
|
||||||
|
<CustomerDescriptorProxy :id="row.clientFk" />
|
||||||
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</VnPaginate>
|
<template #column-id="{ row }">
|
||||||
</QPage>
|
<span class="link" @click.stop>
|
||||||
|
{{ row.userName }}
|
||||||
|
<WorkerDescriptorProxy :id="row.workerFk" />
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</VnTable>
|
||||||
</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