This commit is contained in:
@@ -317,16 +317,16 @@
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</v-row>
|
||||
<v-dialog v-model="openSelectDialog">
|
||||
<v-dialog max-width="600px" v-model="openSelectDialog">
|
||||
<v-card>
|
||||
<v-card-title>
|
||||
<span class="text-h5">{{ $ay.t("SelectAlternateAddress") }}</span>
|
||||
</v-card-title>
|
||||
<v-card-text> </v-card-text>
|
||||
<v-card-text> {{ alternateAddresses }}</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
|
||||
<v-btn color="blue darken-1" text @click="close()">{{
|
||||
<v-btn color="blue darken-1" text @click="closeSelect()">{{
|
||||
$ay.t("OK")
|
||||
}}</v-btn>
|
||||
</v-card-actions>
|
||||
@@ -368,6 +368,9 @@ export default {
|
||||
close() {
|
||||
this.openDialog = false;
|
||||
},
|
||||
closeSelect() {
|
||||
this.openSelectDialog = false;
|
||||
},
|
||||
|
||||
form() {
|
||||
return window.$gz.form;
|
||||
@@ -499,9 +502,55 @@ async function populateAlternateAddresses(vm) {
|
||||
//find all the addressible objects, get their addresses and push into list
|
||||
//at top should be customer, headoffice, then units
|
||||
vm.alternateAddresses = [];
|
||||
const ispostal = vm.selectType == 2;
|
||||
const wo = vm.value;
|
||||
if (wo.customerId != null) {
|
||||
res = await window.$gz.api.get(`customer/address/${wo.customerId}`);
|
||||
let res = await window.$gz.api.get(`customer/address/${wo.customerId}`);
|
||||
if (res.data) {
|
||||
//customer first
|
||||
if (ispostal) {
|
||||
vm.alternateAddresses.push({
|
||||
name: res.data.customerpost.name,
|
||||
viz: formatAddress(res.data.customerpost).postal,
|
||||
src: res.data
|
||||
});
|
||||
//headoffice if present
|
||||
if (res.data.headofficepost) {
|
||||
vm.alternateAddresses.push({
|
||||
name: res.data.headofficepost.name,
|
||||
viz: formatAddress(res.data.headofficepost).postal,
|
||||
src: res.data
|
||||
});
|
||||
}
|
||||
} else {
|
||||
vm.alternateAddresses.push({
|
||||
name: res.data.customerphys.name,
|
||||
viz: formatAddress(res.data.customerphys).physical,
|
||||
src: res.data
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
//Unit addresses
|
||||
//Units only have physical addresses
|
||||
if (!ispostal) {
|
||||
let unitIdList = [];
|
||||
vm.value.items.forEach(i => {
|
||||
i.units.forEach(async u => {
|
||||
if (u.id != null && !unitIdList.includes(u.id)) {
|
||||
unitIdList.push(u.id);
|
||||
//get address
|
||||
let res = await window.$gz.api.get(`unit/address/${u.id}`);
|
||||
if (res.data) {
|
||||
vm.alternateAddresses.push({
|
||||
name: res.data.unit.name,
|
||||
viz: formatAddress(res.data.unit).physical,
|
||||
src: res.data
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -523,7 +572,13 @@ function formatAddress(o) {
|
||||
ret.physical += o.region + " ";
|
||||
}
|
||||
if (!window.$gz.util.stringIsNullOrEmpty(o.country)) {
|
||||
ret.physical += o.country;
|
||||
ret.physical += o.country + " ";
|
||||
}
|
||||
if (!window.$gz.util.stringIsNullOrEmpty(o.latitude)) {
|
||||
ret.physical += ", lat " + o.latitude;
|
||||
}
|
||||
if (!window.$gz.util.stringIsNullOrEmpty(o.longitude)) {
|
||||
ret.physical += ", long " + o.longitude;
|
||||
}
|
||||
|
||||
//Postal
|
||||
|
||||
Reference in New Issue
Block a user