refactor: refs #8316 unify router item and itemType
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Alex Moreno 2025-01-15 10:38:16 +01:00
parent 2c67041030
commit 4c7a35f142
7 changed files with 193 additions and 281 deletions

View File

@ -332,8 +332,8 @@ onBeforeMount(async () => {
:columns="columns" :columns="columns"
prefix="item" prefix="item"
:array-data-props="{ :array-data-props="{
url: 'Items', url: 'Items/filter',
order: ['isActive DESC', 'name', 'id'] order: ['isActive DESC', 'name', 'id'],
}" }"
> >
<template #rightMenu> <template #rightMenu>
@ -347,15 +347,14 @@ onBeforeMount(async () => {
:columns="columns" :columns="columns"
:right-search="false" :right-search="false"
redirect="Item" redirect="Item"
url="Items/filter"
:create="{ :create="{
urlCreate: 'Items/new', urlCreate: 'Items/new',
title: t('item.list.newItem'), title: t('item.list.newItem'),
onDataSaved: ({ id }) => tableRef.redirect(`${id}/basic-data`), onDataSaved: ({ id }) => tableRef.redirect(`${id}/basic-data`),
formInitialData: { formInitialData: {
editorFk: entityId, editorFk: entityId,
tag: defaultTag, tag: defaultTag,
priority: defaultPriority, priority: defaultPriority,
}, },
}" }"
:is-editable="false" :is-editable="false"
@ -397,96 +396,100 @@ onBeforeMount(async () => {
</div> </div>
<FetchedTags :item="row" :columns="3" /> <FetchedTags :item="row" :columns="3" />
</template> </template>
<template #more-create-dialog="{ data }"> <template #more-create-dialog="{ data }">
<VnInput <VnInput
v-model="data.provisionalName" v-model="data.provisionalName"
:label="t('globals.description')" :label="t('globals.description')"
:is-required="true" :is-required="true"
/> />
<VnSelect <VnSelect
url="Tags" url="Tags"
v-model="data.tag" v-model="data.tag"
:label="t('globals.tag')" :label="t('globals.tag')"
:fields="['id', 'name']" :fields="['id', 'name']"
option-label="name" option-label="name"
option-value="id" option-value="id"
:is-required="true" :is-required="true"
:sort-by="['name ASC']" :sort-by="['name ASC']"
> >
<template #option="scope"> <template #option="scope">
<QItem v-bind="scope.itemProps"> <QItem v-bind="scope.itemProps">
<QItemSection> <QItemSection>
<QItemLabel>{{ scope.opt?.name }}</QItemLabel> <QItemLabel>{{ scope.opt?.name }}</QItemLabel>
<QItemLabel caption> #{{ scope.opt?.id }} </QItemLabel> <QItemLabel caption>
</QItemSection> #{{ scope.opt?.id }}
</QItem> </QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
<VnSelect
:options="validPriorities"
v-model="data.priority"
:label="t('item.create.priority')"
:is-required="true"
/>
<VnSelect
url="ItemTypes"
v-model="data.typeFk"
:label="t('item.list.typeName')"
:fields="['id', 'code', 'name']"
option-label="name"
option-value="id"
:is-required="true"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>{{ scope.opt?.name }}</QItemLabel>
<QItemLabel caption>
{{ scope.opt?.code }} #{{ scope.opt?.id }}
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
<VnSelect
url="Intrastats"
v-model="data.intrastatFk"
:label="t('globals.intrastat')"
:fields="['id', 'description']"
option-label="description"
option-value="id"
:is-required="true"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>{{ scope.opt?.description }}</QItemLabel>
<QItemLabel caption>
#{{ scope.opt?.id }}
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
<VnSelect
url="Origins"
v-model="data.originFk"
:label="t('globals.origin')"
:fields="['id', 'code', 'name']"
option-label="code"
option-value="id"
:is-required="true"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>{{ scope.opt?.name }}</QItemLabel>
<QItemLabel caption>
{{ scope.opt?.code }} #{{ scope.opt?.id }}
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
</template> </template>
</VnSelect>
<VnSelect
:options="validPriorities"
v-model="data.priority"
:label="t('item.create.priority')"
:is-required="true"
/>
<VnSelect
url="ItemTypes"
v-model="data.typeFk"
:label="t('item.list.typeName')"
:fields="['id', 'code', 'name']"
option-label="name"
option-value="id"
:is-required="true"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>{{ scope.opt?.name }}</QItemLabel>
<QItemLabel caption>
{{ scope.opt?.code }} #{{ scope.opt?.id }}
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
<VnSelect
url="Intrastats"
v-model="data.intrastatFk"
:label="t('globals.intrastat')"
:fields="['id', 'description']"
option-label="description"
option-value="id"
:is-required="true"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>{{ scope.opt?.description }}</QItemLabel>
<QItemLabel caption> #{{ scope.opt?.id }} </QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
<VnSelect
url="Origins"
v-model="data.originFk"
:label="t('globals.origin')"
:fields="['id', 'code', 'name']"
option-label="code"
option-value="id"
:is-required="true"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>{{ scope.opt?.name }}</QItemLabel>
<QItemLabel caption>
{{ scope.opt?.code }} #{{ scope.opt?.id }}
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
</template>
</VnTable> </VnTable>
</template> </template>
</VnSection> </VnSection>

View File

@ -1,90 +0,0 @@
<script setup>
import { useI18n } from 'vue-i18n';
import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
import VnInput from 'src/components/common/VnInput.vue';
const { t } = useI18n();
const props = defineProps({
dataKey: {
type: String,
required: true,
},
});
const emit = defineEmits(['search']);
const exprBuilder = (param, value) => {
switch (param) {
case 'name':
return {
name: { like: `%${value}%` },
};
case 'code':
return {
code: { like: `%${value}%` },
};
case 'search':
if (value) {
if (!isNaN(value)) {
return { id: value };
} else {
return {
or: [
{
name: {
like: `%${value}%`,
},
},
{
code: {
like: `%${value}%`,
},
},
],
};
}
}
}
};
</script>
<template>
<VnFilterPanel
:data-key="props.dataKey"
:search-button="true"
@search="emit('search')"
search-url="table"
:expr-builder="exprBuilder"
>
<template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs">
<strong>{{ t(`params.${tag.label}`) }}: </strong>
<span>{{ formatFn(tag.value) }}</span>
</div>
</template>
<template #body="{ params }">
<QItem>
<QItemSection>
<VnInput :label="t('Name')" v-model="params.name" is-outlined />
</QItemSection>
</QItem>
<QItem>
<QItemSection>
<VnInput v-model="params.code" :label="t('Code')" is-outlined />
</QItemSection>
</QItem>
</template>
</VnFilterPanel>
</template>
<i18n>
en:
params:
name: Name
code: Code
es:
params:
name: Nombre
code: Código
Name: Nombre
Code: Código
</i18n>

View File

@ -3,7 +3,6 @@ import { useI18n } from 'vue-i18n';
import { ref, computed } from 'vue'; import { ref, computed } from 'vue';
import VnTable from 'components/VnTable/VnTable.vue'; import VnTable from 'components/VnTable/VnTable.vue';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import ItemTypeFilter from './ItemType/ItemTypeFilter.vue';
import WorkerDescriptorProxy from '../Worker/Card/WorkerDescriptorProxy.vue'; import WorkerDescriptorProxy from '../Worker/Card/WorkerDescriptorProxy.vue';
import VnSection from 'src/components/common/VnSection.vue'; import VnSection from 'src/components/common/VnSection.vue';
@ -11,7 +10,41 @@ const { t } = useI18n();
const tableRef = ref(); const tableRef = ref();
const itemCategoriesOptions = ref([]); const itemCategoriesOptions = ref([]);
const temperatureOptions = ref([]); const temperatureOptions = ref([]);
const dataKey='ItemTypeList'; const dataKey = 'ItemTypeList';
const exprBuilder = (param, value) => {
switch (param) {
case 'name':
return {
name: { like: `%${value}%` },
};
case 'code':
return {
code: { like: `%${value}%` },
};
case 'search':
if (value) {
if (!isNaN(value)) {
return { id: value };
} else {
return {
or: [
{
name: {
like: `%${value}%`,
},
},
{
code: {
like: `%${value}%`,
},
},
],
};
}
}
}
};
const columns = computed(() => [ const columns = computed(() => [
{ {
@ -103,18 +136,16 @@ const columns = computed(() => [
@on-fetch="(data) => (temperatureOptions = data)" @on-fetch="(data) => (temperatureOptions = data)"
auto-load auto-load
/> />
<VnSection <VnSection
:data-key="dataKey" :data-key="dataKey"
:columns="columns" :columns="columns"
prefix="itemType" prefix="itemType"
:array-data-props="{ :array-data-props="{
url: 'ItemTypes', url: 'ItemTypes',
order: 'name ASC', order: 'name ASC',
exprBuilder,
}" }"
> >
<template #rightMenu>
<ItemTypeFilter data-key="ItemTypeList" />
</template>
<template #body> <template #body>
<VnTable <VnTable
ref="tableRef" ref="tableRef"
@ -141,7 +172,6 @@ const columns = computed(() => [
}" }"
:columns="columns" :columns="columns"
auto-load auto-load
:right-search="false"
redirect="item/item-type" redirect="item/item-type"
> >
<template #column-workerFk="{ row }"> <template #column-workerFk="{ row }">

View File

@ -15,7 +15,6 @@ import Entry from './entry';
import roadmap from './roadmap'; import roadmap from './roadmap';
import Parking from './parking'; import Parking from './parking';
import Agency from './agency'; import Agency from './agency';
import ItemType from './itemType';
import Zone from './zone'; import Zone from './zone';
import Account from './account'; import Account from './account';
import Monitor from './monitor'; import Monitor from './monitor';
@ -38,7 +37,6 @@ export default [
roadmap, roadmap,
Parking, Parking,
Agency, Agency,
ItemType,
Zone, Zone,
Account, Account,
Monitor, Monitor,

View File

@ -16,7 +16,7 @@ const itemCard = {
'ItemBarcode', 'ItemBarcode',
'ItemShelving', 'ItemShelving',
'ItemLastEntries', 'ItemLastEntries',
] ],
}, },
children: [ children: [
{ {
@ -112,6 +112,45 @@ const itemCard = {
], ],
}; };
const itemTypeCard = {
name: 'ItemTypeCard',
path: ':id',
component: () => import('src/pages/Item/ItemType/Card/ItemTypeCard.vue'),
redirect: { name: 'ItemTypeSummary' },
meta: {
menu: ['ItemTypeBasicData', 'ItemTypeLog'],
},
children: [
{
path: 'summary',
name: 'ItemTypeSummary',
meta: {
title: 'summary',
icon: 'launch',
},
component: () => import('src/pages/Item/ItemType/Card/ItemTypeSummary.vue'),
},
{
path: 'basic-data',
name: 'ItemTypeBasicData',
meta: {
title: 'basicData',
icon: 'vn:settings',
},
component: () => import('src/pages/Item/ItemType/Card/ItemTypeBasicData.vue'),
},
{
path: 'log',
name: 'ItemTypeLog',
meta: {
title: 'log',
icon: 'vn:History',
},
component: () => import('src/pages/Item/ItemType/Card/ItemTypeLog.vue'),
},
],
};
export default { export default {
name: 'Item', name: 'Item',
path: '/item', path: '/item',
@ -125,25 +164,25 @@ export default {
'WasteBreakdown', 'WasteBreakdown',
'ItemFixedPrice', 'ItemFixedPrice',
'ItemRequest', 'ItemRequest',
'ItemTypeList' 'ItemTypeList',
], ],
}, },
component: RouterView, component: RouterView,
redirect: { name: 'ItemMain' }, redirect: { name: 'ItemMain' },
children: [ children: [
{ {
name: 'ItemMain', name: 'ItemMain',
path: '', path: '',
component: () => import('src/components/common/VnModule.vue'), component: () => import('src/components/common/VnModule.vue'),
redirect: { name: 'ItemIndexMain' }, redirect: { name: 'ItemIndexMain' },
children: [ children: [
{ {
path:'', path: '',
name: 'ItemIndexMain', name: 'ItemIndexMain',
redirect: { name: 'ItemList' }, redirect: { name: 'ItemList' },
component: () => import('src/pages/Item/ItemList.vue'), component: () => import('src/pages/Item/ItemList.vue'),
children: [ children: [
{ {
name: 'ItemList', name: 'ItemList',
path: 'list', path: 'list',
meta: { meta: {
@ -151,7 +190,7 @@ export default {
icon: 'view_list', icon: 'view_list',
}, },
}, },
itemCard, itemCard,
], ],
}, },
{ {
@ -186,22 +225,21 @@ export default {
component: () => import('src/pages/Item/ItemFixedPrice.vue'), component: () => import('src/pages/Item/ItemFixedPrice.vue'),
}, },
{ {
path: 'create', path: 'item-type',
name: 'ItemCreate', name: 'ItemTypeMain',
meta: { redirect: { name: 'ItemTypeList' },
title: 'itemCreate',
},
component: () => import('src/pages/Item/ItemCreate.vue'),
},
{
path: 'item-type-list',
name: 'ItemTypeList',
meta: {
title: 'family',
icon: 'contact_support',
},
component: () => import('src/pages/Item/ItemTypeList.vue'), component: () => import('src/pages/Item/ItemTypeList.vue'),
children: [
{
name: 'ItemTypeList',
path: 'list',
meta: {
title: 'family',
icon: 'contact_support',
},
},
itemTypeCard,
],
}, },
], ],
}, },

View File

@ -1,65 +0,0 @@
import { RouterView } from 'vue-router';
const itemTypeCard = {
name: 'ItemTypeCard',
path: ':id',
component: () => import('src/pages/Item/ItemType/Card/ItemTypeCard.vue'),
redirect: { name: 'ItemTypeSummary' },
meta: {
menu: [
'ItemTypeBasicData',
'ItemTypeLog',
]
},
children: [
{
path: 'summary',
name: 'ItemTypeSummary',
meta: {
title: 'summary',
icon: 'launch',
},
component: () => import('src/pages/Item/ItemType/Card/ItemTypeSummary.vue'),
},
{
path: 'basic-data',
name: 'ItemTypeBasicData',
meta: {
title: 'basicData',
icon: 'vn:settings',
},
component: () => import('src/pages/Item/ItemType/Card/ItemTypeBasicData.vue'),
},
{
path: 'log',
name: 'ItemTypeLog',
meta: {
title: 'log',
icon: 'vn:History',
},
component: () => import('src/pages/Item/ItemType/Card/ItemTypeLog.vue'),
},
],
};
export default {
name: 'ItemType',
path: '/item/item-type',
meta: {
title: 'itemType',
icon: 'contact_support',
moduleName: 'ItemType',
menu: [],
},
component: RouterView,
redirect: { name: 'ItemTypeMain' },
children: [
{
name: 'ItemTypeMain',
path: '',
component: () => import('src/components/common/VnModule.vue'),
redirect: { name: 'ItemTypeIndexMain' },
children: [itemTypeCard],
},
],
};

View File

@ -9,7 +9,6 @@ import invoiceIn from './modules/invoiceIn';
import wagon from './modules/wagon'; import wagon from './modules/wagon';
import supplier from './modules/supplier'; import supplier from './modules/supplier';
import travel from './modules/travel'; import travel from './modules/travel';
import ItemType from './modules/itemType';
import shelving from 'src/router/modules/shelving'; import shelving from 'src/router/modules/shelving';
import order from 'src/router/modules/order'; import order from 'src/router/modules/order';
import entry from 'src/router/modules/entry'; import entry from 'src/router/modules/entry';
@ -88,7 +87,6 @@ const routes = [
entry, entry,
parking, parking,
agency, agency,
ItemType,
zone, zone,
account, account,
{ {