Merge pull request 'refs #7366 VnTable' (!489) from 7366-travelMigration2 into dev
gitea/salix-front/pipeline/head This commit looks good Details

Reviewed-on: #489
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
Alex Moreno 2024-07-03 08:32:57 +00:00
commit eeaf7d00e2
6 changed files with 200 additions and 136 deletions

View File

@ -19,7 +19,6 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
onMounted(() => { onMounted(() => {
setOptions(); setOptions();
store.skip = 0; store.skip = 0;
const query = route.query; const query = route.query;
const searchUrl = store.searchUrl; const searchUrl = store.searchUrl;
if (query[searchUrl]) { if (query[searchUrl]) {

View File

@ -1142,6 +1142,16 @@ supplier:
date: Date date: Date
reference: Reference reference: Reference
travel: travel:
travelList:
tableVisibleColumns:
id: Id
ref: Reference
agency: Agency
shipped: Shipped
landed: Landed
warehouseIn: Warehouse in
warehouseOut: Warehouse out
totalEntries: Total entries
summary: summary:
confirmed: Confirmed confirmed: Confirmed
entryId: Entry Id entryId: Entry Id

View File

@ -1115,6 +1115,16 @@ supplier:
date: Fecha date: Fecha
reference: Referencia reference: Referencia
travel: travel:
travelList:
tableVisibleColumns:
id: Id
ref: Referencia
agency: Agencia
shipped: Enviado
landed: Llegada
warehouseIn: Almacén de salida
warehouseOut: Almacén de entrada
totalEntries: Total de entradas
summary: summary:
confirmed: Confirmado confirmed: Confirmado
entryId: Id entrada entryId: Id entrada

View File

@ -33,8 +33,12 @@ const filter = {
<template> <template>
<VnCard <VnCard
data-key="Travel" data-key="Travel"
:filter="filter"
base-url="Travels" base-url="Travels"
search-data-key="TravelList"
searchbar-label="Search travel"
searchbar-info="You can search by travel id or name"
search-url="Travels"
:filter="filter"
:descriptor="TravelDescriptor" :descriptor="TravelDescriptor"
/> />
</template> </template>

View File

@ -12,8 +12,6 @@ import FetchData from 'src/components/FetchData.vue';
import { toDate, toCurrency } from 'src/filters'; import { toDate, toCurrency } from 'src/filters';
import axios from 'axios'; import axios from 'axios';
onUpdated(() => summaryRef.value.fetch());
const $props = defineProps({ const $props = defineProps({
id: { id: {
type: Number, type: Number,

View File

@ -2,31 +2,27 @@
import { onMounted, ref } from 'vue'; import { onMounted, ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import VnPaginate from 'src/components/ui/VnPaginate.vue'; import { useRoute } from 'vue-router';
import CardList from 'src/components/ui/CardList.vue';
import VnLv from 'src/components/ui/VnLv.vue';
import TravelSummary from './Card/TravelSummary.vue';
import TravelFilter from './TravelFilter.vue';
import FetchData from 'components/FetchData.vue';
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
import { useStateStore } from 'stores/useStateStore'; import { useStateStore } from 'stores/useStateStore';
import { toDate } from 'src/filters/index'; import VnTable from 'components/VnTable/VnTable.vue';
import { useSummaryDialog } from 'src/composables/useSummaryDialog'; import { useSummaryDialog } from 'src/composables/useSummaryDialog';
import { getDateQBadgeColor } from 'src/composables/getDateQBadgeColor.js'; import { computed } from 'vue';
import RightMenu from 'src/components/common/RightMenu.vue'; import TravelSummary from './Card/TravelSummary.vue';
import VnSearchbar from 'components/ui/VnSearchbar.vue';
import { dashIfEmpty, toDate } from 'src/filters';
const { viewSummary } = useSummaryDialog();
const router = useRouter(); const router = useRouter();
const { t } = useI18n(); const { t } = useI18n();
const stateStore = useStateStore(); const stateStore = useStateStore();
const { viewSummary } = useSummaryDialog(); const route = useRoute();
const tableRef = ref();
const warehouses = ref([]); const $props = defineProps({
id: {
const navigateToTravelId = (id) => { type: Number,
router.push({ path: `/travel/${id}` }); default: 0,
}; },
});
const entityId = computed(() => $props.id || route.params.id);
const cloneTravel = (travelData) => { const cloneTravel = (travelData) => {
const stringifiedTravelData = JSON.stringify(travelData); const stringifiedTravelData = JSON.stringify(travelData);
redirectToCreateView(stringifiedTravelData); redirectToCreateView(stringifiedTravelData);
@ -40,125 +36,170 @@ const redirectCreateEntryView = (travelData) => {
router.push({ name: 'EntryCreate', query: { travelFk: travelData.id } }); router.push({ name: 'EntryCreate', query: { travelFk: travelData.id } });
}; };
const getWarehouseName = (id) => {
return warehouses.value.find((warehouse) => warehouse.id === id).name;
};
onMounted(async () => { onMounted(async () => {
stateStore.rightDrawer = true; stateStore.rightDrawer = true;
}); });
const columns = computed(() => [
{
align: 'left',
name: 'id',
label: t('travel.travelList.tableVisibleColumns.id'),
isId: true,
field: 'id',
cardVisible: true,
},
{
align: 'left',
name: 'ref',
label: t('travel.travelList.tableVisibleColumns.ref'),
field: 'ref',
component: 'input',
columnField: {
component: null,
},
cardVisible: true,
create: true,
},
{
align: 'left',
name: 'agencyModeFk',
label: t('travel.travelList.tableVisibleColumns.agency'),
field: 'agencyModeFk',
component: 'select',
attrs: {
url: 'agencyModes',
fields: ['id', 'name'],
},
columnField: {
component: null,
},
cardVisible: true,
create: true,
},
{
align: 'left',
name: 'shipped',
label: t('travel.travelList.tableVisibleColumns.shipped'),
field: 'shipped',
component: 'date',
columnField: {
component: null,
},
cardVisible: true,
create: true,
format: (row, dashIfEmpty) => dashIfEmpty(toDate(row.shipped)),
},
{
align: 'left',
name: 'landed',
label: t('travel.travelList.tableVisibleColumns.landed'),
field: 'landed',
component: 'date',
columnField: {
component: null,
},
cardVisible: true,
create: true,
format: (row, dashIfEmpty) => dashIfEmpty(toDate(row.landed)),
},
{
align: 'left',
name: 'warehouseInFk',
label: t('travel.travelList.tableVisibleColumns.warehouseIn'),
field: 'warehouseInFk',
component: 'select',
attrs: {
url: 'warehouses',
fields: ['id', 'name'],
},
columnField: {
component: null,
},
cardVisible: true,
create: true,
},
{
align: 'left',
name: 'warehouseOutFk',
label: t('travel.travelList.tableVisibleColumns.warehouseOut'),
field: 'warehouseOutFk',
component: 'select',
attrs: {
url: 'warehouses',
fields: ['id', 'name'],
},
columnField: {
component: null,
},
cardVisible: true,
create: true,
},
{
align: 'left',
name: 'totalEntries',
label: t('travel.travelList.tableVisibleColumns.totalEntries'),
field: 'totalEntries',
component: 'input',
columnField: {
component: null,
},
cardVisible: true,
create: true,
},
{
align: 'right',
label: '',
name: 'tableActions',
actions: [
{
title: t('Clone'),
icon: 'vn:clone',
action: cloneTravel,
isPrimary: true,
},
{
title: t('Add entry'),
icon: 'contact_support',
action: redirectCreateEntryView,
},
{
title: t('View Summary'),
icon: 'preview',
action: (row) => viewSummary(row.id, TravelSummary),
},
],
},
]);
</script> </script>
<template> <template>
<FetchData <VnSearchbar
url="Warehouses" :info="t('You can search by travel id or name')"
:filter="{ fields: ['id', 'name'] }" :label="t('Search travel')"
order="name"
@on-fetch="(data) => (warehouses = data)"
auto-load
/>
<VnSearchbar data-key="TravelList" :limit="20" :label="t('searchByIdOrReference')" />
<RightMenu>
<template #right-panel>
<TravelFilter data-key="TravelList" />
</template>
</RightMenu>
<QPage class="column items-center q-pa-md">
<div class="vn-card-list">
<VnPaginate
data-key="TravelList" data-key="TravelList"
url="Travels/filter" />
<VnTable
ref="tableRef"
data-key="TravelList"
url="Travels"
:create="{
urlCreate: 'Travels',
title: t('Create Travels'),
onDataSaved: ({ id }) => tableRef.redirect(id),
formInitialData: {
editorFk: entityId,
},
}"
order="landed DESC"
:columns="columns"
default-mode="table"
auto-load auto-load
order="shipped DESC, landed DESC" redirect="travel"
> :right-search="false"
<template #body="{ rows }"> :is-editable="false"
<CardList :use-model="true"
v-for="row of rows"
:key="row.id"
:title="row.ref"
:id="row.id"
@click="navigateToTravelId(row.id)"
>
<template #list-items>
<VnLv
:label="t('globals.agency')"
:value="row.agencyModeName"
/> />
<VnLv
v-if="warehouses.length > 0"
:label="t('globals.wareHouseOut')"
:value="getWarehouseName(row.warehouseOutFk)"
/>
<VnLv :label="t('globals.shipped')">
<template #value>
<QBadge
text-color="black"
v-if="getDateQBadgeColor(row.shipped)"
:color="getDateQBadgeColor(row.shipped)"
class="q-ma-none"
dense
style="font-size: 14px"
>
{{ toDate(row.shipped) }}
</QBadge>
<span v-else>{{ toDate(row.shipped) }}</span>
</template>
</VnLv>
<VnLv :label="t('globals.landed')">
<template #value>
<QBadge
text-color="black"
v-if="getDateQBadgeColor(row.landed)"
:color="getDateQBadgeColor(row.landed)"
class="q-ma-none"
dense
style="font-size: 14px"
>
{{ toDate(row.landed) }}
</QBadge>
<span v-else>{{ toDate(row.landed) }}</span>
</template>
</VnLv>
<VnLv
v-if="warehouses.length > 0"
:label="t('globals.wareHouseIn')"
:value="getWarehouseName(row.warehouseInFk)"
/>
<VnLv
:label="t('globals.totalEntries')"
:value="row.totalEntries"
/>
</template>
<template #actions>
<QBtn
:label="t('components.smartCard.clone')"
@click.stop="cloneTravel(row)"
outline
/>
<QBtn
:label="t('addEntry')"
@click.stop="redirectCreateEntryView(row)"
outline
style="margin-top: 15px"
/>
<QBtn
:label="t('components.smartCard.openSummary')"
@click.stop="viewSummary(row.id, TravelSummary)"
color="primary"
style="margin-top: 15px"
/>
</template>
</CardList>
</template>
</VnPaginate>
</div>
<QPageSticky :offset="[20, 20]">
<QBtn fab icon="add" color="primary" @click="redirectToCreateView()" />
<QTooltip>
{{ t('supplier.list.newSupplier') }}
</QTooltip>
</QPageSticky>
</QPage>
</template> </template>
<i18n> <i18n>
@ -169,4 +210,6 @@ en:
es: es:
addEntry: Añadir entrada addEntry: Añadir entrada
searchByIdOrReference: Buscar por ID o por referencia searchByIdOrReference: Buscar por ID o por referencia
You can search by travel id or name: Buscar por envio por id o nombre
Search travel: Buscar envio
</i18n> </i18n>