1、调整业务模块
This commit is contained in:
@@ -146,7 +146,7 @@
|
||||
<span>{{
|
||||
isTransportPlanPage
|
||||
? formatTransportPlanProvinceCityDistrict(row.departureAddress)
|
||||
: formatTransportPlanProvinceCityDistrict(row.departureAddress)
|
||||
: formatWaybillListAddress(row.departureAddress)
|
||||
}}</span>
|
||||
</el-tooltip>
|
||||
<span v-else>{{ row.departureAddress || '-' }}</span>
|
||||
@@ -161,7 +161,7 @@
|
||||
<span>{{
|
||||
isTransportPlanPage
|
||||
? formatTransportPlanProvinceCityDistrict(row.arrivalAddress)
|
||||
: formatTransportPlanProvinceCityDistrict(row.arrivalAddress)
|
||||
: formatWaybillListAddress(row.arrivalAddress)
|
||||
}}</span>
|
||||
</el-tooltip>
|
||||
<span v-else>{{ row.arrivalAddress || '-' }}</span>
|
||||
@@ -644,7 +644,7 @@
|
||||
@change="handleTaskCarrierTypeChange"
|
||||
>
|
||||
<el-radio-button
|
||||
v-for="item in taskCarrierTypes"
|
||||
v-for="item in waybillTaskCarrierTypes"
|
||||
:key="item"
|
||||
:label="item"
|
||||
:value="item"
|
||||
@@ -1135,8 +1135,9 @@
|
||||
<el-form-item :label="`运费${index + 1}`">
|
||||
<el-input
|
||||
:model-value="taskFullFreightAmount(cargo)"
|
||||
disabled
|
||||
placeholder="自动计算"
|
||||
placeholder="请输入运费"
|
||||
:disabled="dialogReadonly"
|
||||
@input="value => handleTaskFullFreightAmountInput(cargo, value)"
|
||||
>
|
||||
<template #suffix>{{ taskFreightCurrencyLabel }}</template>
|
||||
</el-input>
|
||||
@@ -1195,7 +1196,7 @@
|
||||
@change="handleTaskCarrierTypeChange"
|
||||
>
|
||||
<el-radio-button
|
||||
v-for="item in taskCarrierTypes"
|
||||
v-for="item in waybillTaskCarrierTypes"
|
||||
:key="item"
|
||||
:label="item"
|
||||
:value="item"
|
||||
@@ -2054,7 +2055,7 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #menu-form-before>
|
||||
<template #menu-form>
|
||||
<div
|
||||
v-if="showFooterFreightSummary && !dialogReadonly"
|
||||
class="business-crud-page__shipping-template-footer-summary"
|
||||
@@ -2070,24 +2071,24 @@
|
||||
查看过程配置
|
||||
</el-link>
|
||||
</div>
|
||||
<el-button
|
||||
<div
|
||||
v-if="isStandaloneFormPage && !showTransportPlanCreateActions"
|
||||
@click="closeCrudDialog"
|
||||
class="business-crud-page__standalone-menu-actions"
|
||||
>
|
||||
取消
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="config.enableDraftSave && !dialogReadonly"
|
||||
type="primary"
|
||||
plain
|
||||
:loading="draftSaveLoading"
|
||||
@click="handleDraftSave"
|
||||
>
|
||||
{{ config.draftSaveText || '保存' }}
|
||||
</el-button>
|
||||
</template>
|
||||
|
||||
<template #menu-form>
|
||||
<el-button class="business-crud-page__form-close" @click="closeCrudDialog">
|
||||
{{ isWaybillDetailLayout ? '关闭' : '取消' }}
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="config.enableDraftSave && !dialogReadonly"
|
||||
class="business-crud-page__form-draft"
|
||||
type="primary"
|
||||
plain
|
||||
:loading="draftSaveLoading"
|
||||
@click="handleDraftSave"
|
||||
>
|
||||
{{ config.draftSaveText || '保存' }}
|
||||
</el-button>
|
||||
</div>
|
||||
<div v-if="showTransportPlanCreateActions" class="business-crud-page__create-actions">
|
||||
<el-button :disabled="Boolean(transportPlanCreateActionLoading)" @click="closeCrudDialog">
|
||||
取消
|
||||
@@ -5418,6 +5419,7 @@ const defaultTransportCargo = () => ({
|
||||
quantityUnit: '',
|
||||
unitPrice: '',
|
||||
priceUnit: '元/吨',
|
||||
freightAmount: '',
|
||||
packageType: '',
|
||||
brand: '',
|
||||
specification: '',
|
||||
@@ -5703,6 +5705,8 @@ export default {
|
||||
transportAddressTarget: '',
|
||||
transportAddressLoading: false,
|
||||
transportAddressQuery: {},
|
||||
transportTypeOptions: [],
|
||||
transportTypeOptionsLoading: false,
|
||||
transportAddressRows: [],
|
||||
transportAddressSelected: null,
|
||||
transportAddressPage: {
|
||||
@@ -5743,6 +5747,9 @@ export default {
|
||||
taskCarrierOptions: [],
|
||||
taskCarrierLoading: false,
|
||||
taskCarrierRequestId: 0,
|
||||
waybillCarrierContractsLoaded: false,
|
||||
waybillHasCarrierContracts: null,
|
||||
waybillCarrierContractRequestId: 0,
|
||||
taskDriverOptions: [],
|
||||
taskDriverLoading: false,
|
||||
taskCargoOptionsMap: {},
|
||||
@@ -5872,8 +5879,16 @@ export default {
|
||||
if (this.config.enableWaybillFooterFreightSummary) {
|
||||
this.loadShippingTemplateCurrencyOptions();
|
||||
}
|
||||
this.consumeTemplateCreatePayload();
|
||||
if (this.isStandaloneFormPage) this.$nextTick(() => this.initStandaloneFormPage());
|
||||
if (this.shippingInfoFormEnabled) this.loadTransportTypeOptions();
|
||||
if (this.isStandaloneFormPage) {
|
||||
this.$nextTick(() => {
|
||||
this.initStandaloneFormPage();
|
||||
// 先完成独立表单初始化,再回填模板数据,避免被新增表单默认值覆盖。
|
||||
this.$nextTick(() => this.consumeTemplateCreatePayload());
|
||||
});
|
||||
} else {
|
||||
this.consumeTemplateCreatePayload();
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['permission', 'userInfo']),
|
||||
@@ -6063,6 +6078,16 @@ export default {
|
||||
taskCarrierRequired() {
|
||||
return this.isTaskCarrierRequired(this.form.carrierType);
|
||||
},
|
||||
waybillTaskCarrierTypes() {
|
||||
if (
|
||||
this.isWaybillDetailLayout &&
|
||||
this.waybillCarrierContractsLoaded &&
|
||||
this.waybillHasCarrierContracts === false
|
||||
) {
|
||||
return ['自运'];
|
||||
}
|
||||
return this.taskCarrierTypes;
|
||||
},
|
||||
taskCarrierLabel() {
|
||||
return this.form.carrierType === '网货平台' ? '承运方' : '承运商';
|
||||
},
|
||||
@@ -6636,11 +6661,36 @@ export default {
|
||||
return applyTableMenuWidth(nextOption, menuButtonCount);
|
||||
},
|
||||
formatTransportPlanGoodsInfo(row = {}) {
|
||||
const goodsRows = this.parseJsonArray(row.goodsJson);
|
||||
// 列表接口的货物明细字段存在多种兼容命名,优先使用完整的 goodsJson。
|
||||
const goodsRows = [
|
||||
row.goodsJson,
|
||||
row.goodsList,
|
||||
row.goodsRows,
|
||||
row.cargoList,
|
||||
row.cargoRows,
|
||||
row.goods,
|
||||
]
|
||||
.map(source => {
|
||||
if (source === undefined || source === null || source === '') return [];
|
||||
if (Array.isArray(source)) return source;
|
||||
if (typeof source === 'object') return [source];
|
||||
return this.parseJsonArray(source);
|
||||
})
|
||||
.filter(source => source.length)
|
||||
.sort((left, right) => right.length - left.length)[0] || [];
|
||||
if (!goodsRows.length) return String(row.goodsInfo || row.cargoInfo || '');
|
||||
const groups = goodsRows.reduce((result, item = {}) => {
|
||||
const unit =
|
||||
item.quantityUnit || item.goodsQuantityUnit || item.cargoUnit || item.unit || '';
|
||||
const unit = String(
|
||||
item.quantityUnit ||
|
||||
item.goodsQuantityUnit ||
|
||||
item.cargoUnit ||
|
||||
item.unit ||
|
||||
row.quantityUnit ||
|
||||
row.goodsQuantityUnit ||
|
||||
row.cargoUnit ||
|
||||
row.unit ||
|
||||
''
|
||||
).trim();
|
||||
const key = unit || '__empty__';
|
||||
if (!result[key]) {
|
||||
result[key] = {
|
||||
@@ -6699,6 +6749,28 @@ export default {
|
||||
const cityMatch = text.match(/市/);
|
||||
return cityMatch ? text.slice(0, cityMatch.index + 1) : text;
|
||||
},
|
||||
formatWaybillListAddress(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('/') : text;
|
||||
},
|
||||
hasPermission(code) {
|
||||
return this.isAdmin || this.validData(this.permission && this.permission[code], false);
|
||||
},
|
||||
@@ -6831,41 +6903,43 @@ export default {
|
||||
if (payload.target !== target) return;
|
||||
sessionStorage.removeItem(storageKey);
|
||||
this.$nextTick(() => {
|
||||
this.$refs.crud.rowAdd();
|
||||
this.$nextTick(() => {
|
||||
// 模板主键不能带入目标业务单据,避免提交时被后端误判为更新。
|
||||
const row = { ...(payload.data || {}) };
|
||||
[
|
||||
'id',
|
||||
'createUser',
|
||||
'createUserName',
|
||||
'createDept',
|
||||
'createTime',
|
||||
'updateUser',
|
||||
'updateUserName',
|
||||
'updateTime',
|
||||
].forEach(key => delete row[key]);
|
||||
this.suppressTransportTypeClear = true;
|
||||
Object.assign(this.form, row);
|
||||
this.applyWaybillTemplateTaskData(row);
|
||||
this.$nextTick(() => {
|
||||
this.suppressTransportTypeClear = false;
|
||||
});
|
||||
this.form.planName = this.form.planName || this.form.templateName || '';
|
||||
this.selectedProjectId = this.form.projectId || '';
|
||||
this.attachmentRows = this.parseJsonArray(this.form.attachmentsJson);
|
||||
this.selectedAttachmentRows = [];
|
||||
if (this.contractSelectEnabled) {
|
||||
this.syncCurrentContractOption();
|
||||
this.loadContractOptionsForProject();
|
||||
}
|
||||
if (this.config.enableProjectSelect) this.syncCurrentProjectOption();
|
||||
this.loadProjectProcessConfigState();
|
||||
if (this.config.enableTransportPlanForm) this.initTransportPlanFormRows();
|
||||
if (this.taskInfoFormEnabled) this.initTaskInfoForm();
|
||||
});
|
||||
// 独立表单页已经由路由控制新增状态,不能再调用 rowAdd 打开弹窗。
|
||||
if (!this.isStandaloneFormPage) this.$refs.crud?.rowAdd?.();
|
||||
this.$nextTick(() => this.applyTemplateCreatePayload(payload.data));
|
||||
});
|
||||
},
|
||||
applyTemplateCreatePayload(data) {
|
||||
// 模板主键不能带入目标业务单据,避免提交时被后端误判为更新。
|
||||
const row = { ...(data || {}) };
|
||||
[
|
||||
'id',
|
||||
'createUser',
|
||||
'createUserName',
|
||||
'createDept',
|
||||
'createTime',
|
||||
'updateUser',
|
||||
'updateUserName',
|
||||
'updateTime',
|
||||
].forEach(key => delete row[key]);
|
||||
this.suppressTransportTypeClear = true;
|
||||
Object.assign(this.form, row);
|
||||
this.applyWaybillTemplateTaskData(row);
|
||||
this.$nextTick(() => {
|
||||
this.suppressTransportTypeClear = false;
|
||||
});
|
||||
this.form.planName = this.form.planName || this.form.templateName || '';
|
||||
this.selectedProjectId = this.form.projectId || '';
|
||||
this.attachmentRows = this.parseJsonArray(this.form.attachmentsJson);
|
||||
this.selectedAttachmentRows = [];
|
||||
if (this.contractSelectEnabled) {
|
||||
this.syncCurrentContractOption();
|
||||
this.loadContractOptionsForProject();
|
||||
}
|
||||
if (this.config.enableProjectSelect) this.syncCurrentProjectOption();
|
||||
this.loadProjectProcessConfigState();
|
||||
if (this.config.enableTransportPlanForm) this.initTransportPlanFormRows();
|
||||
if (this.taskInfoFormEnabled) this.initTaskInfoForm();
|
||||
},
|
||||
applyWaybillTemplateTaskData(template = {}) {
|
||||
if (this.config.permission !== 'waybill_manage') return;
|
||||
const goodsRows = this.parseJsonArray(template.goodsJson);
|
||||
@@ -7561,6 +7635,7 @@ export default {
|
||||
const submitRow = { ...row };
|
||||
const skipValidation = saveAsDraft && this.config.skipDraftValidation === true;
|
||||
if (
|
||||
!skipValidation &&
|
||||
['shipping_template', 'transport_plan', 'waybill_manage'].includes(
|
||||
this.config.permission
|
||||
) &&
|
||||
@@ -8014,6 +8089,7 @@ export default {
|
||||
handleDraftSave() {
|
||||
const request =
|
||||
typeof this.api.saveDraft === 'function' ? this.api.saveDraft : this.api.submit;
|
||||
if (this.draftSaveLoading) return;
|
||||
const submitRow = this.normalizeRow(this.form, true);
|
||||
if (!submitRow) return;
|
||||
this.draftSaveLoading = true;
|
||||
@@ -8115,6 +8191,7 @@ export default {
|
||||
this.taskCarrierRequestId += 1;
|
||||
this.taskCarrierOptions = [];
|
||||
this.taskCarrierLoading = false;
|
||||
this.resetWaybillCarrierContractState();
|
||||
this.initTaskInfoForm();
|
||||
this.initTransportPlanFormRows();
|
||||
this.syncBillingPlanJson();
|
||||
@@ -8150,6 +8227,7 @@ export default {
|
||||
this.suppressTransportTypeClear = false;
|
||||
});
|
||||
this.selectedProjectId = this.form.projectId || '';
|
||||
this.resetWaybillCarrierContractState();
|
||||
this.loadProjectProcessConfigState();
|
||||
this.attachmentRows = this.parseJsonArray(this.form.attachmentsJson);
|
||||
this.selectedAttachmentRows = [];
|
||||
@@ -8271,6 +8349,7 @@ export default {
|
||||
this.taskCarrierRequestId += 1;
|
||||
this.taskCarrierOptions = [];
|
||||
this.taskCarrierLoading = false;
|
||||
this.resetWaybillCarrierContractState();
|
||||
this.form.carrierName = '';
|
||||
this.form.carrierId = '';
|
||||
this.form.carrierContractId = '';
|
||||
@@ -8282,6 +8361,9 @@ export default {
|
||||
this.form.projectCode = project.projectCode || '';
|
||||
this.form.undertakeDeptName = project.undertakeDeptName || '';
|
||||
if (this.isWaybillDetailLayout) {
|
||||
this.taskCarrierRequestId += 1;
|
||||
this.taskCarrierLoading = false;
|
||||
this.resetWaybillCarrierContractState();
|
||||
this.form.carrierName = '';
|
||||
this.form.carrierId = '';
|
||||
this.form.carrierContractId = '';
|
||||
@@ -8638,15 +8720,39 @@ export default {
|
||||
parts.length > 1 ? `${parts[0]}.${parts.slice(1).join('').slice(0, 2)}` : parts[0];
|
||||
this.syncTransportCargoJson();
|
||||
},
|
||||
handleTaskFullFreightAmountInput(cargo, value) {
|
||||
this.handleTaskFullFreightNumberInput(cargo, 'freightAmount', value);
|
||||
},
|
||||
taskFullFreightAutoCalculable() {
|
||||
const rows = this.transportCargoRows || [];
|
||||
if (!rows.length) return false;
|
||||
const quantityUnits = rows.map(row => String(row.quantityUnit || '').trim());
|
||||
if (quantityUnits.some(unit => !unit) || new Set(quantityUnits).size !== 1) return false;
|
||||
const quantityUnit = quantityUnits[0];
|
||||
return rows.every(row => {
|
||||
const priceUnit = String(row.priceUnit || '').trim();
|
||||
const separatorIndex = Math.max(priceUnit.lastIndexOf('/'), priceUnit.lastIndexOf('/'));
|
||||
const priceQuantityUnit =
|
||||
separatorIndex >= 0 ? priceUnit.slice(separatorIndex + 1).trim() : priceUnit;
|
||||
return !this.isBillingFieldEmpty(row.unitPrice) && priceQuantityUnit === quantityUnit;
|
||||
});
|
||||
},
|
||||
taskFullFreightQuantity(index) {
|
||||
return this.formatTaskFullFreightNumber(this.transportCargoRows[index]?.quantity || 0);
|
||||
},
|
||||
taskFullFreightAmount(cargo = {}) {
|
||||
if (!this.taskFullFreightAutoCalculable()) {
|
||||
return this.formatTaskFullFreightNumber(cargo.freightAmount);
|
||||
}
|
||||
if (!this.isBillingFieldEmpty(cargo.freightAmount)) {
|
||||
return this.formatTaskFullFreightNumber(cargo.freightAmount);
|
||||
}
|
||||
return this.formatTaskFullFreightNumber(
|
||||
Number(cargo.unitPrice || 0) * Number(cargo.quantity || 0)
|
||||
);
|
||||
},
|
||||
formatTaskFullFreightNumber(value) {
|
||||
if (value === undefined || value === null || String(value).trim() === '') return '';
|
||||
const number = Number(value || 0);
|
||||
if (!Number.isFinite(number)) return '';
|
||||
return Number(number.toFixed(2)).toString();
|
||||
@@ -8668,30 +8774,74 @@ export default {
|
||||
if (this.isWaybillDetailLayout) {
|
||||
this.taskCarrierRequestId += 1;
|
||||
this.taskCarrierOptions = [];
|
||||
this.taskCarrierLoading = false;
|
||||
}
|
||||
},
|
||||
isTaskCarrierRequired(carrierType) {
|
||||
return ['承运商', '网货平台'].includes(String(carrierType || '').trim());
|
||||
},
|
||||
resetWaybillCarrierContractState() {
|
||||
if (!this.isWaybillDetailLayout) return;
|
||||
this.waybillCarrierContractRequestId += 1;
|
||||
this.waybillCarrierContractsLoaded = false;
|
||||
this.waybillHasCarrierContracts = null;
|
||||
},
|
||||
loadWaybillCarrierContractState(project = {}) {
|
||||
if (!this.isWaybillDetailLayout) return Promise.resolve(null);
|
||||
const projectId = project.id || project.projectId || this.form.projectId;
|
||||
const requestId = ++this.waybillCarrierContractRequestId;
|
||||
if (!projectId) {
|
||||
this.waybillCarrierContractsLoaded = false;
|
||||
this.waybillHasCarrierContracts = null;
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
return getContractList(1, 9999, {
|
||||
projectId,
|
||||
projectName: project.projectName || this.form.projectName,
|
||||
contractCategory: '承运商合同',
|
||||
})
|
||||
.then(res => {
|
||||
if (requestId !== this.waybillCarrierContractRequestId) return null;
|
||||
const options = this.getWaybillCarrierContractOptions(extractRecords(res));
|
||||
this.waybillCarrierContractsLoaded = true;
|
||||
this.waybillHasCarrierContracts = options.length > 0;
|
||||
if (!options.length && this.form.carrierType !== '自运') {
|
||||
this.form.carrierType = '自运';
|
||||
this.form.carrierName = '';
|
||||
this.form.carrierId = '';
|
||||
this.form.carrierContractId = '';
|
||||
}
|
||||
return options;
|
||||
})
|
||||
.catch(() => {
|
||||
if (requestId === this.waybillCarrierContractRequestId) {
|
||||
this.waybillCarrierContractsLoaded = false;
|
||||
this.waybillHasCarrierContracts = null;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
},
|
||||
loadTaskCarrierOptions(project = {}) {
|
||||
if (!this.taskInfoFormEnabled || this.taskCarrierLoading) return Promise.resolve([]);
|
||||
if (this.isWaybillDetailLayout) {
|
||||
const projectId = project.id || project.projectId || this.form.projectId;
|
||||
const requestId = ++this.taskCarrierRequestId;
|
||||
if (this.form.carrierType === '承运商') {
|
||||
const carrierTypeAtRequest = this.form.carrierType;
|
||||
const contractPromise = this.loadWaybillCarrierContractState({
|
||||
...project,
|
||||
id: projectId,
|
||||
});
|
||||
if (carrierTypeAtRequest === '承运商') {
|
||||
if (!projectId) {
|
||||
this.taskCarrierOptions = [];
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
this.taskCarrierLoading = true;
|
||||
return getContractList(1, 9999, {
|
||||
projectId,
|
||||
projectName: project.projectName || this.form.projectName,
|
||||
contractCategory: '承运商合同',
|
||||
})
|
||||
.then(res => {
|
||||
return contractPromise
|
||||
.then(options => {
|
||||
if (requestId !== this.taskCarrierRequestId) return this.taskCarrierOptions;
|
||||
this.taskCarrierOptions = this.getWaybillCarrierContractOptions(extractRecords(res));
|
||||
if (options === null) return this.taskCarrierOptions;
|
||||
this.taskCarrierOptions = options || [];
|
||||
return this.taskCarrierOptions;
|
||||
})
|
||||
.catch(() => this.taskCarrierOptions)
|
||||
@@ -8708,7 +8858,7 @@ export default {
|
||||
});
|
||||
if (!projectId) return Promise.resolve(this.taskCarrierOptions);
|
||||
this.taskCarrierLoading = true;
|
||||
return getProjectDetail(projectId)
|
||||
const detailPromise = getProjectDetail(projectId)
|
||||
.then(res => {
|
||||
if (requestId !== this.taskCarrierRequestId) return this.taskCarrierOptions;
|
||||
const detail = res?.data?.data || {};
|
||||
@@ -8719,7 +8869,9 @@ export default {
|
||||
});
|
||||
return this.taskCarrierOptions;
|
||||
})
|
||||
.catch(() => this.taskCarrierOptions)
|
||||
.catch(() => this.taskCarrierOptions);
|
||||
return Promise.all([contractPromise, detailPromise])
|
||||
.then(([, options]) => options)
|
||||
.finally(() => {
|
||||
if (requestId === this.taskCarrierRequestId) this.taskCarrierLoading = false;
|
||||
});
|
||||
@@ -8974,12 +9126,16 @@ export default {
|
||||
},
|
||||
initTaskFullCargoRows(goodsRows = []) {
|
||||
if (!this.taskInfoFormEnabled) return;
|
||||
const freightItems = this.parseJsonObject(this.form.freightJson).freightItems || [];
|
||||
const rows = (goodsRows.length ? goodsRows : this.transportCargoRows).map((row, index) => {
|
||||
const cargo = this.normalizeTransportCargoRow(row);
|
||||
if (index === 0 && !cargo.unitPrice && this.form.unitPrice) {
|
||||
cargo.unitPrice = this.form.unitPrice;
|
||||
}
|
||||
cargo.priceUnit = cargo.priceUnit || this.form.priceUnit || '元/吨';
|
||||
if (this.isBillingFieldEmpty(cargo.freightAmount)) {
|
||||
cargo.freightAmount = freightItems[index]?.freightAmount ?? '';
|
||||
}
|
||||
return cargo;
|
||||
});
|
||||
while (rows.length < 1) {
|
||||
@@ -9076,6 +9232,10 @@ export default {
|
||||
this.$message.warning(`第${index + 1}行单价不能小于0`);
|
||||
return false;
|
||||
}
|
||||
if (!this.isBillingFieldEmpty(cargo.freightAmount) && Number(cargo.freightAmount) < 0) {
|
||||
this.$message.warning(`第${index + 1}行运费不能小于0`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
@@ -9328,6 +9488,7 @@ export default {
|
||||
cargoName: row.cargoName || row.goodsName || '',
|
||||
packageType: row.packageType || row.package || '',
|
||||
specification: row.specification || row.spec || '',
|
||||
freightAmount: row.freightAmount ?? row.amount ?? row.totalAmount ?? '',
|
||||
};
|
||||
['quantity', 'mileage', 'unitPrice'].forEach(prop => {
|
||||
if (Number(cargo[prop]) === -1) cargo[prop] = '';
|
||||
@@ -9470,8 +9631,11 @@ export default {
|
||||
]);
|
||||
},
|
||||
getTransportTypeLabel(value) {
|
||||
if (value && typeof value === 'object') {
|
||||
return value.label || value.dictValue || value.name || value.value || value.dictKey || '';
|
||||
}
|
||||
const column = (this.option.column || []).find(item => item.prop === 'transportType');
|
||||
const dictionary = column?.dicData || [];
|
||||
const dictionary = [...(column?.dicData || []), ...this.transportTypeOptions];
|
||||
const item = dictionary.find(
|
||||
dic =>
|
||||
String(dic.value ?? dic.dictKey ?? '') === String(value ?? '') ||
|
||||
@@ -9479,11 +9643,28 @@ export default {
|
||||
);
|
||||
return item?.label || item?.dictValue || '';
|
||||
},
|
||||
loadTransportTypeOptions() {
|
||||
if (this.transportTypeOptions.length || this.transportTypeOptionsLoading) {
|
||||
return Promise.resolve(this.transportTypeOptions);
|
||||
}
|
||||
this.transportTypeOptionsLoading = true;
|
||||
return getDictionary({ code: 'transport_type' })
|
||||
.then(res => {
|
||||
this.transportTypeOptions = this.normalizeDictOptions(res.data?.data || []);
|
||||
return this.transportTypeOptions;
|
||||
})
|
||||
.finally(() => {
|
||||
this.transportTypeOptionsLoading = false;
|
||||
});
|
||||
},
|
||||
resolveTransportMode(value) {
|
||||
const text = [value, this.form.transportTypeName, this.getTransportTypeLabel(value)]
|
||||
.filter(Boolean)
|
||||
.join(' ')
|
||||
.toLowerCase();
|
||||
const values = [value, this.form.transportTypeName, this.getTransportTypeLabel(value)]
|
||||
.flatMap(item => {
|
||||
if (!item || typeof item !== 'object') return [item];
|
||||
return [item.label, item.dictValue, item.name, item.value, item.dictKey];
|
||||
})
|
||||
.filter(Boolean);
|
||||
const text = values.join(' ').toLowerCase();
|
||||
if (!text) return '';
|
||||
if (
|
||||
text.includes('公路') ||
|
||||
@@ -9715,17 +9896,28 @@ export default {
|
||||
},
|
||||
openTransportAddressDialog(target) {
|
||||
if (!this.ensureTransportTypeBeforeAddress()) return;
|
||||
this.transportAddressTarget = target;
|
||||
this.transportAddressSelected = null;
|
||||
this.resetTransportAddressQuery();
|
||||
this.transportAddressPage.currentPage = 1;
|
||||
this.transportAddressBox = true;
|
||||
const open = () => {
|
||||
this.transportAddressTarget = target;
|
||||
this.transportAddressSelected = null;
|
||||
this.resetTransportAddressQuery();
|
||||
this.transportAddressPage.currentPage = 1;
|
||||
this.transportAddressBox = true;
|
||||
};
|
||||
// Avue 远程字典可能尚未写入 option,先加载后再解析运输方式,避免按空类型查询全部地址。
|
||||
if (this.isTransportPlanPage && !this.getTransportFixedAddressType()) {
|
||||
this.loadTransportTypeOptions().finally(open);
|
||||
return;
|
||||
}
|
||||
open();
|
||||
},
|
||||
openTransportAddressPicker(target) {
|
||||
if (
|
||||
this.transportStationMode &&
|
||||
!(this.isTransportPlanPage && this.transportMode === 'water')
|
||||
) {
|
||||
// 运输计划的常用地址按钮统一使用地址库弹窗,按运输方式筛选并锁定地址类型;
|
||||
// 站点输入框仍保留铁路/航空专用站点选择弹窗。
|
||||
if (this.isTransportPlanPage) {
|
||||
this.openTransportAddressDialog(target);
|
||||
return;
|
||||
}
|
||||
if (this.transportStationMode) {
|
||||
this.openTransportStationDialog(target);
|
||||
return;
|
||||
}
|
||||
@@ -9808,7 +10000,10 @@ 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`] || '';
|
||||
this.$refs.crud?.validateField?.(`${prefix}Address`);
|
||||
// 地址值在本轮响应式更新后再清理校验状态,避免 Avue 以旧空值重新触发必填提示。
|
||||
this.$nextTick(() => {
|
||||
this.$refs.crud?.clearValidate?.([`${prefix}Address`]);
|
||||
});
|
||||
},
|
||||
openTransportMapDialog(target) {
|
||||
if (this.dialogReadonly) return;
|
||||
@@ -9974,7 +10169,9 @@ export default {
|
||||
this.form[`${prefix}Longitude`] = this.transportMapSelected.longitude;
|
||||
this.form[`${prefix}Latitude`] = this.transportMapSelected.latitude;
|
||||
this.transportMapBox = false;
|
||||
this.$refs.crud?.validateField?.(`${prefix}Address`);
|
||||
this.$nextTick(() => {
|
||||
this.$refs.crud?.clearValidate?.([`${prefix}Address`]);
|
||||
});
|
||||
},
|
||||
buildTransportMapSelection({ lng, lat, address, regionName, regionCode }) {
|
||||
const longitude = this.formatCoordinate(lng);
|
||||
@@ -11721,13 +11918,17 @@ export default {
|
||||
this.api.getDetail(row.id).then(res => {
|
||||
const template = res.data?.data || row;
|
||||
const templateType = template.templateType || template.templateTypeName;
|
||||
const target =
|
||||
const listTarget =
|
||||
templateType === '运单' ? '/business/waybill-manage' : '/business/transport-plan';
|
||||
const target = standaloneBusinessFormRoutes[listTarget] || listTarget;
|
||||
sessionStorage.setItem(
|
||||
'business-template-create',
|
||||
JSON.stringify({ target: target.slice('/business/'.length), data: template })
|
||||
JSON.stringify({ target: listTarget.slice('/business/'.length), data: template })
|
||||
);
|
||||
this.$router.push({ path: target, query: { fromTemplate: Date.now().toString() } });
|
||||
this.$router.push({
|
||||
path: target,
|
||||
query: { mode: 'add', fromTemplate: Date.now().toString() },
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -15535,10 +15736,21 @@ export default {
|
||||
|
||||
:global(.business-crud-form-page-dialog .business-crud-page__shipping-template-footer-summary) {
|
||||
position: static;
|
||||
order: 1;
|
||||
height: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
:global(.business-crud-form-page-dialog .avue-form__menu > .business-crud-page__standalone-menu-actions) {
|
||||
display: flex;
|
||||
order: 2;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
:global(.business-crud-form-page-dialog .avue-form__menu > .el-button) {
|
||||
order: 3;
|
||||
}
|
||||
|
||||
:global(.avue--collapse .el-overlay:has(.business-crud-form-page-dialog)) {
|
||||
left: 60px !important;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user