@@ -89,9 +65,12 @@ import FileUpload from '@/components/FileUpload'
import { listByIds } from '@/api/system/oss'
import { updatePurchasePlanDetail } from '@/api/wms/purchasePlanDetail'
import { recognizeText, recognizeBomByModel } from '@/api/system/ocr'
-import { listBomItem, addBomItem } from '@/api/wms/bomItem'
-import { addBom } from '@/api/wms/bom'
-import { updateRawMaterial, addRawMaterial, getRawMaterial } from '@/api/wms/rawMaterial'
+import { listBomItem } from '@/api/wms/bomItem'
+import { getRawMaterial } from '@/api/wms/rawMaterial'
+import Merger from './merger.vue'
+
+import modelImage from '@/assets/images/model.png'
+import ocrImage from '@/assets/images/ocr.png'
const so = {
annex: {
@@ -146,6 +125,11 @@ const so = {
}
}
+// 原子操作, 用于细化的进度展示, 无论其同步还是异步一律视作异步函数执行, 并返回一个Promise
+const atoms = {
+
+}
+
export default {
name: 'QualityCerticate',
components: {
@@ -193,6 +177,8 @@ export default {
resultDiff: true,
oldResult: [],
newResult: [],
+ modelImage,
+ ocrImage,
}
},
methods: {
@@ -205,7 +191,6 @@ export default {
})
},
handleModel() {
-
this.loadingMethod('model', async (res) => {
await this.loadingMethod('old')
console.log(this);
@@ -215,74 +200,23 @@ export default {
},
async handleConfirm() {
- // 确认内容,如果质保单内容与历史质保单内容不一致,则提示用户选择处理方式
- if (this.resultDiff) {
- // 需要选择处理方式
- if (!this.uploadQualityCertificateForm.qualityCertificateType) {
- this.$modal.msgError('请选择处理方式');
- return;
- }
- this.loading = true;
- this.loadingText = '正在处理产品BOM';
- if (this.uploadQualityCertificateForm.qualityCertificateType === 1) {
- // 什么都不需要做,直接完成就可以
- console.log('使用旧的质保单');
- } else if (this.uploadQualityCertificateForm.qualityCertificateType === 2) {
- // 创建一个新的BOM
- const bom = await addBom({
- bomName: 'N' + new Date().getTime(),
- bomCode: 'N' + new Date().getTime(),
- })
- // 将BOMID赋值给对应的materialId
- await updateRawMaterial({
- rawMaterialId: this.info.rawMaterialId,
- bomId: bom.data.bomId,
- })
- // 逐项创建BOMItem
- for (let i = 0; i < this.newResult.length; i++) {
- await addBomItem({
- bomId: bom.data.bomId,
- attrKey: this.newResult[i].attrKey,
- attrValue: this.newResult[i].attrValue,
- })
- }
- console.log('使用新的质保单');
- } else if (this.uploadQualityCertificateForm.qualityCertificateType === 3) {
- console.log('创建新物料');
- // 创建一个新的BOM
- const bom = await addBom({
- bomName: 'N' + new Date().getTime(),
- bomCode: 'N' + new Date().getTime(),
- })
- // 逐项创建BOMItem
- for (let i = 0; i < this.newResult.length; i++) {
- await addBomItem({
- bomId: bom.data.bomId,
- attrKey: this.newResult[i].attrKey,
- attrValue: this.newResult[i].attrValue,
- })
- }
- // 创建一个新的物料,使用原有物料的信息, code使用时间戳
- const { rawMaterialId, rawMaterialCode, ...rawMaterial } = (await getRawMaterial(this.info.rawMaterialId)).data
- const newMaterial = await addRawMaterial({
- ...rawMaterial,
- bomId: bom.data.bomId,
- rawMaterialCode: 'N' + new Date().getTime(),
- })
- // 修改采购单据赋值为新的物料
- await updatePurchasePlanDetail({
- detailId: this.info.detailId,
- rawMaterialId: newMaterial.data.rawMaterialId,
- })
- }
- }
-
- this.loading = false;
-
// 变更状态
this.active = 3;
this.$emit('confirm')
},
+ handleMergerConfirm(res) {
+ if (res.status === 'start') {
+ this.loading = true;
+ this.loadingText = '正在处理产品BOM';
+ } else if (res.status === 'success') {
+ this.loading = false;
+ this.active = 3;
+ this.$emit('confirm')
+ } else if (res.status === 'error') {
+ this.loading = false;
+ this.$modal.msgError('质保单处理失败');
+ }
+ },
async loadingMethod(key, fn) {
this.loading = true;
this.loadingText = so[key].loading;