Browse Source

2026-10-10

优化产品和配方BOM,【Copy】和【粘贴】校验“不能将自己作为子物料”
master
fengyuan_yang 2 months ago
parent
commit
440886b180
  1. 32
      src/views/modules/part/bomManagement.vue
  2. 23
      src/views/modules/part/recipeManagement.vue

32
src/views/modules/part/bomManagement.vue

@ -4536,6 +4536,17 @@ export default {
this.componentData.componentPart = normalizedComponentPart this.componentData.componentPart = normalizedComponentPart
return normalizedComponentPart return normalizedComponentPart
}, },
normalizePartNo (partNo) {
return (partNo || '').toString().trim().toUpperCase()
},
isSelfAsComponent (parentPartNo, componentPart) {
const parent = this.normalizePartNo(parentPartNo)
const child = this.normalizePartNo(componentPart)
return parent !== '' && parent === child
},
findSelfAsComponent (parentPartNo, list) {
return (list || []).find(item => this.isSelfAsComponent(parentPartNo, item && item.componentPart))
},
// 子物料编码失焦事件 // 子物料编码失焦事件
componentPartBlur () { componentPartBlur () {
@ -4743,8 +4754,12 @@ export default {
if (this.checkedPasteBar.length === 0) { if (this.checkedPasteBar.length === 0) {
this.$message.warning('请选择要复制的信息!') this.$message.warning('请选择要复制的信息!')
return return
} else {
this.$confirm("是否确认复制信息?", "提示", {
}
if (this.findSelfAsComponent(this.detailData.partNo, this.checkedPasteBar)) {
this.$message.warning('不能将自己作为子物料!')
return
}
this.$confirm("是否确认复制信息?", "提示", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
@ -4786,7 +4801,6 @@ export default {
this.saveComponentLoading = false this.saveComponentLoading = false
}) })
}) })
}
}, },
// 删除粘贴栏 // 删除粘贴栏
@ -4932,6 +4946,10 @@ export default {
this.$message.warning('请选择子物料编码!') this.$message.warning('请选择子物料编码!')
return return
} }
if (this.isSelfAsComponent(this.componentData.partNo, normalizedComponentPart)) {
this.$message.warning('不能将自己作为子物料!')
return
}
if (this.componentData.productFlag === 'component' && (this.componentData.consumptionItem === '' || this.componentData.consumptionItem == null)) { if (this.componentData.productFlag === 'component' && (this.componentData.consumptionItem === '' || this.componentData.consumptionItem == null)) {
this.$message.warning('请选择消耗项目!') this.$message.warning('请选择消耗项目!')
return return
@ -5159,6 +5177,10 @@ export default {
this.$message.warning('失效日期必须大于生效日期!') this.$message.warning('失效日期必须大于生效日期!')
return return
} }
if (this.findSelfAsComponent(this.copyBomData.partNo, [...(this.subDetailList || []), ...(this.byProductList || [])])) {
this.$message.warning('不能将自己作为子物料!')
return
}
this.copyBomData.previousVersion = this.modalData this.copyBomData.previousVersion = this.modalData
this.copyLoading = true this.copyLoading = true
// 新增主表信息 // 新增主表信息
@ -5232,6 +5254,10 @@ export default {
this.$message.warning('请填写替代编码!') this.$message.warning('请填写替代编码!')
return return
} }
if (this.findSelfAsComponent(this.copyAlternativeData.partNo, [...(this.subDetailList || []), ...(this.byProductList || [])])) {
this.$message.warning('不能将自己作为子物料!')
return
}
// if (this.copyAlternativeData.alternativeDescription === '' || this.copyAlternativeData.alternativeDescription == null) { // if (this.copyAlternativeData.alternativeDescription === '' || this.copyAlternativeData.alternativeDescription == null) {
// this.$message.warning('请填写替代名称!') // this.$message.warning('请填写替代名称!')
// return // return

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

@ -3978,6 +3978,17 @@ export default {
this.componentData.componentPart = normalizedComponentPart this.componentData.componentPart = normalizedComponentPart
return normalizedComponentPart return normalizedComponentPart
}, },
normalizePartNo (partNo) {
return (partNo || '').toString().trim().toUpperCase()
},
isSelfAsComponent (parentPartNo, componentPart) {
const parent = this.normalizePartNo(parentPartNo)
const child = this.normalizePartNo(componentPart)
return parent !== '' && parent === child
},
findSelfAsComponent (parentPartNo, list) {
return (list || []).find(item => this.isSelfAsComponent(parentPartNo, item && item.componentPart))
},
// 子物料编码失焦事件 // 子物料编码失焦事件
componentPartBlur () { componentPartBlur () {
@ -4222,6 +4233,10 @@ export default {
this.$message.warning('请选择子物料编码!') this.$message.warning('请选择子物料编码!')
return return
} }
if (this.isSelfAsComponent(this.componentData.partNo, normalizedComponentPart)) {
this.$message.warning('不能将自己作为子物料!')
return
}
if (this.componentData.productFlag === 'component' && (this.componentData.consumptionItem === '' || this.componentData.consumptionItem == null)) { if (this.componentData.productFlag === 'component' && (this.componentData.consumptionItem === '' || this.componentData.consumptionItem == null)) {
this.$message.warning('请选择消耗项目!') this.$message.warning('请选择消耗项目!')
return return
@ -4428,6 +4443,10 @@ export default {
this.$message.warning('失效日期必须大于生效日期!') this.$message.warning('失效日期必须大于生效日期!')
return return
} }
if (this.findSelfAsComponent(this.copyRecipeData.partNo, [...(this.subDetailList || []), ...(this.byProductList || [])])) {
this.$message.warning('不能将自己作为子物料!')
return
}
this.copyRecipeData.previousVersion = this.modalData this.copyRecipeData.previousVersion = this.modalData
this.copyLoading = true this.copyLoading = true
// 新增主表信息 // 新增主表信息
@ -4505,6 +4524,10 @@ export default {
this.$message.warning('请填写替代名称!') this.$message.warning('请填写替代名称!')
return return
} }
if (this.findSelfAsComponent(this.copyAlternativeData.partNo, [...(this.subDetailList || []), ...(this.byProductList || [])])) {
this.$message.warning('不能将自己作为子物料!')
return
}
this.copyAlternativeData.previousVersion = this.detailData this.copyAlternativeData.previousVersion = this.detailData
this.copyLoading = true this.copyLoading = true
copyAlternative(this.copyAlternativeData).then(({data}) => { copyAlternative(this.copyAlternativeData).then(({data}) => {

Loading…
Cancel
Save