Browse Source

2026-11-24

配方BOM临时配方的子物料维护优化
master
fengyuan_yang 10 hours ago
parent
commit
2f828566c6
  1. 1
      src/api/part/recipeManagement.js
  2. 356
      src/views/modules/part/recipeManagement.vue

1
src/api/part/recipeManagement.js

@ -98,6 +98,7 @@ export const queryRecipeHeader = data => createAPI(`/plm/recipeManagement/queryR
* @returns {*} * @returns {*}
*/ */
export const saveRecipeComponent = data => createAPI(`/plm/recipeManagement/saveRecipeComponent`,'post',data) export const saveRecipeComponent = data => createAPI(`/plm/recipeManagement/saveRecipeComponent`,'post',data)
export const saveRecipeComponentBatch = data => createAPI(`/plm/recipeManagement/saveRecipeComponentBatch`,'post',data)
/** /**
* 修改recipe子明细 * 修改recipe子明细

356
src/views/modules/part/recipeManagement.vue

@ -225,8 +225,7 @@
<el-form label-position="top" style="margin-top: 5px"> <el-form label-position="top" style="margin-top: 5px">
<el-form-item v-if="modalData.flag === '3'"></el-form-item> <el-form-item v-if="modalData.flag === '3'"></el-form-item>
<el-form-item v-else> <el-form-item v-else>
<el-button type="primary" @click="saveComponentModal" style="margin-left: 7px">新增</el-button>
<el-button type="primary" @click="deleteComponentPart">删除</el-button>
<el-button v-if="isTemporaryRecipePart" type="primary" @click="openComponentBatchModal" style="margin-left: 7px">新增/删除</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-table <el-table
@ -504,7 +503,7 @@
</el-form> </el-form>
<el-form :inline="true" label-position="top" :model="componentData" :rules="componentRules" style="margin-left: 5px"> <el-form :inline="true" label-position="top" :model="componentData" :rules="componentRules" style="margin-left: 5px">
<el-form-item :label="'重量分配'" prop="weightShare" :rules="componentRules.weightShare"> <el-form-item :label="'重量分配'" prop="weightShare" :rules="componentRules.weightShare">
<el-input-number :precision="10" :controls="false" :step="0" disabled v-model="componentData.weightShare" @change="changeWeightShare" style="width: 115px"></el-input-number>
<el-input-number :precision="10" :controls="false" :step="0" :disabled="!componentBatchEditing" v-model="componentData.weightShare" @change="changeWeightShare" style="width: 115px"></el-input-number>
</el-form-item> </el-form-item>
<el-form-item :label="'零件-按重量'"> <el-form-item :label="'零件-按重量'">
<el-input-number :precision="10" :controls="false" :step="0" v-model="componentData.partsByWeight" disabled style="width: 115px"></el-input-number> <el-input-number :precision="10" :controls="false" :step="0" v-model="componentData.partsByWeight" disabled style="width: 115px"></el-input-number>
@ -546,9 +545,15 @@
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-footer style="height:35px;margin-top:65px;text-align:center"> <el-footer style="height:35px;margin-top:65px;text-align:center">
<el-button v-if="componentData.flag === '1'" type="primary" @click="componentDataSave(true)">应用</el-button>
<el-button type="primary" @click="componentDataSave(false)">保存</el-button>
<el-button type="primary" @click="componentSaveModal = false">关闭</el-button>
<template v-if="componentBatchEditing">
<el-button type="primary" @click="saveBatchComponentRow(false)">确定</el-button>
<el-button type="primary" @click="closeBatchComponentForm">关闭</el-button>
</template>
<template v-else>
<el-button v-if="componentData.flag === '1'" type="primary" @click="componentDataSave(true)">应用</el-button>
<el-button type="primary" @click="componentDataSave(false)">保存</el-button>
<el-button type="primary" @click="componentSaveModal = false">关闭</el-button>
</template>
</el-footer> </el-footer>
</el-dialog> </el-dialog>
@ -968,6 +973,55 @@
</el-footer> </el-footer>
</el-dialog> </el-dialog>
<el-dialog title="新增/删除子件" :close-on-click-modal="false" v-drag :visible.sync="componentBatchModal" width="1110px">
<div class="rq">
<el-form label-position="top">
<el-form-item>
<el-button type="primary" @click="openBatchComponentForm">新增</el-button>
<el-button type="primary" @click="removeComponentBatchRows">删除</el-button>
<span style="margin-left: 20px">重量分配合计:{{ componentBatchWeightTotal }}</span>
</el-form-item>
</el-form>
<el-table
:data="componentBatchList"
height="360px"
border
@selection-change="componentBatchSelectionChange"
style="width: 100%">
<el-table-column type="selection" align="center" width="50"></el-table-column>
<el-table-column
v-for="(item,index) in columnSubDetailList" :key="index"
:sortable="item.columnSortable"
:prop="item.columnProp"
:header-align="item.headerAlign"
:show-overflow-tooltip="item.showOverflowTooltip"
:align="item.align"
:fixed="item.fixed == ''?false:item.fixed"
:min-width="item.columnWidth"
:label="item.columnLabel">
<template slot-scope="scope">
<span v-if="!item.columnHidden">{{scope.row[item.columnProp]}}</span>
<span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
</template>
</el-table-column>
<el-table-column
fixed="right"
header-align="center"
align="center"
width="80"
label="操作">
<template slot-scope="scope">
<el-link style="cursor: pointer" @click="editBatchComponentRow(scope.row, scope.$index)">编辑</el-link>
</template>
</el-table-column>
</el-table>
</div>
<el-footer style="height: 40px; margin-top: 15px; text-align: center">
<el-button :loading="componentBatchLoading" type="primary" @click="submitComponentBatch">保存</el-button>
<el-button type="primary" @click="componentBatchModal = false">关闭</el-button>
</el-footer>
</el-dialog>
<!-- chooseList模态框 --> <!-- chooseList模态框 -->
<ChooseList ref="baseList" @getBaseData="getBaseData"></ChooseList> <ChooseList ref="baseList" @getBaseData="getBaseData"></ChooseList>
<filter-search :visible.sync="filterVisible" @search="queryByAnyField"></filter-search> <filter-search :visible.sync="filterVisible" @search="queryByAnyField"></filter-search>
@ -990,6 +1044,7 @@ import {
queryPartList, // 查询物料清单 queryPartList, // 查询物料清单
queryRecipeComponent, // 查询recipe子明细 queryRecipeComponent, // 查询recipe子明细
saveRecipeComponent, // 新增recipe子明细 saveRecipeComponent, // 新增recipe子明细
saveRecipeComponentBatch, // 临时物料配方子件整单保存
updateRecipeComponent, // 修改recipe子明细 updateRecipeComponent, // 修改recipe子明细
deleteRecipeComponent, // 删除recipe子明细 deleteRecipeComponent, // 删除recipe子明细
queryOperationList, // 根据物料编码查询工序 queryOperationList, // 根据物料编码查询工序
@ -1024,6 +1079,18 @@ export default {
ChooseList ChooseList
}, },
// 监听 // 监听
computed: {
isTemporaryRecipePart () {
return this.modalData.flag !== '3' && this.detailData.officialFlag !== 'Y'
},
componentBatchWeightTotal () {
const total = (this.componentBatchList || []).reduce((sum, row) => {
const weight = Number(row.weightShare)
return sum + (Number.isFinite(weight) ? weight : 0)
}, 0)
return Number(total.toFixed(6))
}
},
watch: { watch: {
searchData: { searchData: {
deep: true, deep: true,
@ -2975,6 +3042,12 @@ export default {
saveDetailModalFlag :false, saveDetailModalFlag :false,
saveDetailModalDisable: false, saveDetailModalDisable: false,
componentSaveModal: false, componentSaveModal: false,
componentBatchModal: false,
componentBatchList: [],
componentBatchSelection: [],
componentBatchLoading: false,
componentBatchEditing: false,
componentBatchEditIndex: -1,
componentDisableFlag: false, componentDisableFlag: false,
operationModelFlag: false, operationModelFlag: false,
copyRecipeModelFlag: false, copyRecipeModelFlag: false,
@ -3229,7 +3302,9 @@ export default {
createBy: this.$store.state.user.name, createBy: this.$store.state.user.name,
printUnit: '', printUnit: '',
printUnitName: '', printUnitName: '',
officialFlag: 'N'
officialFlag: 'N',
partOfficialStatus: '',
temporaryPartFlag: ''
} }
this.detailData = { this.detailData = {
site: this.$store.state.user.site, site: this.$store.state.user.site,
@ -3281,6 +3356,8 @@ export default {
officialFlag: row.officialFlag, officialFlag: row.officialFlag,
alternativeNo: row.alternativeNo, alternativeNo: row.alternativeNo,
ifsPartNo: row.ifsPartNo, ifsPartNo: row.ifsPartNo,
partOfficialStatus: row.partOfficialStatus,
temporaryPartFlag: row.temporaryPartFlag,
} }
this.subDetailTable = 'recipe_sub_detail' this.subDetailTable = 'recipe_sub_detail'
// 查recipe明细 // 查recipe明细
@ -3422,6 +3499,190 @@ export default {
}) })
}, },
openComponentBatchModal () {
if (!this.detailData.alternativeNo) {
this.$message.warning('请先选择替代!')
return
}
this.componentBatchList = JSON.parse(JSON.stringify(this.subDetailList || []))
this.componentBatchSelection = []
this.componentBatchEditing = false
this.componentBatchEditIndex = -1
this.componentBatchModal = true
},
nextBatchLineSequence () {
return this.componentBatchList.reduce((max, row) => {
const sequence = Number(row.lineSequence)
return Number.isFinite(sequence) ? Math.max(max, sequence) : max
}, 0) + 1
},
openBatchComponentForm () {
this.componentBatchEditing = true
this.componentBatchEditIndex = -1
this.componentData = {
flag: '1',
site: this.$store.state.user.site,
partNo: this.modalData.partNo,
engChgLevel: this.modalData.engChgLevel,
bomType: this.modalData.bomType,
alternativeNo: this.detailData.alternativeNo,
componentPart: '',
componentPartDesc: '',
printUnit: '',
printUnitName: '',
partStatus: '',
partStatusDesc: '',
qtyPerAssembly: undefined,
componentScrap: 0,
issueType: 'Reserve And Backflush',
shrinkageFactor: 0,
lineItemNo: '',
operationId: '',
operationNo: '',
issueToLoc: '',
issueToLocName: '',
noteText: '',
createBy: this.$store.state.user.name,
lineSequence: this.nextBatchLineSequence(),
consumptionItem: 'Consumed',
productFlag: 'component',
weightShare: undefined,
partsByWeight: undefined,
qtyUom: undefined,
issuePlannedScrapDb: 'TRUE',
issueOverreportedQtyDb: 'FALSE',
fixedQtyFlag: 'Not fixed',
promisePlanned: 'Promised',
phantomConsume: 'Not Phantom Consume',
operCostDistribution: '0',
genOhCostDistribution: '0',
qtyKg: undefined,
byProdAsSupplyInMrpDb: 'FALSE',
leadtimeOffset: '0',
stdPlannedItem: '1',
chargedItem: 'Item not charged',
excludeFromCalculationsDb: 'FALSE',
excludeFromAsBuiltDb: 'FALSE',
lotBatchOriginDb: 'FALSE'
}
this.componentDisableFlag = false
this.componentSaveModal = true
},
editBatchComponentRow (row, index) {
this.componentBatchEditing = true
this.componentBatchEditIndex = index
this.componentData = JSON.parse(JSON.stringify(row))
this.componentData.flag = '2'
this.componentData.productFlag = 'component'
this.componentData.partNo = this.modalData.partNo
this.componentData.engChgLevel = this.modalData.engChgLevel
this.componentData.bomType = this.modalData.bomType
this.componentData.alternativeNo = this.detailData.alternativeNo
this.componentData.updateBy = this.$store.state.user.name
this.componentDisableFlag = true
this.componentSaveModal = true
},
componentBatchSelectionChange (selection) {
this.componentBatchSelection = selection
},
removeComponentBatchRows () {
if (!this.componentBatchSelection.length) {
this.$message.warning('请选择要删除的子件!')
return
}
this.componentBatchList = this.componentBatchList.filter(row => this.componentBatchSelection.indexOf(row) === -1)
this.componentBatchSelection = []
},
submitComponentBatch () {
if (!this.componentBatchList.length) {
this.$message.warning('请至少维护一条子件,且重量分配总额必须等于100!')
return
}
const componentParts = []
for (let i = 0; i < this.componentBatchList.length; i++) {
const row = this.componentBatchList[i]
const componentPart = this.normalizePartNo(row.componentPart)
row.componentPart = componentPart
if (!componentPart) {
this.$message.warning('请选择子物料编码!')
return
}
if (this.isSelfAsComponent(this.modalData.partNo, componentPart)) {
this.$message.warning('不能将自己作为子物料!')
return
}
if (componentParts.indexOf(componentPart) !== -1) {
this.$message.warning('子物料【' + componentPart + '】重复!')
return
}
componentParts.push(componentPart)
if (row.weightShare === undefined || row.weightShare === null || row.weightShare === '' || Number(row.weightShare) <= 0) {
this.$message.warning('子物料【' + componentPart + '】的重量分配必须大于0!')
return
}
}
if (Math.abs(this.componentBatchWeightTotal - 100) > 0.000001) {
this.$message.warning('重量分配总额必须等于100,当前合计为' + this.componentBatchWeightTotal + '!')
return
}
const params = {
site: this.modalData.site || this.$store.state.user.site,
partNo: this.modalData.partNo,
engChgLevel: this.modalData.engChgLevel,
bomType: this.modalData.bomType,
alternativeNo: this.detailData.alternativeNo,
createBy: this.$store.state.user.name,
updateBy: this.$store.state.user.name,
informationList: this.componentBatchList.map(row => ({
lineSequence: row.lineSequence,
componentPart: row.componentPart,
componentPartDesc: row.componentPartDesc,
printUnit: row.printUnit,
weightShare: row.weightShare,
partsByWeight: row.partsByWeight,
qtyUom: row.qtyUom,
qtyPerAssembly: row.qtyPerAssembly,
qtyKg: row.qtyKg,
componentScrap: row.componentScrap,
shrinkageFactor: row.shrinkageFactor,
consumptionItem: row.consumptionItem,
issueType: row.issueType,
operationNo: row.operationNo === '' ? null : row.operationNo,
issueToLoc: row.issueToLoc,
noteText: row.noteText,
issuePlannedScrapDb: row.issuePlannedScrapDb,
issueOverreportedQtyDb: row.issueOverreportedQtyDb,
fixedQtyFlag: row.fixedQtyFlag,
promisePlanned: row.promisePlanned,
phantomConsume: row.phantomConsume,
operCostDistribution: row.operCostDistribution,
genOhCostDistribution: row.genOhCostDistribution,
byProdAsSupplyInMrpDb: row.byProdAsSupplyInMrpDb,
leadtimeOffset: row.leadtimeOffset,
stdPlannedItem: row.stdPlannedItem,
chargedItem: row.chargedItem,
excludeFromCalculationsDb: row.excludeFromCalculationsDb,
excludeFromAsBuiltDb: row.excludeFromAsBuiltDb,
lotBatchOriginDb: row.lotBatchOriginDb
}))
}
this.componentBatchLoading = true
saveRecipeComponentBatch(params).then(({data}) => {
this.componentBatchLoading = false
if (data && data.code === 0) {
this.subDetailList = data.rows.subDetailList
this.byProductList = data.rows.byProductList
this.manufStructCostDistribList = data.rows.manufStructCostDistribList
this.componentBatchModal = false
this.$message.success('操作成功')
} else {
this.$alert(data.msg, '错误', { confirmButtonText: '确定' })
}
}).catch(() => {
this.componentBatchLoading = false
})
},
// 子明细新增模态框 // 子明细新增模态框
saveComponentModal () { saveComponentModal () {
this.$alert("配方子件的【新增】【删除】操作需到IFS系统中,然后通过【数据同步-反向】同步到PLM系统!", "提示", { this.$alert("配方子件的【新增】【删除】操作需到IFS系统中,然后通过【数据同步-反向】同步到PLM系统!", "提示", {
@ -3493,6 +3754,7 @@ export default {
// 副产品新增模态框 // 副产品新增模态框
saveByProductModal () { saveByProductModal () {
this.componentBatchEditing = false
if (this.detailData.alternativeNo === '' || this.detailData.alternativeNo == null) { if (this.detailData.alternativeNo === '' || this.detailData.alternativeNo == null) {
this.$message.warning('请先选择替代!') this.$message.warning('请先选择替代!')
return return
@ -3539,6 +3801,7 @@ export default {
// 子明细编辑模态框 // 子明细编辑模态框
updateComponentModal (row) { updateComponentModal (row) {
this.componentBatchEditing = false
this.componentData = { this.componentData = {
flag: '2', flag: '2',
site: row.site, site: row.site,
@ -3809,7 +4072,9 @@ export default {
if (data.page.list.length === 1) { if (data.page.list.length === 1) {
this.modalData.partDesc = data.page.list[0].partDesc this.modalData.partDesc = data.page.list[0].partDesc
this.modalData.printUnit = data.page.list[0].printUnit this.modalData.printUnit = data.page.list[0].printUnit
this.modalData.printUnitName = data.page[0].printUnitName
this.modalData.printUnitName = data.page.list[0].printUnitName
this.modalData.partOfficialStatus = data.page.list[0].partOfficialStatus
this.modalData.temporaryPartFlag = data.page.list[0].temporaryPartFlag
} }
} }
}) })
@ -3821,6 +4086,8 @@ export default {
this.modalData.partDesc = row.partDesc this.modalData.partDesc = row.partDesc
this.modalData.printUnit = row.printUnit this.modalData.printUnit = row.printUnit
this.modalData.printUnitName = row.printUnitName this.modalData.printUnitName = row.printUnitName
this.modalData.partOfficialStatus = row.partOfficialStatus
this.modalData.temporaryPartFlag = row.temporaryPartFlag
this.partModelFlag = false this.partModelFlag = false
}, },
@ -3837,6 +4104,8 @@ export default {
this.componentData.componentPartDesc = row.partDesc this.componentData.componentPartDesc = row.partDesc
this.componentData.printUnit = row.printUnit this.componentData.printUnit = row.printUnit
this.componentData.printUnitName = row.printUnitName this.componentData.printUnitName = row.printUnitName
this.componentData.partStatus = row.partStatus
this.componentData.partStatusDesc = row.partStatusDesc
this.componentPartModelFlag = false this.componentPartModelFlag = false
}, },
@ -3854,11 +4123,13 @@ export default {
}, },
// 子物料列表 // 子物料列表
queryComponentPartModal () {
queryComponentPartModal (keepStatus) {
this.componentPartData.productGroupId4 = '' this.componentPartData.productGroupId4 = ''
this.componentPartData.limit = this.pageSize3 this.componentPartData.limit = this.pageSize3
this.componentPartData.page = this.pageIndex3 this.componentPartData.page = this.pageIndex3
this.componentPartData.status = 'Y'
if (!keepStatus && !this.componentBatchEditing) {
this.componentPartData.status = 'Y'
}
// 查询所有物料 // 查询所有物料
queryPartListAll(this.componentPartData).then(({data}) => { queryPartListAll(this.componentPartData).then(({data}) => {
if (data && data.code === 0) { if (data && data.code === 0) {
@ -4003,6 +4274,8 @@ export default {
this.componentData.componentPartDesc = data.page.list[0].partDesc this.componentData.componentPartDesc = data.page.list[0].partDesc
this.componentData.printUnit = data.page.list[0].printUnit this.componentData.printUnit = data.page.list[0].printUnit
this.componentData.printUnitName = data.page.list[0].printUnitName this.componentData.printUnitName = data.page.list[0].printUnitName
this.componentData.partStatus = data.page.list[0].partStatus
this.componentData.partStatusDesc = data.page.list[0].partStatusDesc
return return
} }
} }
@ -4011,6 +4284,8 @@ export default {
this.componentData.componentPartDesc = '' this.componentData.componentPartDesc = ''
this.componentData.printUnit = '' this.componentData.printUnit = ''
this.componentData.printUnitName = '' this.componentData.printUnitName = ''
this.componentData.partStatus = ''
this.componentData.partStatusDesc = ''
}, },
// copy物料编码失焦事件 // copy物料编码失焦事件
@ -4210,8 +4485,69 @@ export default {
this.componentData.qtyKg = this.componentData.weightShare / 100 this.componentData.qtyKg = this.componentData.weightShare / 100
}, },
closeBatchComponentForm () {
this.componentSaveModal = false
this.componentBatchEditing = false
this.componentBatchEditIndex = -1
},
saveBatchComponentRow (keepOpen) {
if (this.componentData.lineSequence === '' || this.componentData.lineSequence == null) {
this.$message.warning('序号不能为空!')
return
}
const normalizedComponentPart = this.normalizeComponentPartInput()
if (normalizedComponentPart === '') {
this.$message.warning('请选择子物料编码!')
return
}
if (this.isSelfAsComponent(this.componentData.partNo, normalizedComponentPart)) {
this.$message.warning('不能将自己作为子物料!')
return
}
if (this.componentData.consumptionItem === '' || this.componentData.consumptionItem == null) {
this.$message.warning('请选择消耗项目!')
return
}
if (this.componentData.weightShare === '' || this.componentData.weightShare == null || Number(this.componentData.weightShare) <= 0) {
this.$message.warning('请填写重量分配!')
return
}
if (this.componentData.issueType === '' || this.componentData.issueType == null) {
this.$message.warning('请选择生产属性!')
return
}
const duplicated = this.componentBatchList.some((row, index) => {
return index !== this.componentBatchEditIndex && this.normalizePartNo(row.componentPart) === normalizedComponentPart
})
if (duplicated) {
this.$message.warning('子物料【' + normalizedComponentPart + '】重复!')
return
}
this.changeWeightShare()
const row = JSON.parse(JSON.stringify(this.componentData))
row.componentPart = normalizedComponentPart
row.productFlag = 'component'
if (this.componentBatchEditIndex >= 0) {
this.$set(this.componentBatchList, this.componentBatchEditIndex, row)
this.componentSaveModal = false
this.componentBatchEditing = false
return
}
this.componentBatchList.push(row)
if (keepOpen) {
this.openBatchComponentForm()
} else {
this.componentSaveModal = false
this.componentBatchEditing = false
}
},
// 新增子明细方法 // 新增子明细方法
componentDataSave (isClose) { componentDataSave (isClose) {
if (this.componentBatchEditing) {
this.saveBatchComponentRow(isClose)
return
}
if (this.componentData.lineSequence === '' || this.componentData.lineSequence == null) { if (this.componentData.lineSequence === '' || this.componentData.lineSequence == null) {
this.$message.warning('序号不能为空!') this.$message.warning('序号不能为空!')
return return

Loading…
Cancel
Save