⚡ 统一地图选址搜索为高德 place/text 并展示分页候选
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -270,7 +270,7 @@ import { createOption } from '@/option/base/common-address';
|
||||
import { mapGetters } from 'vuex';
|
||||
import { downloadXls } from '@/utils/util';
|
||||
import { getToken } from '@/utils/auth';
|
||||
import { normalizeMapSearchResults } from '@/utils/map-search';
|
||||
import { normalizeMapSearchResults, searchAmapPlaceText } from '@/utils/map-search';
|
||||
import { isMobile } from '@/utils/validate';
|
||||
import NProgress from 'nprogress';
|
||||
import 'nprogress/nprogress.css';
|
||||
@@ -1112,31 +1112,32 @@ export default {
|
||||
this.$message.warning('请输入地址关键词');
|
||||
return;
|
||||
}
|
||||
if (this.mapLoading) return;
|
||||
this.mapSearchResults = [];
|
||||
this.mapLoading = true;
|
||||
this.loadAmap()
|
||||
.then(() => {
|
||||
this.mapLoading = true;
|
||||
this.ensureAmapGeocoder()
|
||||
.then(() => this.runAmapGeocode('location', keyword))
|
||||
.then(result => {
|
||||
this.mapSearchResults = normalizeMapSearchResults(result, keyword);
|
||||
const point = this.resolveMapPoint(result);
|
||||
if (!point) {
|
||||
this.mapStatus = '未找到匹配地址';
|
||||
this.$message.warning('地图搜索无匹配地址');
|
||||
return;
|
||||
}
|
||||
this.pickMapPoint(point, keyword);
|
||||
})
|
||||
.catch(() => {
|
||||
this.mapStatus = '地图搜索失败';
|
||||
this.$message.error('地图搜索失败,请稍后重试');
|
||||
})
|
||||
.finally(() => {
|
||||
this.mapLoading = false;
|
||||
});
|
||||
.then(() => searchAmapPlaceText(keyword))
|
||||
.then(pois => {
|
||||
this.mapSearchResults = normalizeMapSearchResults(pois, keyword);
|
||||
const first = this.mapSearchResults[0];
|
||||
if (!first?.location) {
|
||||
this.mapStatus = '未找到匹配地址';
|
||||
this.$message.warning('地图搜索无匹配地址');
|
||||
return;
|
||||
}
|
||||
return this.$nextTick().then(() => {
|
||||
if (typeof this.amap?.resize === 'function') {
|
||||
this.amap.resize();
|
||||
}
|
||||
this.pickMapPoint(first.location, first.address || first.name || keyword);
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
this.$message.error('高德地图组件加载失败,请稍后重试或重新打开弹窗');
|
||||
this.mapStatus = '未找到匹配地址';
|
||||
this.$message.warning('地图搜索无匹配地址');
|
||||
})
|
||||
.finally(() => {
|
||||
this.mapLoading = false;
|
||||
});
|
||||
},
|
||||
selectMapSearchResult(item) {
|
||||
|
||||
@@ -323,7 +323,7 @@ import { addressTypeOptions } from '@/option/base/common-address';
|
||||
import { config, excelOption, option } from '@/option/business/common-route';
|
||||
import { getToken } from '@/utils/auth';
|
||||
import { openImportDialog } from '@/utils/import-excel';
|
||||
import { normalizeMapSearchResults } from '@/utils/map-search';
|
||||
import { normalizeMapSearchResults, searchAmapPlaceText } from '@/utils/map-search';
|
||||
import { downloadXls } from '@/utils/util';
|
||||
import { isMobile } from '@/utils/validate';
|
||||
import { List, Search } from '@element-plus/icons-vue';
|
||||
@@ -610,25 +610,29 @@ export default {
|
||||
this.$message.warning('请输入地址关键词');
|
||||
return;
|
||||
}
|
||||
if (this.routeMapLoading) return;
|
||||
this.routeMapSearchResults = [];
|
||||
this.routeMapLoading = true;
|
||||
this.loadAmap()
|
||||
.then(() => {
|
||||
this.routeMapLoading = true;
|
||||
return this.ensureRouteAmapGeocoder();
|
||||
})
|
||||
.then(() => this.runAmapGeocode('location', keyword))
|
||||
.then(result => {
|
||||
this.routeMapSearchResults = normalizeMapSearchResults(result, keyword);
|
||||
const point = this.resolveMapPoint(result);
|
||||
if (!point) {
|
||||
.then(() => searchAmapPlaceText(keyword))
|
||||
.then(pois => {
|
||||
this.routeMapSearchResults = normalizeMapSearchResults(pois, keyword);
|
||||
const first = this.routeMapSearchResults[0];
|
||||
if (!first?.location) {
|
||||
this.routeMapStatus = '未找到匹配地址';
|
||||
this.$message.warning('地图搜索无匹配地址');
|
||||
return;
|
||||
}
|
||||
this.pickRouteMapPoint(point, keyword);
|
||||
return this.$nextTick().then(() => {
|
||||
if (typeof this.routeAmap?.resize === 'function') {
|
||||
this.routeAmap.resize();
|
||||
}
|
||||
this.pickRouteMapPoint(first.location, first.address || first.name || keyword);
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
this.routeMapStatus = '地图搜索失败';
|
||||
this.$message.error('地图搜索失败,请稍后重试');
|
||||
this.routeMapStatus = '未找到匹配地址';
|
||||
this.$message.warning('地图搜索无匹配地址');
|
||||
})
|
||||
.finally(() => {
|
||||
this.routeMapLoading = false;
|
||||
|
||||
@@ -5243,7 +5243,7 @@ import { packageOptions } from '@/option/business/common';
|
||||
import { formatUpdateUserName } from '@/utils/audit';
|
||||
import { getToken } from '@/utils/auth';
|
||||
import { openImportDialog } from '@/utils/import-excel';
|
||||
import { normalizeMapSearchResults } from '@/utils/map-search';
|
||||
import { normalizeMapSearchResults, searchAmapPlaceText } from '@/utils/map-search';
|
||||
import { applyTableMenuWidth } from '@/utils/table-menu';
|
||||
import { downloadFileByUrl, downloadXls } from '@/utils/util';
|
||||
import { isMobile } from '@/utils/validate';
|
||||
@@ -10214,31 +10214,32 @@ export default {
|
||||
this.$message.warning('请输入地址关键词');
|
||||
return;
|
||||
}
|
||||
if (this.transportMapLoading) return;
|
||||
this.transportMapSearchResults = [];
|
||||
this.transportMapLoading = true;
|
||||
this.loadAmap()
|
||||
.then(() => {
|
||||
this.transportMapLoading = true;
|
||||
this.ensureTransportAmapGeocoder()
|
||||
.then(() => this.runAmapGeocode('location', keyword))
|
||||
.then(result => {
|
||||
this.transportMapSearchResults = normalizeMapSearchResults(result, keyword);
|
||||
const point = this.resolveMapPoint(result);
|
||||
if (!point) {
|
||||
this.transportMapStatus = '未找到匹配地址';
|
||||
this.$message.warning('地图搜索无匹配地址');
|
||||
return;
|
||||
}
|
||||
this.pickTransportMapPoint(point, keyword);
|
||||
})
|
||||
.catch(() => {
|
||||
this.transportMapStatus = '地图搜索失败';
|
||||
this.$message.error('地图搜索失败,请稍后重试');
|
||||
})
|
||||
.finally(() => {
|
||||
this.transportMapLoading = false;
|
||||
});
|
||||
.then(() => searchAmapPlaceText(keyword))
|
||||
.then(pois => {
|
||||
this.transportMapSearchResults = normalizeMapSearchResults(pois, keyword);
|
||||
const first = this.transportMapSearchResults[0];
|
||||
if (!first?.location) {
|
||||
this.transportMapStatus = '未找到匹配地址';
|
||||
this.$message.warning('地图搜索无匹配地址');
|
||||
return;
|
||||
}
|
||||
return this.$nextTick().then(() => {
|
||||
if (typeof this.transportAmap?.resize === 'function') {
|
||||
this.transportAmap.resize();
|
||||
}
|
||||
this.pickTransportMapPoint(first.location, first.address || first.name || keyword);
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
this.$message.error('高德地图组件加载失败,请稍后重试或重新打开弹窗');
|
||||
this.transportMapStatus = '未找到匹配地址';
|
||||
this.$message.warning('地图搜索无匹配地址');
|
||||
})
|
||||
.finally(() => {
|
||||
this.transportMapLoading = false;
|
||||
});
|
||||
},
|
||||
selectTransportMapSearchResult(item) {
|
||||
|
||||
@@ -612,7 +612,7 @@ let amapLoader;
|
||||
import { getList as getCommonRouteList } from '@/api/business/common-route';
|
||||
import * as api from '@/api/business/master-order';
|
||||
import { formatUpdateUserName } from '@/utils/audit';
|
||||
import { normalizeMapSearchResults } from '@/utils/map-search';
|
||||
import { normalizeMapSearchResults, searchAmapPlaceText } from '@/utils/map-search';
|
||||
import { isMobile } from '@/utils/validate';
|
||||
export default {
|
||||
components: {
|
||||
@@ -1313,24 +1313,31 @@ export default {
|
||||
.catch(() => this.$message.error('高德地图组件加载失败'));
|
||||
},
|
||||
searchAddressMap() {
|
||||
if (!this.mapKeyword.trim()) return this.$message.warning('请输入地址关键词');
|
||||
const keyword = String(this.mapKeyword || '').trim();
|
||||
if (!keyword) return this.$message.warning('请输入地址关键词');
|
||||
if (this.mapLoading) return;
|
||||
this.mapSearchResults = [];
|
||||
this.mapLoading = true;
|
||||
this.loadAmap()
|
||||
.then(() => this.ensureAddressGeocoder())
|
||||
.then(
|
||||
() =>
|
||||
new Promise((resolve, reject) =>
|
||||
this.addressMapGeocoder.getLocation(this.mapKeyword, (status, result) =>
|
||||
status === 'complete' ? resolve(result) : reject(result)
|
||||
)
|
||||
)
|
||||
)
|
||||
.then(result => {
|
||||
this.mapSearchResults = normalizeMapSearchResults(result, this.mapKeyword);
|
||||
const point = this.mapSearchResults[0]?.location;
|
||||
if (!point) return this.$message.warning('地图搜索无匹配地址');
|
||||
this.pickAddressMap(point, this.mapKeyword);
|
||||
.then(() => searchAmapPlaceText(keyword))
|
||||
.then(pois => {
|
||||
this.mapSearchResults = normalizeMapSearchResults(pois, keyword);
|
||||
const first = this.mapSearchResults[0];
|
||||
if (!first?.location) {
|
||||
this.mapStatus = '未找到匹配地址';
|
||||
return this.$message.warning('地图搜索无匹配地址');
|
||||
}
|
||||
return this.$nextTick().then(() => {
|
||||
this.pickAddressMap(first.location, first.address || first.name || keyword);
|
||||
});
|
||||
})
|
||||
.catch(() => this.$message.error('地图搜索失败'));
|
||||
.catch(() => {
|
||||
this.mapStatus = '未找到匹配地址';
|
||||
this.$message.warning('地图搜索无匹配地址');
|
||||
})
|
||||
.finally(() => {
|
||||
this.mapLoading = false;
|
||||
});
|
||||
},
|
||||
selectAddressMapSearchResult(item) {
|
||||
if (item && item.location) {
|
||||
|
||||
@@ -1098,7 +1098,7 @@ import {
|
||||
import { getDictionary as getSystemDictionary } from '@/api/system/dict';
|
||||
import { getDictionary } from '@/api/system/dictbiz';
|
||||
import { packageOptions } from '@/option/business/common';
|
||||
import { normalizeMapSearchResults } from '@/utils/map-search';
|
||||
import { normalizeMapSearchResults, searchAmapPlaceText } from '@/utils/map-search';
|
||||
import { downloadFileByUrl, downloadXls } from '@/utils/util';
|
||||
import { isMobile } from '@/utils/validate';
|
||||
import { Location } from '@element-plus/icons-vue';
|
||||
@@ -2611,21 +2611,22 @@ export default {
|
||||
searchTransportMapKeyword() {
|
||||
const keyword = String(this.transportMapKeyword || '').trim();
|
||||
if (!keyword) return this.$message.warning('请输入地址关键词');
|
||||
if (this.transportMapLoading) return;
|
||||
this.transportMapSearchResults = [];
|
||||
this.transportMapLoading = true;
|
||||
this.loadAmap()
|
||||
.then(() => this.ensureTransportMapGeocoder())
|
||||
.then(() => this.runTransportMapGeocode('location', keyword))
|
||||
.then(result => {
|
||||
this.transportMapSearchResults = normalizeMapSearchResults(result, keyword);
|
||||
const point = this.resolveTransportMapPoint(result);
|
||||
if (!point) throw new Error('未找到匹配地址');
|
||||
.then(() => searchAmapPlaceText(keyword))
|
||||
.then(pois => {
|
||||
this.transportMapSearchResults = normalizeMapSearchResults(pois, keyword);
|
||||
const first = this.transportMapSearchResults[0];
|
||||
if (!first?.location) throw new Error('未找到匹配地址');
|
||||
return this.$nextTick().then(() => {
|
||||
this.transportMapInstance?.resize();
|
||||
return this.pickMapPoint(point, keyword);
|
||||
return this.pickMapPoint(first.location, first.address || first.name || keyword);
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
this.transportMapStatus = '地图搜索失败';
|
||||
this.transportMapStatus = '未找到匹配地址';
|
||||
this.$message.warning('地图搜索无匹配地址');
|
||||
})
|
||||
.finally(() => {
|
||||
|
||||
@@ -2741,7 +2741,7 @@ import { addressTypeOptions } from '@/option/base/common-address';
|
||||
import { packageOptions } from '@/option/business/common';
|
||||
import { formatUpdateUserName } from '@/utils/audit';
|
||||
import { getToken } from '@/utils/auth';
|
||||
import { normalizeMapSearchResults } from '@/utils/map-search';
|
||||
import { normalizeMapSearchResults, searchAmapPlaceText } from '@/utils/map-search';
|
||||
import { applyTableMenuWidth } from '@/utils/table-menu';
|
||||
import { downloadFileByUrl, downloadXls } from '@/utils/util';
|
||||
import { isMobile } from '@/utils/validate';
|
||||
@@ -5771,31 +5771,32 @@ export default {
|
||||
this.$message.warning('请输入地址关键词');
|
||||
return;
|
||||
}
|
||||
if (this.transportMapLoading) return;
|
||||
this.transportMapSearchResults = [];
|
||||
this.transportMapLoading = true;
|
||||
this.loadAmap()
|
||||
.then(() => {
|
||||
this.transportMapLoading = true;
|
||||
this.ensureTransportAmapGeocoder()
|
||||
.then(() => this.runAmapGeocode('location', keyword))
|
||||
.then(result => {
|
||||
this.transportMapSearchResults = normalizeMapSearchResults(result, keyword);
|
||||
const point = this.resolveMapPoint(result);
|
||||
if (!point) {
|
||||
this.transportMapStatus = '未找到匹配地址';
|
||||
this.$message.warning('地图搜索无匹配地址');
|
||||
return;
|
||||
}
|
||||
this.pickTransportMapPoint(point, keyword);
|
||||
})
|
||||
.catch(() => {
|
||||
this.transportMapStatus = '地图搜索失败';
|
||||
this.$message.error('地图搜索失败,请稍后重试');
|
||||
})
|
||||
.finally(() => {
|
||||
this.transportMapLoading = false;
|
||||
});
|
||||
.then(() => searchAmapPlaceText(keyword))
|
||||
.then(pois => {
|
||||
this.transportMapSearchResults = normalizeMapSearchResults(pois, keyword);
|
||||
const first = this.transportMapSearchResults[0];
|
||||
if (!first?.location) {
|
||||
this.transportMapStatus = '未找到匹配地址';
|
||||
this.$message.warning('地图搜索无匹配地址');
|
||||
return;
|
||||
}
|
||||
return this.$nextTick().then(() => {
|
||||
if (typeof this.transportAmap?.resize === 'function') {
|
||||
this.transportAmap.resize();
|
||||
}
|
||||
this.pickTransportMapPoint(first.location, first.address || first.name || keyword);
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
this.$message.error('高德地图组件加载失败,请稍后重试或重新打开弹窗');
|
||||
this.transportMapStatus = '未找到匹配地址';
|
||||
this.$message.warning('地图搜索无匹配地址');
|
||||
})
|
||||
.finally(() => {
|
||||
this.transportMapLoading = false;
|
||||
});
|
||||
},
|
||||
selectTransportMapSearchResult(item) {
|
||||
|
||||
@@ -3101,7 +3101,7 @@ import { formatUpdateUserName } from '@/utils/audit';
|
||||
import { submitMkApprovalFlow } from '@/utils/mk-approval';
|
||||
import { getToken } from '@/utils/auth';
|
||||
import { openImportDialog } from '@/utils/import-excel';
|
||||
import { normalizeMapSearchResults } from '@/utils/map-search';
|
||||
import { normalizeMapSearchResults, searchAmapPlaceText } from '@/utils/map-search';
|
||||
import { applyTableMenuWidth } from '@/utils/table-menu';
|
||||
import { downloadFileByUrl, downloadXls } from '@/utils/util';
|
||||
import { isMobile } from '@/utils/validate';
|
||||
@@ -7965,31 +7965,32 @@ export default {
|
||||
this.$message.warning('请输入地址关键词');
|
||||
return;
|
||||
}
|
||||
if (this.transportMapLoading) return;
|
||||
this.transportMapSearchResults = [];
|
||||
this.transportMapLoading = true;
|
||||
this.loadAmap()
|
||||
.then(() => {
|
||||
this.transportMapLoading = true;
|
||||
this.ensureTransportAmapGeocoder()
|
||||
.then(() => this.runAmapGeocode('location', keyword))
|
||||
.then(result => {
|
||||
this.transportMapSearchResults = normalizeMapSearchResults(result, keyword);
|
||||
const point = this.resolveMapPoint(result);
|
||||
if (!point) {
|
||||
this.transportMapStatus = '未找到匹配地址';
|
||||
this.$message.warning('地图搜索无匹配地址');
|
||||
return;
|
||||
}
|
||||
this.pickTransportMapPoint(point, keyword);
|
||||
})
|
||||
.catch(() => {
|
||||
this.transportMapStatus = '地图搜索失败';
|
||||
this.$message.error('地图搜索失败,请稍后重试');
|
||||
})
|
||||
.finally(() => {
|
||||
this.transportMapLoading = false;
|
||||
});
|
||||
.then(() => searchAmapPlaceText(keyword))
|
||||
.then(pois => {
|
||||
this.transportMapSearchResults = normalizeMapSearchResults(pois, keyword);
|
||||
const first = this.transportMapSearchResults[0];
|
||||
if (!first?.location) {
|
||||
this.transportMapStatus = '未找到匹配地址';
|
||||
this.$message.warning('地图搜索无匹配地址');
|
||||
return;
|
||||
}
|
||||
return this.$nextTick().then(() => {
|
||||
if (typeof this.transportAmap?.resize === 'function') {
|
||||
this.transportAmap.resize();
|
||||
}
|
||||
this.pickTransportMapPoint(first.location, first.address || first.name || keyword);
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
this.$message.error('高德地图组件加载失败,请稍后重试或重新打开弹窗');
|
||||
this.transportMapStatus = '未找到匹配地址';
|
||||
this.$message.warning('地图搜索无匹配地址');
|
||||
})
|
||||
.finally(() => {
|
||||
this.transportMapLoading = false;
|
||||
});
|
||||
},
|
||||
selectTransportMapSearchResult(item) {
|
||||
|
||||
@@ -1727,7 +1727,7 @@ import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { Location, Rank, Refresh, Search, Setting } from '@element-plus/icons-vue';
|
||||
import dayjs from 'dayjs';
|
||||
import { isMobile } from '@/utils/validate';
|
||||
import { normalizeMapSearchResults } from '@/utils/map-search';
|
||||
import { normalizeMapSearchResults, searchAmapPlaceText } from '@/utils/map-search';
|
||||
|
||||
const defaultTransportType = '';
|
||||
const defaultCandidateTransportType = '';
|
||||
@@ -3390,31 +3390,26 @@ export default {
|
||||
ElMessage.warning('请输入地址关键词');
|
||||
return;
|
||||
}
|
||||
if (this.routeChangeMapLoading) return;
|
||||
this.routeChangeMapSearchResults = [];
|
||||
this.routeChangeMapLoading = true;
|
||||
this.loadDetailAmap()
|
||||
.then(() => this.ensureRouteChangeMapGeocoder())
|
||||
.then(
|
||||
() =>
|
||||
new Promise((resolve, reject) => {
|
||||
this.routeChangeMapGeocoder.getLocation(keyword, (status, result) => {
|
||||
if (status === 'complete') resolve(result);
|
||||
else reject(result);
|
||||
});
|
||||
})
|
||||
)
|
||||
.then(result => {
|
||||
this.routeChangeMapSearchResults = normalizeMapSearchResults(result, keyword);
|
||||
const point = this.routeChangeMapSearchResults[0]?.location;
|
||||
if (!point) {
|
||||
.then(() => searchAmapPlaceText(keyword))
|
||||
.then(pois => {
|
||||
this.routeChangeMapSearchResults = normalizeMapSearchResults(pois, keyword);
|
||||
const first = this.routeChangeMapSearchResults[0];
|
||||
if (!first?.location) {
|
||||
this.routeChangeMapStatus = '未找到匹配地址';
|
||||
ElMessage.warning('地图搜索无匹配地址');
|
||||
return;
|
||||
}
|
||||
this.pickRouteChangeMap(point, keyword);
|
||||
return this.$nextTick().then(() => {
|
||||
this.pickRouteChangeMap(first.location, first.address || first.name || keyword);
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
this.routeChangeMapStatus = '地图搜索失败';
|
||||
ElMessage.error('地图搜索失败');
|
||||
this.routeChangeMapStatus = '未找到匹配地址';
|
||||
ElMessage.warning('地图搜索无匹配地址');
|
||||
})
|
||||
.finally(() => {
|
||||
this.routeChangeMapLoading = false;
|
||||
|
||||
Reference in New Issue
Block a user