Browse Source

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

java8
han\hanst 2 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) { 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 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)'
})
// BOMAPI
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) { sizeChangeHandle (val) {

Loading…
Cancel
Save