feat: refs #6919 sync shelving
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-11-18 17:13:42 +01:00
parent 617af7b7cb
commit 96e9d1a00a
8 changed files with 59 additions and 97 deletions

View File

@ -3,11 +3,13 @@ import VnCard from 'components/common/VnCard.vue';
import ShelvingDescriptor from 'pages/Shelving/Card/ShelvingDescriptor.vue'; import ShelvingDescriptor from 'pages/Shelving/Card/ShelvingDescriptor.vue';
import ShelvingFilter from './ShelvingFilter.vue'; import ShelvingFilter from './ShelvingFilter.vue';
import ShelvingSearchbar from './ShelvingSearchbar.vue'; import ShelvingSearchbar from './ShelvingSearchbar.vue';
import filter from './ShelvingFilter.js';
</script> </script>
<template> <template>
<VnCard <VnCard
data-key="Shelving" data-key="Shelving"
url="Shelvings" url="Shelvings"
:filter="filter"
:descriptor="ShelvingDescriptor" :descriptor="ShelvingDescriptor"
:filter-panel="ShelvingFilter" :filter-panel="ShelvingFilter"
search-data-key="ShelvingList" search-data-key="ShelvingList"

View File

@ -1,12 +1,12 @@
<script setup> <script setup>
import { ref, computed } from 'vue'; import { computed } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import CardDescriptor from 'components/ui/CardDescriptor.vue'; import CardDescriptor from 'components/ui/CardDescriptor.vue';
import VnLv from 'components/ui/VnLv.vue'; import VnLv from 'components/ui/VnLv.vue';
import useCardDescription from 'composables/useCardDescription';
import ShelvingDescriptorMenu from 'pages/Shelving/Card/ShelvingDescriptorMenu.vue'; import ShelvingDescriptorMenu from 'pages/Shelving/Card/ShelvingDescriptorMenu.vue';
import VnUserLink from 'src/components/ui/VnUserLink.vue'; import VnUserLink from 'src/components/ui/VnUserLink.vue';
import filter from './ShelvingFilter.js';
const $props = defineProps({ const $props = defineProps({
id: { id: {
@ -22,35 +22,14 @@ const { t } = useI18n();
const entityId = computed(() => { const entityId = computed(() => {
return $props.id || route.params.id; return $props.id || route.params.id;
}); });
const filter = {
include: [
{
relation: 'worker',
scope: {
fields: ['id'],
include: {
relation: 'user',
scope: { fields: ['nickname'] },
},
},
},
{ relation: 'parking' },
],
};
const data = ref(useCardDescription());
const setData = (entity) => (data.value = useCardDescription(entity.code, entity.id));
</script> </script>
<template> <template>
<CardDescriptor <CardDescriptor
module="Shelving" module="Shelving"
:url="`Shelvings/${entityId}`" :url="`Shelvings/${entityId}`"
:filter="filter" :filter="filter"
:title="data.title" title="code"
:subtitle="data.subtitle" data-key="Shelving"
data-key="Shelvings"
@on-fetch="setData"
> >
<template #body="{ entity }"> <template #body="{ entity }">
<VnLv :label="t('globals.code')" :value="entity.code" /> <VnLv :label="t('globals.code')" :value="entity.code" />

View File

@ -0,0 +1,15 @@
export default {
include: [
{
relation: 'worker',
scope: {
fields: ['id'],
include: {
relation: 'user',
scope: { fields: ['nickname'] },
},
},
},
{ relation: 'parking' },
],
};

View File

@ -1,5 +1,4 @@
<script setup> <script setup>
import { useI18n } from 'vue-i18n';
import { computed } from 'vue'; import { computed } from 'vue';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import VnRow from 'components/ui/VnRow.vue'; import VnRow from 'components/ui/VnRow.vue';
@ -7,8 +6,8 @@ import FormModel from 'components/FormModel.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
import filter from './ShelvingFilter.js';
const { t } = useI18n();
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
const entityId = computed(() => route.params.id ?? null); const entityId = computed(() => route.params.id ?? null);
@ -20,22 +19,6 @@ const defaultInitialData = {
isRecyclable: false, isRecyclable: false,
}; };
const shelvingFilter = {
include: [
{
relation: 'worker',
scope: {
fields: ['id'],
include: {
relation: 'user',
scope: { fields: ['nickname'] },
},
},
},
{ relation: 'parking' },
],
};
const onSave = (shelving, newShelving) => { const onSave = (shelving, newShelving) => {
if (isNew) { if (isNew) {
router.push({ name: 'ShelvingBasicData', params: { id: newShelving?.id } }); router.push({ name: 'ShelvingBasicData', params: { id: newShelving?.id } });
@ -45,11 +28,10 @@ const onSave = (shelving, newShelving) => {
<template> <template>
<VnSubToolbar v-if="isNew" /> <VnSubToolbar v-if="isNew" />
<FormModel <FormModel
:url="isNew ? null : `Shelvings/${entityId}`"
:url-create="isNew ? 'Shelvings' : null" :url-create="isNew ? 'Shelvings' : null"
:observe-form-changes="!isNew" :observe-form-changes="!isNew"
:filter="shelvingFilter" :filter="filter"
model="shelving" model="Shelving"
:auto-load="!isNew" :auto-load="!isNew"
:form-initial-data="isNew ? defaultInitialData : null" :form-initial-data="isNew ? defaultInitialData : null"
@on-data-saved="onSave" @on-data-saved="onSave"
@ -58,7 +40,7 @@ const onSave = (shelving, newShelving) => {
<VnRow> <VnRow>
<VnInput <VnInput
v-model="data.code" v-model="data.code"
:label="t('globals.code')" :label="$t('globals.code')"
:rules="validate('Shelving.code')" :rules="validate('Shelving.code')"
/> />
<VnSelect <VnSelect
@ -68,7 +50,7 @@ const onSave = (shelving, newShelving) => {
option-label="code" option-label="code"
:filter-options="['id', 'code']" :filter-options="['id', 'code']"
:fields="['id', 'code']" :fields="['id', 'code']"
:label="t('shelving.list.parking')" :label="$t('shelving.list.parking')"
:rules="validate('Shelving.parkingFk')" :rules="validate('Shelving.parkingFk')"
/> />
</VnRow> </VnRow>
@ -76,12 +58,12 @@ const onSave = (shelving, newShelving) => {
<VnInput <VnInput
v-model="data.priority" v-model="data.priority"
type="number" type="number"
:label="t('shelving.list.priority')" :label="$t('shelving.list.priority')"
:rules="validate('Shelving.priority')" :rules="validate('Shelving.priority')"
/> />
<QCheckbox <QCheckbox
v-model="data.isRecyclable" v-model="data.isRecyclable"
:label="t('shelving.summary.recyclable')" :label="$t('shelving.summary.recyclable')"
:rules="validate('Shelving.isRecyclable')" :rules="validate('Shelving.isRecyclable')"
/> />
</VnRow> </VnRow>

View File

@ -1,15 +1,15 @@
<script setup> <script setup>
import VnSearchbar from 'components/ui/VnSearchbar.vue'; import VnSearchbar from 'components/ui/VnSearchbar.vue';
import {useI18n} from "vue-i18n"; import exprBuilder from '../ShelvingExprBuilder.js';
const { t } = useI18n();
</script> </script>
<template> <template>
<VnSearchbar <VnSearchbar
data-key="ShelvingList" data-key="ShelvingList"
url="Shelvings" url="Shelvings"
:label="t('Search shelving')" :label="$t('Search shelving')"
:info="t('You can search by shelving reference')" :info="$t('You can search by shelving reference')"
:expr-builder="exprBuilder"
/> />
</template> </template>

View File

@ -1,10 +1,10 @@
<script setup> <script setup>
import { computed } from 'vue'; import { computed } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import CardSummary from 'components/ui/CardSummary.vue'; import CardSummary from 'components/ui/CardSummary.vue';
import VnLv from 'components/ui/VnLv.vue'; import VnLv from 'components/ui/VnLv.vue';
import VnUserLink from 'components/ui/VnUserLink.vue'; import VnUserLink from 'components/ui/VnUserLink.vue';
import filter from './ShelvingFilter.js';
const $props = defineProps({ const $props = defineProps({
id: { id: {
@ -13,25 +13,8 @@ const $props = defineProps({
}, },
}); });
const route = useRoute(); const route = useRoute();
const { t } = useI18n();
const entityId = computed(() => $props.id || route.params.id); const entityId = computed(() => $props.id || route.params.id);
const filter = {
include: [
{
relation: 'worker',
scope: {
fields: ['id'],
include: {
relation: 'user',
scope: { fields: ['nickname'] },
},
},
},
{ relation: 'parking' },
],
};
</script> </script>
<template> <template>
@ -40,7 +23,7 @@ const filter = {
ref="summary" ref="summary"
:url="`Shelvings/${entityId}`" :url="`Shelvings/${entityId}`"
:filter="filter" :filter="filter"
data-key="ShelvingSummary" data-key="Shelving"
> >
<template #header="{ entity }"> <template #header="{ entity }">
<div>{{ entity.code }}</div> <div>{{ entity.code }}</div>
@ -51,16 +34,19 @@ const filter = {
class="header header-link" class="header header-link"
:to="{ name: 'ShelvingBasicData', params: { id: entityId } }" :to="{ name: 'ShelvingBasicData', params: { id: entityId } }"
> >
{{ t('globals.pageTitles.basicData') }} {{ $t('globals.pageTitles.basicData') }}
<QIcon name="open_in_new" /> <QIcon name="open_in_new" />
</RouterLink> </RouterLink>
<VnLv :label="t('globals.code')" :value="entity.code" /> <VnLv :label="$t('globals.code')" :value="entity.code" />
<VnLv <VnLv
:label="t('shelving.list.parking')" :label="$t('shelving.list.parking')"
:value="entity.parking?.code" :value="entity.parking?.code"
/> />
<VnLv :label="t('shelving.list.priority')" :value="entity.priority" /> <VnLv
<VnLv v-if="entity.worker" :label="t('globals.worker')"> :label="$t('shelving.list.priority')"
:value="entity.priority"
/>
<VnLv v-if="entity.worker" :label="$t('globals.worker')">
<template #value> <template #value>
<VnUserLink <VnUserLink
:name="entity.worker?.user?.nickname" :name="entity.worker?.user?.nickname"
@ -69,7 +55,7 @@ const filter = {
</template> </template>
</VnLv> </VnLv>
<VnLv <VnLv
:label="t('shelving.summary.recyclable')" :label="$t('shelving.summary.recyclable')"
:value="entity.isRecyclable" :value="entity.isRecyclable"
/> />
</QCard> </QCard>

View File

@ -0,0 +1,10 @@
export default (param, value) => {
switch (param) {
case 'search':
return { code: { like: `%${value}%` } };
case 'parkingFk':
case 'userFk':
case 'isRecyclable':
return { [param]: value };
}
};

View File

@ -1,7 +1,6 @@
<script setup> <script setup>
import VnPaginate from 'components/ui/VnPaginate.vue'; import VnPaginate from 'components/ui/VnPaginate.vue';
import { useStateStore } from 'stores/useStateStore'; import { useStateStore } from 'stores/useStateStore';
import { useI18n } from 'vue-i18n';
import { onMounted, onUnmounted } from 'vue'; import { onMounted, onUnmounted } from 'vue';
import CardList from 'components/ui/CardList.vue'; import CardList from 'components/ui/CardList.vue';
import VnLv from 'components/ui/VnLv.vue'; import VnLv from 'components/ui/VnLv.vue';
@ -11,10 +10,10 @@ import ShelvingSummary from 'pages/Shelving/Card/ShelvingSummary.vue';
import ShelvingSearchbar from 'pages/Shelving/Card/ShelvingSearchbar.vue'; import ShelvingSearchbar from 'pages/Shelving/Card/ShelvingSearchbar.vue';
import { useSummaryDialog } from 'src/composables/useSummaryDialog'; import { useSummaryDialog } from 'src/composables/useSummaryDialog';
import RightMenu from 'src/components/common/RightMenu.vue'; import RightMenu from 'src/components/common/RightMenu.vue';
import exprBuilder from './ShelvingExprBuilder.js';
const stateStore = useStateStore(); const stateStore = useStateStore();
const router = useRouter(); const router = useRouter();
const { t } = useI18n();
const { viewSummary } = useSummaryDialog(); const { viewSummary } = useSummaryDialog();
const filter = { const filter = {
include: [{ relation: 'parking' }], include: [{ relation: 'parking' }],
@ -26,17 +25,6 @@ onUnmounted(() => (stateStore.rightDrawer = false));
function navigate(id) { function navigate(id) {
router.push({ path: `/shelving/${id}` }); router.push({ path: `/shelving/${id}` });
} }
function exprBuilder(param, value) {
switch (param) {
case 'search':
return { code: { like: `%${value}%` } };
case 'parkingFk':
case 'userFk':
case 'isRecyclable':
return { [param]: value };
}
}
</script> </script>
<template> <template>
@ -65,18 +53,18 @@ function exprBuilder(param, value) {
> >
<template #list-items> <template #list-items>
<VnLv <VnLv
:label="t('shelving.list.parking')" :label="$t('shelving.list.parking')"
:title-label="t('shelving.list.parking')" :title-label="$t('shelving.list.parking')"
:value="row.parking?.code" :value="row.parking?.code"
/> />
<VnLv <VnLv
:label="t('shelving.list.priority')" :label="$t('shelving.list.priority')"
:value="row?.priority" :value="row?.priority"
/> />
</template> </template>
<template #actions> <template #actions>
<QBtn <QBtn
:label="t('components.smartCard.openSummary')" :label="$t('components.smartCard.openSummary')"
@click.stop="viewSummary(row.id, ShelvingSummary)" @click.stop="viewSummary(row.id, ShelvingSummary)"
color="primary" color="primary"
/> />
@ -89,7 +77,7 @@ function exprBuilder(param, value) {
<RouterLink :to="{ name: 'ShelvingCreate' }"> <RouterLink :to="{ name: 'ShelvingCreate' }">
<QBtn fab icon="add" color="primary" shortcut="+" /> <QBtn fab icon="add" color="primary" shortcut="+" />
<QTooltip> <QTooltip>
{{ t('shelving.list.newShelving') }} {{ $t('shelving.list.newShelving') }}
</QTooltip> </QTooltip>
</RouterLink> </RouterLink>
</QPageSticky> </QPageSticky>