Commit 4f51b614 by zhangtw

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

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