refs #6694 feat: use VnLocation for WorkerCreate
gitea/salix-front/pipeline/head This commit looks good
Details
gitea/salix-front/pipeline/head This commit looks good
Details
This commit is contained in:
parent
4e66f3c65d
commit
c38e76de88
|
@ -129,5 +129,5 @@ async function onPostcodeCreated(){
|
||||||
<i18n>
|
<i18n>
|
||||||
es:
|
es:
|
||||||
Location: Ubicación
|
Location: Ubicación
|
||||||
Search by postalCode, town, province or country: Buscar por código postal, ciudad o país
|
Search by postalcode, town, province or country: Buscar por código postal, ciudad o país
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
|
@ -9,7 +9,7 @@ import VnInputDate from 'components/common/VnInputDate.vue';
|
||||||
import VnSelectFilter from 'src/components/common/VnSelectFilter.vue';
|
import VnSelectFilter from 'src/components/common/VnSelectFilter.vue';
|
||||||
import VnSelectCreate from 'src/components/common/VnSelectCreate.vue';
|
import VnSelectCreate from 'src/components/common/VnSelectCreate.vue';
|
||||||
import CreateBankEntityForm from 'src/components/CreateBankEntityForm.vue';
|
import CreateBankEntityForm from 'src/components/CreateBankEntityForm.vue';
|
||||||
import CustomerCreateNewPostcode from 'src/components/CreateNewPostcodeForm.vue';
|
import VnLocation from 'src/components/common/VnLocation.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';
|
||||||
|
|
||||||
|
@ -21,14 +21,6 @@ const workerConfigFilter = {
|
||||||
field: ['payMethodFk'],
|
field: ['payMethodFk'],
|
||||||
};
|
};
|
||||||
|
|
||||||
const provincesFilter = {
|
|
||||||
fields: ['id', 'name', 'countryFk'],
|
|
||||||
};
|
|
||||||
|
|
||||||
const townsFilter = {
|
|
||||||
fields: ['id', 'name', 'provinceFk'],
|
|
||||||
};
|
|
||||||
|
|
||||||
const newWorkerForm = ref({
|
const newWorkerForm = ref({
|
||||||
companyFk: null,
|
companyFk: null,
|
||||||
payMethodFk: null,
|
payMethodFk: null,
|
||||||
|
@ -49,9 +41,6 @@ const newWorkerForm = ref({
|
||||||
bankEntityFk: null,
|
bankEntityFk: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
const postcodeFetchDataRef = ref(null);
|
|
||||||
const provincesOptions = ref([]);
|
|
||||||
const townsOptions = ref([]);
|
|
||||||
const companiesOptions = ref([]);
|
const companiesOptions = ref([]);
|
||||||
const workersOptions = ref([]);
|
const workersOptions = ref([]);
|
||||||
const payMethodsOptions = ref([]);
|
const payMethodsOptions = ref([]);
|
||||||
|
@ -66,9 +55,13 @@ const onBankEntityCreated = (data) => {
|
||||||
bankEntitiesOptions.value.push(data);
|
bankEntitiesOptions.value.push(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onPostcodeCreated = async () => {
|
|
||||||
postcodeFetchDataRef.value.fetch();
|
function handleLocation(data, { city, postcode, provinceFk, countryFk }) {
|
||||||
};
|
data.postcode = postcode;
|
||||||
|
data.city = city;
|
||||||
|
data.provinceFk = provinceFk;
|
||||||
|
data.countryFk = countryFk;
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const userInfo = await useUserConfig().fetch();
|
const userInfo = await useUserConfig().fetch();
|
||||||
|
@ -83,24 +76,7 @@ onMounted(async () => {
|
||||||
:filter="workerConfigFilter"
|
:filter="workerConfigFilter"
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
<FetchData
|
|
||||||
ref="postcodeFetchDataRef"
|
|
||||||
url="Postcodes/location"
|
|
||||||
@on-fetch="(data) => (postcodesOptions = data)"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
<FetchData
|
|
||||||
url="Provinces/location"
|
|
||||||
@on-fetch="(data) => (provincesOptions = data)"
|
|
||||||
:filter="provincesFilter"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
<FetchData
|
|
||||||
url="Towns/location"
|
|
||||||
@on-fetch="(data) => (townsOptions = data)"
|
|
||||||
:filter="townsFilter"
|
|
||||||
auto-load
|
|
||||||
/>
|
|
||||||
<FetchData
|
<FetchData
|
||||||
url="Companies"
|
url="Companies"
|
||||||
@on-fetch="(data) => (companiesOptions = data)"
|
@on-fetch="(data) => (companiesOptions = data)"
|
||||||
|
@ -178,77 +154,19 @@ onMounted(async () => {
|
||||||
</VnRow>
|
</VnRow>
|
||||||
<VnRow class="row q-gutter-md q-mb-md">
|
<VnRow class="row q-gutter-md q-mb-md">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<VnSelectCreate
|
<VnLocation
|
||||||
v-model="data.postcode"
|
|
||||||
:label="t('worker.create.postcode')"
|
|
||||||
:rules="validate('Worker.postcode')"
|
:rules="validate('Worker.postcode')"
|
||||||
:roles-allowed-to-create="['deliveryAssistant']"
|
:roles-allowed-to-create="['deliveryAssistant']"
|
||||||
:options="postcodesOptions"
|
:options="postcodesOptions"
|
||||||
option-label="code"
|
v-model="data.location"
|
||||||
option-value="code"
|
@update:model-value="
|
||||||
hide-selected
|
(location) => handleLocation(data, location)
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<template #form>
|
</VnLocation>
|
||||||
<CustomerCreateNewPostcode
|
|
||||||
@on-data-saved="onPostcodeCreated($event)"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<template #option="scope">
|
|
||||||
<QItem v-bind="scope.itemProps">
|
|
||||||
<QItemSection v-if="scope.opt">
|
|
||||||
<QItemLabel>{{ scope.opt.code }}</QItemLabel>
|
|
||||||
<QItemLabel caption
|
|
||||||
>{{ scope.opt.code }} -
|
|
||||||
{{ scope.opt.town.name }} ({{
|
|
||||||
scope.opt.town.province.name
|
|
||||||
}},
|
|
||||||
{{
|
|
||||||
scope.opt.town.province.country.country
|
|
||||||
}})</QItemLabel
|
|
||||||
>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</template>
|
|
||||||
</VnSelectCreate>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<VnSelectFilter
|
|
||||||
:label="t('worker.create.province')"
|
|
||||||
v-model="data.provinceFk"
|
|
||||||
:options="provincesOptions"
|
|
||||||
option-value="id"
|
|
||||||
option-label="name"
|
|
||||||
hide-selected
|
|
||||||
:rules="validate('Worker.provinceFk')"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
<VnRow class="row q-gutter-md q-mb-md">
|
<VnRow class="row q-gutter-md q-mb-md">
|
||||||
<div class="col">
|
|
||||||
<VnSelectFilter
|
|
||||||
:label="t('worker.create.city')"
|
|
||||||
v-model="data.city"
|
|
||||||
:options="townsOptions"
|
|
||||||
option-value="name"
|
|
||||||
option-label="name"
|
|
||||||
hide-selected
|
|
||||||
:rules="validate('Worker.city')"
|
|
||||||
>
|
|
||||||
<template #option="scope">
|
|
||||||
<QItem v-bind="scope.itemProps">
|
|
||||||
<QItemSection>
|
|
||||||
<QItemLabel>{{ scope.opt.name }}</QItemLabel>
|
|
||||||
<QItemLabel caption
|
|
||||||
>{{ scope.opt.name }},
|
|
||||||
{{ scope.opt.province.name }} ({{
|
|
||||||
scope.opt.province.country.country
|
|
||||||
}})</QItemLabel
|
|
||||||
>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</template>
|
|
||||||
</VnSelectFilter>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<VnInput
|
<VnInput
|
||||||
:label="t('worker.create.street')"
|
:label="t('worker.create.street')"
|
||||||
|
|
Loading…
Reference in New Issue