@@ -121,6 +121,9 @@ export default { | |||
}, | |||
}, | |||
methods: { | |||
commit() { | |||
this.$emit('update', this.selected); | |||
}, | |||
handleEquipmentChange(eq, selected) { | |||
this.currentEquipment = eq.id; | |||
this.materialsBomList = eq.materialsBom; | |||
@@ -133,7 +136,7 @@ export default { | |||
equValueBomId: null, | |||
equMaterialBomId: null, | |||
}); | |||
this.$emit('update', this.selected); | |||
// this.$emit('update', this.selected); | |||
} else { | |||
// 清空选择状态 | |||
this.selectedEquipments = this.selectedEquipments.filter( | |||
@@ -144,7 +147,7 @@ export default { | |||
this.selected = this.selected.filter( | |||
(item) => item.equipmentId !== eq.id | |||
); | |||
this.$emit('update', this.selected); | |||
// this.$emit('update', this.selected); | |||
} | |||
}, | |||
@@ -162,11 +165,11 @@ export default { | |||
}); | |||
// 强制更新'设备'一栏 | |||
this.refreshKey = Math.random(); | |||
this.$emit('update', this.selected); | |||
// this.$emit('update', this.selected); | |||
return; | |||
} | |||
selectedItem && (selectedItem.equMaterialBomId = selected ? bomId : null); | |||
this.$emit('update', this.selected); | |||
// this.$emit('update', this.selected); | |||
}, | |||
handleValueBomChange(equipmentId, bomId, selected) { | |||
@@ -182,11 +185,11 @@ export default { | |||
equMaterialBomId: null, | |||
}); | |||
this.refreshKey = Math.random(); | |||
this.$emit('update', this.selected); | |||
// this.$emit('update', this.selected); | |||
return; | |||
} | |||
selectedItem && (selectedItem.equValueBomId = selected ? bomId : null); | |||
this.$emit('update', this.selected); | |||
// this.$emit('update', this.selected); | |||
}, | |||
}, | |||
}; | |||
@@ -68,7 +68,12 @@ | |||
@cancel="cancel" | |||
@confirm="submitForm"> | |||
<!-- <CustomTransfer /> --> | |||
<BomSelector :bom-list="bomList" v-model="selectedBoms" /> | |||
<BomSelector | |||
ref="bomSelector" | |||
v-if="open" | |||
:bom-list="bomList" | |||
:value="selectedBoms" | |||
@update="selectedBoms = $event" /> | |||
</base-dialog> | |||
</section> | |||
</template> | |||
@@ -146,27 +151,32 @@ export default { | |||
data: method !== 'get' ? payload : null, | |||
}); | |||
}, | |||
async submitForm() { | |||
console.log('selectedBoms', this.selectedBoms); | |||
if (this.selectedBoms.length) { | |||
const { code, data } = await this.http( | |||
'/extend/process-flow-det-equipment/createList', | |||
'post', | |||
this.selectedBoms.map((item) => ({ | |||
...item, | |||
flowDetId: this.currentDet.detId, | |||
})) | |||
); | |||
if (code == 0) { | |||
this.$message.success('操作成功'); | |||
this.getList(this.currentDet); | |||
this.cancel(); | |||
submitForm() { | |||
// 现将子组件的修改提交更新至本组件 | |||
this.$refs.bomSelector.commit(); | |||
// 再提交至后端 | |||
this.$nextTick(async () => { | |||
console.log('selectedBoms', this.selectedBoms); | |||
if (this.selectedBoms.length) { | |||
const { code, data } = await this.http( | |||
'/extend/process-flow-det-equipment/createList', | |||
'post', | |||
this.selectedBoms.map((item) => ({ | |||
...item, | |||
flowDetId: this.currentDet.detId, | |||
})) | |||
); | |||
if (code == 0) { | |||
this.$message.success('操作成功'); | |||
this.getList(this.currentDet); | |||
this.cancel(); | |||
} else { | |||
this.$message.error('操作失败'); | |||
} | |||
} else { | |||
this.$message.error('操作失败'); | |||
this.$message.info('请选择设备'); | |||
} | |||
} else { | |||
this.$message.info('请选择设备'); | |||
} | |||
}); | |||
}, | |||
async getList({ | |||
detId, | |||
@@ -202,7 +212,7 @@ export default { | |||
// 设置选中状态 | |||
eq.materialsBom.chosen = eq.materialsBomChoseId ?? null; | |||
eq.valuesBom.chosen = eq.valuesBomChoseId ?? null; | |||
if (eq.materialsBom.chosen || eq.valuesBom.chosen) { | |||
if (eq.equChose || eq.materialsBom.chosen || eq.valuesBom.chosen) { | |||
this.selectedBoms.push({ | |||
equipmentId: eq.id, | |||
equMaterialBomId: eq.materialsBom.chosen, | |||