Commit 4f51b614 by zhangtw

入库结合物料组件,bug修复

parent e1b0bfb8
...@@ -572,9 +572,14 @@ export default { ...@@ -572,9 +572,14 @@ export default {
// 打开物料选择弹窗 // 打开物料选择弹窗
showMaterials(status) { showMaterials(status) {
this.materialSelectOpen = status; this.materialSelectOpen = status;
// 清空之前的选择 if (status) { // 只有打开弹窗时才清空选择
this.selectedMaterialIds = []; this.selectedMaterialIds = []; // 先清空父组件数据
this.selectedMaterials = []; this.selectedMaterials = [];
this.$nextTick(() => {
// 确保弹窗渲染完成后再调用子组件方法
this.$refs.materialSelector?.clearSelection();
});
}
}, },
// 物料选择变化回调 // 物料选择变化回调
...@@ -598,7 +603,7 @@ export default { ...@@ -598,7 +603,7 @@ export default {
if (!exists) { if (!exists) {
this.form.inboundOrderItemsList.push({ this.form.inboundOrderItemsList.push({
materialCode: material.materialCode, // 存储物料编码 materialId: material.materialCode, // 存储物料编码
materialName: material.materialName, // 仅用于展示 materialName: material.materialName, // 仅用于展示
// 其他需要的字段... // 其他需要的字段...
}); });
...@@ -606,6 +611,7 @@ export default { ...@@ -606,6 +611,7 @@ export default {
}); });
this.materialSelectOpen = false; this.materialSelectOpen = false;
this.$refs.inboundItemsRef.handleAddItem(this.selectedMaterials)
this.$message.success(`成功添加 ${this.selectedMaterials.length} 个物料`); this.$message.success(`成功添加 ${this.selectedMaterials.length} 个物料`);
}, },
/** 确认入库操作 */ /** 确认入库操作 */
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
plain plain
icon="el-icon-plus" icon="el-icon-plus"
size="mini" size="mini"
@click="handleAddItem" @click="handleAddItemClick"
>新增物料</el-button> >新增物料</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
...@@ -224,11 +224,25 @@ export default { ...@@ -224,11 +224,25 @@ export default {
columns: { columns: {
type: Array, type: Array,
default: () => [ default: () => [
{ prop: 'materialId', label: '货物ID', width: '120', editable: true }, { prop: 'materialId', label: '货物ID', width: '120', editable: false},
{ prop: 'materialsName', label: '货物名称', width: '120', editable: true}, { prop: 'materialName', label: '货物名称', width: '120', editable: false},
// { prop: 'batchId', label: '批次ID', width: '120', editable: true }, // { prop: 'batchId', label: '批次ID', width: '120', editable: true },
{ prop: 'warehouseId', label: '仓库ID', width: '120', editable: true }, { prop: 'warehouseId', label: '仓库ID', width: '120', editable: true,
{ prop: 'locationId', label: '库位ID', width: '120', editable: true }, type: 'select', // 指定类型为select
options: [ // 下拉选项列表
{ label: '仓库A', value: 'WH001' },
{ label: '仓库B', value: 'WH002' },
{ label: '仓库C', value: 'WH003' }
]
},
{ prop: 'locationId', label: '库位ID', width: '120', editable: true ,
type: 'select', // 指定类型为select
options: [ // 下拉选项列表
{ label: '库位A1', value: 'LOC001' },
{ label: '库位A2', value: 'LOC002' },
{ label: '库位B1', value: 'LOC003' }
]
},
{ prop: 'plannedQuantity', label: '计划数量', width: '100', type: 'number', editable: true }, { prop: 'plannedQuantity', label: '计划数量', width: '100', type: 'number', editable: true },
{ prop: 'actualQuantity', label: '实际数量', width: '100', type: 'number', editable: true }, { prop: 'actualQuantity', label: '实际数量', width: '100', type: 'number', editable: true },
{ prop: 'plannedPackages', label: '计划件数', width: '100', type: 'number', editable: true }, { prop: 'plannedPackages', label: '计划件数', width: '100', type: 'number', editable: true },
...@@ -245,6 +259,7 @@ export default { ...@@ -245,6 +259,7 @@ export default {
}, },
data() { data() {
return { return {
selectedMaterials: [],
loading: false, loading: false,
selectedRows: [], selectedRows: [],
total: 0, total: 0,
...@@ -380,13 +395,16 @@ export default { ...@@ -380,13 +395,16 @@ export default {
return row.id || row.tempId return row.id || row.tempId
}, },
// 新增物料 // 新增物料
handleAddItem() { handleAddItemClick() {
this.$emit('show-materials',true) this.$emit('show-materials',true)
},
handleAddItem(selectedMaterials){
selectedMaterials.forEach(material => {
const newItem = { const newItem = {
id: null, id: null,
orderId: this.orderId, orderId: this.orderId,
materialId: null, materialId: material.materialId,
materialName: material.materialName,
batchId: null, batchId: null,
warehouseId: null, warehouseId: null,
locationId: null, locationId: null,
...@@ -399,16 +417,15 @@ export default { ...@@ -399,16 +417,15 @@ export default {
editable: true, editable: true,
tempId: Date.now() + Math.random() tempId: Date.now() + Math.random()
} }
this.displayData.push(newItem) this.displayData.push(newItem)
// 自动跳转到最后一页 // 自动跳转到最后一页
const totalPages = Math.ceil(this.displayData.length / this.queryParams.pageSize) const totalPages = Math.ceil(this.displayData.length / this.queryParams.pageSize)
if (totalPages > this.queryParams.pageNum) { if (totalPages > this.queryParams.pageNum) {
this.queryParams.pageNum = totalPages this.queryParams.pageNum = totalPages
} }
this.$emit('item-added', newItem) this.$emit('item-added', newItem)
})
console.log(this.displayData)
}, },
// 行编辑 // 行编辑
handleRowEdit(row) { handleRowEdit(row) {
......
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
<!-- 物料表格(隐藏操作列,保留选择功能) --> <!-- 物料表格(隐藏操作列,保留选择功能) -->
<el-table <el-table
ref="materialTable"
v-loading="loading" v-loading="loading"
:data="materialsList" :data="materialsList"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
...@@ -317,6 +318,15 @@ export default { ...@@ -317,6 +318,15 @@ export default {
// 提供外部调用的方法:获取选中的物料详情 // 提供外部调用的方法:获取选中的物料详情
getSelectedMaterials() { getSelectedMaterials() {
return this.selectedRows; return this.selectedRows;
},
// 清空复选框选择
clearSelection() {
if (this.$refs.materialTable) {
this.$refs.materialTable.clearSelection(); // 直接清空表格选择
this.selectedRows = []; // 同步清空选中数据
this.$emit('change', []); // 通知父组件
this.$emit('input', []); // 更新v-model绑定值
}
} }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论