🐛 修复车务非必填-1展示,并完善总单调度与运单表单体验
调度页限制上一段到达后才可调度;司机候选项点击展开;车务多模块-1显示为空;同步配载/总单编辑与导入相关优化。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -24,10 +24,12 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { normalizeMapSearchResults } from '@/utils/map-search';
|
||||
import { normalizeMapSearchResults, searchAmapPlaceText } from '@/utils/map-search';
|
||||
|
||||
const AMAP_KEY = '653b7cf105ad7fb8ec9b2f5198ade315';
|
||||
const AMAP_SECURITY_CODE = '5aab65c632e48ebae0d0e28f5b28e21a';
|
||||
const AMAP_KEY = '13dcb15bc29bfe9c432d17ecd808b812';
|
||||
/** 地点搜索 v5/place/text 使用「Web 服务」类型 Key,由业务自行填写 */
|
||||
const AMAP_WEB_KEY = 'b43016a0d1f5b0c32211560392059708';
|
||||
const AMAP_SECURITY_CODE = 'f9d036ef29e376e15d309e0de5c0f7ab';
|
||||
let amapLoader;
|
||||
|
||||
export default {
|
||||
@@ -90,10 +92,24 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
hasCoordinateValue(value) {
|
||||
return value !== '' && value !== null && value !== undefined;
|
||||
},
|
||||
buildInitialSelection() {
|
||||
// Number('') === 0,空字符串不能当有效坐标,否则会落到 [0,0](非洲附近)
|
||||
if (!this.hasCoordinateValue(this.longitude) || !this.hasCoordinateValue(this.latitude)) {
|
||||
return {};
|
||||
}
|
||||
const longitude = Number(this.longitude);
|
||||
const latitude = Number(this.latitude);
|
||||
if (!Number.isFinite(longitude) || !Number.isFinite(latitude)) {
|
||||
if (
|
||||
!Number.isFinite(longitude) ||
|
||||
!Number.isFinite(latitude) ||
|
||||
longitude < -180 ||
|
||||
longitude > 180 ||
|
||||
latitude < -90 ||
|
||||
latitude > 90
|
||||
) {
|
||||
return {};
|
||||
}
|
||||
return {
|
||||
@@ -131,22 +147,24 @@ export default {
|
||||
this.$nextTick(() => {
|
||||
if (!this.$refs.map) return resolve(null);
|
||||
const initial = this.buildInitialSelection();
|
||||
const center =
|
||||
Number.isFinite(initial.longitude) && Number.isFinite(initial.latitude)
|
||||
? [initial.longitude, initial.latitude]
|
||||
: [116.40769, 39.89945];
|
||||
const hasPoint =
|
||||
Number.isFinite(initial.longitude) && Number.isFinite(initial.latitude);
|
||||
const center = hasPoint
|
||||
? [initial.longitude, initial.latitude]
|
||||
: [116.40769, 39.89945];
|
||||
const zoom = hasPoint ? 14 : 11;
|
||||
if (!this.amap) {
|
||||
this.amap = new window.AMap.Map(this.$refs.map, {
|
||||
center,
|
||||
zoom: initial.longitude ? 14 : 11,
|
||||
zoom,
|
||||
});
|
||||
this.amap.on('click', event => this.pickPoint(event.lnglat));
|
||||
} else {
|
||||
this.amap.resize();
|
||||
this.clearMarker();
|
||||
this.amap.setZoomAndCenter(initial.longitude ? 14 : 11, center);
|
||||
this.amap.setZoomAndCenter(zoom, center);
|
||||
}
|
||||
if (initial.longitude) {
|
||||
if (hasPoint) {
|
||||
const point = new window.AMap.LngLat(initial.longitude, initial.latitude);
|
||||
this.renderMarker(point);
|
||||
this.selected = { ...initial };
|
||||
@@ -204,22 +222,25 @@ export default {
|
||||
this.$message.warning('请输入地址关键词');
|
||||
return;
|
||||
}
|
||||
if (!AMAP_WEB_KEY) {
|
||||
this.$message.warning('请先配置高德 Web 服务 Key');
|
||||
return;
|
||||
}
|
||||
if (this.searching) return;
|
||||
this.searchResults = [];
|
||||
this.searching = true;
|
||||
this.initMap()
|
||||
.then(map => (map ? this.runGeocode('location', keyword) : null))
|
||||
.then(result => {
|
||||
if (!result) return;
|
||||
const geocodes = result.geocodes || (result.location ? [result] : []);
|
||||
this.searchResults = normalizeMapSearchResults(geocodes, keyword);
|
||||
const point = this.searchResults[0]?.location || result.location;
|
||||
if (!point) {
|
||||
.then(map => (map ? searchAmapPlaceText(keyword, { key: AMAP_WEB_KEY }) : null))
|
||||
.then(pois => {
|
||||
if (!pois) return;
|
||||
this.searchResults = normalizeMapSearchResults(pois, keyword);
|
||||
const first = this.searchResults[0];
|
||||
if (!first?.location) {
|
||||
throw new Error('未找到匹配地址');
|
||||
}
|
||||
return this.$nextTick().then(() => {
|
||||
this.amap?.resize();
|
||||
this.pickPoint(point, this.searchResults[0]?.address || keyword);
|
||||
this.pickPoint(first.location, first.address || first.name || keyword);
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
@@ -236,8 +257,10 @@ export default {
|
||||
}
|
||||
},
|
||||
pickPoint(point, fallbackAddress = '') {
|
||||
const longitude = typeof point.getLng === 'function' ? point.getLng() : point.lng;
|
||||
const latitude = typeof point.getLat === 'function' ? point.getLat() : point.lat;
|
||||
const longitude =
|
||||
typeof point.getLng === 'function' ? point.getLng() : point.lng ?? point.longitude;
|
||||
const latitude =
|
||||
typeof point.getLat === 'function' ? point.getLat() : point.lat ?? point.latitude;
|
||||
if (!Number.isFinite(Number(longitude)) || !Number.isFinite(Number(latitude))) {
|
||||
this.$message.warning('选点坐标无效');
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user