feat: apply VnSelect url property for some Customer fields
This commit is contained in:
parent
cfc6bc7d11
commit
ab96586a41
|
@ -43,10 +43,6 @@ const $props = defineProps({
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
// paginate: {
|
|
||||||
// type: Boolean,
|
|
||||||
// default: true,
|
|
||||||
// },
|
|
||||||
fields: {
|
fields: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: null,
|
default: null,
|
||||||
|
@ -59,18 +55,10 @@ const $props = defineProps({
|
||||||
type: String,
|
type: String,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
// orderBy: {
|
|
||||||
// type: String,
|
|
||||||
// default: null,
|
|
||||||
// },
|
|
||||||
limit: {
|
limit: {
|
||||||
type: [Number, String],
|
type: [Number, String],
|
||||||
default: '30',
|
default: '30',
|
||||||
},
|
},
|
||||||
// fetchRef: {
|
|
||||||
// type: Object,
|
|
||||||
// default: null,
|
|
||||||
// },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
@ -93,18 +81,8 @@ const value = computed({
|
||||||
});
|
});
|
||||||
|
|
||||||
function setOptions(data, append = true) {
|
function setOptions(data, append = true) {
|
||||||
// if (isLoading.value) {
|
|
||||||
// data.unshift(...myOptions.value);
|
|
||||||
// }
|
|
||||||
// if (arrayData.store) {
|
|
||||||
// // arrayData.store.data = data;
|
|
||||||
// arrayData.store.hasMoreData = data.length === +$props.limit;
|
|
||||||
// append && myOptions.value.concat(data);
|
|
||||||
// // myOptionsOriginal.value = JSON.parse(JSON.stringify(data));
|
|
||||||
// } else {
|
|
||||||
myOptions.value = JSON.parse(JSON.stringify(data));
|
myOptions.value = JSON.parse(JSON.stringify(data));
|
||||||
if (append) myOptionsOriginal.value = JSON.parse(JSON.stringify(data));
|
if (append) myOptionsOriginal.value = JSON.parse(JSON.stringify(data));
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
const useURL = computed(() => $props.url?.length > 0);
|
const useURL = computed(() => $props.url?.length > 0);
|
||||||
const arrayData = useURL.value
|
const arrayData = useURL.value
|
||||||
|
@ -188,7 +166,6 @@ async function filterHandler(val, update) {
|
||||||
const { data } = await arrayData.fetch({ append: false });
|
const { data } = await arrayData.fetch({ append: false });
|
||||||
newOptions = data;
|
newOptions = data;
|
||||||
myOptionsFiltered.value = data;
|
myOptionsFiltered.value = data;
|
||||||
// setOptions(data, false);
|
|
||||||
}
|
}
|
||||||
update(
|
update(
|
||||||
() => {
|
() => {
|
||||||
|
|
|
@ -16,28 +16,8 @@ const { getTokenMultimedia } = useSession();
|
||||||
const token = getTokenMultimedia();
|
const token = getTokenMultimedia();
|
||||||
|
|
||||||
const workers = ref([]);
|
const workers = ref([]);
|
||||||
const workersCopy = ref([]);
|
|
||||||
const businessTypes = ref([]);
|
const businessTypes = ref([]);
|
||||||
const contactChannels = ref([]);
|
const contactChannels = ref([]);
|
||||||
|
|
||||||
const filterOptions = {
|
|
||||||
options: workers,
|
|
||||||
filterFn: (options, value) => {
|
|
||||||
const search = value.toLowerCase();
|
|
||||||
|
|
||||||
if (value === '') return workersCopy.value;
|
|
||||||
|
|
||||||
return options.value.filter((row) => {
|
|
||||||
const id = row.id;
|
|
||||||
const name = row.name.toLowerCase();
|
|
||||||
|
|
||||||
const idMatches = id === search;
|
|
||||||
const nameMatches = name.indexOf(search) > -1;
|
|
||||||
|
|
||||||
return idMatches || nameMatches;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
|
@ -58,7 +38,7 @@ const filterOptions = {
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<FormModel :url="`Clients/${route.params.id}`" auto-load model="customer">
|
<FormModel :url="`Clients/${route.params.id}`" auto-load model="customer">
|
||||||
<template #form="{ data, validate, filter }">
|
<template #form="{ data, validate }">
|
||||||
<VnRow class="row q-gutter-md q-mb-md">
|
<VnRow class="row q-gutter-md q-mb-md">
|
||||||
<VnInput
|
<VnInput
|
||||||
:label="t('Comercial name')"
|
:label="t('Comercial name')"
|
||||||
|
@ -124,8 +104,7 @@ const filterOptions = {
|
||||||
:options="workers"
|
:options="workers"
|
||||||
:rules="validate('client.salesPersonFk')"
|
:rules="validate('client.salesPersonFk')"
|
||||||
url="Workers/activeWithInheritedRole"
|
url="Workers/activeWithInheritedRole"
|
||||||
@filter="(value, update) => filter(value, update, filterOptions)"
|
:where="{ role: 'salesPerson' }"
|
||||||
:filter="{ where: { role: 'salesPerson' } }"
|
|
||||||
emit-value
|
emit-value
|
||||||
map-options
|
map-options
|
||||||
option-label="name"
|
option-label="name"
|
||||||
|
|
|
@ -23,13 +23,6 @@ const authors = ref();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<FetchData @on-fetch="(data) => (clients = data)" auto-load url="Clients" />
|
|
||||||
<FetchData
|
|
||||||
:filter="{ where: { role: 'salesPerson' } }"
|
|
||||||
@on-fetch="(data) => (salespersons = data)"
|
|
||||||
auto-load
|
|
||||||
url="Workers/activeWithInheritedRole"
|
|
||||||
/>
|
|
||||||
<FetchData @on-fetch="(data) => (countries = data)" auto-load url="Countries" />
|
<FetchData @on-fetch="(data) => (countries = data)" auto-load url="Countries" />
|
||||||
<FetchData
|
<FetchData
|
||||||
@on-fetch="(data) => (authors = data)"
|
@on-fetch="(data) => (authors = data)"
|
||||||
|
@ -47,7 +40,7 @@ const authors = ref();
|
||||||
|
|
||||||
<template #body="{ params, searchFn }">
|
<template #body="{ params, searchFn }">
|
||||||
<QItem class="q-mb-sm">
|
<QItem class="q-mb-sm">
|
||||||
<QItemSection v-if="clients">
|
<QItemSection>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
:label="t('Client')"
|
:label="t('Client')"
|
||||||
:options="clients"
|
:options="clients"
|
||||||
|
@ -62,17 +55,17 @@ const authors = ref();
|
||||||
use-input
|
use-input
|
||||||
v-model="params.clientFk"
|
v-model="params.clientFk"
|
||||||
@update:model-value="searchFn()"
|
@update:model-value="searchFn()"
|
||||||
auto-load
|
url="Clients"
|
||||||
/>
|
/>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
<QItemSection v-else>
|
|
||||||
<QSkeleton class="full-width" type="QInput" />
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
</QItem>
|
||||||
|
|
||||||
<QItem class="q-mb-sm">
|
<QItem class="q-mb-sm">
|
||||||
<QItemSection v-if="salespersons">
|
<QItemSection>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
|
:where="{ role: 'salesPerson' }"
|
||||||
|
option-filter="firstName"
|
||||||
|
url="Workers/activeWithInheritedRole"
|
||||||
:input-debounce="0"
|
:input-debounce="0"
|
||||||
:label="t('Salesperson')"
|
:label="t('Salesperson')"
|
||||||
:options="salespersons"
|
:options="salespersons"
|
||||||
|
@ -89,9 +82,6 @@ const authors = ref();
|
||||||
@update:model-value="searchFn()"
|
@update:model-value="searchFn()"
|
||||||
/>
|
/>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
<QItemSection v-else>
|
|
||||||
<QSkeleton class="full-width" type="QInput" />
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
</QItem>
|
||||||
|
|
||||||
<QItem class="q-mb-sm">
|
<QItem class="q-mb-sm">
|
||||||
|
@ -104,7 +94,7 @@ const authors = ref();
|
||||||
emit-value
|
emit-value
|
||||||
hide-selected
|
hide-selected
|
||||||
map-options
|
map-options
|
||||||
option-label="country"
|
option-label="name"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
outlined
|
outlined
|
||||||
rounded
|
rounded
|
||||||
|
|
Loading…
Reference in New Issue