0
0
Fork 0

fix: refs #7524 use limit shelving Section

This commit is contained in:
Jorge Penadés 2024-08-26 16:39:17 +02:00
parent 566a649c20
commit 7c2a13db0b
2 changed files with 24 additions and 79 deletions

View File

@ -3,6 +3,7 @@ import { ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import VnFilterPanel from 'components/ui/VnFilterPanel.vue'; import VnFilterPanel from 'components/ui/VnFilterPanel.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
const { t } = useI18n(); const { t } = useI18n();
const props = defineProps({ const props = defineProps({
@ -15,25 +16,13 @@ const props = defineProps({
const emit = defineEmits(['search']); const emit = defineEmits(['search']);
const workers = ref(); const workers = ref();
const parkings = ref();
function setWorkers(data) { function setWorkers(data) {
workers.value = data; workers.value = data;
} }
function setParkings(data) {
parkings.value = data;
}
</script> </script>
<template> <template>
<FetchData
url="Parkings"
:filter="{ fields: ['id', 'code'] }"
sort-by="code ASC"
@on-fetch="setParkings"
auto-load
/>
<FetchData <FetchData
url="Workers/activeWithInheritedRole" url="Workers/activeWithInheritedRole"
:filter="{ where: { role: 'salesPerson' } }" :filter="{ where: { role: 'salesPerson' } }"
@ -54,44 +43,36 @@ function setParkings(data) {
</template> </template>
<template #body="{ params }"> <template #body="{ params }">
<QItem class="q-my-sm"> <QItem class="q-my-sm">
<QItemSection v-if="!parkings"> <QItemSection>
<QSkeleton type="QInput" class="full-width" /> <VnSelect
</QItemSection> v-model="params.parkingFk"
<QItemSection v-if="parkings"> url="Parkings"
<QSelect :fields="['id', 'code']"
:label="t('params.parkingFk')"
option-value="id"
option-label="code"
:filter-options="['id', 'code']"
dense dense
outlined outlined
rounded rounded
:label="t('params.parkingFk')" sort-by="code ASC"
v-model="params.parkingFk"
:options="parkings"
option-value="id"
option-label="code"
emit-value
map-options
use-input
:input-debounce="0"
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>
<QItem class="q-mb-sm"> <QItem class="q-mb-sm">
<QItemSection v-if="!workers"> <QItemSection>
<QSkeleton type="QInput" class="full-width" /> <VnSelect
</QItemSection>
<QItemSection v-if="workers">
<QSelect
dense dense
outlined outlined
rounded rounded
:label="t('params.userFk')" :label="t('params.userFk')"
v-model="params.userFk" v-model="params.userFk"
:options="workers" url="Workers/activeWithInheritedRole"
option-value="id" option-value="id"
option-label="name" option-label="firstName"
emit-value :where="{ role: 'salesPerson' }"
map-options sort-by="firstName ASC"
use-input :use-like="false"
:input-debounce="0"
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>

View File

@ -1,12 +1,11 @@
<script setup> <script setup>
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { ref } 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';
import FetchData from 'components/FetchData.vue';
import FormModel from 'components/FormModel.vue'; 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';
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute(); const route = useRoute();
@ -20,30 +19,6 @@ const defaultInitialData = {
isRecyclable: false, isRecyclable: false,
}; };
const parkingFilter = { fields: ['id', 'code'] };
const parkingList = ref([]);
const parkingListCopy = ref([]);
const setParkingList = (data) => {
parkingList.value = data;
parkingListCopy.value = data;
};
const parkingSelectFilter = {
options: parkingList,
filterFn: (options, value) => {
const search = value.trim().toLowerCase();
if (!search || search === '') {
return parkingListCopy.value;
}
return options.value.filter((option) =>
option.code.toLowerCase().startsWith(search)
);
},
};
const shelvingFilter = { const shelvingFilter = {
include: [ include: [
{ {
@ -68,12 +43,6 @@ const onSave = (shelving, newShelving) => {
</script> </script>
<template> <template>
<VnSubToolbar /> <VnSubToolbar />
<FetchData
url="Parkings"
:filter="parkingFilter"
@on-fetch="setParkingList"
auto-load
/>
<FormModel <FormModel
:url="isNew ? null : `Shelvings/${shelvingId}`" :url="isNew ? null : `Shelvings/${shelvingId}`"
:url-create="isNew ? 'Shelvings' : null" :url-create="isNew ? 'Shelvings' : null"
@ -84,27 +53,22 @@ const onSave = (shelving, newShelving) => {
:form-initial-data="defaultInitialData" :form-initial-data="defaultInitialData"
@on-data-saved="onSave" @on-data-saved="onSave"
> >
<template #form="{ data, validate, filter }"> <template #form="{ data, validate }">
<VnRow> <VnRow>
<VnInput <VnInput
v-model="data.code" v-model="data.code"
:label="t('shelving.basicData.code')" :label="t('shelving.basicData.code')"
:rules="validate('Shelving.code')" :rules="validate('Shelving.code')"
/> />
<QSelect <VnSelect
v-model="data.parkingFk" v-model="data.parkingFk"
:options="parkingList" url="Parkings"
option-value="id" option-value="id"
option-label="code" option-label="code"
emit-value :filter-options="['id', 'code']"
:fields="['id', 'code']"
:label="t('shelving.basicData.parking')" :label="t('shelving.basicData.parking')"
map-options
use-input
@filter="
(value, update) => filter(value, update, parkingSelectFilter)
"
:rules="validate('Shelving.parkingFk')" :rules="validate('Shelving.parkingFk')"
:input-debounce="0"
/> />
</VnRow> </VnRow>
<VnRow> <VnRow>