调整业务模块

This commit is contained in:
2026-09-04 05:23:34 +08:00
parent c63c7c3e33
commit e789f1647a
10 changed files with 2082 additions and 591 deletions
+103 -5
View File
@@ -1,7 +1,7 @@
<template>
<basic-container class="master-order-page">
<template v-if="mode === 'list'">
<el-form :model="query" class="master-search" label-width="88px" @submit.prevent>
<el-form :model="query" class="master-search" label-width="160px" @submit.prevent>
<el-row :gutter="16">
<el-col v-for="field in primaryFields" :key="field.prop" :span="6"
><el-form-item :label="field.label"
@@ -330,23 +330,100 @@ export default {
const key = keys.find(item => route[item] !== undefined && route[item] !== null);
return key ? route[key] : 0;
},
isRoadTransportType(type) {
const value = String(type || '').trim().toLowerCase();
return value === 'road' || value.includes('公路');
},
formatRoadAddress(value) {
const text = String(value || '').replace(/\s+/g, '');
if (!text) return '-';
// 公路地址按“市 区县”展示,兼容省市区拼接及历史上只保存市/区县的值。
const withoutProvince = text.replace(/^.*?(?:省|自治区|特别行政区)/, '');
// “梅州市”同时包含“州”和“市”,避免误把城市截断为“梅州”。
const cityMatch = withoutProvince.match(/.+?(?:市|州(?!市)|盟(?!市))/);
if (!cityMatch) return text;
const city = cityMatch[0];
const districtSource = withoutProvince.slice(city.length);
const districtMatch = districtSource.match(/^[^市州盟]*?(?:区|县|旗)/);
if (!districtMatch) return city;
// 兼容“梅县区”这类名称,正则首次命中“县”后还需保留后面的“区”。
const district = `${districtMatch[0]}${
districtSource.slice(districtMatch[0].length).startsWith('区') ? '区' : ''
}`;
return `${city} ${district}`;
},
routeNodeName(value, address, transportType, region = {}) {
const text = String(value || '').trim();
if (!text) return '-';
const siteCode = String(region.siteCode || '').trim();
// 运输方式切换不应改变地址本身的展示模式:有站点编码时显示站点名称,
// 没有站点编码的区域地址统一按“市 区县”格式展示。
if (siteCode && siteCode !== '/') return text;
// 优先从完整的地址名称/详细地址解析,避免后端只返回“梅州”等不完整的市名称时
// 提前返回城市,导致区县被遗漏。
const parsedText = this.formatRoadAddress(text);
if (parsedText.includes(' ')) return parsedText;
const parsedAddress = this.formatRoadAddress(address);
if (parsedAddress.includes(' ')) return parsedAddress;
const city = String(region.cityName || '').trim();
const district = String(region.districtName || '').trim();
if (city && district) return `${city} ${district}`;
if (city) return city;
if (district && address) {
const formattedAddress = this.formatRoadAddress(address);
const addressCity = formattedAddress.split(' ')[0];
if (addressCity && addressCity !== formattedAddress) return `${addressCity} ${district}`;
}
const isRegional =
/省|自治区|特别行政区/.test(text) ||
/(?:市|州|盟).*?(?:区|县|旗)/.test(text) ||
/(?:区|县|旗)$/.test(text);
if (!isRegional) return text;
// 区县简称(如“西乡塘区”)从详细地址中补齐所属城市。
const source = /省|自治区|特别行政区|市|州|盟/.test(text) ? text : address || text;
const formatted = this.formatRoadAddress(source);
if (/(?:区|县|旗)$/.test(text) && !formatted.includes(text)) {
const city = formatted.split(' ')[0];
return city && city !== formatted ? `${city} ${text}` : formatted;
}
return formatted;
},
routeNodes(row = {}) {
const routes = row.routeProgress || [];
const total = this.routeNumber(row.totalQuantity);
const firstTransportType = routes[0]?.transportType || row.routes?.[0]?.transportType || row.transportType || '';
if (!routes.length) {
return [
{
key: 'start',
type: 'start',
text: '起',
name: row.departureName || row.departureAddress || '-',
name: this.routeNodeName(
row.departureName || row.departureAddress,
row.departureAddress,
firstTransportType,
{
cityName: row.departureCityName,
districtName: row.departureDistrictName,
siteCode: row.departureSiteCode,
}
),
lines: [`已调度0/${total}`],
},
{
key: 'end',
type: 'end',
text: '终',
name: row.arrivalName || row.arrivalAddress || '-',
name: this.routeNodeName(
row.arrivalName || row.arrivalAddress,
row.arrivalAddress,
row.finalTransportType || firstTransportType,
{
cityName: row.arrivalCityName,
districtName: row.arrivalDistrictName,
siteCode: row.arrivalSiteCode,
}
),
lines: [`到达0/${total}`],
},
];
@@ -356,7 +433,16 @@ export default {
key: 'start',
type: 'start',
text: '起',
name: row.departureName || row.departureAddress || '-',
name: this.routeNodeName(
row.departureName || row.departureAddress,
row.departureAddress,
firstTransportType,
{
cityName: row.departureCityName,
districtName: row.departureDistrictName,
siteCode: row.departureSiteCode,
}
),
lines: [`已调度${this.routeNumber(routes[0]?.dispatchedQuantity)}/${total}`],
},
...routes.map((route, index) => {
@@ -367,7 +453,16 @@ export default {
key: route.segmentNo || `route-${index}`,
type: isEnd ? 'end' : 'middle',
text: isEnd ? '终' : '经',
name: route.arrivalName || route.departureName || row.arrivalName || '-',
name: this.routeNodeName(
route.arrivalName || route.departureName || row.arrivalName,
route.arrivalAddress || route.departureAddress,
route.transportType,
{
cityName: route.arrivalCityName || route.departureCityName,
districtName: route.arrivalDistrictName || route.departureDistrictName,
siteCode: route.arrivalSiteCode || route.departureSiteCode,
}
),
lines: isEnd
? [`到达${arrived}/${total}`]
: [`到达 ${arrived}/${total}`, `已调度 ${dispatched}/到达${arrived}/${total}`],
@@ -412,6 +507,9 @@ export default {
.el-date-editor {
width: 100%;
}
:deep(.el-form-item__label) {
white-space: nowrap;
}
.search-actions {
display: flex;
justify-content: flex-end;