|
|
|
@ -45,6 +45,19 @@ |
|
|
|
</span> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
|
|
|
|
<!-- 明细操作列 --> |
|
|
|
<el-table-column |
|
|
|
label="操作" |
|
|
|
width="120" |
|
|
|
align="center" |
|
|
|
fixed="right" |
|
|
|
v-if="showActions"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<a type="text" size="small" @click="handleEditDetail(scope.row, props.row)">修改</a> |
|
|
|
<a type="text" size="small" @click="handleDeleteDetail(scope.row, props.row)">删除</a> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
</el-table> |
|
|
|
|
|
|
|
<!-- 空数据状态 --> |
|
|
|
@ -72,12 +85,92 @@ |
|
|
|
style="width: 100px; height: 80px"/></span> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
|
|
|
|
<!-- 主表格操作列 --> |
|
|
|
<el-table-column |
|
|
|
label="操作" |
|
|
|
width="120" |
|
|
|
align="center" |
|
|
|
fixed="right" |
|
|
|
v-if="showActions"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<a type="text" size="small" @click="handleEditBox(scope.row)">修改</a> |
|
|
|
<a type="text" size="small" @click="handleDeleteBox(scope.row)">删除</a> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
</el-table> |
|
|
|
|
|
|
|
<!-- 修改箱信息弹窗 --> |
|
|
|
<el-dialog |
|
|
|
title="修改箱信息" |
|
|
|
:visible.sync="editBoxDialogVisible" |
|
|
|
width="200px" |
|
|
|
:close-on-click-modal="false"> |
|
|
|
<el-form :model="editBoxForm" ref="editBoxForm" label-position="top" label-width="100px"> |
|
|
|
<el-row :gutter="20"> |
|
|
|
<el-col :span="24"> |
|
|
|
<el-form-item label="箱数" prop="box_qty"> |
|
|
|
<el-input v-model="editBoxForm.box_qty" :min="1" :precision="0" style="width: 100%"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="24"> |
|
|
|
<el-form-item label="毛重" prop="grossWeight"> |
|
|
|
<el-input v-model="editBoxForm.grossWeight" :min="0" :precision="2" style="width: 100%"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="24"> |
|
|
|
<el-form-item label="净重" prop="netWeight"> |
|
|
|
<el-input v-model="editBoxForm.netWeight" :min="0" :precision="2" style="width: 100%"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
</el-row> |
|
|
|
</el-form> |
|
|
|
<div slot="footer" class="dialog-footer"> |
|
|
|
<el-button @click="editBoxDialogVisible = false">取消</el-button> |
|
|
|
<el-button type="primary" @click="submitEditBox" >确定</el-button> |
|
|
|
</div> |
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
<!-- 修改明细弹窗 --> |
|
|
|
<el-dialog |
|
|
|
title="修改明细信息" |
|
|
|
:visible.sync="editDetailDialogVisible" |
|
|
|
width="400px" |
|
|
|
:close-on-click-modal="false"> |
|
|
|
<el-form :model="editDetailForm" ref="editDetailForm" label-position="top" label-width="100px"> |
|
|
|
<el-row :gutter="20"> |
|
|
|
<el-col :span="12"> |
|
|
|
<el-form-item label="PO" prop="poNo"> |
|
|
|
<el-input v-model="editDetailForm.poNo" disabled></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="12"> |
|
|
|
<el-form-item label="PN" prop="pn"> |
|
|
|
<el-input v-model="editDetailForm.pn" disabled></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="12"> |
|
|
|
<el-form-item label="数量" prop="qty"> |
|
|
|
<el-input v-model="editDetailForm.qty" style="width: 100%"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="12"> |
|
|
|
<el-form-item label="Rolls" prop="rolls"> |
|
|
|
<el-input v-model="editDetailForm.rolls" style="width: 100%"></el-input> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
</el-row> |
|
|
|
</el-form> |
|
|
|
<div slot="footer" class="dialog-footer"> |
|
|
|
<el-button @click="editDetailDialogVisible = false">取消</el-button> |
|
|
|
<el-button type="primary" @click="submitEditDetail" >确定</el-button> |
|
|
|
</div> |
|
|
|
</el-dialog> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import { selectBoxList, searchCoDelPalletDataNew } from "@/api/ecss/ecss.js" |
|
|
|
import { selectBoxList, searchCoDelPalletDataNew, updateBoxInfo, deleteBoxInfo, updateDetailInfo, deleteDetailInfo } from "@/api/ecss/ecss.js" |
|
|
|
|
|
|
|
export default { |
|
|
|
name: "PackingDetailTab", |
|
|
|
@ -89,6 +182,10 @@ export default { |
|
|
|
height: { |
|
|
|
type: Number, |
|
|
|
default: 200 |
|
|
|
}, |
|
|
|
showActions: { |
|
|
|
type: Boolean, |
|
|
|
default: true |
|
|
|
} |
|
|
|
}, |
|
|
|
data() { |
|
|
|
@ -96,6 +193,31 @@ export default { |
|
|
|
dataListBoxes: [], // 箱数据列表 |
|
|
|
expandedBoxRows: [], // 展开的行 |
|
|
|
dataListLoading: false, |
|
|
|
|
|
|
|
// 修改箱信息弹窗相关 |
|
|
|
editBoxDialogVisible: false, |
|
|
|
editBoxForm: { |
|
|
|
item_no: '', |
|
|
|
box_qty: 1, |
|
|
|
grossWeight: 0, |
|
|
|
netWeight: 0 |
|
|
|
}, |
|
|
|
editBoxSubmitting: false, |
|
|
|
currentEditBox: null, |
|
|
|
|
|
|
|
// 修改明细弹窗相关 |
|
|
|
editDetailDialogVisible: false, |
|
|
|
editDetailForm: { |
|
|
|
itemNo: '', |
|
|
|
poNo: '', |
|
|
|
pn: '', |
|
|
|
qty: 1, |
|
|
|
rolls: 0 |
|
|
|
}, |
|
|
|
editDetailSubmitting: false, |
|
|
|
currentEditDetail: null, |
|
|
|
currentEditBoxForDetail: null, |
|
|
|
|
|
|
|
// 装箱明细列定义 |
|
|
|
columnList3: [ |
|
|
|
{ |
|
|
|
@ -295,7 +417,8 @@ export default { |
|
|
|
this.dataListBoxes = data.rows.map(row => ({ |
|
|
|
...row, |
|
|
|
palletDetails: [], // 初始化明细数据为空 |
|
|
|
loading: false // 初始化加载状态 |
|
|
|
loading: false, // 初始化加载状态 |
|
|
|
hadDetails: false // 初始化是否有明细标记 |
|
|
|
})) |
|
|
|
} else { |
|
|
|
this.dataListBoxes = []; |
|
|
|
@ -318,7 +441,7 @@ export default { |
|
|
|
handleBoxExpand(row, expandedRows) { |
|
|
|
// 判断当前操作是展开还是收起 |
|
|
|
const isExpanding = expandedRows.includes(row); |
|
|
|
|
|
|
|
|
|
|
|
if (isExpanding) { |
|
|
|
// 如果是展开操作,则展开所有行 |
|
|
|
this.expandAll(); |
|
|
|
@ -352,12 +475,25 @@ export default { |
|
|
|
if (data && data.code == 0) { |
|
|
|
// 将明细数据赋值给当前行 |
|
|
|
this.$set(boxRow, 'palletDetails', data.rows); |
|
|
|
|
|
|
|
// 如果明细为空,且之前有明细数据,说明明细被删除了,需要检查box是否也应该被删除 |
|
|
|
if (data.rows.length === 0 && boxRow.hadDetails) { |
|
|
|
// 延迟刷新列表,让后端有时间处理删除逻辑 |
|
|
|
setTimeout(() => { |
|
|
|
this.loadBoxList(); |
|
|
|
}, 500); |
|
|
|
} |
|
|
|
|
|
|
|
// 标记是否有过明细数据 |
|
|
|
this.$set(boxRow, 'hadDetails', data.rows.length > 0); |
|
|
|
} else { |
|
|
|
this.$set(boxRow, 'palletDetails', []); |
|
|
|
this.$set(boxRow, 'hadDetails', false); |
|
|
|
} |
|
|
|
}).catch(error => { |
|
|
|
console.error('加载栈板明细数据失败:', error); |
|
|
|
this.$set(boxRow, 'palletDetails', []); |
|
|
|
this.$set(boxRow, 'hadDetails', false); |
|
|
|
}).finally(() => { |
|
|
|
// 清除加载状态 |
|
|
|
this.$set(boxRow, 'loading', false); |
|
|
|
@ -382,7 +518,7 @@ export default { |
|
|
|
expandAll() { |
|
|
|
// 获取所有行的key |
|
|
|
this.expandedBoxRows = this.dataListBoxes.map(row => this.getBoxRowKey(row)); |
|
|
|
|
|
|
|
|
|
|
|
// 为每个行加载明细数据 |
|
|
|
this.dataListBoxes.forEach(row => { |
|
|
|
this.loadPalletDetails(row); |
|
|
|
@ -397,6 +533,197 @@ export default { |
|
|
|
// 刷新数据的公共方法 |
|
|
|
refresh() { |
|
|
|
this.loadBoxList(); |
|
|
|
}, |
|
|
|
|
|
|
|
/* |
|
|
|
* 删除逻辑说明: |
|
|
|
* 1. 删除明细时: |
|
|
|
* - 先删除明细数据 |
|
|
|
* - 检查该明细所属的box是否还有其他明细 |
|
|
|
* - 如果没有明细了,自动删除对应的box |
|
|
|
* |
|
|
|
* 2. 删除box时: |
|
|
|
* - 先检查是否有明细数据 |
|
|
|
* - 如果有明细,提示用户并同时删除所有明细和box |
|
|
|
* - 如果没有明细,直接删除box |
|
|
|
*/ |
|
|
|
|
|
|
|
// 处理修改箱信息 |
|
|
|
handleEditBox(boxRow) { |
|
|
|
this.currentEditBox = boxRow; |
|
|
|
this.editBoxForm.item_no = boxRow.item_no; |
|
|
|
this.editBoxForm.box_qty = boxRow.box_qty; |
|
|
|
this.editBoxForm.grossWeight = boxRow.grossWeight; |
|
|
|
this.editBoxForm.netWeight = boxRow.netWeight; |
|
|
|
this.editBoxDialogVisible = true; |
|
|
|
}, |
|
|
|
|
|
|
|
// 处理删除箱信息 |
|
|
|
handleDeleteBox(boxRow) { |
|
|
|
// 直接删除box及其所有明细,无需校验 |
|
|
|
this.deleteBoxWithDetails(boxRow); |
|
|
|
}, |
|
|
|
|
|
|
|
// 删除箱信息(包含明细) |
|
|
|
deleteBoxWithDetails(boxRow) { |
|
|
|
this.$confirm(`确定要删除序号为 ${boxRow.item_no} 的箱信息吗?删除后无法恢复!`, '警告', { |
|
|
|
confirmButtonText: '确定', |
|
|
|
cancelButtonText: '取消', |
|
|
|
type: 'warning' |
|
|
|
}).then(() => { |
|
|
|
// 构造删除参数 |
|
|
|
const deleteParams = { |
|
|
|
site: this.currentRow.site, |
|
|
|
buNo: this.currentRow.buNo, |
|
|
|
delNo: this.currentRow.delNo, |
|
|
|
item_no: boxRow.item_no, |
|
|
|
palletRemark: boxRow.palletRemark |
|
|
|
}; |
|
|
|
deleteBoxInfo(deleteParams).then(({data}) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
this.loadBoxList() |
|
|
|
this.$message({ |
|
|
|
message: '操作成功', |
|
|
|
type: 'success', |
|
|
|
duration: 1500, |
|
|
|
onClose: () => {} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
this.$alert(data.msg, '错误', { |
|
|
|
confirmButtonText: '确定' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// 处理修改明细 |
|
|
|
handleEditDetail(detailRow, boxRow) { |
|
|
|
this.currentEditDetail = detailRow; |
|
|
|
this.currentEditBoxForDetail = boxRow; |
|
|
|
this.editDetailForm.itemNo = detailRow.itemNo; |
|
|
|
this.editDetailForm.poNo = detailRow.poNo; |
|
|
|
this.editDetailForm.pn = detailRow.pn; |
|
|
|
this.editDetailForm.qty = detailRow.qty; |
|
|
|
this.editDetailForm.rolls = detailRow.rolls; |
|
|
|
this.editDetailDialogVisible = true; |
|
|
|
}, |
|
|
|
|
|
|
|
// 提交修改箱信息 |
|
|
|
submitEditBox() { |
|
|
|
this.$refs.editBoxForm.validate(valid => { |
|
|
|
if (valid) { |
|
|
|
this.editBoxSubmitting = true; |
|
|
|
|
|
|
|
// 构造更新参数 |
|
|
|
const updateParams = { |
|
|
|
site: this.currentRow.site, |
|
|
|
buNo: this.currentRow.buNo, |
|
|
|
delNo: this.currentRow.delNo, |
|
|
|
item_no: this.currentEditBox.item_no, |
|
|
|
palletRemark: this.currentEditBox.palletRemark, |
|
|
|
box_qty: this.editBoxForm.box_qty, |
|
|
|
grossWeight: this.editBoxForm.grossWeight, |
|
|
|
netWeight: this.editBoxForm.netWeight, |
|
|
|
updateBy: this.$store.state.user.name |
|
|
|
}; |
|
|
|
|
|
|
|
updateBoxInfo(updateParams).then(({ data }) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
this.editBoxDialogVisible = false; |
|
|
|
this.loadBoxList() |
|
|
|
this.$message({ |
|
|
|
message: '操作成功', |
|
|
|
type: 'success', |
|
|
|
duration: 1500, |
|
|
|
onClose: () => {} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
this.$alert(data.msg, '错误', { |
|
|
|
confirmButtonText: '确定' |
|
|
|
}) |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// 提交修改明细 |
|
|
|
submitEditDetail() { |
|
|
|
this.$refs.editDetailForm.validate(valid => { |
|
|
|
if (valid) { |
|
|
|
this.editDetailSubmitting = true; |
|
|
|
|
|
|
|
// 构造更新参数 |
|
|
|
const updateParams = { |
|
|
|
site: this.currentRow.site, |
|
|
|
buNo: this.currentRow.buNo, |
|
|
|
delNo: this.currentRow.delNo, |
|
|
|
seqNo: this.currentEditDetail.seqNo, |
|
|
|
itemNo: this.currentEditDetail.itemNo, |
|
|
|
notifyDetailItemNo: this.currentEditDetail.notifyDetailItemNo, |
|
|
|
poNo: this.editDetailForm.poNo, |
|
|
|
pn: this.editDetailForm.pn, |
|
|
|
qty: this.editDetailForm.qty, |
|
|
|
oldQty: this.currentEditDetail.qty, |
|
|
|
rolls: this.editDetailForm.rolls, |
|
|
|
updateBy: this.$store.state.user.name |
|
|
|
}; |
|
|
|
|
|
|
|
updateDetailInfo(updateParams).then(({ data }) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
this.editDetailDialogVisible = false; |
|
|
|
this.loadBoxList() |
|
|
|
this.$message({ |
|
|
|
message: '操作成功', |
|
|
|
type: 'success', |
|
|
|
duration: 1500, |
|
|
|
onClose: () => {} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
this.$alert(data.msg, '错误', { |
|
|
|
confirmButtonText: '确定' |
|
|
|
}) |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// 删除明细 |
|
|
|
handleDeleteDetail(detailRow, boxRow) { |
|
|
|
this.$confirm(`确定要删除这个明细信息吗?删除后无法恢复!`, '警告', { |
|
|
|
confirmButtonText: '确定', |
|
|
|
cancelButtonText: '取消', |
|
|
|
type: 'warning' |
|
|
|
}).then(() => { |
|
|
|
// 构造删除参数 |
|
|
|
const deleteParams = { |
|
|
|
site: this.currentRow.site, |
|
|
|
buNo: this.currentRow.buNo, |
|
|
|
delNo: this.currentRow.delNo, |
|
|
|
seqNo: detailRow.seqNo, |
|
|
|
itemNo: detailRow.itemNo, |
|
|
|
notifyDetailItemNo: detailRow.notifyDetailItemNo, |
|
|
|
partNo: detailRow.part_no, |
|
|
|
qty: detailRow.qty |
|
|
|
}; |
|
|
|
deleteDetailInfo(deleteParams).then(({data}) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
this.loadBoxList() |
|
|
|
this.$message({ |
|
|
|
message: '操作成功', |
|
|
|
type: 'success', |
|
|
|
duration: 1500, |
|
|
|
onClose: () => {} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
this.$alert(data.msg, '错误', { |
|
|
|
confirmButtonText: '确定' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|