Merge pull request '#8664 - refactorCmrList' (!1501) from 8664-refactorCmrList into dev
gitea/salix-front/pipeline/head This commit looks good Details

Reviewed-on: #1501
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
Jose Antonio Tubau 2025-03-11 07:40:38 +00:00
commit 3aba6cf3ea
3 changed files with 74 additions and 39 deletions

View File

@ -2,28 +2,38 @@
import { onBeforeMount, onMounted, computed, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { Notify } from 'quasar';
import { useRoute } from 'vue-router';
import { useSession } from 'src/composables/useSession';
import { toDateHourMin } from 'filters/index';
import { useStateStore } from 'src/stores/useStateStore';
import axios from 'axios';
import TicketDescriptorProxy from 'pages/Ticket/Card/TicketDescriptorProxy.vue';
import CustomerDescriptorProxy from 'pages/Customer/Card/CustomerDescriptorProxy.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import VnTable from 'components/VnTable/VnTable.vue';
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
const route = useRoute();
const { t } = useI18n();
const { getTokenMultimedia } = useSession();
const token = getTokenMultimedia();
const state = useStateStore();
const warehouses = ref([]);
const selectedRows = ref([]);
const dataKey = 'CmrList';
const shipped = Date.vnNew();
shipped.setHours(0, 0, 0, 0);
shipped.setDate(shipped.getDate() - 1);
const userParams = {
shipped: null,
};
const columns = computed(() => [
{
align: 'left',
name: 'cmrFk',
label: t('route.cmr.list.cmrFk'),
label: t('route.cmr.params.cmrFk'),
chip: {
condition: () => true,
},
@ -32,62 +42,67 @@ const columns = computed(() => [
{
align: 'center',
name: 'hasCmrDms',
label: t('route.cmr.list.hasCmrDms'),
label: t('route.cmr.params.hasCmrDms'),
component: 'checkbox',
cardVisible: true,
},
{
align: 'left',
label: t('route.cmr.list.ticketFk'),
label: t('route.cmr.params.ticketFk'),
name: 'ticketFk',
},
{
align: 'left',
label: t('route.cmr.list.routeFk'),
label: t('route.cmr.params.routeFk'),
name: 'routeFk',
},
{
align: 'left',
label: t('route.cmr.list.clientFk'),
label: t('route.cmr.params.clientFk'),
name: 'clientFk',
},
{
align: 'right',
label: t('route.cmr.list.country'),
label: t('route.cmr.params.countryFk'),
name: 'countryFk',
cardVisible: true,
component: 'select',
attrs: {
url: 'countries',
fields: ['id', 'name'],
optionLabel: 'name',
optionValue: 'id',
},
columnFilter: {
inWhere: true,
component: 'select',
name: 'countryFk',
attrs: {
url: 'countries',
fields: ['id', 'name'],
},
},
format: ({ countryName }) => countryName,
},
{
align: 'right',
label: t('route.cmr.list.shipped'),
label: t('route.cmr.params.shipped'),
name: 'shipped',
cardVisible: true,
columnFilter: {
component: 'date',
inWhere: true,
},
component: 'date',
format: ({ shipped }) => toDateHourMin(shipped),
},
{
align: 'right',
label: t('route.cmr.params.warehouseFk'),
name: 'warehouseFk',
label: t('globals.warehouse'),
columnFilter: {
component: 'select',
},
component: 'select',
attrs: {
options: warehouses.value,
url: 'warehouses',
fields: ['id', 'name'],
},
columnFilter: {
inWhere: true,
name: 'warehouseFk',
attrs: {
url: 'warehouses',
fields: ['id', 'name'],
},
},
format: ({ warehouseName }) => warehouseName,
},
@ -96,7 +111,7 @@ const columns = computed(() => [
name: 'tableActions',
actions: [
{
title: t('Ver cmr'),
title: t('route.cmr.params.viewCmr'),
icon: 'visibility',
isPrimary: true,
action: (row) => window.open(getCmrUrl(row?.cmrFk), '_blank'),
@ -105,13 +120,17 @@ const columns = computed(() => [
},
]);
onBeforeMount(async () => {
const { data } = await axios.get('Warehouses');
warehouses.value = data;
onBeforeMount(() => {
initializeFromQuery();
});
onMounted(() => (state.rightDrawer = true));
const initializeFromQuery = () => {
const query = route.query.table ? JSON.parse(route.query.table) : {};
shipped.value = query.shipped || shipped.toISOString();
Object.assign(userParams, { shipped });
};
function getApiUrl() {
return new URL(window.location).origin;
}
@ -133,6 +152,11 @@ function downloadPdfs() {
}
</script>
<template>
<VnSearchbar
:data-key
:label="t('route.cmr.search')"
:info="t('route.cmr.searchInfo')"
/>
<VnSubToolbar>
<template #st-actions>
<QBtn
@ -142,16 +166,16 @@ function downloadPdfs() {
:disable="!selectedRows?.length"
@click="downloadPdfs"
>
<QTooltip>{{ t('route.cmr.list.downloadCmrs') }}</QTooltip>
<QTooltip>{{ t('route.cmr.params.downloadCmrs') }}</QTooltip>
</QBtn>
</template>
</VnSubToolbar>
<VnTable
ref="tableRef"
data-key="CmrList"
:data-key
url="Cmrs/filter"
:columns="columns"
:right-search="true"
:user-params="userParams"
default-mode="table"
v-model:selected="selectedRows"
table-height="85vh"

View File

@ -3,16 +3,19 @@ route:
search: Search roadmap
searchInfo: You can search by roadmap reference
params:
id: Id
name: Name
etd: ETD
tractorPlate: Plate
price: Price
observations: Observations
id: ID
name: Name
cmrFk: CMR id
hasCmrDms: Attached in gestdoc
ticketFk: Ticketd id
routeFk: Route id
clientFk: Client id
countryFk: Country
warehouseFk: Warehouse
shipped: Shipped
agencyAgreement: Agency agreement
agencyModeName: Agency route
@ -42,7 +45,9 @@ route:
search: Search route
searchInfo: You can search by route reference
cmr:
list:
search: Search Cmr
searchInfo: You can search Cmr by Id
params:
results: results
cmrFk: CMR id
hasCmrDms: Attached in gestdoc
@ -50,8 +55,10 @@ route:
'false': 'No'
ticketFk: Ticketd id
routeFk: Route id
country: Country
countryFk: Country
clientFk: Client id
warehouseFk: Warehouse
shipped: Preparation date
viewCmr: View CMR
downloadCmrs: Download CMRs
downloadCmrs: Download CMRs
search: General search

View File

@ -3,8 +3,6 @@ route:
search: Buscar troncales
searchInfo: Puedes buscar por referencia del troncal
params:
agencyModeName: Agencia Ruta
agencyAgreement: Agencia Acuerdo
id: Id
name: Troncal
etd: ETD
@ -13,9 +11,15 @@ route:
observations: Observaciones
cmrFk: Id CMR
hasCmrDms: Gestdoc
search: Búsqueda general
ticketFk: Id ticket
routeFK: Id ruta
routeFk: Id ruta
clientFk: Id cliente
countryFk: Pais
warehouseFk: Almacén
shipped: Fecha preparación
agencyModeName: Agencia Ruta
agencyAgreement: Agencia Acuerdo
Worker: Trabajador
Agency: Agencia
Vehicle: Vehículo
@ -55,4 +59,4 @@ route:
clientFk: Id cliente
shipped: Fecha preparación
viewCmr: Ver CMR
downloadCmrs: Descargar CMRs
downloadCmrs: Descargar CMRs