feat(分条/更新): 添加复制源卷信息功能

在分条和更新页面添加复制源卷信息按钮,方便用户快速填充表单。复制时自动排除卷号等特定字段,并处理数值类型转换。同时优化了复制逻辑,确保相关字段的联动更新。
This commit is contained in:
砂糖
2026-03-21 10:40:14 +08:00
parent 0c86b80fb2
commit 1b22ec6173
2 changed files with 77 additions and 10 deletions

View File

@@ -202,6 +202,7 @@
</el-form-item>
<el-form-item>
<el-button type="info" @click="copyFromSourceCoil" icon="el-icon-document-copy">复制源卷信息</el-button>
<el-button :loading="buttonLoading" type="primary" @click="addSplit">提交分条</el-button>
<el-button :loading="buttonLoading" @click="resetSplitForm">重置</el-button>
</el-form-item>
@@ -813,6 +814,52 @@ export default {
if (!dict) return code;
const item = dict.find(item => item.value === code);
return item ? item.label : code;
},
// 复制源卷信息到分条表单
copyFromSourceCoil() {
// 复制除了指定字段之外的其他字段
const excludeFields = ['enterCoilNo', 'currentCoilNo', 'coilId', 'createTime', 'createBy'];
// 构建要复制的字段
const copiedFields = {
supplierCoilNo: this.coilInfo.supplierCoilNo,
warehouseId: this.coilInfo.warehouseId,
actualWarehouseId: this.coilInfo.actualWarehouseId,
team: this.coilInfo.team,
materialType: this.coilInfo.materialType,
itemType: this.coilInfo.itemType,
itemId: this.coilInfo.itemId,
qualityStatus: this.coilInfo.qualityStatus,
trimmingRequirement: this.coilInfo.trimmingRequirement,
packingStatus: this.coilInfo.packingStatus,
packagingRequirement: this.coilInfo.packagingRequirement,
grossWeight: parseFloat(this.coilInfo.grossWeight) || null,
netWeight: parseFloat(this.coilInfo.netWeight) || null,
length: parseFloat(this.coilInfo.length) || null,
actualLength: parseFloat(this.coilInfo.actualLength) || null,
actualWidth: parseFloat(this.coilInfo.actualWidth) || null,
temperGrade: this.coilInfo.temperGrade,
coatingType: this.coilInfo.coatingType,
remark: this.coilInfo.remark,
productionStartTime: this.coilInfo.productionStartTime,
productionEndTime: this.coilInfo.productionEndTime,
productionDuration: this.coilInfo.productionDuration,
formattedDuration: this.coilInfo.productionDuration ? this.formatDuration(this.coilInfo.productionDuration * 60 * 1000) : ''
};
// 合并到分条表单
this.splitForm = {
...this.splitForm,
...copiedFields
};
// 同步材料类型和长度显示状态
if (this.splitForm.materialType) {
this.handleMaterialTypeChange(this.splitForm.materialType);
}
this.$message.success('已复制源卷信息,请根据需要修改');
}
},
}

View File

@@ -85,9 +85,9 @@
<el-card class="form-card">
<div slot="header" class="card-header">
<span><i class="el-icon-edit-outline"></i> {{ '更新信息' }}</span>
<!-- <el-button type="text" size="mini" @click="copyFromCurrent" icon="el-icon-document-copy">
复制当前信息
</el-button> -->
<el-button type="text" size="mini" @click="copyFromCurrent" icon="el-icon-document-copy">
复制源卷信息
</el-button>
</div>
<el-form ref="updateForm" :model="updateForm" :rules="rules" label-width="80px" size="small">
@@ -820,23 +820,43 @@ export default {
// 复制当前信息到更新表单
copyFromCurrent() {
const itemType = this.currentInfo.materialType === '原料' ? 'raw_material' : 'product';
this.updateForm = {
currentCoilNo: this.currentInfo.currentCoilNo,
// 复制除了指定字段之外的其他字段
const excludeFields = ['enterCoilNo', 'currentCoilNo', 'coilId', 'createTime', 'createBy'];
// 构建要复制的字段
const copiedFields = {
team: this.currentInfo.team,
materialType: this.currentInfo.materialType,
// 不复制 itemType 和 itemId让它们由 materialType 自动决定
itemType,
itemType: this.currentInfo.itemType,
itemId: this.currentInfo.itemId,
grossWeight: parseFloat(this.currentInfo.grossWeight) || null,
netWeight: parseFloat(this.currentInfo.netWeight) || null,
warehouseId: this.currentInfo.warehouseId,
actualWarehouseId: this.currentInfo.actualWarehouseId,
length: parseFloat(this.currentInfo.length) || null,
remark: this.currentInfo.remark
actualLength: parseFloat(this.currentInfo.actualLength) || null,
actualWidth: parseFloat(this.currentInfo.actualWidth) || null,
temperGrade: this.currentInfo.temperGrade,
coatingType: this.currentInfo.coatingType,
qualityStatus: this.currentInfo.qualityStatus,
packagingRequirement: this.currentInfo.packagingRequirement,
packingStatus: this.currentInfo.packingStatus,
trimmingRequirement: this.currentInfo.trimmingRequirement,
remark: this.currentInfo.remark,
productionStartTime: this.currentInfo.productionStartTime,
productionEndTime: this.currentInfo.productionEndTime,
productionDuration: this.currentInfo.productionDuration,
formattedDuration: this.currentInfo.productionDuration ? this.formatDuration(this.currentInfo.productionDuration * 60 * 1000) : ''
};
// 合并到更新表单
this.updateForm = {
...this.updateForm,
...copiedFields
};
// materialType 会触发 watch自动设置 itemType 并加载物品列表
this.$message.success('已复制当前信息,包含' + this.currentInfo.materialType + '类型的相关信息, 请根据需要修改');
this.$message.success('已复制源卷信息,请根据需要修改');
},
// 保存更新