调整 iam

This commit is contained in:
2026-09-16 06:30:30 +08:00
parent 6a87066097
commit c1c4fa18c9
26 changed files with 1517 additions and 666 deletions
@@ -85,15 +85,23 @@
</template>
<template #departureAddress="{ row }">
<el-tooltip v-if="row.departureAddress" :content="row.departureAddress" placement="top">
<span>{{ formatTransportPlanProvinceCityDistrict(row.departureAddress) }}</span>
<el-tooltip
v-if="row.departureAddress || row.departureName"
:content="row.departureAddress || row.departureName"
placement="top"
>
<span>{{ formatTransportPlanListAddress(row, 'departure') }}</span>
</el-tooltip>
<span v-else>-</span>
</template>
<template #arrivalAddress="{ row }">
<el-tooltip v-if="row.arrivalAddress" :content="row.arrivalAddress" placement="top">
<span>{{ formatTransportPlanProvinceCityDistrict(row.arrivalAddress) }}</span>
<el-tooltip
v-if="row.arrivalAddress || row.arrivalName"
:content="row.arrivalAddress || row.arrivalName"
placement="top"
>
<span>{{ formatTransportPlanListAddress(row, 'arrival') }}</span>
</el-tooltip>
<span v-else>-</span>
</template>
@@ -574,7 +582,7 @@
>
<el-link
type="primary"
v-if="hasPermission(`${config.permission}_view`) && !showDetailButton(row)"
v-if="showViewButton(row)"
@click="$refs.crud.rowView(row, index)"
>
查看
@@ -1492,27 +1500,38 @@
<el-input
v-model="dispatchItemForm.departureName"
:placeholder="dispatchStationNamePlaceholder"
:suffix-icon="dispatchStationMode ? Search : undefined"
disabled
/>
:readonly="dispatchStationMode"
@click="openDispatchPrimaryAddressPicker('departure')"
>
<template v-if="dispatchStationMode" #suffix>
<el-icon
class="transport-plan-page__map-suffix"
@click.stop="openDispatchSecondaryAddressPicker('departure')"
>
<Search />
</el-icon>
</template>
</el-input>
<el-input
v-model="dispatchItemForm.departureAddress"
:placeholder="dispatchAddressDetailPlaceholder"
disabled
:readonly="dispatchStationMode"
@click="handleDispatchSecondaryAddressInputClick('departure')"
>
<template v-if="!dispatchStationMode" #suffix>
<el-link
type="primary"
:underline="false"
class="transport-plan-page__address-choose-link"
@click.stop="openTransportMapDialog('departure')"
>选择</el-link
>
</template>
</el-input>
<span class="transport-plan-page__route-label">联系人</span>
<el-input v-model="dispatchItemForm.departureContact" placeholder="请输入" disabled />
<el-input v-model="dispatchItemForm.departureContact" placeholder="请输入" />
<span class="transport-plan-page__route-label">联系方式</span>
<el-input v-model="dispatchItemForm.departurePhone" placeholder="请输入" disabled />
<el-input v-model="dispatchItemForm.departurePhone" placeholder="请输入" />
</div>
</el-form-item>
<el-form-item label="收货地址" required>
@@ -1520,27 +1539,38 @@
<el-input
v-model="dispatchItemForm.arrivalName"
:placeholder="dispatchStationNamePlaceholder"
:suffix-icon="dispatchStationMode ? Search : undefined"
disabled
/>
:readonly="dispatchStationMode"
@click="openDispatchPrimaryAddressPicker('arrival')"
>
<template v-if="dispatchStationMode" #suffix>
<el-icon
class="transport-plan-page__map-suffix"
@click.stop="openDispatchSecondaryAddressPicker('arrival')"
>
<Search />
</el-icon>
</template>
</el-input>
<el-input
v-model="dispatchItemForm.arrivalAddress"
:placeholder="dispatchAddressDetailPlaceholder"
disabled
:readonly="dispatchStationMode"
@click="handleDispatchSecondaryAddressInputClick('arrival')"
>
<template v-if="!dispatchStationMode" #suffix>
<el-link
type="primary"
:underline="false"
class="transport-plan-page__address-choose-link"
@click.stop="openTransportMapDialog('arrival')"
>选择</el-link
>
</template>
</el-input>
<span class="transport-plan-page__route-label">联系人</span>
<el-input v-model="dispatchItemForm.arrivalContact" placeholder="请输入" disabled />
<el-input v-model="dispatchItemForm.arrivalContact" placeholder="请输入" />
<span class="transport-plan-page__route-label">联系方式</span>
<el-input v-model="dispatchItemForm.arrivalPhone" placeholder="请输入" disabled />
<el-input v-model="dispatchItemForm.arrivalPhone" placeholder="请输入" />
</div>
</el-form-item>
</div>
@@ -1576,20 +1606,15 @@
><span class="transport-plan-page__required-column">货物类型</span></template
>
<template #default="{ row }">
<el-select
<el-autocomplete
v-model="row.cargoType"
placeholder="请选择货物类型"
placeholder="请输入货物类型"
clearable
filterable
:debounce="300"
:fetch-suggestions="fetchDispatchConfiguredCargoTypeSuggestions"
@select="item => handleDispatchConfiguredCargoTypeSelect(row, item)"
@change="value => handleDispatchConfiguredCargoTypeChange(row, value)"
>
<el-option
v-for="item in getDispatchConfiguredCargoTypeOptions()"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
/>
</template>
</el-table-column>
<el-table-column min-width="240" align="center">
@@ -1597,20 +1622,18 @@
><span class="transport-plan-page__required-column">货物名称</span></template
>
<template #default="{ row }">
<el-select
<el-autocomplete
v-model="row.cargoName"
placeholder="请选择货物名称"
placeholder="请输入货物名称"
clearable
filterable
:debounce="300"
:fetch-suggestions="
(queryString, callback) =>
fetchDispatchConfiguredCargoNameSuggestions(queryString, callback, row)
"
@select="item => handleDispatchConfiguredCargoNameSelect(row, item)"
@change="value => handleDispatchConfiguredCargoNameChange(row, value)"
>
<el-option
v-for="item in getDispatchConfiguredCargoNameOptions(row)"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
/>
</template>
</el-table-column>
<el-table-column label="包装" min-width="130" align="center">
@@ -1627,7 +1650,11 @@
</el-table-column>
<el-table-column label="剩余数量" min-width="130" align="center">
<template #default="{ row }">
{{ formatDispatchQuantity(dispatchItemRemainingQuantity(row)) }}
{{
isDispatchPlanQuantityUnlimited(row)
? '-'
: formatDispatchQuantity(dispatchItemRemainingQuantity(row))
}}
</template>
</el-table-column>
<el-table-column min-width="130" align="center">
@@ -1848,36 +1875,33 @@
<el-input v-model="dispatchItemForm.escortPhone" placeholder="请输入" />
</el-form-item>
<el-form-item label="货物类型" required>
<el-select
<el-autocomplete
v-model="dispatchItemForm.cargoType"
placeholder="请选择货物类型"
placeholder="请输入货物类型"
clearable
filterable
@change="handleDispatchConfiguredCargoTypeChange(dispatchItemForm, $event)"
>
<el-option
v-for="item in getDispatchConfiguredCargoTypeOptions()"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
:debounce="300"
:fetch-suggestions="fetchDispatchConfiguredCargoTypeSuggestions"
@select="item => handleDispatchConfiguredCargoTypeSelect(dispatchItemForm, item)"
@change="value => handleDispatchConfiguredCargoTypeChange(dispatchItemForm, value)"
/>
</el-form-item>
<el-form-item label="货物名称" required>
<el-select
<el-autocomplete
v-model="dispatchItemForm.cargoName"
placeholder="请选择货物名称"
placeholder="请输入货物名称"
clearable
filterable
@change="handleDispatchConfiguredCargoNameChange(dispatchItemForm, $event)"
>
<el-option
v-for="item in getDispatchConfiguredCargoNameOptions(dispatchItemForm)"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
:debounce="300"
:fetch-suggestions="
(queryString, callback) =>
fetchDispatchConfiguredCargoNameSuggestions(
queryString,
callback,
dispatchItemForm
)
"
@select="item => handleDispatchConfiguredCargoNameSelect(dispatchItemForm, item)"
@change="value => handleDispatchConfiguredCargoNameChange(dispatchItemForm, value)"
/>
</el-form-item>
<el-form-item label="规格">
<el-input v-model="dispatchItemForm.specification" placeholder="请输入" />
@@ -1902,7 +1926,10 @@
</el-select>
</template>
</el-input>
<div class="transport-plan-page__dispatch-quantity-hint">
<div
v-if="!isDispatchPlanQuantityUnlimited(dispatchItemForm)"
class="transport-plan-page__dispatch-quantity-hint"
>
剩余数量{{
formatDispatchQuantity(dispatchItemRemainingQuantity(dispatchItemForm))
}}
@@ -3412,15 +3439,21 @@ export default {
}));
},
dispatchHasAddableQuantity() {
return this.dispatchTableQuantityItems.some(
item => item.total > 0 && item.listed < item.total - 1e-8
);
const items = this.dispatchTableQuantityItems;
if (!items.length) return true;
// 0
if (items.every(item => item.total <= 0)) return true;
return items.some(item => item.total > 0 && item.listed < item.total - 1e-8);
},
dispatchSummaryText() {
const formatSummary = field =>
this.dispatchSummaryItems
.map(item => `${this.formatDispatchQuantity(item[field])}${item.unit}`)
.join('、');
const unlimited = this.dispatchSummaryItems.every(item => item.total <= 0);
if (unlimited) {
return `已调度 ${formatSummary('assigned') || `0${TRANSPORT_PLAN_QUANTITY_UNIT}`}`;
}
return `${formatSummary('total')} | 已调度 ${formatSummary(
'assigned'
)}剩余${formatSummary('remaining')}`;
@@ -3606,12 +3639,13 @@ export default {
return ['water', 'rail', 'air'].includes(this.transportMode);
},
transportStationTypeLabel() {
const mode = this.dispatchItemBox ? this.dispatchTransportMode : this.transportMode;
const labelMap = {
water: '港口/码头',
rail: '铁路车站',
air: '空港机场',
};
return labelMap[this.transportMode] || '';
return labelMap[mode] || '';
},
transportStationNamePlaceholder() {
if (!this.transportStationMode) return '行政区划自动带出';
@@ -3798,6 +3832,37 @@ export default {
const cityMatch = text.match(/市/);
return cityMatch ? text.slice(0, cityMatch.index + 1) : text;
},
formatTransportPlanListAddress(row = {}, field) {
const address = String(row[`${field}Address`] || '').trim();
const name = String(row[`${field}Name`] || '').trim();
const fromAddress = this.extractTransportPlanProvinceCityDistrict(address);
if (fromAddress) return fromAddress;
const fromName = this.extractTransportPlanProvinceCityDistrict(name);
if (fromName) return fromName;
return name || address || '-';
},
extractTransportPlanProvinceCityDistrict(value) {
const text = String(value || '')
.trim()
.replace(/[\\/||、,\s]+/g, '');
if (!text) return '';
const districtPattern = '(?:自治县|自治旗|林区|矿区|新区|开发区|区|县|旗)';
const parts = [];
let remainder = text;
const province = text.match(/^(.+?(?:省|自治区|特别行政区))/);
if (province) {
parts.push(province[1]);
remainder = text.slice(province[1].length);
}
const city = remainder.match(/^(.+?市)/);
if (city) {
parts.push(city[1]);
remainder = remainder.slice(city[1].length);
}
const district = remainder.match(new RegExp(`^(.+?${districtPattern})`));
if (district) parts.push(district[1]);
return parts.length ? parts.join('/') : '';
},
formatTransportPlanRoadCityDistrict(value) {
const text = String(value || '').trim();
if (!text) return '-';
@@ -3955,6 +4020,11 @@ export default {
const status = this.statusValue(row);
return status !== 'draft';
},
showViewButton(row) {
if (!this.hasPermission(`${this.config.permission}_view`)) return false;
if (this.statusValue(row) === 'draft') return false;
return !this.showDetailButton(row);
},
formatDetailValue(row, prop) {
if (!row) return '-';
if (prop === 'businessStatus') return this.displayStatus(row, prop);
@@ -4540,6 +4610,37 @@ export default {
getDispatchRemainingQuantity(unit) {
return this.getDispatchSummaryItem(unit)?.remaining || 0;
},
/** 计划总量为 0 时不限制调度数量 */
isDispatchPlanQuantityUnlimited(row = {}) {
const unit = this.getDispatchQuantityUnit(row);
const hasCargoIdentity = Boolean(
String(row.cargoName || row.goodsName || row.name || '').trim() ||
String(row.cargoType || row.secondCargoTypeName || row.goodsType || row.type || '').trim()
);
const planGoodsRows = this.dispatchPlanGoodsRows;
if (planGoodsRows.length && hasCargoIdentity) {
const cargoKey = this.getDispatchCargoIdentity(row);
const matchedPlanRows = planGoodsRows.filter(
goods => this.getDispatchCargoIdentity(goods) === cargoKey
);
if (!matchedPlanRows.length) {
return (this.getDispatchSummaryItem(unit)?.total || 0) <= 0;
}
const total = matchedPlanRows.reduce(
(sum, goods) =>
sum +
this.parseDispatchQuantity(
goods.quantity || goods.cargoQuantity || goods.goodsQuantity
),
0
);
return total <= 0;
}
if (!planGoodsRows.length) {
return Number(this.dispatchRow.totalQuantity || this.dispatchRow.quantity || 0) <= 0;
}
return (this.getDispatchSummaryItem(unit)?.total || 0) <= 0;
},
formatDispatchQuantity(value) {
const number = Number(value || 0);
if (!Number.isFinite(number)) return '0';
@@ -5238,6 +5339,13 @@ export default {
}
},
ensureTransportTypeBeforeAddress() {
if (this.dispatchItemBox) {
const transportType =
this.dispatchItemForm.transportType || this.dispatchRow?.transportType || '';
if (!this.isBillingFieldEmpty(transportType)) return true;
this.$message.warning('请先选择运输方式');
return false;
}
if (!this.shippingInfoFormEnabled || !this.isBillingFieldEmpty(this.form.transportType)) {
return true;
}
@@ -5314,19 +5422,21 @@ export default {
},
openTransportStationDialog(target) {
if (!this.ensureTransportTypeBeforeAddress()) return;
if (!this.transportStationMode) return;
const stationMode = this.dispatchItemBox ? this.dispatchStationMode : this.transportStationMode;
if (!stationMode) return;
this.transportStationTarget = target;
this.transportStationQuery = {};
this.transportStationPage.currentPage = 1;
this.transportStationBox = true;
},
getTransportStationListRequest() {
const mode = this.dispatchItemBox ? this.dispatchTransportMode : this.transportMode;
const requestMap = {
water: getPortTerminalList,
rail: getRailwayStationList,
air: getAirportMasterList,
};
return requestMap[this.transportMode];
return requestMap[mode];
},
loadTransportStationList() {
const request = this.getTransportStationListRequest();
@@ -5436,7 +5546,28 @@ export default {
water: '港口/码头',
air: '空港机场',
};
return typeMap[this.transportMode] || '';
const mode = this.dispatchItemBox ? this.dispatchTransportMode : this.transportMode;
return typeMap[mode] || '';
},
getTransportAddressForm() {
return this.dispatchItemBox ? this.dispatchItemForm : this.form;
},
openDispatchPrimaryAddressPicker(target) {
if (this.dispatchStationMode) {
this.openTransportStationDialog(target);
}
},
openDispatchSecondaryAddressPicker(target) {
if (this.dispatchStationMode) {
this.openTransportStationDialog(target);
return;
}
this.openTransportMapDialog(target);
},
handleDispatchSecondaryAddressInputClick(target) {
if (this.dispatchStationMode) {
this.openDispatchSecondaryAddressPicker(target);
}
},
loadTransportAddressList() {
this.transportAddressLoading = true;
@@ -5487,35 +5618,39 @@ export default {
},
applyTransportAddress(target, address = {}) {
const prefix = target === 'departure' ? 'departure' : 'arrival';
this.form[`${prefix}Name`] = address.preferRegionName
const addressForm = this.getTransportAddressForm();
addressForm[`${prefix}Name`] = address.preferRegionName
? address.regionName || address.addressName || ''
: address.addressName || address.regionName || '';
this.form[`${prefix}Address`] = address.detailAddress || address.address || '';
this.form[`${prefix}AddressCode`] = address.addressCode || '';
this.form[`${prefix}SiteCode`] =
addressForm[`${prefix}Address`] = address.detailAddress || address.address || '';
addressForm[`${prefix}AddressCode`] = address.addressCode || '';
addressForm[`${prefix}SiteCode`] =
address.addressType === '常规地址'
? '/'
: address.siteCodeDisplay || address.siteCode || '';
this.form[`${prefix}Longitude`] = address.longitude || '';
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`] || '';
addressForm[`${prefix}Longitude`] = address.longitude || '';
addressForm[`${prefix}Latitude`] = address.latitude || '';
addressForm[`${prefix}Contact`] =
address.contactName || addressForm[`${prefix}Contact`] || '';
addressForm[`${prefix}Phone`] = address.contactPhone || addressForm[`${prefix}Phone`] || '';
// Avue
this.$nextTick(() => {
this.$refs.crud?.clearValidate?.([`${prefix}Address`]);
});
},
openTransportMapDialog(target) {
if (this.dialogReadonly) return;
if (this.dialogReadonly && !this.dispatchItemBox) return;
if (!this.ensureTransportTypeBeforeAddress()) return;
const prefix = target === 'departure' ? 'departure' : 'arrival';
const addressForm = this.getTransportAddressForm();
this.transportMapTarget = prefix;
this.transportMapKeyword = this.form[`${prefix}Address`] || this.form[`${prefix}Name`] || '';
this.transportMapKeyword =
addressForm[`${prefix}Address`] || addressForm[`${prefix}Name`] || '';
this.transportMapSelected = this.buildTransportMapSelection({
lng: this.form[`${prefix}Longitude`],
lat: this.form[`${prefix}Latitude`],
address: this.form[`${prefix}Address`],
regionName: this.form[`${prefix}Name`],
lng: addressForm[`${prefix}Longitude`],
lat: addressForm[`${prefix}Latitude`],
address: addressForm[`${prefix}Address`],
regionName: addressForm[`${prefix}Name`],
});
this.transportMapStatus = this.transportMapSelected.longitude
? '已加载当前选点,可重新选点'
@@ -5673,12 +5808,13 @@ export default {
return;
}
const prefix = this.transportMapTarget;
this.form[`${prefix}Address`] =
this.transportMapSelected.detailAddress || this.form[`${prefix}Address`];
this.form[`${prefix}Name`] =
this.transportMapSelected.regionName || this.form[`${prefix}Name`];
this.form[`${prefix}Longitude`] = this.transportMapSelected.longitude;
this.form[`${prefix}Latitude`] = this.transportMapSelected.latitude;
const addressForm = this.getTransportAddressForm();
addressForm[`${prefix}Address`] =
this.transportMapSelected.detailAddress || addressForm[`${prefix}Address`];
addressForm[`${prefix}Name`] =
this.transportMapSelected.regionName || addressForm[`${prefix}Name`];
addressForm[`${prefix}Longitude`] = this.transportMapSelected.longitude;
addressForm[`${prefix}Latitude`] = this.transportMapSelected.latitude;
this.transportMapBox = false;
this.$nextTick(() => {
this.$refs.crud?.clearValidate?.([`${prefix}Address`]);
@@ -7287,8 +7423,9 @@ export default {
item.cargoTypePath.join('/') === rowTypePath.join('/')
)
: goodsOptions;
const source = filtered.length ? filtered : goodsOptions;
const options = new Map();
filtered.forEach(item => {
source.forEach(item => {
if (!item.cargoName || options.has(item.cargoName)) return;
options.set(item.cargoName, {
label: item.cargoName,
@@ -7302,26 +7439,73 @@ export default {
});
return Array.from(options.values());
},
handleDispatchConfiguredCargoTypeChange(row, value) {
const option = this.getDispatchConfiguredCargoTypeOptions().find(
item => String(item.value) === String(value || '')
fetchDispatchConfiguredCargoTypeSuggestions(queryString, callback) {
const keyword = String(queryString || '').trim().toLowerCase();
const options = this.getDispatchConfiguredCargoTypeOptions().map(item => ({
...item,
value: item.label,
}));
callback(
keyword
? options.filter(item => String(item.value).toLowerCase().includes(keyword))
: options
);
row.cargoType = option?.label || '';
row.cargoTypeCode = option?.cargoTypeCode || '';
row.cargoTypePath = option?.cargoTypePath || [];
},
fetchDispatchConfiguredCargoNameSuggestions(queryString, callback, row = {}) {
const keyword = String(queryString || '').trim().toLowerCase();
const options = this.getDispatchConfiguredCargoNameOptions(row).map(item => ({
...item,
value: item.label,
}));
callback(
keyword
? options.filter(item => String(item.value).toLowerCase().includes(keyword))
: options
);
},
handleDispatchConfiguredCargoTypeSelect(row, item = {}) {
this.handleDispatchConfiguredCargoTypeChange(row, item.value || item.label || '');
},
handleDispatchConfiguredCargoNameSelect(row, item = {}) {
this.handleDispatchConfiguredCargoNameChange(row, item.value || item.label || '');
},
handleDispatchConfiguredCargoTypeChange(row, value) {
const nextValue = String(value ?? row.cargoType ?? '').trim();
const option = this.getDispatchConfiguredCargoTypeOptions().find(
item => String(item.value) === nextValue || item.label === nextValue
);
if (option) {
row.cargoType = option.label || '';
row.cargoTypeCode = option.cargoTypeCode || '';
row.cargoTypePath = option.cargoTypePath || [];
} else {
row.cargoType = nextValue;
row.cargoTypeCode = '';
row.cargoTypePath = [];
}
row.cargoName = '';
row.specification = '';
row.model = '';
},
handleDispatchConfiguredCargoNameChange(row, value) {
const nextValue = String(value ?? row.cargoName ?? '').trim();
const option = this.getDispatchConfiguredCargoNameOptions(row).find(
item => String(item.value) === String(value || '')
item => String(item.value) === nextValue || item.label === nextValue
);
row.cargoName = option?.value || '';
if (!option) return;
row.cargoType = option.cargoTypeLabel || row.cargoType || '';
row.cargoTypeCode = option.cargoTypeCode || row.cargoTypeCode || '';
row.cargoTypePath = option.cargoTypePath || row.cargoTypePath || [];
if (!option) {
row.cargoName = nextValue;
return;
}
const previousType = String(row.cargoType || '').trim();
const isKnownType = this.getDispatchConfiguredCargoTypeOptions().some(
item => item.label === previousType || String(item.value) === previousType
);
row.cargoName = option.value || '';
if (!previousType || isKnownType) {
row.cargoType = option.cargoTypeLabel || previousType;
row.cargoTypeCode = option.cargoTypeCode || row.cargoTypeCode || '';
row.cargoTypePath = option.cargoTypePath || row.cargoTypePath || [];
}
row.specification = option.specification || row.specification || '';
row.model = option.model || row.model || '';
},
@@ -7345,10 +7529,7 @@ export default {
vehicleNo: this.dispatchRow.vehicleNo || '',
cargoName: defaultGoods.cargoName || this.dispatchRow.cargoName || '',
cargoType: defaultGoods.cargoType || this.dispatchRow.cargoType || '',
quantity:
index >= 0
? defaultGoods.quantity || ''
: this.formatDispatchQuantity(this.getDispatchRemainingQuantity(defaultUnit)),
quantity: '',
quantityUnit: defaultUnit,
specification: defaultGoods.specification || '',
model: defaultGoods.model || '',
@@ -8003,6 +8184,7 @@ export default {
quantityGroups.set(key, group);
});
for (const { row: goods, quantity } of quantityGroups.values()) {
if (this.isDispatchPlanQuantityUnlimited(goods)) continue;
const unit = this.getDispatchQuantityUnit(goods);
const remaining = this.dispatchItemRemainingQuantity(goods);
if (quantity - remaining > 1e-8) {