质保单处理
This commit is contained in:
@@ -1,5 +1,11 @@
|
|||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用ocr, 直接识别图像中的文字
|
||||||
|
*
|
||||||
|
* @param {string} imgUrl 图片url
|
||||||
|
* @returns {Promise<string>} 识别结果
|
||||||
|
*/
|
||||||
export function recognizeText({ imgUrl }) {
|
export function recognizeText({ imgUrl }) {
|
||||||
return request({
|
return request({
|
||||||
url: '/wms/purchasePlan/recognizeText',
|
url: '/wms/purchasePlan/recognizeText',
|
||||||
@@ -7,3 +13,18 @@ export function recognizeText({ imgUrl }) {
|
|||||||
data: { imgUrl }
|
data: { imgUrl }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用通义千问模型, 识别图片中的文字
|
||||||
|
*
|
||||||
|
* @param {string} imageUrl 图片url
|
||||||
|
* @returns {Promise<string>} 识别结果
|
||||||
|
*/
|
||||||
|
export function recognizeBomByModel({ imageUrl }) {
|
||||||
|
return request({
|
||||||
|
url: '/wms/imageRecognition/recognize',
|
||||||
|
method: 'post',
|
||||||
|
data: { imageUrl },
|
||||||
|
timeout: 100000
|
||||||
|
})
|
||||||
|
}
|
||||||
BIN
klp-ui/src/assets/images/model.png
Normal file
BIN
klp-ui/src/assets/images/model.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 107 KiB |
BIN
klp-ui/src/assets/images/ocr.png
Normal file
BIN
klp-ui/src/assets/images/ocr.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 284 KiB |
@@ -422,6 +422,7 @@ export default {
|
|||||||
// });
|
// });
|
||||||
},
|
},
|
||||||
handleUploadQualityCertificateConfirm() {
|
handleUploadQualityCertificateConfirm() {
|
||||||
|
this.uploadQualityCertificateOpen = false;
|
||||||
this.handleStatusChange(this.uploadQualityCertificateInfo, EPurchaseDetailStatus.FINISH, '采购完成');
|
this.handleStatusChange(this.uploadQualityCertificateInfo, EPurchaseDetailStatus.FINISH, '采购完成');
|
||||||
},
|
},
|
||||||
/** 创建入库单按钮操作 */
|
/** 创建入库单按钮操作 */
|
||||||
|
|||||||
@@ -5,7 +5,9 @@
|
|||||||
<el-step style="cursor: pointer;" @click.native="active = 1" title="质保单处理" icon="el-icon-edit" />
|
<el-step style="cursor: pointer;" @click.native="active = 1" title="质保单处理" icon="el-icon-edit" />
|
||||||
<el-step style="cursor: pointer;" @click.native="active = 2" title="质保单审核" icon="el-icon-check" />
|
<el-step style="cursor: pointer;" @click.native="active = 2" title="质保单审核" icon="el-icon-check" />
|
||||||
</el-steps>
|
</el-steps>
|
||||||
<file-upload v-if="active === 0" v-model="uploadQualityCertificateForm.qualityCertificate" />
|
<div v-if="active === 0" style="padding: 30px;">
|
||||||
|
<file-upload v-model="uploadQualityCertificateForm.qualityCertificate" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<div v-if="active === 1">
|
<div v-if="active === 1">
|
||||||
<el-row>
|
<el-row>
|
||||||
@@ -18,12 +20,14 @@
|
|||||||
<!-- 卡片按钮,点击后调用ocr -->
|
<!-- 卡片按钮,点击后调用ocr -->
|
||||||
<div style="height: 300px; border: 1px solid #ccc; border-radius: 10px; padding: 20px; cursor: pointer;" @click="handleOcr">
|
<div style="height: 300px; border: 1px solid #ccc; border-radius: 10px; padding: 20px; cursor: pointer;" @click="handleOcr">
|
||||||
OCR识别
|
OCR识别
|
||||||
|
<img src="@/assets/images/ocr.png" alt="ocr" style="width: 100%; height: 100%;" />
|
||||||
</div>
|
</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<!-- 卡片按钮,点击后调用大模型 -->
|
<!-- 卡片按钮,点击后调用大模型 -->
|
||||||
<div style="height: 300px; border: 1px solid #ccc; border-radius: 10px; padding: 20px; cursor: pointer;" @click="handleModel">
|
<div style="height: 300px; border: 1px solid #ccc; border-radius: 10px; padding: 20px; cursor: pointer;" @click="handleModel">
|
||||||
大模型识别
|
大模型识别
|
||||||
|
<img src="@/assets/images/model.png" alt="model" style="width: 100%; height: 100%;" />
|
||||||
</div>
|
</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@@ -31,13 +35,22 @@
|
|||||||
|
|
||||||
<div v-if="active === 2">
|
<div v-if="active === 2">
|
||||||
<div v-if="resultDiff">
|
<div v-if="resultDiff">
|
||||||
<el-alert title="质保单处理结果与历史质保单不一致,请选择处理方式" type="warning" />
|
<el-row>
|
||||||
|
<el-alert title="质保单处理结果与历史质保单不一致,请选择处理方式" type="warning" />
|
||||||
|
</el-row>
|
||||||
|
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
历史质保单
|
<el-table :data="oldResult" style="width: 100%">
|
||||||
|
<el-table-column prop="attrKey" label="属性名称" />
|
||||||
|
<el-table-column prop="attrValue" label="属性值" />
|
||||||
|
</el-table>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
新质保单
|
<el-table :data="newResult" style="width: 100%">
|
||||||
|
<el-table-column prop="attrKey" label="属性名称" />
|
||||||
|
<el-table-column prop="attrValue" label="属性值" />
|
||||||
|
</el-table>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row>
|
<el-row>
|
||||||
@@ -52,14 +65,17 @@
|
|||||||
<el-button type="primary" @click="handleConfirm">确认</el-button>
|
<el-button type="primary" @click="handleConfirm">确认</el-button>
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
|
<el-row>
|
||||||
|
<el-alert title="请核对识别结果是否正确" type="success" />
|
||||||
|
</el-row>
|
||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
质保单内容
|
质保单内容
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<div>
|
<div>
|
||||||
<img style="width: 100%; height: 100%;" :src="file.url" alt="">
|
<img style="width: 100%; height: 100%;" :src="file.url" alt="">
|
||||||
</div>
|
</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-button type="primary" @click="handleConfirm">确认</el-button>
|
<el-button type="primary" @click="handleConfirm">确认</el-button>
|
||||||
@@ -72,14 +88,16 @@
|
|||||||
import FileUpload from '@/components/FileUpload'
|
import FileUpload from '@/components/FileUpload'
|
||||||
import { listByIds } from '@/api/system/oss'
|
import { listByIds } from '@/api/system/oss'
|
||||||
import { updatePurchasePlanDetail } from '@/api/wms/purchasePlanDetail'
|
import { updatePurchasePlanDetail } from '@/api/wms/purchasePlanDetail'
|
||||||
import { recognizeText } from '@/api/system/ocr'
|
import { recognizeText, recognizeBomByModel } from '@/api/system/ocr'
|
||||||
import { listBomItem } from '@/api/wms/bomItem'
|
import { listBomItem, addBomItem } from '@/api/wms/bomItem'
|
||||||
|
import { addBom } from '@/api/wms/bom'
|
||||||
|
import { updateRawMaterial, addRawMaterial, getRawMaterial } from '@/api/wms/rawMaterial'
|
||||||
|
|
||||||
const so = {
|
const so = {
|
||||||
annex: {
|
annex: {
|
||||||
loading: '正在保存质保单',
|
loading: '正在保存质保单',
|
||||||
handler: (vm, newVal) => {
|
handler: async (vm, newVal) => {
|
||||||
return updatePurchasePlanDetail({
|
return await updatePurchasePlanDetail({
|
||||||
...vm.info,
|
...vm.info,
|
||||||
annex: newVal
|
annex: newVal
|
||||||
})
|
})
|
||||||
@@ -87,36 +105,43 @@ const so = {
|
|||||||
},
|
},
|
||||||
ocr: {
|
ocr: {
|
||||||
loading: '等待ocr识别结果',
|
loading: '等待ocr识别结果',
|
||||||
handler: (vm) => {
|
handler: async (vm) => {
|
||||||
console.log(vm.file, 'vm.file');
|
const text = await recognizeText({ imgUrl: vm.file.url })
|
||||||
return recognizeText({ imgUrl: vm.file.url }).then(res => {
|
return text;
|
||||||
console.log(res, 'res');
|
|
||||||
return res;
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
model: {
|
model: {
|
||||||
loading: '等待大模型识别结果',
|
loading: '等待大模型识别结果',
|
||||||
|
handler: async (vm) => {
|
||||||
|
const res = await recognizeBomByModel({ imageUrl: vm.file.url })
|
||||||
|
vm.newResult = res.data.structuredResult.attributes;
|
||||||
|
vm.$modal.msgSuccess(res.data.structuredResult.summary);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
bom: {
|
bom: {
|
||||||
loading: '正在处理BOM'
|
loading: '正在处理BOM'
|
||||||
},
|
},
|
||||||
oss: {
|
oss: {
|
||||||
loading: '正在获取质保单',
|
loading: '正在获取质保单',
|
||||||
handler: (vm, newVal) => {
|
handler: async (vm, newVal) => {
|
||||||
return listByIds(newVal).then(res => {
|
const res = await listByIds(newVal)
|
||||||
vm.file = res.data[0];
|
vm.file = res.data[0];
|
||||||
vm.active = 1;
|
vm.active = 1;
|
||||||
return res.data[0];
|
return res.data[0];
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
old: {
|
old: {
|
||||||
loading: '正在获取历史质保单',
|
loading: '正在获取历史质保单',
|
||||||
handler: (vm, newVal) => {
|
handler: async (vm, newVal) => {
|
||||||
return listBomItem({
|
// 查询对应的bomId
|
||||||
itemId: vm.info.rawMaterialId,
|
const res = await getRawMaterial(vm.info.rawMaterialId)
|
||||||
|
const bomId = res.data.bomId;
|
||||||
|
const bomItemRes = await listBomItem({
|
||||||
|
bomId,
|
||||||
})
|
})
|
||||||
|
vm.oldResult = bomItemRes.rows;
|
||||||
|
return bomItemRes.rows;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -165,17 +190,29 @@ export default {
|
|||||||
file: undefined,
|
file: undefined,
|
||||||
loading: false,
|
loading: false,
|
||||||
loadingText: '加载中...',
|
loadingText: '加载中...',
|
||||||
resultDiff: true
|
resultDiff: true,
|
||||||
|
oldResult: [],
|
||||||
|
newResult: [],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleOcr() {
|
handleOcr() {
|
||||||
this.loadingMethod('ocr', (res) => {
|
this.loadingMethod('ocr', (res) => {
|
||||||
console.log(res, 'res');
|
this.loadingMethod('old').then(() => {
|
||||||
|
this.handleCompareResult()
|
||||||
|
this.active = 2;
|
||||||
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleModel() {
|
handleModel() {
|
||||||
this.active = 2;
|
|
||||||
|
this.loadingMethod('model', async (res) => {
|
||||||
|
await this.loadingMethod('old')
|
||||||
|
console.log(this);
|
||||||
|
this.handleCompareResult()
|
||||||
|
this.active = 2;
|
||||||
|
})
|
||||||
|
|
||||||
},
|
},
|
||||||
async handleConfirm() {
|
async handleConfirm() {
|
||||||
// 确认内容,如果质保单内容与历史质保单内容不一致,则提示用户选择处理方式
|
// 确认内容,如果质保单内容与历史质保单内容不一致,则提示用户选择处理方式
|
||||||
@@ -185,29 +222,95 @@ export default {
|
|||||||
this.$modal.msgError('请选择处理方式');
|
this.$modal.msgError('请选择处理方式');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.loading = true;
|
||||||
|
this.loadingText = '正在处理产品BOM';
|
||||||
if (this.uploadQualityCertificateForm.qualityCertificateType === 1) {
|
if (this.uploadQualityCertificateForm.qualityCertificateType === 1) {
|
||||||
|
// 什么都不需要做,直接完成就可以
|
||||||
console.log('使用旧的质保单');
|
console.log('使用旧的质保单');
|
||||||
} else if (this.uploadQualityCertificateForm.qualityCertificateType === 2) {
|
} 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('使用新的质保单');
|
console.log('使用新的质保单');
|
||||||
} else if (this.uploadQualityCertificateForm.qualityCertificateType === 3) {
|
} else if (this.uploadQualityCertificateForm.qualityCertificateType === 3) {
|
||||||
console.log('创建新物料');
|
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.active = 3;
|
||||||
this.$emit('confirm')
|
this.$emit('confirm')
|
||||||
},
|
},
|
||||||
loadingMethod(key, fn) {
|
async loadingMethod(key, fn) {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.loadingText = so[key].loading;
|
this.loadingText = so[key].loading;
|
||||||
so[key].handler(this, this.uploadQualityCertificateForm.qualityCertificate).then((res) => {
|
try {
|
||||||
fn && fn(res)
|
const res = await so[key].handler(this, this.uploadQualityCertificateForm.qualityCertificate)
|
||||||
this.loading = false;
|
fn && await fn(res)
|
||||||
}).catch(() => {
|
return res;
|
||||||
this.loading = false;
|
} catch {
|
||||||
this.$modal.msgError('操作失败');
|
this.$modal.msgError('操作失败');
|
||||||
});
|
} finally {
|
||||||
|
this.loading = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 比较新旧result是否一致
|
||||||
|
handleCompareResult() {
|
||||||
|
// 先检查新旧result是否一致
|
||||||
|
if (this.oldResult.length !== this.newResult.length) {
|
||||||
|
this.resultDiff = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 比较新旧result是否一致
|
||||||
|
for (let i = 0; i < this.oldResult.length; i++) {
|
||||||
|
if (this.oldResult[i].attrKey !== this.newResult[i].attrKey || this.oldResult[i].attrValue !== this.newResult[i].attrValue) {
|
||||||
|
this.resultDiff = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.resultDiff = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user