Merge branch 'dev' into e2e_monitor

This commit is contained in:
Javier Segarra 2025-03-28 01:32:52 +01:00
commit 269427e08c
16 changed files with 175 additions and 136 deletions

View File

@ -1,5 +1,5 @@
<script setup>
import { onMounted, ref } from 'vue';
import { onMounted, ref, computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { useState } from 'src/composables/useState';
import { useStateStore } from 'stores/useStateStore';
@ -18,6 +18,14 @@ const state = useState();
const user = state.getUser();
const appName = 'Lilium';
const pinnedModulesRef = ref();
const hostname = window.location.hostname;
const env = ref();
const getEnvironment = computed(() => {
env.value = hostname.split('-');
if (env.value.length <= 1) return;
return env.value[0];
});
onMounted(() => stateStore.setMounted());
const refresh = () => window.location.reload();
@ -49,6 +57,9 @@ const refresh = () => window.location.reload();
{{ t('globals.backToDashboard') }}
</QTooltip>
</QBtn>
<QBadge v-if="getEnvironment" color="primary" align="top">
{{ getEnvironment }}
</QBadge>
</RouterLink>
<VnBreadcrumbs v-if="$q.screen.gt.sm" />
<QSpinner

View File

@ -0,0 +1,53 @@
<script setup>
import { ref } from 'vue';
import VnSelect from './VnSelect.vue';
const stateBtnDropdownRef = ref();
const emit = defineEmits(['changeState']);
const $props = defineProps({
disable: {
type: Boolean,
default: null,
},
options: {
type: Array,
default: null,
},
optionLabel: {
type: String,
default: 'name',
},
optionValue: {
type: String,
default: 'id',
},
});
async function changeState(value) {
stateBtnDropdownRef.value?.hide();
emit('changeState', value);
}
</script>
<template>
<QBtnDropdown
ref="stateBtnDropdownRef"
color="black"
text-color="white"
:label="$t('globals.changeState')"
:disable="$props.disable"
>
<VnSelect
:options="$props.options"
:option-label="$props.optionLabel"
:option-value="$props.optionValue"
hide-selected
hide-dropdown-icon
focus-on-mount
@update:model-value="changeState"
>
</VnSelect>
</QBtnDropdown>
</template>

View File

@ -57,4 +57,5 @@ function handleClick() {
{{ capitalize(type).replace('-', '') }}
</QTooltip>
</QBtn>
{{ phoneNumber }}
</template>

View File

@ -43,7 +43,7 @@ const val = computed(() => $props.value);
<span style="color: var(--vn-label-color)">{{ label }}</span>
</slot>
</div>
<div class="value">
<div class="value" v-if="value || $slots.value">
<slot name="value">
<span :title="value" style="text-overflow: ellipsis">
{{ dash ? dashIfEmpty(value) : value }}

View File

@ -842,6 +842,7 @@ travel:
availabledHour: Availabled hour
thermographs: Thermographs
hb: HB
roundedCc: Rounded CC
basicData:
daysInForward: Automatic movement (Raid)
isRaid: Raid

View File

@ -925,6 +925,7 @@ travel:
availabled: F. Disponible
availabledHour: Hora Disponible
hb: HB
roundedCc: CC redondeado
basicData:
daysInForward: Desplazamiento automatico (redada)
isRaid: Redada

View File

@ -21,6 +21,7 @@ import CustomerDescriptorProxy from 'src/pages/Customer/Card/CustomerDescriptorP
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
import DepartmentDescriptorProxy from 'src/pages/Worker/Department/Card/DepartmentDescriptorProxy.vue';
import ClaimDescriptorMenu from './ClaimDescriptorMenu.vue';
import VnDropdown from 'src/components/common/VnDropdown.vue';
const route = useRoute();
const router = useRouter();
@ -36,7 +37,7 @@ const $props = defineProps({
});
const entityId = computed(() => $props.id || route.params.id);
const ClaimStates = ref([]);
const claimStates = ref([]);
const claimDmsRef = ref();
const claimDms = ref([]);
const multimediaDialog = ref();
@ -173,7 +174,9 @@ function openDialog(dmsId) {
}
async function changeState(value) {
await axios.patch(`Claims/updateClaim/${entityId.value}`, { claimStateFk: value });
await axios.patch(`Claims/updateClaim/${entityId.value}`, {
claimStateFk: value,
});
router.go(route.fullPath);
}
@ -183,13 +186,18 @@ function claimUrl(section) {
</script>
<template>
<FetchData
url="ClaimStates"
:filter="{ fields: ['id', 'description'] }"
@on-fetch="(data) => (claimStates = data)"
auto-load
/>
<FetchData
url="ClaimDms"
:filter="claimDmsFilter"
@on-fetch="(data) => setClaimDms(data)"
ref="claimDmsRef"
/>
<FetchData url="ClaimStates" @on-fetch="(data) => (ClaimStates = data)" auto-load />
<CardSummary
ref="summary"
:url="`Claims/${entityId}/getSummary`"
@ -201,34 +209,11 @@ function claimUrl(section) {
{{ claim.id }} - {{ claim.client.name }} ({{ claim.client.id }})
</template>
<template #header-right>
<QBtnDropdown
side
top
color="black"
text-color="white"
:label="t('globals.changeState')"
>
<QList>
<QVirtualScroll
class="max-container-height"
:items="ClaimStates"
separator
v-slot="{ item, index }"
>
<QItem
:key="index"
dense
clickable
v-close-popup
@click="changeState(item.id)"
>
<QItemSection>
<QItemLabel>{{ item.description }}</QItemLabel>
</QItemSection>
</QItem>
</QVirtualScroll>
</QList>
</QBtnDropdown>
<VnDropdown
:options="claimStates"
option-label="description"
@change-state="changeState"
/>
</template>
<template #menu="{ entity }">
<ClaimDescriptorMenu :claim="entity.claim" />

View File

@ -8,6 +8,6 @@ import filter from './EntryFilter.js';
data-key="Entry"
url="Entries"
:descriptor="EntryDescriptor"
:filter="filter"
:filter="{ ...filter, where: { id: $route.params.id } }"
/>
</template>

View File

@ -248,7 +248,6 @@ function getBadgeAttrs(row) {
let timeDiff = today - timeTicket;
if (timeDiff > 0) return { color: 'info', 'text-color': 'black' };
if (timeDiff < 0) return { color: 'warning', 'text-color': 'black' };
switch (row.entryTypeCode) {
case 'regularization':
@ -274,6 +273,7 @@ function getBadgeAttrs(row) {
default:
break;
}
if (timeDiff > 0) return { color: 'info', 'text-color': 'black' };
return { color: 'transparent' };
}

View File

@ -1,13 +1,14 @@
<script setup>
import { ref, computed } from 'vue';
import { useI18n } from 'vue-i18n';
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
import DepartmentDescriptorProxy from '../Worker/Department/Card/DepartmentDescriptorProxy.vue';
import CustomerDescriptorProxy from 'src/pages/Customer/Card/CustomerDescriptorProxy.vue';
import { toDateFormat } from 'src/filters/date.js';
import VnTable from 'src/components/VnTable/VnTable.vue';
import VnInputDate from 'src/components/common/VnInputDate.vue';
import VnRow from 'src/components/ui/VnRow.vue';
import { dateRange } from 'src/filters';
import useOpenURL from 'src/composables/useOpenURL';
const { t } = useI18n();
const dates = dateRange(Date.vnNew());
@ -94,6 +95,7 @@ const columns = computed(() => [
columnClass: 'no-padding',
},
]);
const openTab = (id) => useOpenURL(`#/customer/${id}/summary`);
</script>
<template>
@ -113,6 +115,8 @@ const columns = computed(() => [
:disable-option="{ card: true }"
dense
class="q-px-none"
:row-click="({ id }) => openTab(id)"
:row-ctrl-click="(_, { id }) => openTab(id)"
>
<template #top-left>
<VnRow>
@ -121,12 +125,16 @@ const columns = computed(() => [
</VnRow>
</template>
<template #column-departmentFk="{ row }">
<span class="link" :title="row.department" v-text="row.department" />
<WorkerDescriptorProxy :id="row.departmentFk" dense />
<span @click.stop.prevent class="link" :title="row.department">
{{ row.department }}
<DepartmentDescriptorProxy :id="row.departmentFk" dense
/></span>
</template>
<template #column-clientFk="{ row }">
<span class="link" :title="row.clientName" v-text="row.clientName" />
<CustomerDescriptorProxy :id="row.clientFk" />
<span @click.stop.prevent class="link" :title="row.clientName">
{{ row.clientName }}
<CustomerDescriptorProxy :id="row.clientFk" dense
/></span>
</template>
</VnTable>
</template>

View File

@ -10,6 +10,7 @@ import { toCurrency } from 'src/filters';
import { useVnConfirm } from 'composables/useVnConfirm';
import axios from 'axios';
import VnDateBadge from 'src/components/common/VnDateBadge.vue';
import useOpenURL from 'src/composables/useOpenURL';
const { t } = useI18n();
const { openConfirmationModal } = useVnConfirm();
@ -109,8 +110,7 @@ const removeOrders = async () => {
await table.value.reload();
};
const openTab = (id) =>
window.open(`#/order/${id}/summary`, '_blank', 'noopener, noreferrer');
const openTab = (id) => useOpenURL(`#/order/${id}/summary`);
</script>
<template>
<VnTable
@ -130,6 +130,7 @@ const openTab = (id) =>
}"
default-mode="table"
:row-click="({ id }) => openTab(id)"
:row-ctrl-click="(_, { id }) => openTab(id)"
v-model:selected="selectedRows"
:disable-option="{ card: true }"
>
@ -169,16 +170,16 @@ const openTab = (id) =>
</template>
<template #column-clientFk="{ row }">
<div @click.stop.prevent :title="row.clientName">
<span class="link" v-text="row.clientName" />
<CustomerDescriptorProxy :id="row.clientFk" />
</div>
<span class="link" @click.stop :title="row.clientName">
{{ row.clientName }}
<CustomerDescriptorProxy :id="row.clientFk" dense
/></span>
</template>
<template #column-departmentFk="{ row }">
<div @click.stop.prevent :title="row.departmentName">
<span class="link" v-text="row.departmentName" />
<DepartmentDescriptorProxy :id="row.departmentFk" dense />
</div>
<span class="link" @click.stop :title="row.departmentName">
{{ row.departmentName }}
<DepartmentDescriptorProxy :id="row.departmentFk" dense
/></span>
</template>
</VnTable>
</template>

View File

@ -405,22 +405,19 @@ const openTab = (id) => useOpenURL(`#/ticket/${id}/sale`);
<span :title="row.province" v-text="row.province" />
</template>
<template #column-state="{ row }">
<div @click.stop.prevent>
<div v-if="row.refFk">
<span class="link">{{ row.refFk }}</span>
<InvoiceOutDescriptorProxy :id="row.invoiceOutId" />
</div>
<QBadge
v-else
:color="stateColors[row.classColor] || 'transparent'"
:text-color="stateColors[row.classColor] ? 'black' : 'white'"
class="q-pa-sm"
style="font-size: 14px"
@click="openTab(row.id)"
>
{{ row.state }}
</QBadge>
<div v-if="row.refFk" @click.stop.prevent>
<span class="link">{{ row.refFk }}</span>
<InvoiceOutDescriptorProxy :id="row.invoiceOutId" />
</div>
<QBadge
v-else
:color="stateColors[row.classColor] || 'transparent'"
:text-color="stateColors[row.classColor] ? 'black' : 'white'"
class="q-pa-sm"
style="font-size: 14px"
>
{{ row.state }}
</QBadge>
</template>
<template #column-isFragile="{ row }">
<QIcon v-if="row.isFragile" name="local_bar" color="primary" size="sm">

View File

@ -21,6 +21,7 @@ import VnSelect from 'src/components/common/VnSelect.vue';
import VnToSummary from 'src/components/ui/VnToSummary.vue';
import TicketDescriptorMenu from './TicketDescriptorMenu.vue';
import TicketProblems from 'src/components/TicketProblems.vue';
import VnDropdown from 'src/components/common/VnDropdown.vue';
const route = useRoute();
const { notify } = useNotify();
@ -40,7 +41,7 @@ const ticket = computed(() => summary.value?.entity);
const editableStates = ref([]);
const ticketUrl = ref();
const grafanaUrl = 'https://grafana.verdnatura.es';
const stateBtnDropdownRef = ref();
const descriptorData = useArrayData('Ticket');
onMounted(async () => {
@ -67,7 +68,6 @@ function isEditable() {
}
async function changeState(value) {
stateBtnDropdownRef.value?.hide();
const formData = {
ticketFk: entityId.value,
code: value,
@ -113,25 +113,12 @@ onMounted(async () => {
</div>
</template>
<template #header-right>
<div>
<QBtnDropdown
ref="stateBtnDropdownRef"
color="black"
text-color="white"
:label="t('globals.changeState')"
:disable="!isEditable()"
>
<VnSelect
:options="editableStates"
hide-selected
option-label="name"
option-value="code"
hide-dropdown-icon
focus-on-mount
@update:model-value="changeState"
/>
</QBtnDropdown>
</div>
<VnDropdown
:disable="!isEditable()"
:options="editableStates"
option-value="code"
@change-state="changeState"
/>
</template>
<template #menu="{ entity }">
<TicketDescriptorMenu :ticket="entity" />
@ -229,27 +216,23 @@ onMounted(async () => {
:value="toDate(entity.landed)"
/>
<VnLv :label="t('globals.packages')" :value="entity.packages" />
<VnLv :value="entity.address.phone">
<template #label>
{{ t('ticket.summary.consigneePhone') }}
<VnLv :label="t('ticket.summary.consigneePhone')">
<template #value>
<VnLinkPhone :phone-number="entity.address.phone" />
</template>
</VnLv>
<VnLv :value="entity.address.mobile">
<template #label>
{{ t('ticket.summary.consigneeMobile') }}
<VnLv :label="t('ticket.summary.consigneeMobile')">
<template #value>
<VnLinkPhone :phone-number="entity.address.mobile" />
</template>
</VnLv>
<VnLv :value="entity.client.phone">
<template #label>
{{ t('ticket.summary.clientPhone') }}
<VnLv :label="t('ticket.summary.clientPhone')">
<template #value>
<VnLinkPhone :phone-number="entity.client.phone" />
</template>
</VnLv>
<VnLv :value="entity.client.mobile">
<template #label>
{{ t('ticket.summary.clientMobile') }}
<VnLv :label="t('ticket.summary.clientMobile')">
<template #value>
<VnLinkPhone :phone-number="entity.client.mobile" />
</template>
</VnLv>

View File

@ -89,6 +89,13 @@ const entriesTableColumns = computed(() => {
showValue: true,
},
{ label: 'CC', field: 'cc', name: 'cc', align: 'left', showValue: true },
{
label: t('travel.summary.roundedCc'),
field: 'cc',
name: 'roundedCc',
align: 'left',
showValue: true,
},
{
label: 'Pallet',
field: 'pallet',
@ -191,14 +198,15 @@ const entriesTotals = computed(() => {
freightValue: 0,
packageValue: 0,
cc: 0,
roundedCc: 0,
pallet: 0,
m3: 0,
};
entriesTableRows.value.forEach((row) => {
for (const key in totals) {
if (key === 'cc') {
totals[key] += Math.ceil(row[key] || 0);
if (key === 'roundedCc') {
totals['roundedCc'] += Math.ceil(row['cc'] || 0);
} else {
totals[key] += row[key] || 0;
}
@ -210,6 +218,7 @@ const entriesTotals = computed(() => {
freight: toCurrency(totals.freightValue),
packageValue: toCurrency(totals.packageValue),
cc: totals.cc.toFixed(2),
roundedCc: totals.roundedCc,
pallet: totals.pallet.toFixed(2),
m3: totals.m3.toFixed(2),
};
@ -374,6 +383,11 @@ onMounted(async () => {
</QBtn>
</QTd>
</template>
<template #body-cell-roundedCc="{ col, value }">
<QTd>
{{ Math.ceil(value) || 0 }}
</QTd>
</template>
<template #body-cell-observation="{ value }">
<QTd>
<QIcon name="insert_drive_file" color="primary" size="24px">
@ -390,6 +404,7 @@ onMounted(async () => {
<QTd class="text-bold">{{ entriesTotals.freight }}</QTd>
<QTd class="text-bold">{{ entriesTotals.packageValue }}</QTd>
<QTd class="text-bold">{{ entriesTotals.cc }}</QTd>
<QTd class="text-bold">{{ entriesTotals.roundedCc }}</QTd>
<QTd class="text-bold">{{ entriesTotals.pallet }}</QTd>
<QTd class="text-bold">{{ entriesTotals.m3 }}</QTd>
</template>

View File

@ -141,7 +141,6 @@ const columns = computed(() => [
label: 'id',
field: 'id',
name: 'id',
align: 'center',
showValue: true,
sortable: true,
},
@ -165,7 +164,7 @@ const columns = computed(() => [
label: t('globals.amount'),
name: 'invoiceAmount',
field: 'entries',
align: 'left',
align: 'right',
showValue: true,
sortable: true,
format: (value) =>
@ -190,7 +189,7 @@ const columns = computed(() => [
label: t('globals.packages'),
field: 'stickers',
name: 'stickers',
align: 'left',
align: 'right',
showValue: true,
sortable: true,
},
@ -198,7 +197,7 @@ const columns = computed(() => [
label: '%',
field: '',
name: 'percentage',
align: 'center',
align: 'right',
showValue: false,
sortable: true,
},
@ -214,7 +213,7 @@ const columns = computed(() => [
label: t('extraCommunity.physicKg'),
field: 'loadedKg',
name: 'loadedKg',
align: 'left',
align: 'right',
showValue: true,
sortable: true,
},
@ -222,7 +221,7 @@ const columns = computed(() => [
label: 'KG Vol.',
field: 'volumeKg',
name: 'volumeKg',
align: 'left',
align: 'right',
showValue: true,
sortable: true,
},
@ -277,7 +276,6 @@ async function getData() {
const onStoreDataChange = () => {
const newData = JSON.parse(JSON.stringify(arrayData.store.data)) || [];
rows.value = newData;
// el objetivo de esto es guardar una copia de los valores iniciales de todas las rows para corroborar si la data cambio antes de guardar los cambios
originalRowDataCopy.value = JSON.parse(JSON.stringify(newData));
};
@ -300,20 +298,17 @@ const openReportPdf = () => {
};
const saveFieldValue = async (val, field, index) => {
// Evitar la solicitud de guardado si el valor no ha cambiado
if (originalRowDataCopy.value[index][field] == val) return;
const id = rows.value[index].id;
const params = { [field]: val };
await axios.patch(`Travels/${id}`, params);
// Actualizar la copia de los datos originales con el nuevo valor
originalRowDataCopy.value[index][field] = val;
await arrayData.fetch({ append: false });
};
const stopEventPropagation = (event, col) => {
// Detener la propagación del evento de los siguientes elementos para evitar el click sobre la row que dispararía la función navigateToTravelId
if (!['ref', 'id', 'cargoSupplierNickname', 'kg'].includes(col.name)) return;
event.preventDefault();
event.stopPropagation();
@ -335,14 +330,12 @@ onMounted(async () => {
await getData();
});
// Handler del evento @dragstart (inicio del drag) y guarda información inicial
const handleDragStart = (event, rowIndex, entryIndex) => {
draggedRowIndex.value = rowIndex;
entryRowIndex.value = entryIndex;
event.dataTransfer.effectAllowed = 'move';
};
// Handler del evento @dragenter (cuando haces drag sobre une elemento y lo arrastras sobre un posible target de drop) y actualiza el targetIndex
const handleDragEnter = (_, targetIndex) => {
targetRowIndex.value = targetIndex;
};
@ -356,11 +349,8 @@ const saveRowDrop = async (targetRowIndex) => {
const moveRow = async (draggedRowIndex, targetRowIndex, entryIndex) => {
try {
if (draggedRowIndex === targetRowIndex) return;
// Remover entry de la row original
draggedEntry.value = rows.value[draggedRowIndex].entries.splice(entryIndex, 1)[0];
//Si la row de destino por alguna razón no tiene la propiedad entry la creamos
if (!rows.value[targetRowIndex].entries) rows.value[targetRowIndex].entries = [];
// Añadir entry a la row de destino
rows.value[targetRowIndex].entries.push(draggedEntry.value);
await saveRowDrop(targetRowIndex);
@ -370,13 +360,11 @@ const moveRow = async (draggedRowIndex, targetRowIndex, entryIndex) => {
}
};
// Handler de cuando haces un drop tanto dentro como fuera de la tabla para limpiar acciones y data
const handleDragEnd = () => {
stopScroll();
cleanDragAndDropData();
};
// Handler del evento @drop (cuando soltas el elemento draggeado sobre un target)
const handleDrop = () => {
if (
!draggedRowIndex.value &&
@ -399,7 +387,6 @@ const cleanDragAndDropData = () => {
const scrollInterval = ref(null);
const startScroll = (direction) => {
// Iniciar el scroll en la dirección especificada
if (!scrollInterval.value) {
scrollInterval.value = requestAnimationFrame(() => scroll(direction));
}
@ -413,14 +400,12 @@ const stopScroll = () => {
};
const scroll = (direction) => {
// Controlar el desplazamiento en la dirección especificada
const yOffset = direction === 'up' ? -2 : 2;
window.scrollBy(0, yOffset);
const windowHeight = window.innerHeight;
const documentHeight = document.body.offsetHeight;
// Verificar si se alcanzaron los límites de la ventana para detener el desplazamiento
if (
(direction === 'up' && window.scrollY > 0) ||
(direction === 'down' && windowHeight + window.scrollY < documentHeight)
@ -431,13 +416,10 @@ const scroll = (direction) => {
}
};
// Handler del scroll mientras se hace el drag de una row
const handleDragScroll = (event) => {
// Obtener la posición y dimensiones del cursor
const y = event.clientY;
const windowHeight = window.innerHeight;
// Verificar si el cursor está cerca del borde superior o inferior de la ventana
const nearTop = y < 150;
const nearBottom = y > windowHeight - 100;
@ -547,7 +529,7 @@ watch(route, () => {
? `${props.row.percentageKg}%`
: '-'
"
class="text-left q-py-xs q-px-sm"
class="text-right q-py-xs q-px-sm"
:color="getColor(props.row.percentageKg)"
/>
<span
@ -566,7 +548,6 @@ watch(route, () => {
]"
v-text="col.value"
/>
<!-- Main Row Descriptors -->
<TravelDescriptorProxy
v-if="col.name === 'id'"
:id="props.row.id"
@ -597,7 +578,7 @@ watch(route, () => {
index === props.row.entries.length - 1,
}"
>
<QTd>
<QTd class="text-right">
<QBtn dense flat class="link">{{ entry.id }} </QBtn>
<EntryDescriptorProxy :id="entry.id" />
</QTd>
@ -605,7 +586,7 @@ watch(route, () => {
<QBtn flat class="link" dense>{{ entry.supplierName }}</QBtn>
<SupplierDescriptorProxy :id="entry.supplierFk" />
</QTd>
<QTd>
<QTd class="text-center">
<QIcon
v-if="entry.isCustomInspectionRequired"
name="warning"
@ -615,21 +596,21 @@ watch(route, () => {
>
</QIcon>
</QTd>
<QTd>
<QTd class="text-right">
<span>{{ toCurrency(entry.invoiceAmount) }}</span>
</QTd>
<QTd>
<span>{{ entry.reference }}</span>
</QTd>
<QTd>
<QTd class="text-right">
<span>{{ entry.stickers }}</span>
</QTd>
<QTd />
<QTd></QTd>
<QTd>
<QTd class="text-right">
<span>{{ entry.loadedkg }}</span>
</QTd>
<QTd>
<QTd class="text-right">
<span>{{ entry.volumeKg }}</span>
</QTd>
<QTd />
@ -664,9 +645,6 @@ watch(route, () => {
:deep(.q-table) {
border-collapse: collapse;
th {
padding: 0;
}
tbody tr td {
&:nth-child(1) {
max-width: 65px;
@ -675,6 +653,10 @@ watch(route, () => {
padding: 0;
}
}
thead > tr > th {
padding: 3px;
color: var(--vn-label-color);
}
}
.q-td :deep(input) {

View File

@ -44,11 +44,12 @@ describe('EntryList', () => {
},
);
checkBadgeDate(
// fix on task https://redmine.verdnatura.es/issues/8638
/* checkBadgeDate(
'td[data-col-field="landed"] > div .bg-info',
(badgeDate, compareDate) => {
expect(badgeDate.getTime()).to.be.lessThan(compareDate.getTime());
},
);
); */
});
});