0
0
Fork 0

refs #6111 clean code fix changes

This commit is contained in:
Carlos Satorres 2024-04-12 10:27:30 +02:00
parent 2eaa184fe0
commit 40a3815e85
2 changed files with 14 additions and 109 deletions

View File

@ -91,6 +91,10 @@ export default {
log: 'Logs',
parkingList: 'Parkings list',
},
actions: 'Acciones',
started: 'Hora inicio',
finished: 'Hora fin',
volume: 'Volumen',
},
errors: {
statusUnauthorized: 'Access denied',

View File

@ -2,7 +2,7 @@
import VnPaginate from 'components/ui/VnPaginate.vue';
import { useStateStore } from 'stores/useStateStore';
import { useI18n } from 'vue-i18n';
import { computed, onMounted, reactive, onUnmounted, ref } from 'vue';
import { computed, onMounted, onUnmounted, ref } from 'vue';
import { dashIfEmpty, toHour } from 'src/filters';
import VnSelectFilter from 'components/common/VnSelectFilter.vue';
import FetchData from 'components/FetchData.vue';
@ -37,15 +37,6 @@ const columns = computed(() => [
field: (row) => row.id,
sortable: true,
align: 'center',
columnFilter: {
component: 'VnInput',
type: 'text',
filterValue: null,
event: getInputEvents,
attrs: {
dense: true,
},
},
},
{
name: 'worker',
@ -53,18 +44,6 @@ const columns = computed(() => [
field: (row) => row.workerUserName,
sortable: true,
align: 'left',
columnFilter: {
component: 'VnSelectFilter',
type: 'select',
filterValue: null,
event: getInputEvents,
attrs: {
options: workers,
'option-value': 'id',
'option-label': 'nickname',
dense: true,
},
},
},
{
name: 'agency',
@ -72,18 +51,6 @@ const columns = computed(() => [
field: (row) => row.agencyName,
sortable: true,
align: 'left',
columnFilter: {
component: 'VnSelectFilter',
type: 'select',
filterValue: null,
event: getInputEvents,
attrs: {
options: agencyList,
'option-value': 'id',
'option-label': 'name',
dense: true,
},
},
},
{
name: 'vehicle',
@ -91,18 +58,6 @@ const columns = computed(() => [
field: (row) => row.vehiclePlateNumber,
sortable: true,
align: 'left',
columnFilter: {
component: 'VnSelectFilter',
type: 'select',
filterValue: null,
event: getInputEvents,
attrs: {
options: vehicleList,
'option-value': 'id',
'option-label': 'numberPlate',
dense: true,
},
},
},
{
name: 'date',
@ -110,12 +65,6 @@ const columns = computed(() => [
field: (row) => row.created,
sortable: true,
align: 'left',
columnFilter: {
component: 'VnInputDate',
type: 'select',
filterValue: null,
event: getInputEvents,
},
},
{
name: 'volume',
@ -130,38 +79,20 @@ const columns = computed(() => [
field: (row) => row.description,
sortable: true,
align: 'left',
columnFilter: {
component: 'VnInput',
type: 'select',
filterValue: null,
event: getInputEvents,
},
},
{
name: 'hourStarted',
name: 'started',
label: t('hourStarted'),
field: (row) => toHour(row.started),
sortable: true,
align: 'left',
columnFilter: {
component: 'VnInputTime',
type: 'select',
filterValue: null,
event: getInputEvents,
},
},
{
name: 'hourFinished',
name: 'finished',
label: t('hourFinished'),
field: (row) => toHour(row.finished),
sortable: true,
align: 'left',
columnFilter: {
component: 'VnInputDate',
type: 'select',
filterValue: null,
event: getInputEvents,
},
},
{
name: 'actions',
@ -170,7 +101,6 @@ const columns = computed(() => [
align: 'right',
},
]);
const params = reactive({});
const arrayData = useArrayData('EntryLatestBuys', {
url: 'Buys/latestBuysFilter',
order: ['itemFk DESC'],
@ -190,23 +120,6 @@ const allColumnNames = ref([]);
const confirmationDialog = ref(false);
const startingDate = ref(null);
const getInputEvents = (col) => {
return col.columnFilter.type === 'select'
? { 'update:modelValue': () => applyColumnFilter(col) }
: {
'keyup.enter': () => applyColumnFilter(col),
};
};
const applyColumnFilter = async (col) => {
try {
params[col.field] = col.columnFilter.filterValue;
await arrayData.addFilter({ params });
} catch (err) {
console.error('Error applying column filter', err);
}
};
const cloneRoutes = () => {
axios.post('Routes/clone', {
created: startingDate.value,
@ -260,7 +173,6 @@ const openTicketsDialog = (id) => {
onMounted(async () => {
stateStore.rightDrawer = true;
allColumnNames.value = columns.value.map((col) => col.name);
console.log('les columnes', allColumnNames.value);
await arrayData.fetch({ append: false });
});
onUnmounted(() => (stateStore.rightDrawer = false));
@ -435,7 +347,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
</QTd>
</template>
<template #body-cell-vehicle="{ row }">
<QTd class="vehicle">
<QTd class="small-column">
<VnSelectFilter
:label="t('Vehicle')"
v-model="row.vehicleFk"
@ -452,7 +364,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
</QTd>
</template>
<template #body-cell-date="{ row }">
<QTd class="table-input-cell">
<QTd class="table-input-cell small-column">
<VnInputDate
v-model="row.created"
hide-bottom-space
@ -477,7 +389,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
</QTd>
</template>
<template #body-cell-started="{ row }">
<QTd class="table-input-cell">
<QTd class="table-input-cell small-column">
<VnInputTime
v-model="row.started"
:label="t('hourStarted')"
@ -490,7 +402,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
</QTd>
</template>
<template #body-cell-finished="{ row }">
<QTd class="table-input-cell">
<QTd class="table-input-cell small-column">
<VnInputTime
v-model="row.finished"
autofocus
@ -502,18 +414,6 @@ onUnmounted(() => (stateStore.rightDrawer = false));
@update:model-value="updateRoute(row)"
/>
</QTd>
<QTd class="table-input-cell">
<VnInputTime
v-model="row.finished"
autofocus
:label="t('Hour finished')"
:rules="validate('route.finished')"
:is-clearable="false"
hide-bottom-space
dense
@update:model-value="updateRoute(row)"
/>
</QTd>
</template>
<template #body-cell-actions="props">
<QTd :props="props">
@ -585,7 +485,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
gap: 12px;
}
.vehicle {
.small-column {
max-width: 150px;
}
@ -594,12 +494,13 @@ td:last-child {
background-color: var(--vn-section-color);
position: sticky;
right: 0;
z-index: 1;
}
</style>
<i18n>
en:
newRoute: New Route
hourStarted: Started hour
hourFinished: Finished hour
es:
ID: ID
Worker: Trabajador