Commit 0f1dfefb authored by liwei's avatar liwei

ocr识别

parent 3bf78e93
...@@ -15,3 +15,27 @@ export function aliOcr(businessId) { ...@@ -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) { ...@@ -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 @@ ...@@ -117,8 +117,8 @@
<el-col :span="6"> <!-- 每列占 12 格(总 24 格) --> <el-col :span="6"> <!-- 每列占 12 格(总 24 格) -->
<el-form-item label="请选择订单类型"> <el-form-item label="请选择订单类型">
<el-select v-model="subType" placeholder="小类型" @change="selectHandler"> <el-select v-model="subType" placeholder="小类型" @change="selectHandler">
<el-option label="a1" value="a1" /> <el-option label="type1" value="1" />
<el-option label="a2" value="a2" /> <el-option label="type2" value="2" />
</el-select> </el-select>
</el-form-item> </el-form-item>
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
<el-upload <el-upload
action="http://localhost:8089/common2oss/upload?temp=temp" action="http://localhost:8089/common2oss/upload?temp=temp"
multiple multiple
:on-success="saveBusId" :on-success="updateFileSuccess"
> >
<i class="el-icon-upload" /> <i class="el-icon-upload" />
<el-button type="primary">点击上传</el-button> <el-button type="primary">点击上传</el-button>
...@@ -139,23 +139,23 @@ ...@@ -139,23 +139,23 @@
</el-col> </el-col>
<el-col :span="6"> <el-col :span="6">
<el-form-item label="识别结果"> <el-form-item label="识别结果">
<el-select v-model="wrSelected" placeholder="识别结果"> <el-select v-model="ocrResult" placeholder="识别结果" disabled>
<el-option <el-option
v-for="val in wrVal" v-for="val in ocrResultSelect"
:key="val.value" :key="val.value"
:value="val.value" :value="val.value"
:label="val.label" :label="val.label"
/> />
</el-select>
</el-select></el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
</el-form> </el-form>
<div v-if="showSelectedTableA1"> <div v-if="showModelType1">
<ACheckOrders :ocr-array="ocrArray" /> <ACheckOrders :ocr-array="ocrArray" @afterUpdate="getAfterUpdateData"/>
</div> </div>
<div v-if="showSelectedTableA2"> <div v-if="showModelType2">
<BCheckOrders :ocr-array="ocrArray" /> <BCheckOrders :ocr-array="ocrArray" />
</div> </div>
<div <div
...@@ -176,7 +176,7 @@ ...@@ -176,7 +176,7 @@
</template> </template>
<script> <script>
import { queryList, aliOcr } from '@/api/sample/chCheckOrder' import { queryList, getOcrData, addOcrData } from '@/api/sample/chCheckOrder'
import { parseTime } from '@/utils' import { parseTime } from '@/utils'
import BCheckOrders from '@/views/sample/chCheckOrder/CheckOrders/BCheckOrders.vue' import BCheckOrders from '@/views/sample/chCheckOrder/CheckOrders/BCheckOrders.vue'
import ACheckOrders from '@/views/sample/chCheckOrder/CheckOrders/ACheckOrders.vue' import ACheckOrders from '@/views/sample/chCheckOrder/CheckOrders/ACheckOrders.vue'
...@@ -189,6 +189,7 @@ export default { ...@@ -189,6 +189,7 @@ export default {
title: '', title: '',
open: false, open: false,
form: {}, form: {},
// 校验规则
rules: { rules: {
file: [ file: [
{ required: true, message: '请输入文件', trigger: 'blur' }, { required: true, message: '请输入文件', trigger: 'blur' },
...@@ -223,25 +224,27 @@ export default { ...@@ -223,25 +224,27 @@ export default {
basicinfoMationList: [], basicinfoMationList: [],
showPdfTable01: false, showPdfTable01: false,
showPdfTable02: false, showPdfTable02: false,
// 大类型
type: '', type: '',
// 小类型
subType: '', subType: '',
// table列表数据
showSelectedTableA1: false, tableData: [],
showSelectedTableA2: false, // 模版1展示
wrVal: [ showModelType1: false,
{ // 模版2展示
value: 1, showModelType2: false,
label: '正确' // 总识别结果下拉框
}, ocrResultSelect: [
{ { value: '1', label: '正确' },
value: 0, { value: '0', label: '错误' }
label: '错误'
}
], ],
wrSelected: '', // 总识别结果
businessId: '', ocrResult: '',
ocrArray: '', // 上传的图片id
ocrData: [] pictureId: '',
// 扫描得到的数据
ocrArray: ''
} }
}, },
/** 路由离开前存储筛选条件*/ /** 路由离开前存储筛选条件*/
...@@ -264,6 +267,25 @@ export default { ...@@ -264,6 +267,25 @@ export default {
this.getList() this.getList()
}, },
methods: { 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) { focusNextInput(form) {
this.$nextTick(() => { this.$nextTick(() => {
...@@ -308,36 +330,47 @@ export default { ...@@ -308,36 +330,47 @@ export default {
}, },
// 提交 // 提交
submitForm() { submitForm() {
this.$refs.form.validate((valid) => { const params = {
if (valid) { chType: '1',
// 校验通过,提交表单或进行其他操作 chStype: '1',
if (this.form.businessId !== undefined) { chResult: '成功',
updataInfo(this.form).then(res => { chAlter: '1',
if (res.code === 200) { chFile: 129,
this.open = false chjson: JSON.stringify(this.tableData)
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)
}
})
}
} }
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() { getList() {
...@@ -373,8 +406,9 @@ export default { ...@@ -373,8 +406,9 @@ export default {
handleExport() { handleExport() {
}, },
// 开始识别
startOcr() { startOcr() {
this.ocr(this.businessId) this.ocr(this.pictureId)
}, },
cancel() { cancel() {
this.open = false this.open = false
...@@ -391,36 +425,41 @@ export default { ...@@ -391,36 +425,41 @@ export default {
} }
this.$refs.form.clearValidate() this.$refs.form.clearValidate()
}, },
handleChange(value) { // 上传图片成功后的回调方法
switch (value[0]) { updateFileSuccess(res) {
case 'a': this.pictureId = res.data.businessId
this.showPdfTable01 = true
this.showPdfTable02 = false
break
case 'b':
this.showPdfTable01 = false
this.showPdfTable02 = true
break
}
}, },
saveBusId(res) { // 获取识别数据
this.businessId = res.data.businessId ocr(pictureId) {
}, const params = {
ocr(businessId) { businessId: 129,
aliOcr(businessId).then(res => { type: 1
this.ocrArray = res.data.chJson }
// console.log(ocrArray) 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) { selectHandler(val) {
switch (val) { switch (val) {
case 'a1': case '1':
this.showSelectedTableA1 = true this.showModelType1 = true
this.showSelectedTableA2 = false this.showModelType2 = false
break break
case 'a2': case '2':
this.showSelectedTableA2 = true this.showModelType2 = true
this.showSelectedTableA1 = false this.showModelType1 = false
break 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