调整预结算、正式结算
This commit is contained in:
@@ -303,6 +303,7 @@
|
||||
<el-button
|
||||
type="primary"
|
||||
:disabled="!routeMapSelected.longitude"
|
||||
:loading="routeMapConfirmLoading"
|
||||
@click="confirmRouteMapPick"
|
||||
>
|
||||
确定
|
||||
@@ -315,6 +316,7 @@
|
||||
<script>
|
||||
import * as api from '@/api/business/common-route';
|
||||
import { getList as getCommonAddressList } from '@/api/base/common-address';
|
||||
import { getDetail as getRegionDetail } from '@/api/base/region';
|
||||
import { exportBlob } from '@/api/common';
|
||||
import { getDeptTree } from '@/api/system/dept';
|
||||
import { addressTypeOptions } from '@/option/base/common-address';
|
||||
@@ -356,6 +358,7 @@ export default {
|
||||
routeMapVisible: false,
|
||||
routeMapTarget: '',
|
||||
routeMapLoading: false,
|
||||
routeMapConfirmLoading: false,
|
||||
routeMapKeyword: '',
|
||||
routeMapStatus: '可搜索地址或点击地图选点',
|
||||
routeMapSelected: {},
|
||||
@@ -496,14 +499,22 @@ export default {
|
||||
this.addressLoading = false;
|
||||
});
|
||||
},
|
||||
selectAddressRow(row) {
|
||||
async selectAddressRow(row) {
|
||||
if (!row) return;
|
||||
this.applyAddress(this.addressTarget, row);
|
||||
const applied = await this.applyAddress(this.addressTarget, row);
|
||||
if (!applied) return;
|
||||
this.addressDialogVisible = false;
|
||||
},
|
||||
applyAddress(target, address) {
|
||||
async applyAddress(target, address) {
|
||||
if (!target || !address) return;
|
||||
const prefix = target === 'departure' ? 'departure' : 'arrival';
|
||||
const regionIds = await this.resolveRegionIds(address.regionCode);
|
||||
if (!this.hasCompleteRegionIds(regionIds)) {
|
||||
this.$message.warning('该常用地址缺少完整的省、市、区ID,请先维护行政区划');
|
||||
return false;
|
||||
}
|
||||
this.applyRegionIds(prefix, regionIds);
|
||||
this.form[`${prefix}AddressId`] = address.id || '';
|
||||
this.form[`${prefix}Name`] = address.addressName || '';
|
||||
this.form[`${prefix}Address`] = address.detailAddress || '';
|
||||
this.form[`${prefix}AddressCode`] = address.addressCode || '';
|
||||
@@ -515,6 +526,7 @@ export default {
|
||||
this.form[`${prefix}Latitude`] = address.latitude || '';
|
||||
this.form[`${prefix}Contact`] = address.contactName || this.form[`${prefix}Contact`] || '';
|
||||
this.form[`${prefix}Phone`] = address.contactPhone || this.form[`${prefix}Phone`] || '';
|
||||
return true;
|
||||
},
|
||||
openRouteMapDialog(target) {
|
||||
if (this.dialogReadonly) return;
|
||||
@@ -526,6 +538,10 @@ export default {
|
||||
lat: this.form[`${prefix}Latitude`],
|
||||
address: this.form[`${prefix}Address`],
|
||||
regionName: this.form[`${prefix}Name`],
|
||||
regionCode: this.form[`${prefix}DistrictId`],
|
||||
provinceId: this.form[`${prefix}ProvinceId`],
|
||||
cityId: this.form[`${prefix}CityId`],
|
||||
districtId: this.form[`${prefix}DistrictId`],
|
||||
});
|
||||
this.routeMapStatus = this.routeMapSelected.longitude
|
||||
? '已加载当前选点,可重新选点'
|
||||
@@ -638,6 +654,7 @@ export default {
|
||||
...this.routeMapSelected,
|
||||
detailAddress: address.detailAddress || this.routeMapSelected.detailAddress,
|
||||
regionName: address.regionName || this.routeMapSelected.regionName,
|
||||
regionCode: address.regionCode || '',
|
||||
};
|
||||
this.routeMapKeyword = this.routeMapSelected.detailAddress || this.routeMapKeyword;
|
||||
this.routeMapStatus = this.routeMapSelected.detailAddress || '已选点,可确认回填';
|
||||
@@ -656,28 +673,90 @@ export default {
|
||||
this.routeAmapMarker.setMap(this.routeAmap);
|
||||
this.routeAmap.setCenter(point);
|
||||
},
|
||||
confirmRouteMapPick() {
|
||||
async confirmRouteMapPick() {
|
||||
if (!this.routeMapSelected.longitude) {
|
||||
this.$message.warning('请先搜索或点击地图完成选点');
|
||||
return;
|
||||
}
|
||||
const prefix = this.routeMapTarget;
|
||||
this.form[`${prefix}Address`] =
|
||||
this.routeMapSelected.detailAddress || this.form[`${prefix}Address`];
|
||||
this.form[`${prefix}Name`] = this.routeMapSelected.regionName || this.form[`${prefix}Name`];
|
||||
this.form[`${prefix}Longitude`] = this.routeMapSelected.longitude;
|
||||
this.form[`${prefix}Latitude`] = this.routeMapSelected.latitude;
|
||||
this.routeMapVisible = false;
|
||||
this.$refs.crud?.validateField?.(`${prefix}Address`);
|
||||
this.routeMapConfirmLoading = true;
|
||||
try {
|
||||
const regionIds = await this.resolveRegionIds(this.routeMapSelected.regionCode);
|
||||
if (!this.hasCompleteRegionIds(regionIds)) {
|
||||
this.$message.warning('当前选点未解析到完整的省、市、区ID,请重新选择地址');
|
||||
return;
|
||||
}
|
||||
this.applyRegionIds(prefix, regionIds);
|
||||
this.form[`${prefix}AddressId`] = '';
|
||||
this.form[`${prefix}AddressCode`] = '';
|
||||
this.form[`${prefix}SiteCode`] = '';
|
||||
this.form[`${prefix}Address`] =
|
||||
this.routeMapSelected.detailAddress || this.form[`${prefix}Address`];
|
||||
this.form[`${prefix}Name`] = this.routeMapSelected.regionName || this.form[`${prefix}Name`];
|
||||
this.form[`${prefix}Longitude`] = this.routeMapSelected.longitude;
|
||||
this.form[`${prefix}Latitude`] = this.routeMapSelected.latitude;
|
||||
this.routeMapVisible = false;
|
||||
this.$refs.crud?.validateField?.(`${prefix}Address`);
|
||||
} finally {
|
||||
this.routeMapConfirmLoading = false;
|
||||
}
|
||||
},
|
||||
buildRouteMapSelection({ lng, lat, address, regionName }) {
|
||||
buildRouteMapSelection({
|
||||
lng,
|
||||
lat,
|
||||
address,
|
||||
regionName,
|
||||
regionCode,
|
||||
provinceId,
|
||||
cityId,
|
||||
districtId,
|
||||
}) {
|
||||
return {
|
||||
longitude: this.formatCoordinate(lng),
|
||||
latitude: this.formatCoordinate(lat),
|
||||
detailAddress: address || '',
|
||||
regionName: regionName || '',
|
||||
regionCode: regionCode || '',
|
||||
provinceId: provinceId || '',
|
||||
cityId: cityId || '',
|
||||
districtId: districtId || '',
|
||||
};
|
||||
},
|
||||
applyRegionIds(prefix, regionIds = {}) {
|
||||
this.form[`${prefix}ProvinceId`] = regionIds.provinceId || '';
|
||||
this.form[`${prefix}CityId`] = regionIds.cityId || '';
|
||||
this.form[`${prefix}DistrictId`] = regionIds.districtId || '';
|
||||
},
|
||||
hasCompleteRegionIds(regionIds = {}) {
|
||||
return Boolean(regionIds.provinceId && regionIds.cityId && regionIds.districtId);
|
||||
},
|
||||
fallbackRegionIds(regionCode) {
|
||||
const code = String(regionCode || '').trim();
|
||||
if (!/^\d{6}$/.test(code)) {
|
||||
return { provinceId: '', cityId: '', districtId: '' };
|
||||
}
|
||||
return {
|
||||
provinceId: `${code.slice(0, 2)}0000`,
|
||||
cityId: `${code.slice(0, 4)}00`,
|
||||
districtId: code,
|
||||
};
|
||||
},
|
||||
async resolveRegionIds(regionCode) {
|
||||
const fallback = this.fallbackRegionIds(regionCode);
|
||||
if (!regionCode) return fallback;
|
||||
try {
|
||||
const res = await getRegionDetail(regionCode);
|
||||
const region = res.data.data || {};
|
||||
return {
|
||||
provinceId: String(region.provinceCode || fallback.provinceId || ''),
|
||||
cityId: String(region.cityCode || fallback.cityId || ''),
|
||||
districtId: String(region.districtCode || region.code || fallback.districtId || ''),
|
||||
};
|
||||
} catch (error) {
|
||||
window.console.log(error);
|
||||
return fallback;
|
||||
}
|
||||
},
|
||||
formatCoordinate(value) {
|
||||
if (value === undefined || value === null || value === '') return '';
|
||||
const numberValue = Number(value);
|
||||
@@ -754,6 +833,7 @@ export default {
|
||||
return {
|
||||
detailAddress: regeocode.formattedAddress || '',
|
||||
regionName: [component.province, city, component.district].filter(Boolean).join(''),
|
||||
regionCode: component.adcode || '',
|
||||
};
|
||||
},
|
||||
normalizeRow(row) {
|
||||
|
||||
Reference in New Issue
Block a user