|
|
|
@ -1,5 +1,12 @@ |
|
|
|
<template> |
|
|
|
<div class="packing-detail-tab"> |
|
|
|
<!-- 批量编辑按钮 --> |
|
|
|
<div class="batch-edit-toolbar" v-if="showActions"> |
|
|
|
<el-button type="primary" size="small" icon="el-icon-edit" @click="openBatchEditDialog"> |
|
|
|
批量编辑 |
|
|
|
</el-button> |
|
|
|
</div> |
|
|
|
|
|
|
|
<el-table |
|
|
|
:data="dataListBoxes" |
|
|
|
:height="height" |
|
|
|
@ -168,11 +175,144 @@ |
|
|
|
<el-button type="primary" @click="submitEditDetail" >确定</el-button> |
|
|
|
</div> |
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
<!-- 批量编辑弹窗 --> |
|
|
|
<el-dialog |
|
|
|
title="批量编辑装箱明细" |
|
|
|
:visible.sync="batchEditDialogVisible" |
|
|
|
width="60%" |
|
|
|
top="5vh" |
|
|
|
custom-class="batch-edit-dialog" |
|
|
|
:close-on-click-modal="false" |
|
|
|
@open="loadBatchEditData"> |
|
|
|
<div class="batch-edit-container" v-loading="batchEditLoading"> |
|
|
|
<!-- 操作提示 --> |
|
|
|
<div class="batch-edit-tips"> |
|
|
|
<el-alert |
|
|
|
type="info" |
|
|
|
:closable="false" |
|
|
|
show-icon> |
|
|
|
<template slot="title"> |
|
|
|
<span>直接在表格中编辑数据,修改后点击"保存所有修改"按钮提交</span> |
|
|
|
<span v-if="batchEditModifiedCount > 0" class="modified-count"> |
|
|
|
(已修改 <b>{{ batchEditModifiedCount }}</b> 处) |
|
|
|
</span> |
|
|
|
</template> |
|
|
|
</el-alert> |
|
|
|
</div> |
|
|
|
|
|
|
|
<!-- 行合并表格 --> |
|
|
|
<el-table |
|
|
|
:data="batchEditTableData" |
|
|
|
:span-method="batchEditSpanMethod" |
|
|
|
border |
|
|
|
size="small" |
|
|
|
max-height="60vh" |
|
|
|
style="width: 100%" |
|
|
|
:row-class-name="getBatchEditRowClassName" |
|
|
|
:header-cell-style="{background:'#f5f7fa', color:'#606266', fontWeight:'600'}"> |
|
|
|
|
|
|
|
<!-- Box信息列(会合并) --> |
|
|
|
<el-table-column label="序号" prop="item_no" width="60" align="center"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<span class="box-info-cell">{{ scope.row.item_no }}</span> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
|
|
|
|
<el-table-column label="箱数" prop="box_qty" width="80" align="center"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-input |
|
|
|
v-model="scope.row.box_qty" |
|
|
|
size="mini" |
|
|
|
type="number" |
|
|
|
:class="{'modified-input': isBoxFieldModified(scope.row, 'box_qty')}" |
|
|
|
@input="onBatchBoxQtyInput(scope.row)" |
|
|
|
@change="onBatchBoxFieldChange(scope.row, 'box_qty')"> |
|
|
|
</el-input> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
|
|
|
|
<el-table-column label="毛重" prop="grossWeight" width="100" align="center"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-input |
|
|
|
v-model="scope.row.grossWeight" |
|
|
|
size="mini" |
|
|
|
type="number" |
|
|
|
:class="{'modified-input': isBoxFieldModified(scope.row, 'grossWeight')}" |
|
|
|
@input="onBatchGrossWeightInput(scope.row)" |
|
|
|
@change="onBatchBoxFieldChange(scope.row, 'grossWeight')"> |
|
|
|
</el-input> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
|
|
|
|
<el-table-column label="净重" prop="netWeight" width="100" align="center"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-input |
|
|
|
v-model="scope.row.netWeight" |
|
|
|
size="mini" |
|
|
|
type="number" |
|
|
|
:class="{'modified-input': isBoxFieldModified(scope.row, 'netWeight')}" |
|
|
|
@input="onBatchNetWeightInput(scope.row)" |
|
|
|
@change="onBatchBoxFieldChange(scope.row, 'netWeight')"> |
|
|
|
</el-input> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
|
|
|
|
<!-- 明细信息列(不合并) --> |
|
|
|
<el-table-column label="PO" prop="poNo" min-width="120" align="left"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<span>{{ scope.row.poNo || '-' }}</span> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
|
|
|
|
<el-table-column label="PN" prop="pn" min-width="120" align="left"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<span>{{ scope.row.pn || '-' }}</span> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
|
|
|
|
<el-table-column label="数量" prop="qty" width="100" align="center"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-input |
|
|
|
v-model="scope.row.qty" |
|
|
|
size="mini" |
|
|
|
type="number" |
|
|
|
:class="{'modified-input': isDetailFieldModified(scope.row, 'qty')}" |
|
|
|
@change="onBatchDetailFieldChange(scope.row, 'qty')"> |
|
|
|
</el-input> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
|
|
|
|
<el-table-column label="Rolls" prop="rolls" width="80" align="center"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<el-input |
|
|
|
v-model="scope.row.rolls" |
|
|
|
size="mini" |
|
|
|
type="number" |
|
|
|
:class="{'modified-input': isDetailFieldModified(scope.row, 'rolls')}" |
|
|
|
@change="onBatchDetailFieldChange(scope.row, 'rolls')"> |
|
|
|
</el-input> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
</el-table> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div slot="footer" class="dialog-footer"> |
|
|
|
<el-button @click="batchEditDialogVisible = false">取消</el-button> |
|
|
|
<el-button |
|
|
|
type="primary" |
|
|
|
:loading="batchEditSaving" |
|
|
|
:disabled="batchEditModifiedCount === 0" |
|
|
|
@click="saveBatchEdit"> |
|
|
|
保存所有修改 ({{ batchEditModifiedCount }}) |
|
|
|
</el-button> |
|
|
|
</div> |
|
|
|
</el-dialog> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import { selectBoxList, searchCoDelPalletDataNew, updateBoxInfo, deleteBoxInfo, updateDetailInfo, deleteDetailInfo } from "@/api/ecss/ecss.js" |
|
|
|
import { selectBoxList, searchCoDelPalletDataNew, updateBoxInfo, deleteBoxInfo, updateDetailInfo, deleteDetailInfo, batchUpdatePackingInfo } from "@/api/ecss/ecss.js" |
|
|
|
|
|
|
|
export default { |
|
|
|
name: "PackingDetailTab", |
|
|
|
@ -220,6 +360,16 @@ export default { |
|
|
|
currentEditDetail: null, |
|
|
|
currentEditBoxForDetail: null, |
|
|
|
|
|
|
|
// 批量编辑弹窗相关 |
|
|
|
batchEditDialogVisible: false, |
|
|
|
batchEditLoading: false, |
|
|
|
batchEditSaving: false, |
|
|
|
batchEditTableData: [], // 扁平化的表格数据 |
|
|
|
batchEditOriginalData: {}, // 原始数据快照(用于对比是否修改) |
|
|
|
batchEditModifiedBoxes: {}, // 修改过的Box记录 |
|
|
|
batchEditModifiedDetails: {}, // 修改过的明细记录 |
|
|
|
batchEditSpanInfo: [], // 行合并信息 |
|
|
|
|
|
|
|
// 装箱明细列定义 |
|
|
|
columnList3: [ |
|
|
|
{ |
|
|
|
@ -390,6 +540,13 @@ export default { |
|
|
|
] |
|
|
|
} |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
// 批量编辑修改数量 |
|
|
|
batchEditModifiedCount() { |
|
|
|
return Object.keys(this.batchEditModifiedBoxes).length + |
|
|
|
Object.keys(this.batchEditModifiedDetails).length; |
|
|
|
} |
|
|
|
}, |
|
|
|
watch: { |
|
|
|
currentRow: { |
|
|
|
handler(newVal) { |
|
|
|
@ -865,6 +1022,444 @@ export default { |
|
|
|
}); |
|
|
|
|
|
|
|
return sums; |
|
|
|
}, |
|
|
|
|
|
|
|
// ========== 批量编辑相关方法 ========== |
|
|
|
|
|
|
|
/** |
|
|
|
* 打开批量编辑弹窗 |
|
|
|
*/ |
|
|
|
openBatchEditDialog() { |
|
|
|
this.batchEditDialogVisible = true; |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 加载批量编辑数据 |
|
|
|
* 将Box和明细数据扁平化为一个表格数据 |
|
|
|
*/ |
|
|
|
async loadBatchEditData() { |
|
|
|
this.batchEditLoading = true; |
|
|
|
this.batchEditTableData = []; |
|
|
|
this.batchEditOriginalData = {}; |
|
|
|
this.batchEditModifiedBoxes = {}; |
|
|
|
this.batchEditModifiedDetails = {}; |
|
|
|
this.batchEditSpanInfo = []; |
|
|
|
|
|
|
|
try { |
|
|
|
// 先获取Box列表 |
|
|
|
const boxResponse = await selectBoxList(this.currentRow); |
|
|
|
if (!boxResponse.data || boxResponse.data.code !== 0) { |
|
|
|
this.$message.error('加载箱数据失败'); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const boxes = boxResponse.data.rows || []; |
|
|
|
const tableData = []; |
|
|
|
const spanInfo = []; |
|
|
|
|
|
|
|
// 遍历每个Box,获取其明细 |
|
|
|
for (const box of boxes) { |
|
|
|
const detailParams = { |
|
|
|
site: this.currentRow.site, |
|
|
|
buNo: this.currentRow.buNo, |
|
|
|
delNo: this.currentRow.delNo, |
|
|
|
seqNo: box.item_no, |
|
|
|
palletRemark: box.palletRemark |
|
|
|
}; |
|
|
|
|
|
|
|
const detailResponse = await searchCoDelPalletDataNew(detailParams); |
|
|
|
const details = (detailResponse.data && detailResponse.data.code === 0) |
|
|
|
? detailResponse.data.rows || [] |
|
|
|
: []; |
|
|
|
|
|
|
|
// 记录该Box的起始行索引和跨行数 |
|
|
|
const startIndex = tableData.length; |
|
|
|
const rowCount = details.length > 0 ? details.length : 1; |
|
|
|
spanInfo.push({ startIndex, rowCount, boxKey: this.getBoxRowKey(box) }); |
|
|
|
|
|
|
|
if (details.length > 0) { |
|
|
|
// 有明细时,为每个明细创建一行 |
|
|
|
details.forEach((detail, idx) => { |
|
|
|
const rowData = { |
|
|
|
// Box信息 |
|
|
|
_boxKey: this.getBoxRowKey(box), |
|
|
|
_isFirstRowOfBox: idx === 0, |
|
|
|
_rowSpan: idx === 0 ? details.length : 0, |
|
|
|
item_no: box.item_no, |
|
|
|
palletRemark: box.palletRemark, |
|
|
|
box_qty: box.box_qty, |
|
|
|
grossWeight: box.grossWeight, |
|
|
|
netWeight: box.netWeight, |
|
|
|
// 明细信息 |
|
|
|
_detailKey: `${detail.seqNo}_${detail.itemNo}_${detail.notifyDetailItemNo}`, |
|
|
|
_hasDetail: true, |
|
|
|
seqNo: detail.seqNo, |
|
|
|
itemNo: detail.itemNo, |
|
|
|
notifyDetailItemNo: detail.notifyDetailItemNo, |
|
|
|
poNo: detail.poNo, |
|
|
|
pn: detail.pn, |
|
|
|
qty: detail.qty, |
|
|
|
rolls: detail.rolls |
|
|
|
}; |
|
|
|
tableData.push(rowData); |
|
|
|
|
|
|
|
// 保存原始数据 |
|
|
|
this.batchEditOriginalData[rowData._detailKey] = { |
|
|
|
qty: detail.qty, |
|
|
|
rolls: detail.rolls |
|
|
|
}; |
|
|
|
}); |
|
|
|
|
|
|
|
// 保存Box原始数据 |
|
|
|
this.batchEditOriginalData[this.getBoxRowKey(box)] = { |
|
|
|
box_qty: box.box_qty, |
|
|
|
grossWeight: box.grossWeight, |
|
|
|
netWeight: box.netWeight |
|
|
|
}; |
|
|
|
} else { |
|
|
|
// 没有明细时,创建一行空明细的数据 |
|
|
|
const rowData = { |
|
|
|
_boxKey: this.getBoxRowKey(box), |
|
|
|
_isFirstRowOfBox: true, |
|
|
|
_rowSpan: 1, |
|
|
|
item_no: box.item_no, |
|
|
|
palletRemark: box.palletRemark, |
|
|
|
box_qty: box.box_qty, |
|
|
|
grossWeight: box.grossWeight, |
|
|
|
netWeight: box.netWeight, |
|
|
|
_hasDetail: false, |
|
|
|
poNo: '', |
|
|
|
pn: '', |
|
|
|
qty: '', |
|
|
|
rolls: '' |
|
|
|
}; |
|
|
|
tableData.push(rowData); |
|
|
|
|
|
|
|
// 保存Box原始数据 |
|
|
|
this.batchEditOriginalData[this.getBoxRowKey(box)] = { |
|
|
|
box_qty: box.box_qty, |
|
|
|
grossWeight: box.grossWeight, |
|
|
|
netWeight: box.netWeight |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this.batchEditTableData = tableData; |
|
|
|
this.batchEditSpanInfo = spanInfo; |
|
|
|
} catch (error) { |
|
|
|
console.error('加载批量编辑数据失败:', error); |
|
|
|
this.$message.error('加载数据失败'); |
|
|
|
} finally { |
|
|
|
this.batchEditLoading = false; |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 表格行合并方法 |
|
|
|
*/ |
|
|
|
batchEditSpanMethod({ row, column, rowIndex, columnIndex }) { |
|
|
|
// Box信息列(前4列:序号、箱数、毛重、净重)需要合并 |
|
|
|
if (columnIndex < 4) { |
|
|
|
if (row._isFirstRowOfBox) { |
|
|
|
return { |
|
|
|
rowspan: row._rowSpan, |
|
|
|
colspan: 1 |
|
|
|
}; |
|
|
|
} else { |
|
|
|
return { |
|
|
|
rowspan: 0, |
|
|
|
colspan: 0 |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
return { |
|
|
|
rowspan: 1, |
|
|
|
colspan: 1 |
|
|
|
}; |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 检查Box字段是否被修改 |
|
|
|
*/ |
|
|
|
isBoxFieldModified(row, field) { |
|
|
|
const boxKey = row._boxKey; |
|
|
|
return this.batchEditModifiedBoxes[boxKey] && |
|
|
|
this.batchEditModifiedBoxes[boxKey][field] !== undefined; |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 检查明细字段是否被修改 |
|
|
|
*/ |
|
|
|
isDetailFieldModified(row, field) { |
|
|
|
if (!row._hasDetail) return false; |
|
|
|
const detailKey = row._detailKey; |
|
|
|
return this.batchEditModifiedDetails[detailKey] && |
|
|
|
this.batchEditModifiedDetails[detailKey][field] !== undefined; |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 批量编辑-箱数输入时联动计算净重 |
|
|
|
* 计算公式:净重 = 毛重 - box_qty/2 |
|
|
|
*/ |
|
|
|
onBatchBoxQtyInput(row) { |
|
|
|
if (this._isBatchCalculating) return; |
|
|
|
this._isBatchCalculating = true; |
|
|
|
|
|
|
|
try { |
|
|
|
const boxQty = parseFloat(row.box_qty) || 0; |
|
|
|
const grossWeight = parseFloat(row.grossWeight) || 0; |
|
|
|
|
|
|
|
// 计算净重:净重 = 毛重 - box_qty/2 |
|
|
|
const netWeight = grossWeight - (boxQty / 2); |
|
|
|
row.netWeight = netWeight.toFixed(2); |
|
|
|
|
|
|
|
// 同步更新所有同Box的行 |
|
|
|
const boxKey = row._boxKey; |
|
|
|
this.batchEditTableData.forEach(r => { |
|
|
|
if (r._boxKey === boxKey) { |
|
|
|
r.box_qty = row.box_qty; |
|
|
|
r.netWeight = row.netWeight; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// 触发净重的变化检测 |
|
|
|
this.onBatchBoxFieldChange(row, 'netWeight'); |
|
|
|
} finally { |
|
|
|
this._isBatchCalculating = false; |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 批量编辑-毛重输入时联动计算净重 |
|
|
|
* 计算公式:净重 = 毛重 - box_qty/2 |
|
|
|
*/ |
|
|
|
onBatchGrossWeightInput(row) { |
|
|
|
if (this._isBatchCalculating) return; |
|
|
|
this._isBatchCalculating = true; |
|
|
|
|
|
|
|
try { |
|
|
|
const grossWeight = parseFloat(row.grossWeight) || 0; |
|
|
|
const boxQty = parseFloat(row.box_qty) || 0; |
|
|
|
|
|
|
|
// 计算净重:净重 = 毛重 - box_qty/2 |
|
|
|
const netWeight = grossWeight - (boxQty / 2); |
|
|
|
row.netWeight = netWeight.toFixed(2); |
|
|
|
|
|
|
|
// 同步更新所有同Box的行 |
|
|
|
const boxKey = row._boxKey; |
|
|
|
this.batchEditTableData.forEach(r => { |
|
|
|
if (r._boxKey === boxKey) { |
|
|
|
r.grossWeight = row.grossWeight; |
|
|
|
r.netWeight = row.netWeight; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// 触发净重的变化检测 |
|
|
|
this.onBatchBoxFieldChange(row, 'netWeight'); |
|
|
|
} finally { |
|
|
|
this._isBatchCalculating = false; |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 批量编辑-净重输入时联动计算毛重 |
|
|
|
* 计算公式:毛重 = 净重 + box_qty/2 |
|
|
|
*/ |
|
|
|
onBatchNetWeightInput(row) { |
|
|
|
if (this._isBatchCalculating) return; |
|
|
|
this._isBatchCalculating = true; |
|
|
|
|
|
|
|
try { |
|
|
|
const netWeight = parseFloat(row.netWeight) || 0; |
|
|
|
const boxQty = parseFloat(row.box_qty) || 0; |
|
|
|
|
|
|
|
// 计算毛重:毛重 = 净重 + box_qty/2 |
|
|
|
const grossWeight = netWeight + (boxQty / 2); |
|
|
|
row.grossWeight = grossWeight.toFixed(2); |
|
|
|
|
|
|
|
// 同步更新所有同Box的行 |
|
|
|
const boxKey = row._boxKey; |
|
|
|
this.batchEditTableData.forEach(r => { |
|
|
|
if (r._boxKey === boxKey) { |
|
|
|
r.netWeight = row.netWeight; |
|
|
|
r.grossWeight = row.grossWeight; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// 触发毛重的变化检测 |
|
|
|
this.onBatchBoxFieldChange(row, 'grossWeight'); |
|
|
|
} finally { |
|
|
|
this._isBatchCalculating = false; |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* Box字段变化处理 |
|
|
|
*/ |
|
|
|
onBatchBoxFieldChange(row, field) { |
|
|
|
const boxKey = row._boxKey; |
|
|
|
const original = this.batchEditOriginalData[boxKey]; |
|
|
|
|
|
|
|
if (!original) return; |
|
|
|
|
|
|
|
// 检查是否与原始值不同 |
|
|
|
const currentValue = String(row[field]); |
|
|
|
const originalValue = String(original[field]); |
|
|
|
|
|
|
|
if (currentValue !== originalValue) { |
|
|
|
// 有变化,记录修改 |
|
|
|
if (!this.batchEditModifiedBoxes[boxKey]) { |
|
|
|
this.$set(this.batchEditModifiedBoxes, boxKey, {}); |
|
|
|
} |
|
|
|
this.$set(this.batchEditModifiedBoxes[boxKey], field, { |
|
|
|
oldValue: original[field], |
|
|
|
newValue: row[field] |
|
|
|
}); |
|
|
|
|
|
|
|
// 同步更新所有同Box的行 |
|
|
|
this.batchEditTableData.forEach(r => { |
|
|
|
if (r._boxKey === boxKey) { |
|
|
|
r[field] = row[field]; |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
// 恢复原值,移除修改记录 |
|
|
|
if (this.batchEditModifiedBoxes[boxKey]) { |
|
|
|
this.$delete(this.batchEditModifiedBoxes[boxKey], field); |
|
|
|
if (Object.keys(this.batchEditModifiedBoxes[boxKey]).length === 0) { |
|
|
|
this.$delete(this.batchEditModifiedBoxes, boxKey); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 明细字段变化处理 |
|
|
|
*/ |
|
|
|
onBatchDetailFieldChange(row, field) { |
|
|
|
if (!row._hasDetail) return; |
|
|
|
|
|
|
|
const detailKey = row._detailKey; |
|
|
|
const original = this.batchEditOriginalData[detailKey]; |
|
|
|
|
|
|
|
if (!original) return; |
|
|
|
|
|
|
|
const currentValue = String(row[field]); |
|
|
|
const originalValue = String(original[field]); |
|
|
|
|
|
|
|
if (currentValue !== originalValue) { |
|
|
|
// 有变化,记录修改 |
|
|
|
if (!this.batchEditModifiedDetails[detailKey]) { |
|
|
|
this.$set(this.batchEditModifiedDetails, detailKey, { |
|
|
|
row: row // 保存行引用,方便后续提交 |
|
|
|
}); |
|
|
|
} |
|
|
|
this.$set(this.batchEditModifiedDetails[detailKey], field, { |
|
|
|
oldValue: original[field], |
|
|
|
newValue: row[field] |
|
|
|
}); |
|
|
|
} else { |
|
|
|
// 恢复原值,移除修改记录 |
|
|
|
if (this.batchEditModifiedDetails[detailKey]) { |
|
|
|
this.$delete(this.batchEditModifiedDetails[detailKey], field); |
|
|
|
// 检查是否还有其他字段被修改 |
|
|
|
const remainingFields = Object.keys(this.batchEditModifiedDetails[detailKey]) |
|
|
|
.filter(k => k !== 'row'); |
|
|
|
if (remainingFields.length === 0) { |
|
|
|
this.$delete(this.batchEditModifiedDetails, detailKey); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取批量编辑行样式 |
|
|
|
*/ |
|
|
|
getBatchEditRowClassName({ row, rowIndex }) { |
|
|
|
const classes = []; |
|
|
|
// 检查该行是否有Box修改 |
|
|
|
if (this.batchEditModifiedBoxes[row._boxKey]) { |
|
|
|
classes.push('box-modified-row'); |
|
|
|
} |
|
|
|
// 检查该行是否有明细修改 |
|
|
|
if (row._hasDetail && this.batchEditModifiedDetails[row._detailKey]) { |
|
|
|
classes.push('detail-modified-row'); |
|
|
|
} |
|
|
|
return classes.join(' '); |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 保存批量编辑 |
|
|
|
*/ |
|
|
|
async saveBatchEdit() { |
|
|
|
if (this.batchEditModifiedCount === 0) { |
|
|
|
this.$message.warning('没有需要保存的修改'); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
this.batchEditSaving = true; |
|
|
|
|
|
|
|
try { |
|
|
|
// 构造Box修改列表 |
|
|
|
const boxList = []; |
|
|
|
for (const boxKey of Object.keys(this.batchEditModifiedBoxes)) { |
|
|
|
const row = this.batchEditTableData.find(r => r._boxKey === boxKey); |
|
|
|
if (!row) continue; |
|
|
|
|
|
|
|
boxList.push({ |
|
|
|
item_no: row.item_no, |
|
|
|
palletRemark: row.palletRemark, |
|
|
|
box_qty: row.box_qty, |
|
|
|
grossWeight: row.grossWeight, |
|
|
|
netWeight: row.netWeight |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
// 构造明细修改列表 |
|
|
|
const detailList = []; |
|
|
|
for (const detailKey of Object.keys(this.batchEditModifiedDetails)) { |
|
|
|
const detailMod = this.batchEditModifiedDetails[detailKey]; |
|
|
|
const row = detailMod.row; |
|
|
|
if (!row) continue; |
|
|
|
|
|
|
|
detailList.push({ |
|
|
|
seqNo: row.seqNo, |
|
|
|
itemNo: row.itemNo, |
|
|
|
notifyDetailItemNo: row.notifyDetailItemNo, |
|
|
|
poNo: row.poNo, |
|
|
|
pn: row.pn, |
|
|
|
qty: row.qty, |
|
|
|
rolls: row.rolls |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
// 调用批量修改API |
|
|
|
const batchParams = { |
|
|
|
site: this.currentRow.site, |
|
|
|
buNo: this.currentRow.buNo, |
|
|
|
delNo: this.currentRow.delNo, |
|
|
|
updateBy: this.$store.state.user.name, |
|
|
|
boxList: boxList, |
|
|
|
detailList: detailList |
|
|
|
}; |
|
|
|
|
|
|
|
const response = await batchUpdatePackingInfo(batchParams); |
|
|
|
|
|
|
|
if (response.data && response.data.code === 0) { |
|
|
|
this.$message.success(`成功保存 ${this.batchEditModifiedCount} 处修改`); |
|
|
|
this.batchEditDialogVisible = false; |
|
|
|
this.loadBoxList(); // 刷新主表格 |
|
|
|
} else { |
|
|
|
this.$alert(response.data.msg || '保存失败', '错误', { |
|
|
|
confirmButtonText: '确定' |
|
|
|
}); |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|
console.error('批量保存失败:', error); |
|
|
|
this.$message.error('保存失败'); |
|
|
|
} finally { |
|
|
|
this.batchEditSaving = false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -996,4 +1591,154 @@ export default { |
|
|
|
/deep/ .el-table__body-wrapper::-webkit-scrollbar-thumb:hover { |
|
|
|
background: #a8a8a8; |
|
|
|
} |
|
|
|
|
|
|
|
/* 批量编辑工具栏 */ |
|
|
|
.batch-edit-toolbar { |
|
|
|
margin-bottom: 10px; |
|
|
|
display: flex; |
|
|
|
justify-content: flex-end; |
|
|
|
} |
|
|
|
|
|
|
|
/* 批量编辑弹窗样式 */ |
|
|
|
/deep/ .batch-edit-dialog { |
|
|
|
border-radius: 8px; |
|
|
|
} |
|
|
|
|
|
|
|
/deep/ .batch-edit-dialog .el-dialog__header { |
|
|
|
background-color: #f5f7fa; |
|
|
|
border-bottom: 1px solid #e4e7ed; |
|
|
|
padding: 15px 20px; |
|
|
|
border-radius: 8px 8px 0 0; |
|
|
|
} |
|
|
|
|
|
|
|
/deep/ .batch-edit-dialog .el-dialog__title { |
|
|
|
font-size: 16px; |
|
|
|
font-weight: 600; |
|
|
|
color: #303133; |
|
|
|
} |
|
|
|
|
|
|
|
/deep/ .batch-edit-dialog .el-dialog__body { |
|
|
|
padding: 15px 20px; |
|
|
|
} |
|
|
|
|
|
|
|
/deep/ .batch-edit-dialog .el-dialog__footer { |
|
|
|
border-top: 1px solid #e4e7ed; |
|
|
|
padding: 12px 20px; |
|
|
|
} |
|
|
|
|
|
|
|
/* 批量编辑弹窗容器 */ |
|
|
|
.batch-edit-container { |
|
|
|
min-height: 300px; |
|
|
|
} |
|
|
|
|
|
|
|
/* 批量编辑提示 */ |
|
|
|
.batch-edit-tips { |
|
|
|
margin-bottom: 15px; |
|
|
|
} |
|
|
|
|
|
|
|
.batch-edit-tips .modified-count { |
|
|
|
color: #e6a23c; |
|
|
|
margin-left: 10px; |
|
|
|
} |
|
|
|
|
|
|
|
.batch-edit-tips .modified-count b { |
|
|
|
color: #f56c6c; |
|
|
|
font-size: 16px; |
|
|
|
} |
|
|
|
|
|
|
|
/* 批量编辑表格样式 */ |
|
|
|
/deep/ .batch-edit-container .el-table { |
|
|
|
border-radius: 4px; |
|
|
|
border: 1px solid #ebeef5; |
|
|
|
} |
|
|
|
|
|
|
|
/* 表头样式 - 确保表头可见 */ |
|
|
|
/deep/ .batch-edit-container .el-table__header-wrapper { |
|
|
|
background-color: #f5f7fa; |
|
|
|
} |
|
|
|
|
|
|
|
/deep/ .batch-edit-container .el-table th { |
|
|
|
background-color: #f5f7fa !important; |
|
|
|
color: #606266 !important; |
|
|
|
font-weight: 600; |
|
|
|
font-size: 13px; |
|
|
|
padding: 8px 0; |
|
|
|
} |
|
|
|
|
|
|
|
/deep/ .batch-edit-container .el-table th .cell { |
|
|
|
color: #606266 !important; |
|
|
|
font-weight: 600; |
|
|
|
} |
|
|
|
|
|
|
|
/* Box信息单元格样式 */ |
|
|
|
.box-info-cell { |
|
|
|
font-weight: 600; |
|
|
|
color: #409eff; |
|
|
|
font-size: 13px; |
|
|
|
} |
|
|
|
|
|
|
|
/* 修改过的输入框样式 */ |
|
|
|
/deep/ .batch-edit-container .modified-input .el-input__inner { |
|
|
|
background-color: #fff7e6; |
|
|
|
border-color: #e6a23c; |
|
|
|
color: #e6a23c; |
|
|
|
} |
|
|
|
|
|
|
|
/* 修改过的行样式 */ |
|
|
|
/deep/ .batch-edit-container .box-modified-row td:nth-child(-n+4) { |
|
|
|
background-color: #fdf6ec !important; |
|
|
|
} |
|
|
|
|
|
|
|
/deep/ .batch-edit-container .detail-modified-row td:nth-child(n+5) { |
|
|
|
background-color: #fff7e6 !important; |
|
|
|
} |
|
|
|
|
|
|
|
/* 输入框样式 */ |
|
|
|
/deep/ .batch-edit-container .el-input--mini .el-input__inner { |
|
|
|
text-align: center; |
|
|
|
padding: 0 8px; |
|
|
|
border-color: #dcdfe6; |
|
|
|
} |
|
|
|
|
|
|
|
/deep/ .batch-edit-container .el-input--mini .el-input__inner:focus { |
|
|
|
border-color: #409eff; |
|
|
|
} |
|
|
|
|
|
|
|
/* 表格单元格内边距 */ |
|
|
|
/deep/ .batch-edit-container .el-table td { |
|
|
|
padding: 6px 0; |
|
|
|
} |
|
|
|
|
|
|
|
/deep/ .batch-edit-container .el-table .cell { |
|
|
|
padding: 0 8px; |
|
|
|
} |
|
|
|
|
|
|
|
/* 数字输入框隐藏上下箭头 */ |
|
|
|
/deep/ .batch-edit-container input[type="number"]::-webkit-inner-spin-button, |
|
|
|
/deep/ .batch-edit-container input[type="number"]::-webkit-outer-spin-button { |
|
|
|
-webkit-appearance: none; |
|
|
|
margin: 0; |
|
|
|
} |
|
|
|
|
|
|
|
/deep/ .batch-edit-container input[type="number"] { |
|
|
|
-moz-appearance: textfield; |
|
|
|
} |
|
|
|
|
|
|
|
/* 合并单元格的垂直居中 */ |
|
|
|
/deep/ .batch-edit-container .el-table__body td[rowspan] { |
|
|
|
vertical-align: middle; |
|
|
|
} |
|
|
|
|
|
|
|
/deep/ .batch-edit-container .el-table__body td[rowspan] .cell { |
|
|
|
display: flex; |
|
|
|
align-items: center; |
|
|
|
justify-content: center; |
|
|
|
height: 100%; |
|
|
|
} |
|
|
|
|
|
|
|
/* 文字样式 */ |
|
|
|
/deep/ .batch-edit-container .el-table .cell span { |
|
|
|
font-size: 13px; |
|
|
|
color: #606266; |
|
|
|
} |
|
|
|
</style> |