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

View File

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