Merge remote-tracking branch 'origin/0.8.X' into 0.8.X
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import request from '@/utils/request'
|
||||
import axios from 'axios'
|
||||
|
||||
/**
|
||||
* 调用ocr, 直接识别图像中的文字
|
||||
@@ -41,4 +42,18 @@ export function recognizePdfText({ pdfUrl }) {
|
||||
method: 'post',
|
||||
data: { pdfUrl },
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试外网连接
|
||||
*/
|
||||
export function testNet() {
|
||||
// ping一下百度
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.get('https://api.thecatapi.com/v1/images/search?limit=1').then(res => {
|
||||
resolve(true)
|
||||
}).catch(err => {
|
||||
resolve(false)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
@click.stop="openKeyListDialog"></i>
|
||||
<div style="margin-bottom: 10px; display: flex; align-items: center; justify-content: center;">
|
||||
<span style="font-weight: bold; font-size: 16px;">OCR识别</span>
|
||||
<el-tooltip content="通过OCR自动识别PDF质保单内容" placement="top">
|
||||
<el-tooltip content="通过OCR自动识别质保单内容, 仅支持pdf格式" placement="top">
|
||||
<i class="el-icon-question" style="margin-left: 6px; color: #409EFF; cursor: pointer;"></i>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
@@ -37,7 +37,7 @@
|
||||
<div style="border: 1px solid #ccc; border-radius: 10px; padding: 20px; cursor: pointer; text-align: center;">
|
||||
<div style="margin-bottom: 10px; display: flex; align-items: center; justify-content: center;">
|
||||
<span style="font-weight: bold; font-size: 16px;">大模型识别</span>
|
||||
<el-tooltip content="通过AI大模型识别图片质保单内容" placement="top">
|
||||
<el-tooltip content="通过AI大模型识别质保单内容, 仅支持图片格式" placement="top">
|
||||
<i class="el-icon-question" style="margin-left: 6px; color: #409EFF; cursor: pointer;"></i>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
@@ -91,7 +91,7 @@
|
||||
import FileUpload from '@/components/FileUpload'
|
||||
import { listByIds } from '@/api/system/oss'
|
||||
import { updatePurchasePlanDetail } from '@/api/wms/purchasePlanDetail'
|
||||
import { recognizeText, recognizeBomByModel, recognizePdfText } from '@/api/system/ocr'
|
||||
import { recognizeText, recognizeBomByModel, recognizePdfText, testNet } from '@/api/system/ocr'
|
||||
import { listBomItem } from '@/api/wms/bomItem'
|
||||
import { getRawMaterial } from '@/api/wms/rawMaterial'
|
||||
import Merger from './merger.vue'
|
||||
@@ -189,7 +189,14 @@ const so = {
|
||||
model: {
|
||||
loading: '等待大模型识别结果',
|
||||
handler: async (vm) => {
|
||||
// 外网连通测试,如果失败给出提示请打开外网
|
||||
const flag = await testNet()
|
||||
if (!flag) {
|
||||
vm.$modal.msgError('请打开外网连接以使用大模型');
|
||||
return;
|
||||
}
|
||||
const res = await recognizeBomByModel({ imageUrl: vm.file.url })
|
||||
|
||||
vm.newResult = res.data.attributes;
|
||||
vm.$modal.msgSuccess("识别成功");
|
||||
return res;
|
||||
|
||||
Reference in New Issue
Block a user