+
- 保存
+ 保存
关闭
@@ -2525,6 +2526,7 @@ export default {
saveDetailLoading: false,
computeLoading: false,
copyBomQueryLoading: false,
+ batchUpdateSaveLoading: false,
// 控制
modalFlag: false,
modalDisableFlag: false,
@@ -3131,6 +3133,22 @@ export default {
// 判断子物料工序是否选择
packageSaveData () {
+ // 检查单位用量是否为空
+ const hasEmptyQty = this.subDetailList.some(item =>
+ item.qtyPerAssembly === null ||
+ item.qtyPerAssembly === '' ||
+ item.qtyPerAssembly === undefined
+ )
+
+ if (hasEmptyQty) {
+ this.$alert('单位用量不允许为空,请填写完整后再保存!', '验证失败', {
+ confirmButtonText: '确定',
+ type: 'warning'
+ })
+ return
+ }
+
+ // 检查工序是否为空
const allAHasValue = this.subDetailList.every(item => item.operationId !== null && item.operationId !== '')
if (!allAHasValue) {
this.$confirm(`存在未选择工序的子物料,是否确认保存数据?`, '提示', {
@@ -3895,8 +3913,15 @@ export default {
},
async batchUpdateComponentsSave() {
+ // 开启loading
+ this.batchUpdateSaveLoading = true
+
let flag = true
- for (let i = 0; i < this.subDetailList.length; i++) {
+ // 保存原始列表长度
+ const listLength = this.subDetailList.length
+
+ for (let i = 0; i < listLength; i++) {
+ // 每次从最新的列表中获取数据,因为前面的计算可能已经更新了列表
let row = this.subDetailList[i]
this.componentData = {
flag: '2',
@@ -3943,64 +3968,85 @@ export default {
}
if (this.componentData.lineSequence === '' || this.componentData.lineSequence == null) {
this.$message.warning('序号不能为空!')
+ this.batchUpdateSaveLoading = false
return
}
if (this.componentData.partNo === '' || this.componentData.partNo == null) {
this.$message.warning('请选择主记录物料编码!')
+ this.batchUpdateSaveLoading = false
return
}
if (this.componentData.bomType === '' || this.componentData.bomType == null) {
this.$message.warning('请选择主记录制造类型!')
+ this.batchUpdateSaveLoading = false
return
}
if (this.componentData.engChgLevel === '' || this.componentData.engChgLevel == null) {
this.$message.warning('请填写主记录BOM版本号!')
+ this.batchUpdateSaveLoading = false
return
}
if (this.componentData.componentPart === '' || this.componentData.componentPart == null) {
this.$message.warning('请选择子物料编码!')
+ this.batchUpdateSaveLoading = false
return
}
if (this.componentData.productFlag === 'component' && (this.componentData.consumptionItem === '' || this.componentData.consumptionItem == null)) {
this.$message.warning('请选择消耗项目!')
+ this.batchUpdateSaveLoading = false
return
}
if (this.componentData.componentScrap === '' || this.componentData.componentScrap == null) {
this.$message.warning('请填写调机量!')
+ this.batchUpdateSaveLoading = false
return
}
if (this.componentData.shrinkageFactor === '' || this.componentData.shrinkageFactor == null) {
this.$message.warning('请填写损耗率!')
+ this.batchUpdateSaveLoading = false
return
}
if (this.componentData.issueType === '' || this.componentData.issueType == null) {
this.$message.warning('请选择生产属性!')
+ this.batchUpdateSaveLoading = false
return
}
try {
const {data} = await computeQtyPerAssemblyEdit(this.componentData)
- if (data && data.code !== 0) {
+ if (data && data.code === 0) {
+ // 更新列表数据
+ this.subDetailList = data.rows.subDetailList
+ } else if (data && data.code !== 0) {
flag = false
+ this.batchUpdateSaveLoading = false
this.$alert('第'+(i+1)+'行'+data.msg, '错误', {
confirmButtonText: '确定'
})
+ break
}
} catch (error) {
flag = false
+ this.batchUpdateSaveLoading = false
this.$alert('第'+(i+1)+'行请求失败', '错误', {
confirmButtonText: '确定'
})
+ break
}
}
+ // 关闭loading
+ this.batchUpdateSaveLoading = false
+
if(flag) {
this.$message({
- message: '操作成功',
+ message: '批量修改并计算完成',
type: 'success',
duration: 1500,
onClose: () => {}
})
this.batchUpdateComponentsFlag = false
+ // 刷新表格显示
+ this.$forceUpdate()
}
},
diff --git a/src/views/modules/part/quicklyCreateBom.vue b/src/views/modules/part/quicklyCreateBom.vue
index 205bb29..4e2d785 100644
--- a/src/views/modules/part/quicklyCreateBom.vue
+++ b/src/views/modules/part/quicklyCreateBom.vue
@@ -105,9 +105,9 @@
-
+
-
+
@@ -4688,28 +4688,28 @@ export default {
try {
const priorityList = []
const otherList = []
-
+
umList.forEach(item => {
if (!item) return
const umid = String(item.fieldname1 || item.UMID || '')
const umName = String(item.caption1 || item.UMName || '')
const isQianZhang = umid === '1002' || umName.includes('千张')
const isMi = umName === '米' || (umName.includes('米') && umName.length <= 2 && !umName.includes('千'))
-
+
if (isMi || isQianZhang) {
priorityList.push({ item, isMi, isQianZhang })
} else {
otherList.push(item)
}
})
-
+
// 米优先,然后千张
priorityList.sort((a, b) => {
if (a.isMi && !b.isMi) return -1
if (!a.isMi && b.isMi) return 1
return 0
})
-
+
if (priorityList.length > 0) {
umList = [...priorityList.map(p => p.item), ...otherList]
}
@@ -4717,7 +4717,7 @@ export default {
console.warn('计量单位排序失败,使用原始顺序:', error)
}
}
-
+
for (let i = 0; i < this.partList1.length; i++) {
this.$set(this.partList1[i], 'umList', umList);
this.$set(this.partList1[i], 'partFamilyList', data.data.list[i][0]);