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 ShelvingFilter from './ShelvingFilter.vue';
import ShelvingSearchbar from './ShelvingSearchbar.vue';
import filter from './ShelvingFilter.js';
</script>
<template>
<VnCard
data-key="Shelving"
url="Shelvings"
:filter="filter"
:descriptor="ShelvingDescriptor"
:filter-panel="ShelvingFilter"
search-data-key="ShelvingList"

View File

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

View File

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

View File

@ -1,10 +1,10 @@
<script setup>
import { computed } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import CardSummary from 'components/ui/CardSummary.vue';
import VnLv from 'components/ui/VnLv.vue';
import VnUserLink from 'components/ui/VnUserLink.vue';
import filter from './ShelvingFilter.js';
const $props = defineProps({
id: {
@ -13,25 +13,8 @@ const $props = defineProps({
},
});
const route = useRoute();
const { t } = useI18n();
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>
<template>
@ -40,7 +23,7 @@ const filter = {
ref="summary"
:url="`Shelvings/${entityId}`"
:filter="filter"
data-key="ShelvingSummary"
data-key="Shelving"
>
<template #header="{ entity }">
<div>{{ entity.code }}</div>
@ -51,16 +34,19 @@ const filter = {
class="header header-link"
:to="{ name: 'ShelvingBasicData', params: { id: entityId } }"
>
{{ t('globals.pageTitles.basicData') }}
{{ $t('globals.pageTitles.basicData') }}
<QIcon name="open_in_new" />
</RouterLink>
<VnLv :label="t('globals.code')" :value="entity.code" />
<VnLv :label="$t('globals.code')" :value="entity.code" />
<VnLv
:label="t('shelving.list.parking')"
:label="$t('shelving.list.parking')"
:value="entity.parking?.code"
/>
<VnLv :label="t('shelving.list.priority')" :value="entity.priority" />
<VnLv v-if="entity.worker" :label="t('globals.worker')">
<VnLv
:label="$t('shelving.list.priority')"
:value="entity.priority"
/>
<VnLv v-if="entity.worker" :label="$t('globals.worker')">
<template #value>
<VnUserLink
:name="entity.worker?.user?.nickname"
@ -69,7 +55,7 @@ const filter = {
</template>
</VnLv>
<VnLv
:label="t('shelving.summary.recyclable')"
:label="$t('shelving.summary.recyclable')"
:value="entity.isRecyclable"
/>
</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>
import VnPaginate from 'components/ui/VnPaginate.vue';
import { useStateStore } from 'stores/useStateStore';
import { useI18n } from 'vue-i18n';
import { onMounted, onUnmounted } from 'vue';
import CardList from 'components/ui/CardList.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 { useSummaryDialog } from 'src/composables/useSummaryDialog';
import RightMenu from 'src/components/common/RightMenu.vue';
import exprBuilder from './ShelvingExprBuilder.js';
const stateStore = useStateStore();
const router = useRouter();
const { t } = useI18n();
const { viewSummary } = useSummaryDialog();
const filter = {
include: [{ relation: 'parking' }],
@ -26,17 +25,6 @@ onUnmounted(() => (stateStore.rightDrawer = false));
function navigate(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>
<template>
@ -65,18 +53,18 @@ function exprBuilder(param, value) {
>
<template #list-items>
<VnLv
:label="t('shelving.list.parking')"
:title-label="t('shelving.list.parking')"
:label="$t('shelving.list.parking')"
:title-label="$t('shelving.list.parking')"
:value="row.parking?.code"
/>
<VnLv
:label="t('shelving.list.priority')"
:label="$t('shelving.list.priority')"
:value="row?.priority"
/>
</template>
<template #actions>
<QBtn
:label="t('components.smartCard.openSummary')"
:label="$t('components.smartCard.openSummary')"
@click.stop="viewSummary(row.id, ShelvingSummary)"
color="primary"
/>
@ -89,7 +77,7 @@ function exprBuilder(param, value) {
<RouterLink :to="{ name: 'ShelvingCreate' }">
<QBtn fab icon="add" color="primary" shortcut="+" />
<QTooltip>
{{ t('shelving.list.newShelving') }}
{{ $t('shelving.list.newShelving') }}
</QTooltip>
</RouterLink>
</QPageSticky>