0
0
Fork 0

Merge branch 'dev' into 6943-fixCustomer

This commit is contained in:
Javier Segarra 2024-07-23 18:44:08 +00:00
commit 2c0b215023
8 changed files with 178 additions and 53 deletions

View File

@ -37,6 +37,10 @@ const $props = defineProps({
type: [Function, Boolean], type: [Function, Boolean],
default: null, default: null,
}, },
rowCtrlClick: {
type: [Function, Boolean],
default: null,
},
redirect: { redirect: {
type: String, type: String,
default: null, default: null,
@ -174,13 +178,17 @@ function splitColumns(columns) {
}; };
for (const col of columns) { for (const col of columns) {
if (col.name == 'tableActions') splittedColumns.value.actions = col; if (col.name == 'tableActions') {
col.orderBy = false;
splittedColumns.value.actions = col;
}
if (col.chip) splittedColumns.value.chips.push(col); if (col.chip) splittedColumns.value.chips.push(col);
if (col.isTitle) splittedColumns.value.title = col; if (col.isTitle) splittedColumns.value.title = col;
if (col.create) splittedColumns.value.create.push(col); if (col.create) splittedColumns.value.create.push(col);
if (col.cardVisible) splittedColumns.value.cardVisible.push(col); if (col.cardVisible) splittedColumns.value.cardVisible.push(col);
if ($props.isEditable && col.disable == null) col.disable = false; if ($props.isEditable && col.disable == null) col.disable = false;
if ($props.useModel) col.columnFilter = { ...col.columnFilter, inWhere: true }; if ($props.useModel && col.columnFilter != false)
col.columnFilter = { ...col.columnFilter, inWhere: true };
splittedColumns.value.columns.push(col); splittedColumns.value.columns.push(col);
} }
// Status column // Status column
@ -205,6 +213,16 @@ const rowClickFunction = computed(() => {
return () => {}; return () => {};
}); });
const rowCtrlClickFunction = computed(() => {
if ($props.rowCtrlClick != undefined) return $props.rowCtrlClick;
if ($props.redirect)
return (evt, { id }) => {
stopEventPropagation(evt);
window.open(`/#/${$props.redirect}/${id}`, '_blank');
};
return () => {};
});
function redirectFn(id) { function redirectFn(id) {
router.push({ path: `/${$props.redirect}/${id}` }); router.push({ path: `/${$props.redirect}/${id}` });
} }
@ -277,6 +295,10 @@ defineExpose({
:search-url="searchUrl" :search-url="searchUrl"
/> />
<VnTableOrder <VnTableOrder
v-if="
col?.columnFilter !== false &&
col?.name !== 'tableActions'
"
v-model="orders[col.name]" v-model="orders[col.name]"
:name="col.orderBy ?? col.name" :name="col.orderBy ?? col.name"
:data-key="$attrs['data-key']" :data-key="$attrs['data-key']"
@ -417,6 +439,11 @@ defineExpose({
class="no-margin q-px-xs" class="no-margin q-px-xs"
:class="[getColAlign(col), col.columnClass]" :class="[getColAlign(col), col.columnClass]"
v-if="col.visible ?? true" v-if="col.visible ?? true"
@click.ctrl="
($event) =>
rowCtrlClickFunction &&
rowCtrlClickFunction($event, row)
"
> >
<slot :name="`column-${col.name}`" :col="col" :row="row"> <slot :name="`column-${col.name}`" :col="col" :row="row">
<VnTableColumn <VnTableColumn

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { onMounted, onUnmounted } from 'vue'; import { onMounted, onUnmounted, ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import RightMenu from 'src/components/common/RightMenu.vue'; import RightMenu from 'src/components/common/RightMenu.vue';
import VnTable from 'components/VnTable/VnTable.vue'; import VnTable from 'components/VnTable/VnTable.vue';
@ -15,12 +15,13 @@ const columns = [
{ {
align: 'center', align: 'center',
label: t('entry.latestBuys.tableVisibleColumns.image'), label: t('entry.latestBuys.tableVisibleColumns.image'),
name: 'image', name: 'itemFk',
columnField: { columnField: {
component: VnImg, component: VnImg,
attrs: (id) => { attrs: (id) => {
return { return {
id, id,
size: '50x50',
width: '50px', width: '50px',
}; };
}, },
@ -169,6 +170,7 @@ const columns = [
format: (row, dashIfEmpty) => dashIfEmpty(toDate(row.landing)), format: (row, dashIfEmpty) => dashIfEmpty(toDate(row.landing)),
}, },
]; ];
const tableRef = ref();
onMounted(async () => { onMounted(async () => {
stateStore.rightDrawer = true; stateStore.rightDrawer = true;
@ -191,6 +193,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
order="id DESC" order="id DESC"
:columns="columns" :columns="columns"
redirect="entry" redirect="entry"
:row-click="({ entryFk }) => tableRef.redirect(entryFk)"
auto-load auto-load
:right-search="false" :right-search="false"
/> />

View File

@ -3,7 +3,7 @@ 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 { useSession } from 'src/composables/useSession'; import { useSession } from 'src/composables/useSession';
import { toDate } from 'filters/index'; import { toDate, toDateHourMin } from 'filters/index';
import { useStateStore } from 'src/stores/useStateStore'; import { useStateStore } from 'src/stores/useStateStore';
import axios from 'axios'; import axios from 'axios';
@ -30,53 +30,69 @@ const columns = computed(() => [
isId: true, isId: true,
}, },
{ {
align: 'left', align: 'center',
name: 'hasCmrDms', name: 'hasCmrDms',
label: t('route.cmr.list.hasCmrDms'), label: t('route.cmr.list.hasCmrDms'),
component: 'checkbox', component: 'checkbox',
cardVisible: true, cardVisible: true,
}, },
{ {
align: 'left',
label: t('route.cmr.list.ticketFk'), label: t('route.cmr.list.ticketFk'),
name: 'ticketFk', name: 'ticketFk',
}, },
{ {
align: 'left',
label: t('route.cmr.list.routeFk'), label: t('route.cmr.list.routeFk'),
name: 'routeFk', name: 'routeFk',
}, },
{ {
align: 'left',
label: t('route.cmr.list.clientFk'), label: t('route.cmr.list.clientFk'),
name: 'clientFk', name: 'clientFk',
}, },
{ {
align: 'left', align: 'right',
label: t('route.cmr.list.country'), label: t('route.cmr.list.country'),
name: 'country', name: 'countryFk',
cardVisible: true, cardVisible: true,
},
{
align: 'center',
label: t('route.cmr.list.shipped'),
name: 'shipped',
cardVisible: true,
component: 'date',
columnFilter: {
alias: 'c',
inWhere: true,
},
format: ({ date }) => toDate(date),
},
{
align: 'center',
name: 'warehouseFk',
label: t('globals.warehouse'),
component: 'select',
attrs: { attrs: {
options: warehouses.value, url: 'countries',
fields: ['id', 'name'],
optionLabel: 'name',
optionValue: 'id',
}, },
columnFilter: {
inWhere: true,
component: 'select',
},
format: ({ countryName }) => countryName,
}, },
{ {
align: 'right', align: 'right',
label: t('route.cmr.list.shipped'),
name: 'shipped',
cardVisible: true,
columnFilter: {
component: 'date',
inWhere: true,
},
format: ({ shipped }) => toDateHourMin(shipped),
},
{
align: 'right',
name: 'warehouseFk',
label: t('globals.warehouse'),
columnFilter: {
component: 'select',
},
attrs: {
options: warehouses.value,
},
format: ({ warehouseName }) => warehouseName,
},
{
align: 'center',
name: 'tableActions', name: 'tableActions',
actions: [ actions: [
{ {
@ -153,7 +169,7 @@ function downloadPdfs() {
</template> </template>
<template #column-clientFk="{ row }"> <template #column-clientFk="{ row }">
<span class="link" @click.stop> <span class="link" @click.stop>
{{ row.ticketFk }} {{ row.clientFk }}
<CustomerDescriptorProxy :id="row.clientFk" /> <CustomerDescriptorProxy :id="row.clientFk" />
</span> </span>
</template> </template>

View File

@ -36,23 +36,20 @@ const tableRef = ref();
const columns = computed(() => [ const columns = computed(() => [
{ {
align: 'left', align: 'left',
name: 'id', name: 'routeFk',
label: 'Id', label: 'Id',
chip: { chip: {
condition: () => true, condition: () => true,
}, },
isId: true, isId: true,
columnFilter: false,
}, },
{ {
align: 'left', align: 'left',
name: 'created', name: 'created',
label: t('Date'), label: t('Date'),
component: 'date', columnFilter: false,
columnFilter: { format: ({ created }) => toDate(created),
alias: 'c',
inWhere: true,
},
format: ({ date }) => toDate(date),
}, },
{ {
align: 'left', align: 'left',
@ -66,40 +63,63 @@ const columns = computed(() => [
label: t('Agency agreement'), label: t('Agency agreement'),
cardVisible: true, cardVisible: true,
}, },
{
align: 'left',
name: 'to',
label: t('To'),
visible: false,
cardVisible: true,
create: true,
component: 'date',
format: ({ date }) => toDate(date),
},
{
align: 'left',
name: 'from',
label: t('From'),
visible: false,
cardVisible: true,
create: true,
component: 'date',
format: ({ date }) => toDate(date),
},
{ {
align: 'left', align: 'left',
name: 'packages', name: 'packages',
label: t('Packages'), label: t('Packages'),
columnFilter: false,
}, },
{ {
align: 'left', align: 'left',
name: 'm3', name: 'm3',
label: 'm³', label: 'm³',
cardVisible: true, cardVisible: true,
columnFilter: { columnFilter: false,
inWhere: true,
},
}, },
{ {
align: 'left', align: 'left',
name: 'kmTotal', name: 'kmTotal',
label: t('Km'), label: t('Km'),
cardVisible: true, cardVisible: true,
columnFilter: false,
}, },
{ {
align: 'left', align: 'left',
name: 'price', name: 'price',
label: t('Price'), label: t('Price'),
columnFilter: false,
}, },
{ {
align: 'left', align: 'left',
name: 'invoiceInFk', name: 'invoiceInFk',
label: t('Received'), label: t('Received'),
columnFilter: false,
}, },
{ {
align: 'left', align: 'left',
name: 'supplierName', name: 'supplierName',
label: t('Autonomous'), label: t('Autonomous'),
columnFilter: false,
}, },
{ {
align: 'right', align: 'right',

View File

@ -24,7 +24,6 @@ const selectedRows = ref([]);
const tableRef = ref([]); const tableRef = ref([]);
const confirmationDialog = ref(false); const confirmationDialog = ref(false);
const startingDate = ref(null); const startingDate = ref(null);
const refreshKey = ref(0);
const router = useRouter(); const router = useRouter();
const routeFilter = { const routeFilter = {
include: [ include: [
@ -45,9 +44,7 @@ const columns = computed(() => [
condition: () => true, condition: () => true,
}, },
isId: true, isId: true,
columnFilter: { columnFilter: false,
name: 'search',
},
}, },
{ {
align: 'left', align: 'left',
@ -65,6 +62,9 @@ const columns = computed(() => [
label: 'workerUserName', label: 'workerUserName',
}, },
}, },
columnFilter: {
inWhere: true,
},
useLike: false, useLike: false,
cardVisible: true, cardVisible: true,
format: (row, dashIfEmpty) => dashIfEmpty(row.travelRef), format: (row, dashIfEmpty) => dashIfEmpty(row.travelRef),
@ -102,18 +102,38 @@ const columns = computed(() => [
label: 'vehiclePlateNumber', label: 'vehiclePlateNumber',
}, },
}, },
columnFilter: {
inWhere: true,
},
}, },
{ {
align: 'left', align: 'left',
name: 'created', name: 'created',
label: t('Date'), label: t('Date'),
columnFilter: false,
cardVisible: true,
create: true,
component: 'date',
format: ({ date }) => toDate(date),
},
{
align: 'left',
name: 'to',
label: t('To'),
visible: false,
cardVisible: true,
create: true,
component: 'date',
format: ({ date }) => toDate(date),
},
{
align: 'left',
name: 'from',
label: t('From'),
visible: false,
cardVisible: true, cardVisible: true,
create: true, create: true,
component: 'date', component: 'date',
columnFilter: {
alias: 'c',
inWhere: true,
},
format: ({ date }) => toDate(date), format: ({ date }) => toDate(date),
}, },
{ {
@ -136,18 +156,21 @@ const columns = computed(() => [
name: 'started', name: 'started',
label: t('hourStarted'), label: t('hourStarted'),
component: 'time', component: 'time',
columnFilter: false,
}, },
{ {
align: 'left', align: 'left',
name: 'finished', name: 'finished',
label: t('hourFinished'), label: t('hourFinished'),
component: 'time', component: 'time',
columnFilter: false,
}, },
{ {
align: 'left', align: 'left',
name: 'isOk', name: 'isOk',
label: t('Served'), label: t('Served'),
component: 'checkbox', component: 'checkbox',
columnFilter: false,
}, },
{ {
align: 'right', align: 'right',
@ -183,8 +206,8 @@ const cloneRoutes = () => {
created: startingDate.value, created: startingDate.value,
ids: selectedRows.value.map((row) => row?.id), ids: selectedRows.value.map((row) => row?.id),
}); });
tableRef.value.reload();
startingDate.value = null; startingDate.value = null;
tableRef.value.reload();
}; };
const showRouteReport = () => { const showRouteReport = () => {
@ -220,7 +243,7 @@ const openTicketsDialog = (id) => {
id, id,
}, },
}) })
.onOk(() => refreshKey.value++); .onOk(() => tableRef.value.reload());
}; };
</script> </script>
@ -249,6 +272,7 @@ const openTicketsDialog = (id) => {
</QDialog> </QDialog>
<VnSubToolbar /> <VnSubToolbar />
<VnTable <VnTable
class="route-list"
ref="tableRef" ref="tableRef"
data-key="RouteList" data-key="RouteList"
url="Routes/filter" url="Routes/filter"
@ -266,7 +290,6 @@ const openTicketsDialog = (id) => {
}" }"
save-url="Routes/crud" save-url="Routes/crud"
:disable-option="{ card: true }" :disable-option="{ card: true }"
:use-model="true"
table-height="85vh" table-height="85vh"
v-model:selected="selectedRows" v-model:selected="selectedRows"
:table="{ :table="{
@ -332,6 +355,8 @@ en:
hourStarted: Started hour hourStarted: Started hour
hourFinished: Finished hour hourFinished: Finished hour
es: es:
From: Desde
To: Hasta
Worker: Trabajador Worker: Trabajador
Agency: Agencia Agency: Agencia
Vehicle: Vehículo Vehicle: Vehículo

View File

@ -2,7 +2,7 @@
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { computed, ref } from 'vue'; import { computed, ref } from 'vue';
import { dashIfEmpty } from 'src/filters'; import { dashIfEmpty } from 'src/filters';
import { toDate } from 'filters/index'; import { toDate, toDateHourMin } from 'filters/index';
import { useQuasar } from 'quasar'; import { useQuasar } from 'quasar';
import { useSummaryDialog } from 'composables/useSummaryDialog'; import { useSummaryDialog } from 'composables/useSummaryDialog';
import toCurrency from 'filters/toCurrency'; import toCurrency from 'filters/toCurrency';
@ -43,10 +43,9 @@ const columns = computed(() => [
label: t('ETD'), label: t('ETD'),
component: 'date', component: 'date',
columnFilter: { columnFilter: {
alias: 'c',
inWhere: true, inWhere: true,
}, },
format: ({ date }) => toDate(date), format: ({ created }) => toDate(created),
cardVisible: true, cardVisible: true,
}, },
{ {
@ -200,6 +199,12 @@ function confirmRemove() {
}" }"
:disable-option="{ card: true }" :disable-option="{ card: true }"
> >
<template #column-etd="{ row }">
{{ toDateHourMin(row.etd) }}
</template>
<template #column-supplierFk="{ row }">
{{ row.supplierFk }}
</template>
<template #more-create-dialog="{ data }"> <template #more-create-dialog="{ data }">
<VnInputDate v-model="data.etd" /> <VnInputDate v-model="data.etd" />
<VnInputTime v-model="data.etd" /> <VnInputTime v-model="data.etd" />

View File

@ -0,0 +1,13 @@
describe('RoadMap', () => {
beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer');
cy.visit(`/#/route/roadmap`);
});
it('Route list create roadmap and redirect', () => {
cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click();
cy.get('input[name="name"]').eq(1).type('roadMapTestOne{enter}');
cy.get('.q-notification__message').should('have.text', 'Data created');
cy.url().should('include', '/summary');
});
});

View File

@ -4,12 +4,28 @@ describe('Route', () => {
cy.login('developer'); cy.login('developer');
cy.visit(`/#/route/list`); cy.visit(`/#/route/list`);
}); });
const getVnSelect =
'> :nth-child(1) > .column > .q-field > .q-field__inner > .q-field__control > .q-field__control-container';
const getRowColumn = (row, column) => `:nth-child(${row}) > :nth-child(${column})`;
it('Route list create route', () => { it('Route list create route', () => {
cy.visit(`/#/route/list`);
cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click(); cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click();
cy.get('input[name="description"]').eq(1).type('routeTestOne{enter}'); cy.get('input[name="description"]').eq(1).type('routeTestOne{enter}');
cy.get('.q-notification__message').should('have.text', 'Data created'); cy.get('.q-notification__message').should('have.text', 'Data created');
cy.url().should('include', '/summary'); cy.url().should('include', '/summary');
}); });
it('Route list search and edit', () => {
cy.get('input[name="description"]').type('routeTestOne{enter}');
cy.get('.q-table tr')
.its('length')
.then((rowCount) => {
expect(rowCount).to.be.greaterThan(0);
});
cy.get(getRowColumn(1, 3) + getVnSelect).type('{downArrow}{enter}');
cy.get(getRowColumn(1, 4) + getVnSelect).type('{downArrow}{enter}');
cy.get(getRowColumn(1, 5) + getVnSelect).type('{downArrow}{enter}');
cy.get('button[title="Save"]').click();
cy.get('.q-notification__message').should('have.text', 'Data created');
});
}); });