Commit 0f1dfefb authored by liwei's avatar liwei

ocr识别

parent 3bf78e93
......@@ -15,3 +15,27 @@ export function aliOcr(businessId) {
})
}
// 获取ocr扫描数据
export function getOcrData(params) {
return request({
url: '/chcheckorder/submit',
method: 'post',
data: params,
headers: {
'Content-Type': 'application/json;charset=UTF-8'
}
})
}
// 新增扫描的数据
export function addOcrData(params) {
return request({
url: '/chcheckorder/add',
method: 'post',
data: params,
headers: {
'Content-Type': 'application/json;charset=UTF-8'
}
})
}
......@@ -105,3 +105,11 @@ export function importExcel(data) {
})
}
// 8.根据字典类型查询字典数据信息
export function getDict(dictType) {
return request({
url: '/system/dict/data/type/' + dictType,
method: 'get'
})
}
......@@ -117,8 +117,8 @@
<el-col :span="6"> <!-- 每列占 12 格(总 24 格) -->
<el-form-item label="请选择订单类型">
<el-select v-model="subType" placeholder="小类型" @change="selectHandler">
<el-option label="a1" value="a1" />
<el-option label="a2" value="a2" />
<el-option label="type1" value="1" />
<el-option label="type2" value="2" />
</el-select>
</el-form-item>
......@@ -129,7 +129,7 @@
<el-upload
action="http://localhost:8089/common2oss/upload?temp=temp"
multiple
:on-success="saveBusId"
:on-success="updateFileSuccess"
>
<i class="el-icon-upload" />
<el-button type="primary">点击上传</el-button>
......@@ -139,23 +139,23 @@
</el-col>
<el-col :span="6">
<el-form-item label="识别结果">
<el-select v-model="wrSelected" placeholder="识别结果">
<el-select v-model="ocrResult" placeholder="识别结果" disabled>
<el-option
v-for="val in wrVal"
v-for="val in ocrResultSelect"
:key="val.value"
:value="val.value"
:label="val.label"
/>
</el-select></el-form-item>
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div v-if="showSelectedTableA1">
<ACheckOrders :ocr-array="ocrArray" />
<div v-if="showModelType1">
<ACheckOrders :ocr-array="ocrArray" @afterUpdate="getAfterUpdateData"/>
</div>
<div v-if="showSelectedTableA2">
<div v-if="showModelType2">
<BCheckOrders :ocr-array="ocrArray" />
</div>
<div
......@@ -176,7 +176,7 @@
</template>
<script>
import { queryList, aliOcr } from '@/api/sample/chCheckOrder'
import { queryList, getOcrData, addOcrData } from '@/api/sample/chCheckOrder'
import { parseTime } from '@/utils'
import BCheckOrders from '@/views/sample/chCheckOrder/CheckOrders/BCheckOrders.vue'
import ACheckOrders from '@/views/sample/chCheckOrder/CheckOrders/ACheckOrders.vue'
......@@ -189,6 +189,7 @@ export default {
title: '',
open: false,
form: {},
// 校验规则
rules: {
file: [
{ required: true, message: '请输入文件', trigger: 'blur' },
......@@ -223,25 +224,27 @@ export default {
basicinfoMationList: [],
showPdfTable01: false,
showPdfTable02: false,
// 大类型
type: '',
// 小类型
subType: '',
showSelectedTableA1: false,
showSelectedTableA2: false,
wrVal: [
{
value: 1,
label: '正确'
},
{
value: 0,
label: '错误'
}
// table列表数据
tableData: [],
// 模版1展示
showModelType1: false,
// 模版2展示
showModelType2: false,
// 总识别结果下拉框
ocrResultSelect: [
{ value: '1', label: '正确' },
{ value: '0', label: '错误' }
],
wrSelected: '',
businessId: '',
ocrArray: '',
ocrData: []
// 总识别结果
ocrResult: '',
// 上传的图片id
pictureId: '',
// 扫描得到的数据
ocrArray: ''
}
},
/** 路由离开前存储筛选条件*/
......@@ -264,6 +267,25 @@ export default {
this.getList()
},
methods: {
// 获取修改后的整个table列表数据
getAfterUpdateData(value) {
// 遍历value 取最后一个值,如果有一个NO则为错误
// for (let i = 0; i < value.length; i++) {
// if (value[i][value[i].length - 1] === 'NO') {
// this.ocrResult = '0'
// } else {
// this.ocrResult = '1'
// }
// }
this.tableData = JSON.parse(JSON.stringify(value))
// 遍历value
for (let i = 0; i < this.tableData.length; i++) {
const keys = Object.keys(this.tableData[i]) // 获取对象的所有键
for (let j = 0; j < Math.min(4, keys.length); j++) {
delete this.tableData[i][keys[j]] // 删除前四个键值对
}
}
},
// 回车跳转下一个输入框
focusNextInput(form) {
this.$nextTick(() => {
......@@ -308,36 +330,47 @@ export default {
},
// 提交
submitForm() {
this.$refs.form.validate((valid) => {
if (valid) {
// 校验通过,提交表单或进行其他操作
if (this.form.businessId !== undefined) {
updataInfo(this.form).then(res => {
if (res.code === 200) {
this.open = false
this.$message.success('操作成功')
this.getList()
this.reFrom()
this.queryParams.page = 1
} else if (res.code === null) {
this.$message.error(res.message)
}
})
} else {
add(this.form).then(res => {
if (res.code === 200) {
this.open = false
this.$message.success('操作成功')
this.getList()
this.reFrom()
this.queryParams.page = 1
} else if (res.code === null) {
this.$message.error(res.message)
}
})
}
const params = {
chType: '1',
chStype: '1',
chResult: '成功',
chAlter: '1',
chFile: 129,
chjson: JSON.stringify(this.tableData)
}
addOcrData(params).then(res => {
})
// this.$refs.form.validate((valid) => {
// if (valid) {
// // 校验通过,提交表单或进行其他操作
// if (this.form.businessId !== undefined) {
// updataInfo(this.form).then(res => {
// if (res.code === 200) {
// this.open = false
// this.$message.success('操作成功')
// this.getList()
// this.reFrom()
// this.queryParams.page = 1
// } else if (res.code === null) {
// this.$message.error(res.message)
// }
// })
// } else {
// add(this.form).then(res => {
// if (res.code === 200) {
// this.open = false
// this.$message.success('操作成功')
// this.getList()
// this.reFrom()
// this.queryParams.page = 1
// } else if (res.code === null) {
// this.$message.error(res.message)
// }
// })
// }
// }
// })
},
// 初始化获取数据
getList() {
......@@ -373,8 +406,9 @@ export default {
handleExport() {
},
// 开始识别
startOcr() {
this.ocr(this.businessId)
this.ocr(this.pictureId)
},
cancel() {
this.open = false
......@@ -391,36 +425,41 @@ export default {
}
this.$refs.form.clearValidate()
},
handleChange(value) {
switch (value[0]) {
case 'a':
this.showPdfTable01 = true
this.showPdfTable02 = false
break
case 'b':
this.showPdfTable01 = false
this.showPdfTable02 = true
break
}
// 上传图片成功后的回调方法
updateFileSuccess(res) {
this.pictureId = res.data.businessId
},
saveBusId(res) {
this.businessId = res.data.businessId
},
ocr(businessId) {
aliOcr(businessId).then(res => {
this.ocrArray = res.data.chJson
// console.log(ocrArray)
// 获取识别数据
ocr(pictureId) {
const params = {
businessId: 129,
type: 1
}
getOcrData(params).then(res => {
this.ocrArray = res.data
// 遍历this.ocrArray 将最后一项全部改为OK for循环
for (let i = 0; i < this.ocrArray.length; i++) {
if (this.ocrArray[i].length > 0) {
if (i !== this.ocrArray.length - 1) {
// 不是最后一行数据
this.ocrArray[i][this.ocrArray[i].length - 1] = 'OK'// 修改最后一个元素
} else {
// 最后一行数据
this.ocrArray[i][0] = 'OK'// 修改最后一个元素
}
}
}
})
},
selectHandler(val) {
switch (val) {
case 'a1':
this.showSelectedTableA1 = true
this.showSelectedTableA2 = false
case '1':
this.showModelType1 = true
this.showModelType2 = false
break
case 'a2':
this.showSelectedTableA2 = true
this.showSelectedTableA1 = false
case '2':
this.showModelType2 = true
this.showModelType1 = false
break
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment