Merge pull request 'feature/ms-95-postcode-autocomplete' (#67) from feature/ms-95-postcode-autocomplete into dev
Reviewed-on: hyervoni/salix-front-mindshore#67
This commit is contained in:
commit
b41da81f3e
|
@ -19,8 +19,8 @@ const cityFormData = reactive({
|
||||||
|
|
||||||
const provincesOptions = ref([]);
|
const provincesOptions = ref([]);
|
||||||
|
|
||||||
const onDataSaved = () => {
|
const onDataSaved = (dataSaved) => {
|
||||||
emit('onDataSaved');
|
emit('onDataSaved', dataSaved);
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -32,12 +32,20 @@ const onDataSaved = (dataSaved) => {
|
||||||
emit('onDataSaved', dataSaved);
|
emit('onDataSaved', dataSaved);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onCityCreated = async () => {
|
const onCityCreated = async ({ name, provinceFk }, formData) => {
|
||||||
await townsFetchDataRef.value.fetch();
|
await townsFetchDataRef.value.fetch();
|
||||||
|
formData.townFk = townsLocationOptions.value.find((town) => town.name === name).id;
|
||||||
|
formData.provinceFk = provinceFk;
|
||||||
|
formData.countryFk = provincesOptions.value.find(
|
||||||
|
(province) => province.id === provinceFk
|
||||||
|
).countryFk;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onProvinceCreated = async () => {
|
const onProvinceCreated = async ({ name }, formData) => {
|
||||||
await provincesFetchDataRef.value.fetch();
|
await provincesFetchDataRef.value.fetch();
|
||||||
|
formData.provinceFk = provincesOptions.value.find(
|
||||||
|
(province) => province.name === name
|
||||||
|
).id;
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -88,7 +96,9 @@ const onProvinceCreated = async () => {
|
||||||
:roles-allowed-to-create="['deliveryAssistant']"
|
:roles-allowed-to-create="['deliveryAssistant']"
|
||||||
>
|
>
|
||||||
<template #form>
|
<template #form>
|
||||||
<CreateNewCityForm @on-data-saved="onCityCreated($event)" />
|
<CreateNewCityForm
|
||||||
|
@on-data-saved="onCityCreated($event, data)"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
</VnSelectCreate>
|
</VnSelectCreate>
|
||||||
</div>
|
</div>
|
||||||
|
@ -107,7 +117,7 @@ const onProvinceCreated = async () => {
|
||||||
>
|
>
|
||||||
<template #form>
|
<template #form>
|
||||||
<CreateNewProvinceForm
|
<CreateNewProvinceForm
|
||||||
@on-data-saved="onProvinceCreated($event)"
|
@on-data-saved="onProvinceCreated($event, data)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</VnSelectCreate>
|
</VnSelectCreate>
|
||||||
|
|
|
@ -19,8 +19,8 @@ const provinceFormData = reactive({
|
||||||
|
|
||||||
const autonomiesOptions = ref([]);
|
const autonomiesOptions = ref([]);
|
||||||
|
|
||||||
const onDataSaved = () => {
|
const onDataSaved = (dataSaved) => {
|
||||||
emit('onDataSaved');
|
emit('onDataSaved', dataSaved);
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -14,16 +14,22 @@ import VnSelectCreate from 'src/components/common/VnSelectCreate.vue';
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
|
const townsFetchDataRef = ref(null);
|
||||||
|
const postcodeFetchDataRef = ref(null);
|
||||||
const typesTaxes = ref([]);
|
const typesTaxes = ref([]);
|
||||||
const typesTransactions = ref([]);
|
const typesTransactions = ref([]);
|
||||||
const postcodeFetchDataRef = ref(null);
|
|
||||||
const citiesLocationOptions = ref([]);
|
const citiesLocationOptions = ref([]);
|
||||||
const provincesLocationOptions = ref([]);
|
const provincesLocationOptions = ref([]);
|
||||||
const countriesOptions = ref([]);
|
const countriesOptions = ref([]);
|
||||||
const postcodesOptions = ref([]);
|
const postcodesOptions = ref([]);
|
||||||
|
|
||||||
const onPostcodeCreated = async () => {
|
const onPostcodeCreated = async ({ code, provinceFk, townFk, countryFk }, formData) => {
|
||||||
postcodeFetchDataRef.value.fetch();
|
await postcodeFetchDataRef.value.fetch();
|
||||||
|
await townsFetchDataRef.value.fetch();
|
||||||
|
formData.postcode = code;
|
||||||
|
formData.provinceFk = provinceFk;
|
||||||
|
formData.city = citiesLocationOptions.value.find((town) => town.id === townFk).name;
|
||||||
|
formData.countryFk = countryFk;
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -35,6 +41,7 @@ const onPostcodeCreated = async () => {
|
||||||
url="SageTransactionTypes"
|
url="SageTransactionTypes"
|
||||||
/>
|
/>
|
||||||
<FetchData
|
<FetchData
|
||||||
|
ref="townsFetchDataRef"
|
||||||
@on-fetch="(data) => (citiesLocationOptions = data)"
|
@on-fetch="(data) => (citiesLocationOptions = data)"
|
||||||
auto-load
|
auto-load
|
||||||
url="Towns/location"
|
url="Towns/location"
|
||||||
|
@ -49,7 +56,12 @@ const onPostcodeCreated = async () => {
|
||||||
auto-load
|
auto-load
|
||||||
url="Countries"
|
url="Countries"
|
||||||
/>
|
/>
|
||||||
|
<FetchData
|
||||||
|
ref="postcodeFetchDataRef"
|
||||||
|
url="Postcodes/location"
|
||||||
|
@on-fetch="(data) => (postcodesOptions = data)"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
<FormModel
|
<FormModel
|
||||||
:url-update="`Clients/${route.params.id}/updateFiscalData`"
|
:url-update="`Clients/${route.params.id}/updateFiscalData`"
|
||||||
:url="`Clients/${route.params.id}/getCard`"
|
:url="`Clients/${route.params.id}/getCard`"
|
||||||
|
@ -114,7 +126,7 @@ const onPostcodeCreated = async () => {
|
||||||
>
|
>
|
||||||
<template #form>
|
<template #form>
|
||||||
<CustomerCreateNewPostcode
|
<CustomerCreateNewPostcode
|
||||||
@on-data-saved="onPostcodeCreated($event)"
|
@on-data-saved="onPostcodeCreated($event, data)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #option="scope">
|
<template #option="scope">
|
||||||
|
@ -136,7 +148,6 @@ const onPostcodeCreated = async () => {
|
||||||
</VnSelectCreate>
|
</VnSelectCreate>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<!-- ciudades -->
|
|
||||||
<VnSelectFilter
|
<VnSelectFilter
|
||||||
:label="t('City')"
|
:label="t('City')"
|
||||||
:options="citiesLocationOptions"
|
:options="citiesLocationOptions"
|
||||||
|
@ -169,7 +180,7 @@ const onPostcodeCreated = async () => {
|
||||||
hide-selected
|
hide-selected
|
||||||
option-label="name"
|
option-label="name"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
v-model="data.province"
|
v-model="data.provinceFk"
|
||||||
>
|
>
|
||||||
<template #option="scope">
|
<template #option="scope">
|
||||||
<QItem v-bind="scope.itemProps">
|
<QItem v-bind="scope.itemProps">
|
||||||
|
@ -189,7 +200,7 @@ const onPostcodeCreated = async () => {
|
||||||
hide-selected
|
hide-selected
|
||||||
option-label="country"
|
option-label="country"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
v-model="data.country"
|
v-model="data.countryFk"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
|
|
|
@ -30,6 +30,7 @@ const newClientForm = reactive({
|
||||||
});
|
});
|
||||||
|
|
||||||
const postcodeFetchDataRef = ref(null);
|
const postcodeFetchDataRef = ref(null);
|
||||||
|
const townsFetchDataRef = ref(null);
|
||||||
const workersOptions = ref([]);
|
const workersOptions = ref([]);
|
||||||
const businessTypesOptions = ref([]);
|
const businessTypesOptions = ref([]);
|
||||||
const citiesLocationOptions = ref([]);
|
const citiesLocationOptions = ref([]);
|
||||||
|
@ -37,8 +38,13 @@ const provincesLocationOptions = ref([]);
|
||||||
const countriesOptions = ref([]);
|
const countriesOptions = ref([]);
|
||||||
const postcodesOptions = ref([]);
|
const postcodesOptions = ref([]);
|
||||||
|
|
||||||
const onPostcodeCreated = async () => {
|
const onPostcodeCreated = async ({ code, provinceFk, townFk, countryFk }, formData) => {
|
||||||
postcodeFetchDataRef.value.fetch();
|
await postcodeFetchDataRef.value.fetch();
|
||||||
|
await townsFetchDataRef.value.fetch();
|
||||||
|
formData.postcode = code;
|
||||||
|
formData.provinceFk = provinceFk;
|
||||||
|
formData.city = citiesLocationOptions.value.find((town) => town.id === townFk).name;
|
||||||
|
formData.countryFk = countryFk;
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -60,6 +66,7 @@ const onPostcodeCreated = async () => {
|
||||||
url="BusinessTypes"
|
url="BusinessTypes"
|
||||||
/>
|
/>
|
||||||
<FetchData
|
<FetchData
|
||||||
|
ref="townsFetchDataRef"
|
||||||
@on-fetch="(data) => (citiesLocationOptions = data)"
|
@on-fetch="(data) => (citiesLocationOptions = data)"
|
||||||
auto-load
|
auto-load
|
||||||
url="Towns/location"
|
url="Towns/location"
|
||||||
|
@ -78,7 +85,6 @@ const onPostcodeCreated = async () => {
|
||||||
<VnSubToolbar />
|
<VnSubToolbar />
|
||||||
<FormModel
|
<FormModel
|
||||||
:form-initial-data="newClientForm"
|
:form-initial-data="newClientForm"
|
||||||
:observe-form-changes="false"
|
|
||||||
model="client"
|
model="client"
|
||||||
url-create="Clients/createWithUser"
|
url-create="Clients/createWithUser"
|
||||||
>
|
>
|
||||||
|
@ -145,7 +151,7 @@ const onPostcodeCreated = async () => {
|
||||||
>
|
>
|
||||||
<template #form>
|
<template #form>
|
||||||
<CustomerCreateNewPostcode
|
<CustomerCreateNewPostcode
|
||||||
@on-data-saved="onPostcodeCreated($event)"
|
@on-data-saved="onPostcodeCreated($event, data)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #option="scope">
|
<template #option="scope">
|
||||||
|
|
|
@ -15,6 +15,7 @@ const route = useRoute();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
const postcodeFetchDataRef = ref(null);
|
const postcodeFetchDataRef = ref(null);
|
||||||
|
const townsFetchDataRef = ref(null);
|
||||||
const sageTaxTypesOptions = ref([]);
|
const sageTaxTypesOptions = ref([]);
|
||||||
const sageWithholdingsOptions = ref([]);
|
const sageWithholdingsOptions = ref([]);
|
||||||
const sageTransactionTypesOptions = ref([]);
|
const sageTransactionTypesOptions = ref([]);
|
||||||
|
@ -24,8 +25,13 @@ const provincesLocationOptions = ref([]);
|
||||||
const townsLocationOptions = ref([]);
|
const townsLocationOptions = ref([]);
|
||||||
const countriesOptions = ref([]);
|
const countriesOptions = ref([]);
|
||||||
|
|
||||||
const onPostcodeCreated = async () => {
|
const onPostcodeCreated = async ({ code, provinceFk, townFk, countryFk }, formData) => {
|
||||||
postcodeFetchDataRef.value.fetch();
|
await postcodeFetchDataRef.value.fetch();
|
||||||
|
await townsFetchDataRef.value.fetch();
|
||||||
|
formData.postCode = code;
|
||||||
|
formData.provinceFk = provinceFk;
|
||||||
|
formData.city = townsLocationOptions.value.find((town) => town.id === townFk).name;
|
||||||
|
formData.countryFk = countryFk;
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
@ -56,6 +62,7 @@ const onPostcodeCreated = async () => {
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
<FetchData
|
<FetchData
|
||||||
|
ref="townsFetchDataRef"
|
||||||
@on-fetch="(data) => (townsLocationOptions = data)"
|
@on-fetch="(data) => (townsLocationOptions = data)"
|
||||||
auto-load
|
auto-load
|
||||||
url="Towns/location"
|
url="Towns/location"
|
||||||
|
@ -167,19 +174,18 @@ const onPostcodeCreated = async () => {
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<VnSelectCreate
|
<VnSelectCreate
|
||||||
v-model="data.postCode"
|
|
||||||
:label="t('supplier.fiscalData.postcode')"
|
:label="t('supplier.fiscalData.postcode')"
|
||||||
|
v-model="data.postCode"
|
||||||
|
:options="postcodesOptions"
|
||||||
:rules="validate('supplier.postCode')"
|
:rules="validate('supplier.postCode')"
|
||||||
:roles-allowed-to-create="['deliveryAssistant']"
|
:roles-allowed-to-create="['deliveryAssistant']"
|
||||||
:options="postcodesOptions"
|
|
||||||
option-label="code"
|
option-label="code"
|
||||||
option-value="code"
|
option-value="code"
|
||||||
map-options
|
|
||||||
hide-selected
|
hide-selected
|
||||||
>
|
>
|
||||||
<template #form>
|
<template #form>
|
||||||
<CustomerCreateNewPostcode
|
<CustomerCreateNewPostcode
|
||||||
@on-data-saved="onPostcodeCreated($event)"
|
@on-data-saved="onPostcodeCreated($event, data)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #option="scope">
|
<template #option="scope">
|
||||||
|
@ -282,6 +288,7 @@ const onPostcodeCreated = async () => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
|
<pre> {{ data }}</pre>
|
||||||
</template>
|
</template>
|
||||||
</FormModel>
|
</FormModel>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -50,6 +50,7 @@ const newWorkerForm = ref({
|
||||||
});
|
});
|
||||||
|
|
||||||
const postcodeFetchDataRef = ref(null);
|
const postcodeFetchDataRef = ref(null);
|
||||||
|
const townsFetchDataRef = ref(null);
|
||||||
const provincesOptions = ref([]);
|
const provincesOptions = ref([]);
|
||||||
const townsOptions = ref([]);
|
const townsOptions = ref([]);
|
||||||
const companiesOptions = ref([]);
|
const companiesOptions = ref([]);
|
||||||
|
@ -66,8 +67,12 @@ const onBankEntityCreated = (data) => {
|
||||||
bankEntitiesOptions.value.push(data);
|
bankEntitiesOptions.value.push(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onPostcodeCreated = async () => {
|
const onPostcodeCreated = async ({ code, provinceFk, townFk }, formData) => {
|
||||||
postcodeFetchDataRef.value.fetch();
|
await postcodeFetchDataRef.value.fetch();
|
||||||
|
await townsFetchDataRef.value.fetch();
|
||||||
|
formData.postcode = code;
|
||||||
|
formData.provinceFk = provinceFk;
|
||||||
|
formData.city = townsOptions.value.find((town) => town.id === townFk).name;
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
@ -96,6 +101,7 @@ onMounted(async () => {
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
<FetchData
|
<FetchData
|
||||||
|
ref="townsFetchDataRef"
|
||||||
url="Towns/location"
|
url="Towns/location"
|
||||||
@on-fetch="(data) => (townsOptions = data)"
|
@on-fetch="(data) => (townsOptions = data)"
|
||||||
:filter="townsFilter"
|
:filter="townsFilter"
|
||||||
|
@ -190,7 +196,7 @@ onMounted(async () => {
|
||||||
>
|
>
|
||||||
<template #form>
|
<template #form>
|
||||||
<CustomerCreateNewPostcode
|
<CustomerCreateNewPostcode
|
||||||
@on-data-saved="onPostcodeCreated($event)"
|
@on-data-saved="onPostcodeCreated($event, data)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #option="scope">
|
<template #option="scope">
|
||||||
|
@ -357,6 +363,7 @@ onMounted(async () => {
|
||||||
</template>
|
</template>
|
||||||
</VnSelectCreate>
|
</VnSelectCreate>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
|
<pre>{{ data }}</pre>
|
||||||
</template>
|
</template>
|
||||||
</FormModel>
|
</FormModel>
|
||||||
</QPage>
|
</QPage>
|
||||||
|
|
Loading…
Reference in New Issue