forked from verdnatura/salix-front
feat: remove duplicity
This commit is contained in:
parent
ea43df81fd
commit
c878fc9cff
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { onMounted, ref, reactive } from 'vue';
|
||||
import { onMounted, ref, reactive, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
|
@ -12,6 +12,7 @@ const { notify } = useNotify();
|
|||
|
||||
const deliveryMethodFk = ref('delivery');
|
||||
const deliveryMethods = ref({});
|
||||
const inq = ref([]);
|
||||
const formData = reactive({});
|
||||
|
||||
const arrayData = useArrayData('ZoneDeliveryDays', {
|
||||
|
@ -39,11 +40,18 @@ const onSubmit = async () => {
|
|||
};
|
||||
|
||||
onMounted(async () => {
|
||||
deliveryMethodFk.value = 'delivery';
|
||||
formData.geoFk = arrayData.store?.userParams?.geoFk;
|
||||
formData.agencyModeFk = arrayData.store?.userParams?.agencyModeFk;
|
||||
if (formData.geoFk || formData.agencyModeFk) await fetchData();
|
||||
});
|
||||
watch(
|
||||
() => deliveryMethodFk.value,
|
||||
() => {
|
||||
inq.value = {
|
||||
deliveryMethodFk: { inq: deliveryMethods.value[deliveryMethodFk.value] },
|
||||
};
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -52,13 +60,14 @@ onMounted(async () => {
|
|||
:fields="['id', 'name', 'deliveryMethodFk']"
|
||||
@on-fetch="
|
||||
(data) => {
|
||||
console.log('data: ', data);
|
||||
console.log('deliveryMethodsConfig: ', deliveryMethodsConfig);
|
||||
Object.entries(deliveryMethodsConfig).forEach(([key, value]) => {
|
||||
deliveryMethods[key] = data
|
||||
.filter((code) => value.includes(code.code))
|
||||
.map((method) => method.id);
|
||||
});
|
||||
inq = {
|
||||
deliveryMethodFk: { inq: deliveryMethods[deliveryMethodFk] },
|
||||
};
|
||||
}
|
||||
"
|
||||
auto-load
|
||||
|
@ -112,9 +121,7 @@ onMounted(async () => {
|
|||
v-model="formData.agencyModeFk"
|
||||
url="AgencyModes/isActive"
|
||||
:fields="['id', 'name']"
|
||||
:where="{
|
||||
deliveryMethodFk: { inq: deliveryMethods[deliveryMethodFk] },
|
||||
}"
|
||||
:where="inq"
|
||||
sort-by="name ASC"
|
||||
option-value="id"
|
||||
option-label="name"
|
||||
|
@ -129,9 +136,7 @@ onMounted(async () => {
|
|||
v-model="formData.agencyModeFk"
|
||||
url="AgencyModes/isActive"
|
||||
:fields="['id', 'name']"
|
||||
:where="{
|
||||
deliveryMethodFk: { inq: deliveryMethods[deliveryMethodFk] },
|
||||
}"
|
||||
:where="inq"
|
||||
sort-by="name ASC"
|
||||
option-value="id"
|
||||
option-label="name"
|
||||
|
|
Loading…
Reference in New Issue