perf: #6943 Create ticket from client
gitea/salix-front/pipeline/pr-master There was a failure building this commit
Details
gitea/salix-front/pipeline/pr-master There was a failure building this commit
Details
This commit is contained in:
parent
8e52bd0688
commit
87ba74bcfc
|
@ -19,7 +19,6 @@ import VnTitle from 'src/components/common/VnTitle.vue';
|
|||
import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
|
||||
import ZoneDescriptorProxy from 'src/pages/Zone/Card/ZoneDescriptorProxy.vue';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import TicketDescriptorMenu from './TicketDescriptorMenu.vue';
|
||||
import VnToSummary from 'src/components/ui/VnToSummary.vue';
|
||||
|
||||
const route = useRoute();
|
||||
|
@ -87,10 +86,6 @@ async function changeState(value) {
|
|||
function toTicketUrl(section) {
|
||||
return '#/ticket/' + entityId.value + '/' + section;
|
||||
}
|
||||
function isOnTicketCard() {
|
||||
const currentPath = route.path;
|
||||
return currentPath.startsWith('/ticket');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script setup>
|
||||
import axios from 'axios';
|
||||
import { computed, ref, onMounted } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useQuasar } from 'quasar';
|
||||
|
@ -24,6 +24,8 @@ import { toTimeFormat } from 'src/filters/date';
|
|||
import InvoiceOutDescriptorProxy from '../InvoiceOut/Card/InvoiceOutDescriptorProxy.vue';
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
const { t } = useI18n();
|
||||
const { viewSummary } = useSummaryDialog();
|
||||
const tableRef = ref();
|
||||
|
@ -40,16 +42,18 @@ from.setDate(from.getDate() - 7);
|
|||
const to = Date.vnNew();
|
||||
to.setHours(23, 59, 0, 0);
|
||||
to.setDate(to.getDate() + 1);
|
||||
|
||||
const userParams = {
|
||||
from: null,
|
||||
to: null,
|
||||
};
|
||||
// Método para inicializar las variables desde la query string
|
||||
onMounted(() => {
|
||||
initializeFromQuery();
|
||||
stateStore.rightDrawer = true;
|
||||
if (!route.query.createForm) return;
|
||||
onClientSelected(JSON.parse(route.query.createForm));
|
||||
});
|
||||
const initializeFromQuery = () => {
|
||||
const query = route.query.table ? JSON.parse(route.query.table) : {};
|
||||
|
||||
// Asigna los valores a las variables correspondientes
|
||||
from.value = query.from || from.toISOString();
|
||||
to.value = query.to || to.toISOString();
|
||||
Object.assign(userParams, { from, to });
|
||||
|
@ -206,13 +210,19 @@ const columns = computed(() => [
|
|||
{
|
||||
title: t('ticketList.summary'),
|
||||
icon: 'preview',
|
||||
isPrimary: true,
|
||||
action: (row) => viewSummary(row.id, TicketSummary),
|
||||
action: (row, evt) => {
|
||||
if (evt && evt.ctrlKey) {
|
||||
const url = router.resolve({
|
||||
params: { id: row.id },
|
||||
name: 'TicketCard',
|
||||
}).href;
|
||||
window.open(url, '_blank');
|
||||
} else viewSummary(row.id, TicketSummary);
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
function redirectToLines(id) {
|
||||
const url = `#/ticket/${id}/sale`;
|
||||
window.open(url, '_blank');
|
||||
|
@ -268,9 +278,8 @@ const fetchAddresses = async (formData) => {
|
|||
if (!formData.clientId) return;
|
||||
|
||||
const filter = {
|
||||
fields: ['nickname', 'street', 'city', 'id'],
|
||||
where: { isActive: true },
|
||||
order: 'nickname ASC',
|
||||
fields: ['nickname', 'street', 'city', 'id', 'isActive'],
|
||||
order: ['isDefaultAddress DESC', 'isActive DESC', 'nickname ASC'],
|
||||
};
|
||||
const params = { filter: JSON.stringify(filter) };
|
||||
const { data } = await axios.get(`Clients/${formData.clientId}/addresses`, {
|
||||
|
@ -302,11 +311,6 @@ const getDateColor = (date) => {
|
|||
if (comparation < 0) return 'bg-success';
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
initializeFromQuery();
|
||||
stateStore.rightDrawer = true;
|
||||
});
|
||||
|
||||
async function makeInvoice(ticket) {
|
||||
const ticketsIds = ticket.map((item) => item.id);
|
||||
const { data } = await axios.post(`Tickets/invoiceTicketsAndPdf`, { ticketsIds });
|
||||
|
@ -472,7 +476,7 @@ function setReference(data) {
|
|||
urlCreate: 'Tickets/new',
|
||||
title: t('ticketList.createTicket'),
|
||||
onDataSaved: ({ id }) => tableRef.redirect(id),
|
||||
formInitialData: {},
|
||||
formInitialData: { clientId: null },
|
||||
}"
|
||||
default-mode="table"
|
||||
:order="['shippedDate DESC', 'shippedHour ASC', 'zoneLanding ASC', 'id']"
|
||||
|
@ -616,6 +620,7 @@ function setReference(data) {
|
|||
option-value="id"
|
||||
option-label="name"
|
||||
hide-selected
|
||||
required
|
||||
@update:model-value="(client) => onClientSelected(data)"
|
||||
:sort-by="'id ASC'"
|
||||
>
|
||||
|
@ -635,7 +640,7 @@ function setReference(data) {
|
|||
</VnRow>
|
||||
<VnRow>
|
||||
<VnSelect
|
||||
url="Addresses"
|
||||
required
|
||||
:label="t('ticket.create.address')"
|
||||
v-model="data.addressId"
|
||||
:options="addressesOptions"
|
||||
|
@ -646,7 +651,22 @@ function setReference(data) {
|
|||
@update:model-value="() => fetchAvailableAgencies(data)"
|
||||
>
|
||||
<template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
<QItem
|
||||
v-bind="scope.itemProps"
|
||||
:class="{ disabled: !scope.opt.isActive }"
|
||||
>
|
||||
<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>
|
||||
{{ scope.opt.nickname }}
|
||||
|
@ -680,6 +700,7 @@ function setReference(data) {
|
|||
option-value="id"
|
||||
option-label="name"
|
||||
hide-selected
|
||||
required
|
||||
@update:model-value="() => fetchAvailableAgencies(data)"
|
||||
/>
|
||||
</div>
|
||||
|
@ -693,7 +714,6 @@ function setReference(data) {
|
|||
option-value="agencyModeFk"
|
||||
option-label="agencyMode"
|
||||
hide-selected
|
||||
:disable="!data.clientId || !data.landed || !data.warehouseId"
|
||||
/>
|
||||
</div>
|
||||
</VnRow>
|
||||
|
@ -829,7 +849,14 @@ function setReference(data) {
|
|||
</QTooltip>
|
||||
</QPageSticky>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.disabled,
|
||||
.disabled *,
|
||||
[disabled],
|
||||
[disabled] * {
|
||||
cursor: pointer !important;
|
||||
}
|
||||
</style>
|
||||
<i18n>
|
||||
es:
|
||||
Search ticket: Buscar ticket
|
||||
|
|
Loading…
Reference in New Issue