1、修复基础配置
2、修复业务模块 3、拆分页面代码
This commit is contained in:
@@ -1041,21 +1041,25 @@
|
||||
label-width="auto"
|
||||
class="waybill-manage-page__freight-form waybill-manage-page__freight-form--road"
|
||||
>
|
||||
<template v-for="(cargo, index) in transportCargoRows" :key="index">
|
||||
<template v-for="(group, index) in taskFreightGroups" :key="group.key">
|
||||
<el-form-item :label="`单价${index + 1}`">
|
||||
<el-input
|
||||
v-model="cargo.unitPrice"
|
||||
:model-value="taskFullFreightGroupUnitPrice(group)"
|
||||
placeholder="请输入"
|
||||
clearable
|
||||
:disabled="dialogReadonly"
|
||||
@input="value => handleTaskFullFreightNumberInput(cargo, 'unitPrice', value)"
|
||||
@input="
|
||||
value => handleTaskFullFreightGroupNumberInput(group, 'unitPrice', value)
|
||||
"
|
||||
@clear="() => handleTaskFullFreightGroupNumberInput(group, 'unitPrice', '')"
|
||||
>
|
||||
<template #append>
|
||||
<el-select
|
||||
v-model="cargo.priceUnit"
|
||||
:model-value="taskFullFreightGroupPriceUnit(group)"
|
||||
class="waybill-manage-page__append-select waybill-manage-page__append-select--wide"
|
||||
placeholder="单位"
|
||||
:disabled="dialogReadonly"
|
||||
@change="value => handleTaskFullFreightGroupPriceUnitChange(group, value)"
|
||||
@visible-change="visible => visible && loadTaskFeeUnitOptions()"
|
||||
>
|
||||
<el-option
|
||||
@@ -1069,17 +1073,17 @@
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="`数量合计${index + 1}`">
|
||||
<el-input :model-value="taskFullFreightQuantity(index)" disabled>
|
||||
<el-input :model-value="taskFullFreightGroupQuantity(group)" disabled>
|
||||
<template #append>
|
||||
<el-select
|
||||
:model-value="cargo.quantityUnit"
|
||||
:model-value="group.quantityUnit"
|
||||
class="waybill-manage-page__append-select waybill-manage-page__append-select--wide"
|
||||
placeholder="单位"
|
||||
disabled
|
||||
>
|
||||
<el-option
|
||||
:label="cargo.quantityUnit || '单位'"
|
||||
:value="cargo.quantityUnit || ''"
|
||||
:label="group.quantityUnit || '单位'"
|
||||
:value="group.quantityUnit || ''"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
@@ -1087,10 +1091,11 @@
|
||||
</el-form-item>
|
||||
<el-form-item :label="`运费${index + 1}`">
|
||||
<el-input
|
||||
:model-value="taskFullFreightAmount(cargo)"
|
||||
:model-value="taskFullFreightGroupAmount(group)"
|
||||
placeholder="请输入运费"
|
||||
:disabled="dialogReadonly"
|
||||
@input="value => handleTaskFullFreightAmountInput(cargo, value)"
|
||||
@input="value => handleTaskFullFreightGroupAmountInput(group, value)"
|
||||
@clear="() => handleTaskFullFreightGroupAmountInput(group, '')"
|
||||
>
|
||||
<template #suffix>{{ taskFreightCurrencyLabel }}</template>
|
||||
</el-input>
|
||||
@@ -1520,11 +1525,7 @@
|
||||
<span>
|
||||
运费合计:<strong>¥{{ formatFooterFreightTotal }}</strong>
|
||||
</span>
|
||||
<el-link
|
||||
v-if="hasProjectProcessConfig"
|
||||
type="primary"
|
||||
@click="openWaybillProcessConfig"
|
||||
>
|
||||
<el-link v-if="hasProjectProcessConfig" type="primary" @click="openWaybillProcessConfig">
|
||||
查看过程配置
|
||||
</el-link>
|
||||
</div>
|
||||
@@ -3362,9 +3363,25 @@ export default {
|
||||
const amount = quantity * unitPrice;
|
||||
return Number.isInteger(amount) ? String(amount) : String(Number(amount.toFixed(2)));
|
||||
},
|
||||
taskFreightGroups() {
|
||||
const groups = [];
|
||||
const groupMap = new Map();
|
||||
(this.transportCargoRows || []).forEach((cargo, index) => {
|
||||
const quantityUnit = String(cargo.quantityUnit || '').trim();
|
||||
const key = quantityUnit || `__empty_${index}`;
|
||||
let group = groupMap.get(key);
|
||||
if (!group) {
|
||||
group = { key, quantityUnit, rows: [] };
|
||||
groupMap.set(key, group);
|
||||
groups.push(group);
|
||||
}
|
||||
group.rows.push(cargo);
|
||||
});
|
||||
return groups;
|
||||
},
|
||||
taskFullFreightTotal() {
|
||||
const total = this.transportCargoRows.reduce(
|
||||
(sum, cargo) => sum + Number(this.taskFullFreightAmount(cargo) || 0),
|
||||
const total = this.taskFreightGroups.reduce(
|
||||
(sum, group) => sum + Number(this.taskFullFreightGroupAmount(group) || 0),
|
||||
0
|
||||
);
|
||||
return this.formatTaskFullFreightNumber(total);
|
||||
@@ -3852,7 +3869,8 @@ export default {
|
||||
fillCustomerNameFromProject(projectId = this.form.projectId) {
|
||||
if (this.form.customerName || !projectId) return Promise.resolve(this.form.customerName);
|
||||
const project = this.projectOptions.find(item => String(item.id) === String(projectId));
|
||||
const customerName = project?.customerNames || project?.customerName || project?.customer || '';
|
||||
const customerName =
|
||||
project?.customerNames || project?.customerName || project?.customer || '';
|
||||
if (customerName) {
|
||||
this.form.customerName = customerName;
|
||||
return Promise.resolve(customerName);
|
||||
@@ -5253,6 +5271,69 @@ export default {
|
||||
Number(cargo.unitPrice || 0) * Number(cargo.quantity || 0)
|
||||
);
|
||||
},
|
||||
taskFullFreightGroupQuantity(group = {}) {
|
||||
const total = (group.rows || []).reduce((sum, cargo) => sum + Number(cargo.quantity || 0), 0);
|
||||
return this.formatTaskFullFreightNumber(total);
|
||||
},
|
||||
taskFullFreightGroupUnitPrice(group = {}) {
|
||||
const prices = (group.rows || [])
|
||||
.map(cargo => String(cargo.unitPrice ?? '').trim())
|
||||
.filter(Boolean);
|
||||
if (!prices.length || prices.some(price => price !== prices[0])) return '';
|
||||
return prices[0];
|
||||
},
|
||||
taskFullFreightGroupPriceUnit(group = {}) {
|
||||
return group.rows?.[0]?.priceUnit || (group.quantityUnit ? `元/${group.quantityUnit}` : '');
|
||||
},
|
||||
taskFullFreightGroupAmount(group = {}) {
|
||||
const total = (group.rows || []).reduce(
|
||||
(sum, cargo) => sum + Number(this.taskFullFreightAmount(cargo) || 0),
|
||||
0
|
||||
);
|
||||
return this.formatTaskFullFreightNumber(total);
|
||||
},
|
||||
handleTaskFullFreightGroupNumberInput(group, prop, value) {
|
||||
const text = String(value || '').replace(/[^\d.]/g, '');
|
||||
const parts = text.split('.');
|
||||
const normalized =
|
||||
parts.length > 1 ? `${parts[0]}.${parts.slice(1).join('').slice(0, 2)}` : parts[0];
|
||||
(group.rows || []).forEach(cargo => {
|
||||
cargo[prop] = normalized;
|
||||
});
|
||||
this.syncTransportCargoJson();
|
||||
},
|
||||
handleTaskFullFreightGroupPriceUnitChange(group, value) {
|
||||
(group.rows || []).forEach(cargo => {
|
||||
cargo.priceUnit = value || '';
|
||||
});
|
||||
this.syncTransportCargoJson();
|
||||
},
|
||||
handleTaskFullFreightGroupAmountInput(group, value) {
|
||||
const text = String(value || '').replace(/[^\d.]/g, '');
|
||||
const parts = text.split('.');
|
||||
const normalized =
|
||||
parts.length > 1 ? `${parts[0]}.${parts.slice(1).join('').slice(0, 2)}` : parts[0];
|
||||
const rows = group.rows || [];
|
||||
const total = Number(normalized || 0);
|
||||
const quantities = rows.map(cargo => Math.max(0, Number(cargo.quantity || 0)));
|
||||
const quantityTotal = quantities.reduce((sum, quantity) => sum + quantity, 0);
|
||||
let allocated = 0;
|
||||
rows.forEach((cargo, index) => {
|
||||
if (index === rows.length - 1) {
|
||||
cargo.freightAmount = this.formatTaskFullFreightNumber(total - allocated);
|
||||
return;
|
||||
}
|
||||
let amount = 0;
|
||||
if (quantityTotal) {
|
||||
amount = Number((total * (quantities[index] / quantityTotal)).toFixed(2));
|
||||
} else if (index === 0) {
|
||||
amount = total;
|
||||
}
|
||||
allocated += amount;
|
||||
cargo.freightAmount = this.formatTaskFullFreightNumber(amount);
|
||||
});
|
||||
this.syncTransportCargoJson();
|
||||
},
|
||||
formatTaskFullFreightNumber(value) {
|
||||
if (value === undefined || value === null || String(value).trim() === '') return '';
|
||||
const number = Number(value || 0);
|
||||
|
||||
Reference in New Issue
Block a user