Browse Source

批量修改箱明细

java8
han\hanst 1 month ago
parent
commit
72f784b9c8
  1. 43
      src/views/modules/ecss/codelnotifyConfirm.vue
  2. 139
      src/views/modules/ecss/components/PackingDetailTab.vue

43
src/views/modules/ecss/codelnotifyConfirm.vue

@ -348,21 +348,26 @@
<el-divider></el-divider> <el-divider></el-divider>
<el-form label-position="top" class="box-info-form"> <el-form label-position="top" class="box-info-form">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="8">
<el-col :span="6">
<el-form-item label="箱数"> <el-form-item label="箱数">
<el-input v-model="palletModelData.boxQty" type="number" placeholder="请输入箱数" @input="calculateWeightsByBoxQty"></el-input> <el-input v-model="palletModelData.boxQty" type="number" placeholder="请输入箱数" @input="calculateWeightsByBoxQty"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8">
<el-col :span="6">
<el-form-item label="毛重"> <el-form-item label="毛重">
<el-input v-model="palletModelData.grossWeight" type="number" placeholder="自动计算"></el-input> <el-input v-model="palletModelData.grossWeight" type="number" placeholder="自动计算"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8">
<el-col :span="6">
<el-form-item label="净重"> <el-form-item label="净重">
<el-input v-model="palletModelData.netWeight" type="number" placeholder="自动计算"></el-input> <el-input v-model="palletModelData.netWeight" type="number" placeholder="自动计算"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="6">
<el-form-item label="总Rolls">
<el-input v-model="palletModelData.rolls" type="number" placeholder=""></el-input>
</el-form-item>
</el-col>
</el-row> </el-row>
</el-form> </el-form>
</div> </div>
@ -391,7 +396,7 @@
</el-table-column> </el-table-column>
<el-table-column label="Rolls" align="center" width="80"> <el-table-column label="Rolls" align="center" width="80">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input v-model.number="scope.row.rolls" type="number" :min="0" :max="999999" size="mini" placeholder="自动计算"></el-input>
<el-input v-model="scope.row.rolls" type="number" :min="0" :max="999999" size="mini" placeholder="自动计算" @input="delayCalculateTotalRolls"></el-input>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center" width="70"> <el-table-column label="操作" align="center" width="70">
@ -720,6 +725,7 @@
grossWeight:'', grossWeight:'',
netWeight:'', netWeight:'',
palletRemark:'', palletRemark:'',
rolls:'',
}, },
boxModelFlag:false, boxModelFlag:false,
@ -2533,12 +2539,15 @@
}); });
}, },
/** /**
* 根据物料装箱数量自动计算总箱数毛重和净重
* 根据物料装箱数量自动计算总箱数毛重净重和总Rolls
*/ */
calculateTotalBoxQtyAndWeights() { calculateTotalBoxQtyAndWeights() {
// //
const selectedRows = this.dataList8.filter(item => item.useQty && item.useQty > 0); const selectedRows = this.dataList8.filter(item => item.useQty && item.useQty > 0);
// Rolls
this.calculateTotalRolls();
if (selectedRows.length === 0) { if (selectedRows.length === 0) {
// //
this.palletModelData.boxQty = null; this.palletModelData.boxQty = null;
@ -2581,6 +2590,30 @@
this.palletModelData.grossWeight = parseFloat(totalGrossWeight.toFixed(2)); this.palletModelData.grossWeight = parseFloat(totalGrossWeight.toFixed(2));
this.palletModelData.netWeight = parseFloat(totalNetWeight.toFixed(2)); this.palletModelData.netWeight = parseFloat(totalNetWeight.toFixed(2));
}, },
/**
* 汇总明细的Rolls总和
*/
calculateTotalRolls() {
let totalRolls = 0;
this.dataList8.forEach(row => {
const rollsValue = parseFloat(row.rolls);
if (!isNaN(rollsValue) && rollsValue > 0) {
totalRolls += rollsValue;
}
});
// Rolls
this.$set(this.palletModelData, 'rolls', totalRolls > 0 ? Math.round(totalRolls) : null);
},
/**
* 延迟计算总Rolls等待v-model更新完成
*/
delayCalculateTotalRolls() {
this.$nextTick(() => {
this.calculateTotalRolls();
});
},
/** /**
* 根据箱数自动计算毛重和净重 * 根据箱数自动计算毛重和净重
* 计算公式来自后端代码2991-2992 * 计算公式来自后端代码2991-2992

139
src/views/modules/ecss/components/PackingDetailTab.vue

@ -117,21 +117,26 @@
:close-on-click-modal="false"> :close-on-click-modal="false">
<el-form :model="editBoxForm" ref="editBoxForm" label-position="top" label-width="100px"> <el-form :model="editBoxForm" ref="editBoxForm" label-position="top" label-width="100px">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="24">
<el-col :span="12">
<el-form-item label="箱数" prop="box_qty"> <el-form-item label="箱数" prop="box_qty">
<el-input v-model="editBoxForm.box_qty" @input="onBoxQtyChange" :min="1" :precision="0" style="width: 100%"></el-input> <el-input v-model="editBoxForm.box_qty" @input="onBoxQtyChange" :min="1" :precision="0" style="width: 100%"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="24">
<el-col :span="12">
<el-form-item label="毛重" prop="grossWeight"> <el-form-item label="毛重" prop="grossWeight">
<el-input v-model="editBoxForm.grossWeight" @input="onGrossWeightChange" :min="0" :precision="2" style="width: 100%"></el-input> <el-input v-model="editBoxForm.grossWeight" @input="onGrossWeightChange" :min="0" :precision="2" style="width: 100%"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="24">
<el-col :span="12">
<el-form-item label="净重" prop="netWeight"> <el-form-item label="净重" prop="netWeight">
<el-input v-model="editBoxForm.netWeight" @input="onNetWeightChange" :min="0" :precision="2" style="width: 100%"></el-input> <el-input v-model="editBoxForm.netWeight" @input="onNetWeightChange" :min="0" :precision="2" style="width: 100%"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12">
<el-form-item label="Rolls" prop="netWeight">
<el-input v-model="editBoxForm.rolls" :min="0" :precision="2" style="width: 100%"></el-input>
</el-form-item>
</el-col>
</el-row> </el-row>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
@ -258,6 +263,20 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="总Rolls" prop="rolls" width="100" align="center">
<template slot-scope="scope">
<el-input
v-model="scope.row.rolls"
size="mini"
type="number"
:disabled="hasDetailRolls(scope.row)"
:placeholder="hasDetailRolls(scope.row) ? '自动计算' : '请输入'"
:class="{'modified-input': isBoxFieldModified(scope.row, 'rolls')}"
@change="onBatchBoxFieldChange(scope.row, 'rolls')">
</el-input>
</template>
</el-table-column>
<!-- 明细信息列不合并 --> <!-- 明细信息列不合并 -->
<el-table-column label="PO" prop="poNo" min-width="120" align="left"> <el-table-column label="PO" prop="poNo" min-width="120" align="left">
<template slot-scope="scope"> <template slot-scope="scope">
@ -283,14 +302,15 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="Rolls" prop="rolls" width="80" align="center">
<el-table-column label="Rolls" prop="detailRolls" width="80" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input <el-input
v-model="scope.row.rolls"
v-model="scope.row.detailRolls"
size="mini" size="mini"
type="number" type="number"
:class="{'modified-input': isDetailFieldModified(scope.row, 'rolls')}"
@change="onBatchDetailFieldChange(scope.row, 'rolls')">
:class="{'modified-input': isDetailFieldModified(scope.row, 'detailRolls')}"
@input="onDetailRollsInput(scope.row)"
@change="onBatchDetailFieldChange(scope.row, 'detailRolls')">
</el-input> </el-input>
</template> </template>
</el-table-column> </el-table-column>
@ -342,7 +362,8 @@ export default {
item_no: '', item_no: '',
box_qty: 1, box_qty: 1,
grossWeight: 0, grossWeight: 0,
netWeight: 0
netWeight: 0,
rolls: 0
}, },
editBoxSubmitting: false, editBoxSubmitting: false,
currentEditBox: null, currentEditBox: null,
@ -537,6 +558,24 @@ export default {
fixed: '', fixed: '',
columnWidth: 50 columnWidth: 50
}, },
{
userId: this.$store.state.user.name,
functionId: 801002,
serialNumber: '801002TableNetWeight',
tableId: "801002Table3",
tableName: "装箱明细",
columnProp: "rolls",
headerAlign: "center",
align: "right",
columnLabel: "总Rolls",
columnHidden: false,
columnImage: false,
columnSortable: false,
sortLv: 0,
status: true,
fixed: '',
columnWidth: 50
},
] ]
} }
}, },
@ -714,6 +753,7 @@ export default {
this.editBoxForm.box_qty = boxRow.box_qty; this.editBoxForm.box_qty = boxRow.box_qty;
this.editBoxForm.grossWeight = boxRow.grossWeight; this.editBoxForm.grossWeight = boxRow.grossWeight;
this.editBoxForm.netWeight = boxRow.netWeight; this.editBoxForm.netWeight = boxRow.netWeight;
this.editBoxForm.rolls = boxRow.rolls;
this.editBoxDialogVisible = true; this.editBoxDialogVisible = true;
}, },
@ -863,6 +903,7 @@ export default {
box_qty: this.editBoxForm.box_qty, box_qty: this.editBoxForm.box_qty,
grossWeight: this.editBoxForm.grossWeight, grossWeight: this.editBoxForm.grossWeight,
netWeight: this.editBoxForm.netWeight, netWeight: this.editBoxForm.netWeight,
rolls: this.editBoxForm.rolls,
updateBy: this.$store.state.user.name updateBy: this.$store.state.user.name
}; };
@ -1090,6 +1131,7 @@ export default {
box_qty: box.box_qty, box_qty: box.box_qty,
grossWeight: box.grossWeight, grossWeight: box.grossWeight,
netWeight: box.netWeight, netWeight: box.netWeight,
rolls: box.rolls, // BoxRolls
// //
_detailKey: `${detail.seqNo}_${detail.itemNo}_${detail.notifyDetailItemNo}`, _detailKey: `${detail.seqNo}_${detail.itemNo}_${detail.notifyDetailItemNo}`,
_hasDetail: true, _hasDetail: true,
@ -1099,14 +1141,14 @@ export default {
poNo: detail.poNo, poNo: detail.poNo,
pn: detail.pn, pn: detail.pn,
qty: detail.qty, qty: detail.qty,
rolls: detail.rolls
detailRolls: detail.rolls // Rolls
}; };
tableData.push(rowData); tableData.push(rowData);
// //
this.batchEditOriginalData[rowData._detailKey] = { this.batchEditOriginalData[rowData._detailKey] = {
qty: detail.qty, qty: detail.qty,
rolls: detail.rolls
detailRolls: detail.rolls
}; };
}); });
@ -1114,7 +1156,8 @@ export default {
this.batchEditOriginalData[this.getBoxRowKey(box)] = { this.batchEditOriginalData[this.getBoxRowKey(box)] = {
box_qty: box.box_qty, box_qty: box.box_qty,
grossWeight: box.grossWeight, grossWeight: box.grossWeight,
netWeight: box.netWeight
netWeight: box.netWeight,
rolls: box.rolls
}; };
} else { } else {
// //
@ -1127,11 +1170,12 @@ export default {
box_qty: box.box_qty, box_qty: box.box_qty,
grossWeight: box.grossWeight, grossWeight: box.grossWeight,
netWeight: box.netWeight, netWeight: box.netWeight,
rolls: box.rolls, // BoxRolls
_hasDetail: false, _hasDetail: false,
poNo: '', poNo: '',
pn: '', pn: '',
qty: '', qty: '',
rolls: ''
detailRolls: ''
}; };
tableData.push(rowData); tableData.push(rowData);
@ -1139,7 +1183,8 @@ export default {
this.batchEditOriginalData[this.getBoxRowKey(box)] = { this.batchEditOriginalData[this.getBoxRowKey(box)] = {
box_qty: box.box_qty, box_qty: box.box_qty,
grossWeight: box.grossWeight, grossWeight: box.grossWeight,
netWeight: box.netWeight
netWeight: box.netWeight,
rolls: box.rolls
}; };
} }
} }
@ -1158,8 +1203,8 @@ export default {
* 表格行合并方法 * 表格行合并方法
*/ */
batchEditSpanMethod({ row, column, rowIndex, columnIndex }) { batchEditSpanMethod({ row, column, rowIndex, columnIndex }) {
// Box4
if (columnIndex < 4) {
// Box5Rolls
if (columnIndex < 5) {
if (row._isFirstRowOfBox) { if (row._isFirstRowOfBox) {
return { return {
rowspan: row._rowSpan, rowspan: row._rowSpan,
@ -1372,6 +1417,63 @@ export default {
} }
}, },
/**
* 明细Rolls输入事件处理 - 自动计算总Rolls
*/
onDetailRollsInput(row) {
this.$nextTick(() => {
this.calculateBoxTotalRolls(row);
});
},
/**
* 计算同一Box下所有明细Rolls的总和
*/
calculateBoxTotalRolls(row) {
const boxKey = row._boxKey;
// Box
const boxRows = this.batchEditTableData.filter(r => r._boxKey === boxKey && r._hasDetail);
// Rolls
let totalDetailRolls = 0;
let hasDetailRolls = false;
boxRows.forEach(r => {
const rollsValue = parseFloat(r.detailRolls);
if (!isNaN(rollsValue) && rollsValue > 0) {
totalDetailRolls += rollsValue;
hasDetailRolls = true;
}
});
// RollsRolls
const newRolls = hasDetailRolls ? Math.round(totalDetailRolls) : null;
// BoxRolls
this.batchEditTableData.forEach(r => {
if (r._boxKey === boxKey) {
this.$set(r, 'rolls', newRolls);
}
});
// Box
this.onBatchBoxFieldChange(row, 'rolls');
},
/**
* 检查Box是否有明细Rolls值用于禁用总Rolls输入
*/
hasDetailRolls(row) {
const boxKey = row._boxKey;
const boxRows = this.batchEditTableData.filter(r => r._boxKey === boxKey && r._hasDetail);
return boxRows.some(r => {
const rollsValue = parseFloat(r.detailRolls);
return !isNaN(rollsValue) && rollsValue > 0;
});
},
/** /**
* 获取批量编辑行样式 * 获取批量编辑行样式
*/ */
@ -1411,7 +1513,8 @@ export default {
palletRemark: row.palletRemark, palletRemark: row.palletRemark,
box_qty: row.box_qty, box_qty: row.box_qty,
grossWeight: row.grossWeight, grossWeight: row.grossWeight,
netWeight: row.netWeight
netWeight: row.netWeight,
rolls: row.rolls // BoxRolls
}); });
} }
@ -1429,7 +1532,7 @@ export default {
poNo: row.poNo, poNo: row.poNo,
pn: row.pn, pn: row.pn,
qty: row.qty, qty: row.qty,
rolls: row.rolls
rolls: row.detailRolls // Rolls
}); });
} }
@ -1596,7 +1699,7 @@ export default {
.batch-edit-toolbar { .batch-edit-toolbar {
margin-bottom: 10px; margin-bottom: 10px;
display: flex; display: flex;
justify-content: flex-end;
justify-content: flex-start;
} }
/* 批量编辑弹窗样式 */ /* 批量编辑弹窗样式 */

Loading…
Cancel
Save