added new way to select areas for shipping note
This commit is contained in:
@@ -163,14 +163,21 @@ Vue.component('warehouse-shipping-note-modal', {
|
||||
},
|
||||
watch: {
|
||||
geoAddr: async function() {
|
||||
const [lat, lon] = this.geoAddr.split(',');
|
||||
if (!this.geoAddr) return;
|
||||
const areaMode = this.geoAddr.includes(', area');
|
||||
const [lat, lon] = this.geoAddr.replace(', area', '').split(',');
|
||||
const { address } = (await axios.get(`${window.TT_CONFIG["BASE_PATH"]}/WarehouseShippingNote/geoReverse?lat=${lat}&lon=${lon}`)).data;
|
||||
|
||||
if (areaMode === false) {
|
||||
const addrKey = ['road', 'village', 'hamlet', 'residential', 'city'].find(k => address[k]);
|
||||
this.shippingNote.deliveryAddressLine = addrKey ? `${address[addrKey]}${address["house_number"] ? ` ${address["house_number"]}` : ''}` : '';
|
||||
} else if (areaMode === true) {
|
||||
this.shippingNote.deliveryAddressLine = 'Gebiet';
|
||||
this.shippingNote.deliveryAddressName = `Gebiet ${address["village"] ?? address.residential ?? address.city ?? address["town"]}`;
|
||||
}
|
||||
|
||||
this.shippingNote.deliveryAddressPLZ = address["postcode"];
|
||||
this.shippingNote.deliveryAddressCity = address["village"] ?? address.city ?? address["town"];
|
||||
this.shippingNote.deliveryAddressCity = address["village"] ?? address.residential ?? address.city ?? address["town"];
|
||||
this.updateKilometer().then();
|
||||
},
|
||||
selectedBillingAddress: async function() {
|
||||
@@ -223,7 +230,7 @@ Vue.component('warehouse-shipping-note-modal', {
|
||||
this.hoursLoading = false;
|
||||
},
|
||||
async updateKilometer(carId) {
|
||||
if (!carId || carId === '0') return this.$refs.hoursManager.updateField('kilometerCount', null);
|
||||
if (!carId || carId === '0' && this.$refs.hoursManager) return this.$refs.hoursManager?.updateField('kilometerCount', null);
|
||||
this.hoursLoading = true;
|
||||
const delAddr = this.shippingNote.deliveryAddressLine + ' ' + this.shippingNote.deliveryAddressPLZ + ' ' + this.shippingNote.deliveryAddressCity;
|
||||
const {data} = await axios.get(window.TT_CONFIG["BASE_PATH"] + '/WarehouseShippingNote/getDistance?from=Xinon%20GmbH&to=' + delAddr);
|
||||
|
||||
Reference in New Issue
Block a user