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

View File

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

View File

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