Browse Source

选择物料分类后同时更新物料主数据的FamilyID

java8
han\hanst 12 months ago
parent
commit
8694a8f361
  1. 85
      src/views/modules/part/bom_create.vue

85
src/views/modules/part/bom_create.vue

@ -4103,10 +4103,91 @@ export default {
})
},
/**
* 选择物料分类
* 双击选择后执行两个保存操作:
* 1. 保存到当前BOM子物料行
* 2. 保存到物料主数据(part表)
*/
getRowData (row) {
this.$set(this.subDetailList[this.familyData.indexOfList], 'familyName', row.familyName);
this.$set(this.subDetailList[this.familyData.indexOfList], 'familyID', row.familyID);
console.log('📦 选择物料分类:', row.familyID, row.familyName)
// 1. 更新前端显示
const currentRow = this.subDetailList[this.familyData.indexOfList]
this.$set(this.subDetailList[this.familyData.indexOfList], 'familyName', row.familyName)
this.$set(this.subDetailList[this.familyData.indexOfList], 'familyID', row.familyID)
// 2. 关闭对话框
this.familyDialogFlag = false
// 3. 执行两个保存操作
this.saveFamilyToComponentAndPart(currentRow, row)
},
/**
* 保存物料分类到BOM子物料和物料主数据
* @param {Object} bomRow - BOM子物料行数据
* @param {Object} familyRow - 选择的物料分类数据
*/
saveFamilyToComponentAndPart(bomRow, familyRow) {
// 构建保存数据
const saveData = {
site: bomRow.site,
buNo: bomRow.buNo,
partNo: bomRow.partNo,
engChgLevel: bomRow.engChgLevel,
bomType: bomRow.bomType,
alternativeNo: bomRow.alternativeNo,
componentPart: bomRow.componentPart,
lineItemNo: bomRow.lineItemNo,
familyID: familyRow.familyID,
qtyPerAssembly: bomRow.qtyPerAssembly,
componentScrap: bomRow.componentScrap,
shrinkageFactor: bomRow.shrinkageFactor,
issueType: bomRow.issueType,
operationId: bomRow.operationId,
issueToLoc: bomRow.issueToLoc,
noteText: bomRow.noteText,
lineSequence: bomRow.lineSequence,
consumptionItem: bomRow.consumptionItem,
updateBy: this.$store.state.user.name
}
console.log('💾 保存物料分类,物料编码:', bomRow.componentPart, ',分类:', familyRow.familyID)
// 显示loading
const loadingInstance = this.$loading({
lock: true,
text: '正在保存物料分类...',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.3)'
})
// 调用更新BOM子物料的API(会同时更新物料主数据)
updateBomComponent(saveData).then(({data}) => {
loadingInstance.close()
if (data && data.code === 0) {
this.$message({
message: '物料分类保存成功',
type: 'success',
duration: 1500
})
console.log('✅ 物料分类保存成功')
// 刷新子物料列表以获取最新数据
if (data.rows && data.rows.subDetailList) {
this.subDetailList = data.rows.subDetailList
this.tableKey++
this.$forceUpdate()
}
} else {
this.$message.error(data.msg || '保存失败')
}
}).catch((error) => {
loadingInstance.close()
console.error('保存物料分类失败:', error)
this.$message.error('保存失败,请重试')
})
},
sizeChangeHandle (val) {

Loading…
Cancel
Save