0
0
Fork 0

refactor: refs #6242 modified front to show ticket problems

This commit is contained in:
Jon Elias 2024-10-17 07:32:06 +02:00
parent fdf6fd2bba
commit f6051ae15c
7 changed files with 126 additions and 105 deletions

View File

@ -364,7 +364,7 @@ const openTab = (id) =>
<template #column-totalProblems="{ row }"> <template #column-totalProblems="{ row }">
<span> <span>
<QIcon <QIcon
v-if="row.isTaxDataChecked === 0" v-if="row.isTaxDataChecked === 1"
name="vn:no036" name="vn:no036"
color="primary" color="primary"
size="xs" size="xs"

View File

@ -1,8 +1,7 @@
<script setup> <script setup>
import { ref, computed, onMounted } from 'vue'; import { ref, computed } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import axios from 'axios';
import CustomerDescriptorProxy from 'pages/Customer/Card/CustomerDescriptorProxy.vue'; import CustomerDescriptorProxy from 'pages/Customer/Card/CustomerDescriptorProxy.vue';
import CardDescriptor from 'components/ui/CardDescriptor.vue'; import CardDescriptor from 'components/ui/CardDescriptor.vue';
import TicketDescriptorMenu from './TicketDescriptorMenu.vue'; import TicketDescriptorMenu from './TicketDescriptorMenu.vue';
@ -10,8 +9,7 @@ import VnLv from 'src/components/ui/VnLv.vue';
import useCardDescription from 'src/composables/useCardDescription'; import useCardDescription from 'src/composables/useCardDescription';
import VnUserLink from 'src/components/ui/VnUserLink.vue'; import VnUserLink from 'src/components/ui/VnUserLink.vue';
import { toDateTimeFormat } from 'src/filters/date'; import { toDateTimeFormat } from 'src/filters/date';
import FetchData from 'src/components/FetchData.vue';
onMounted(async () => await getTicketData());
const $props = defineProps({ const $props = defineProps({
id: { id: {
@ -27,8 +25,7 @@ const { t } = useI18n();
const entityId = computed(() => { const entityId = computed(() => {
return $props.id || route.params.id; return $props.id || route.params.id;
}); });
const sales = ref({}); const problems = ref({});
const rounding = ref();
const filter = { const filter = {
include: [ include: [
@ -107,37 +104,14 @@ const data = ref(useCardDescription());
function ticketFilter(ticket) { function ticketFilter(ticket) {
return JSON.stringify({ clientFk: ticket.clientFk }); return JSON.stringify({ clientFk: ticket.clientFk });
} }
const getTicketData = async () => {
const { data } = await axios.get(`tickets/filter`, {
params: { id: entityId.value },
});
rounding.value = data[0]?.hasRounding;
getSales();
};
const getSales = async () => {
const { data } = await axios.get(`Tickets/${route.params.id}/getSales`);
if (data) {
sales.value = data;
await sales.value.map((sale) => {
return {
...sale,
hasRounding: false,
};
});
await sales.value.forEach((sale) => {
if (rounding?.value?.includes(sale.concept)) {
sale.hasRounding = true;
}
});
}
};
</script> </script>
<template> <template>
<FetchData
:url="`Tickets/${entityId}/getTicketProblems`"
auto-load
@on-fetch="(data) => (problems = data)"
/>
<CardDescriptor <CardDescriptor
module="Ticket" module="Ticket"
:url="`Tickets/${entityId}`" :url="`Tickets/${entityId}`"
@ -145,7 +119,6 @@ const getSales = async () => {
:title="data.title" :title="data.title"
:subtitle="data.subtitle" :subtitle="data.subtitle"
data-key="ticketData" data-key="ticketData"
@on-fetch="getTicketData"
> >
<template #menu="{ entity }"> <template #menu="{ entity }">
<TicketDescriptorMenu :ticket="entity" /> <TicketDescriptorMenu :ticket="entity" />
@ -199,14 +172,6 @@ const getSales = async () => {
> >
<QTooltip>{{ t('Client inactive') }}</QTooltip> <QTooltip>{{ t('Client inactive') }}</QTooltip>
</QIcon> </QIcon>
<QIcon
v-if="entity.client.isFreezed == true"
name="vn:frozen"
size="xs"
color="primary"
>
<QTooltip>{{ t('Client Frozen') }}</QTooltip>
</QIcon>
<QIcon <QIcon
v-if="entity.problem.includes('hasRisk')" v-if="entity.problem.includes('hasRisk')"
name="vn:risk" name="vn:risk"
@ -231,9 +196,49 @@ const getSales = async () => {
> >
<QTooltip>{{ t('This ticket is deleted') }}</QTooltip> <QTooltip>{{ t('This ticket is deleted') }}</QTooltip>
</QIcon> </QIcon>
<div v-for="sale in sales" :key="sale.id"> <div v-for="problem in problems" :key="problem" class="q-gutter-x-xs">
<QIcon <QIcon
v-if="sale?.hasRounding" v-if="problem?.hasComponentLack"
color="primary"
name="vn:components"
size="xs"
>
<QTooltip>
{{ t('ticket.summary.hasComponentLack') }}
</QTooltip>
</QIcon>
<QIcon
v-show="problem?.risk"
name="vn:risk"
:color="problem?.hasHighRisk ? 'negative' : 'primary'"
size="xs"
>
<QTooltip
>{{ $t('salesTicketsTable.risk') }}: {{ row.risk }}</QTooltip
>
</QIcon>
<QIcon v-if="problem?.hasItemDelay" color="primary" size="xs">
<QTooltip>
{{ t('ticket.summary.hasItemDelay') }}
</QTooltip>
</QIcon>
<QIcon v-if="problem?.hasItemLost" color="primary" size="xs">
<QTooltip>
{{ t('ticket.summary.hasItemLost') }}
</QTooltip>
</QIcon>
<QIcon
name="vn:unavailable"
v-show="problem?.hasItemShortage"
color="primary"
size="xs"
>
<QTooltip>
{{ t('ticket.summary.itemShortage') }}
</QTooltip>
</QIcon>
<QIcon
v-if="problem?.hasRounding"
color="primary" color="primary"
name="sync_problem" name="sync_problem"
size="xs" size="xs"
@ -242,6 +247,32 @@ const getSales = async () => {
{{ t('ticketList.rounding') }} {{ t('ticketList.rounding') }}
</QTooltip> </QTooltip>
</QIcon> </QIcon>
<QIcon
v-if="problem?.hasTicketRequest"
color="primary"
name="vn:buyrequest"
size="xs"
>
<QTooltip>
{{ t('ticket.summary.hasTicketRequest') }}
</QTooltip>
</QIcon>
<QIcon
v-if="problem.isFreezed"
name="vn:frozen"
size="xs"
color="primary"
>
<QTooltip>{{ t('Client Frozen') }}</QTooltip>
</QIcon>
<QIcon
v-show="problem.isTaxDataChecked"
name="vn:no036"
size="xs"
color="primary"
>
<QTooltip>{{ t('Client not checked') }}</QTooltip>
</QIcon>
</div> </div>
</QCardActions> </QCardActions>
</template> </template>

View File

@ -50,17 +50,12 @@ const transfer = ref({
sales: [], sales: [],
}); });
const tableRef = ref([]); const tableRef = ref([]);
const roundingName = ref();
watch( watch(
() => route.params.id, () => route.params.id,
async () => await getSales() async () => await getSales()
); );
onMounted(async () => {
getTicketData();
});
const columns = computed(() => [ const columns = computed(() => [
{ {
align: 'left', align: 'left',
@ -162,19 +157,8 @@ const getConfig = async () => {
}; };
const onSalesFetched = (salesData) => { const onSalesFetched = (salesData) => {
sales.value = salesData.map((sale) => { sales.value = salesData;
return { for (let sale of salesData) sale.amount = getSaleTotal(sale);
...sale,
amount: getSaleTotal(sale),
hasRounding: false,
};
});
sales.value.forEach((sale) => {
if (roundingName?.value?.includes(sale.concept)) {
sale.hasRounding = true;
}
});
}; };
const getSales = async () => { const getSales = async () => {
@ -195,14 +179,6 @@ const getSaleTotal = (sale) => {
return price - discount; return price - discount;
}; };
const getTicketData = async () => {
const { data } = await axios.get(`tickets/filter`, {
params: { id: route.params.id },
});
roundingName.value = data[0]?.hasRounding;
};
const resetChanges = async () => { const resetChanges = async () => {
arrayData.fetch({ append: false }); arrayData.fetch({ append: false });
getSales(); getSales();
@ -635,7 +611,7 @@ watch(
<VnTable <VnTable
ref="tableRef" ref="tableRef"
data-key="TicketSales" data-key="TicketSales"
:data="sales" :url="`Tickets/${route.params.id}/getSales`"
:columns="columns" :columns="columns"
v-model:selected="selectedRows" v-model:selected="selectedRows"
:bottom="true" :bottom="true"
@ -658,7 +634,6 @@ watch(
:default-reset="false" :default-reset="false"
:default-save="false" :default-save="false"
:disabled-attr="isTicketEditable" :disabled-attr="isTicketEditable"
@request-success="getSales"
> >
<template #column-statusIcons="{ row }"> <template #column-statusIcons="{ row }">
<router-link <router-link
@ -699,7 +674,7 @@ watch(
size="xs" size="xs"
> >
<QTooltip> <QTooltip>
{{ t('ticketSale.hasComponentLack') }} {{ t('ticket.summary.hasComponentLack') }}
</QTooltip> </QTooltip>
</QIcon> </QIcon>
<QIcon v-if="row.hasRounding" color="primary" name="sync_problem" size="xs"> <QIcon v-if="row.hasRounding" color="primary" name="sync_problem" size="xs">
@ -707,6 +682,16 @@ watch(
{{ t('ticketList.rounding') }} {{ t('ticketList.rounding') }}
</QTooltip> </QTooltip>
</QIcon> </QIcon>
<QIcon v-if="row.hasItemLost" color="primary" size="xs">
<QTooltip>
{{ t('ticketList.itemLost') }}
</QTooltip>
</QIcon>
<QIcon v-if="row.hasItemDelay" color="primary" size="xs">
<QTooltip>
{{ t('ticketList.itemDelay') }}
</QTooltip>
</QIcon>
</template> </template>
<template #column-image="{ row }"> <template #column-image="{ row }">
<div class="image-wrapper"> <div class="image-wrapper">

View File

@ -38,11 +38,9 @@ const ticket = computed(() => summaryRef.value?.entity);
const editableStates = ref([]); const editableStates = ref([]);
const ticketUrl = ref(); const ticketUrl = ref();
const grafanaUrl = 'https://grafana.verdnatura.es'; const grafanaUrl = 'https://grafana.verdnatura.es';
const roundingName = ref();
onMounted(async () => { onMounted(async () => {
ticketUrl.value = (await getUrl('ticket/')) + entityId.value + '/'; ticketUrl.value = (await getUrl('ticket/')) + entityId.value + '/';
getTicketData();
}); });
function formattedAddress() { function formattedAddress() {
@ -103,27 +101,6 @@ function getNoteValue(description) {
function toTicketUrl(section) { function toTicketUrl(section) {
return '#/ticket/' + entityId.value + '/' + section; return '#/ticket/' + entityId.value + '/' + section;
} }
const getTicketData = async () => {
const { data } = await axios.get(`tickets/filter`, {
params: { id: entityId.value },
});
if (data) {
roundingName.value = data[0]?.hasRounding;
ticket.value.sales.map((sale) => {
return {
...sale,
hasRounding: false,
};
});
ticket.value.sales.forEach((sale) => {
if (roundingName?.value?.includes(sale.concept)) {
sale.hasRounding = true;
}
});
}
};
</script> </script>
<template> <template>
@ -431,7 +408,7 @@ const getTicketData = async () => {
</QTooltip> </QTooltip>
</QIcon> </QIcon>
<QIcon <QIcon
v-if="props.row.hasRounding" v-show="props.row.hasRounding"
color="primary" color="primary"
name="sync_problem" name="sync_problem"
size="xs" size="xs"
@ -440,6 +417,24 @@ const getTicketData = async () => {
{{ t('ticketList.rounding') }} {{ t('ticketList.rounding') }}
</QTooltip> </QTooltip>
</QIcon> </QIcon>
<QIcon
v-show="props.row.hasItemLost"
color="primary"
size="xs"
>
<QTooltip>
{{ t('ticketList.itemLost') }}
</QTooltip>
</QIcon>
<QIcon
v-show="props.row.hasItemDelay"
color="primary"
size="xs"
>
<QTooltip>
{{ t('ticketList.itemDelay') }}
</QTooltip>
</QIcon>
</QTd> </QTd>
<QTd> <QTd>
<QBtn class="link" flat> <QBtn class="link" flat>

View File

@ -487,13 +487,13 @@ function setReference(data) {
<template #column-statusIcons="{ row }"> <template #column-statusIcons="{ row }">
<div class="q-gutter-x-xs"> <div class="q-gutter-x-xs">
<QIcon <QIcon
v-if="row.isTaxDataChecked === 0" v-if="row.isTaxDataChecked === 1"
color="primary" color="primary"
name="vn:no036" name="vn:no036"
size="xs" size="xs"
> >
<QTooltip> <QTooltip>
{{ t('No verified data') }} {{ t('ticketList.noVerifiedData') }}
</QTooltip> </QTooltip>
</QIcon> </QIcon>
<QIcon <QIcon
@ -503,7 +503,7 @@ function setReference(data) {
size="xs" size="xs"
> >
<QTooltip> <QTooltip>
{{ t('Purchase request') }} {{ t('ticketList.purchaseRequest') }}
</QTooltip> </QTooltip>
</QIcon> </QIcon>
<QIcon <QIcon
@ -513,12 +513,12 @@ function setReference(data) {
size="xs" size="xs"
> >
<QTooltip> <QTooltip>
{{ t('Not visible') }} {{ t('ticketList.notVisible') }}
</QTooltip> </QTooltip>
</QIcon> </QIcon>
<QIcon v-if="row.isFreezed" color="primary" name="vn:frozen" size="xs"> <QIcon v-if="row.isFreezed" color="primary" name="vn:frozen" size="xs">
<QTooltip> <QTooltip>
{{ t('Client frozen') }} {{ t('ticketList.clientFrozen') }}
</QTooltip> </QTooltip>
</QIcon> </QIcon>
<QIcon v-if="row.risk" color="primary" name="vn:risk" size="xs"> <QIcon v-if="row.risk" color="primary" name="vn:risk" size="xs">
@ -531,7 +531,7 @@ function setReference(data) {
size="xs" size="xs"
> >
<QTooltip> <QTooltip>
{{ t('Component lack') }} {{ t('ticketList.componentLack') }}
</QTooltip> </QTooltip>
</QIcon> </QIcon>
<QIcon <QIcon

View File

@ -273,3 +273,8 @@ ticketList:
addressNickname: Address nickname addressNickname: Address nickname
ref: Reference ref: Reference
rounding: Rounding rounding: Rounding
noVerifiedData: No verified data
purchaseRequest: Purchase request
notVisible: Not visible
clientFrozen: Client frozen
componentLack: Component lack

View File

@ -276,3 +276,8 @@ ticketList:
addressNickname: Alias consignatario addressNickname: Alias consignatario
ref: Referencia ref: Referencia
rounding: Redondeo rounding: Redondeo
noVerifiedData: Sin datos comprobados
purchaseRequest: Petición de compra
notVisible: No visible
clientFrozen: Cliente congelado
componentLack: Faltan componentes