perf: refs #7679 #7679 improve watch
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
2bd004f52b
commit
692c649b8c
|
@ -79,14 +79,20 @@ async function onProvinceCreated(data) {
|
||||||
watch(
|
watch(
|
||||||
() => [postcodeFormData.countryFk],
|
() => [postcodeFormData.countryFk],
|
||||||
async (newCountryFk, oldValueFk) => {
|
async (newCountryFk, oldValueFk) => {
|
||||||
if (!!oldValueFk[0] && newCountryFk[0] !== oldValueFk[0]) {
|
if (Array.isArray(newCountryFk)) {
|
||||||
|
newCountryFk = newCountryFk[0];
|
||||||
|
}
|
||||||
|
if (Array.isArray(oldValueFk)) {
|
||||||
|
oldValueFk = oldValueFk[0];
|
||||||
|
}
|
||||||
|
if (!!oldValueFk && newCountryFk !== oldValueFk) {
|
||||||
postcodeFormData.provinceFk = null;
|
postcodeFormData.provinceFk = null;
|
||||||
postcodeFormData.townFk = null;
|
postcodeFormData.townFk = null;
|
||||||
}
|
}
|
||||||
if ((newCountryFk, newCountryFk !== postcodeFormData.countryFk)) {
|
if (oldValueFk !== newCountryFk) {
|
||||||
await provincesFetchDataRef.value.fetch({
|
await provincesFetchDataRef.value.fetch({
|
||||||
where: {
|
where: {
|
||||||
countryFk: newCountryFk[0],
|
countryFk: newCountryFk,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await townsFetchDataRef.value.fetch({
|
await townsFetchDataRef.value.fetch({
|
||||||
|
@ -103,9 +109,12 @@ watch(
|
||||||
watch(
|
watch(
|
||||||
() => postcodeFormData.provinceFk,
|
() => postcodeFormData.provinceFk,
|
||||||
async (newProvinceFk) => {
|
async (newProvinceFk) => {
|
||||||
if (newProvinceFk[0] && newProvinceFk[0] !== postcodeFormData.provinceFk) {
|
if (Array.isArray(newProvinceFk)) {
|
||||||
|
newProvinceFk = newProvinceFk[0];
|
||||||
|
}
|
||||||
|
if (newProvinceFk !== postcodeFormData.provinceFk) {
|
||||||
await townsFetchDataRef.value.fetch({
|
await townsFetchDataRef.value.fetch({
|
||||||
where: { provinceFk: newProvinceFk[0] },
|
where: { provinceFk: newProvinceFk },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue