Commit 8348ee8e authored by Zachary's avatar Zachary

add:新增对识别内容的处理,处理后的数据放入表格

parent fba06273
import request from '@/utils/request'
// 查询列表
export function queryList(params) {
return request({
url: '/chcheckorder/queryChCheckOrderByPagination',
method: 'get',
params
})
}
export function aliOcr(businessId) {
return request({
url: '/chcheckorder/aliOcr/' + businessId,
method: 'get'
})
}
export const HEAD_ROWS_OF_TABLE1 = [
'No.',
'规格值(MM)',
'测量仪器',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'10',
'MAX',
'MIN',
'结果'
]
export const HEAD_VOLUMES_OF_TABLE1 = [
'外观',
'A',
'B',
'C',
'E',
'M',
'L',
'N',
'F',
'W1',
'W2',
'重量',
'弯曲尺寸',
'浇口强度N(1)',
'浇口强度N(2)',
'浇口强度N(3)',
'浇口强度N(4)'
]
<template>
<el-form>
<el-table
:data="tableData"
style="width: 100%"
:cell-style="cellStyle"
>
<el-table-column
prop="NO"
label="规格(项目)MM"
fixed
/>
<el-table-column
prop="difference"
label="区分"
fixed
/>
<el-table-column
prop="measureInstrument"
label="测定器"
fixed
/>
<el-table-column
prop="one"
label="1"
width="130"
>
<template slot-scope="scope">
<el-input
v-model="scope.row.one"
:class="{ 'error-border': scope.row.error }"
@change="(value)=>ocrVerify(value,scope.row,scope.row.index,scope.column.index)"
/>
<!-- 错误提示 -->
<div v-if="scope.row.error" class="error-message">
{{ scope.row.error }}
</div>
</template>
</el-table-column>
<el-table-column
prop="two"
label="2"
width="130"
>
<template slot-scope="scope">
<el-input
v-model="scope.row.two"
:class="{ 'error-border': scope.row.error }"
@change="(value)=>ocrVerify(value,scope.row,scope.$index,scope.column.property)"
/>
<!-- 错误提示 -->
<div v-if="scope.row.error" class="error-message">
{{ scope.row.error }}
</div>
</template>
</el-table-column>
<el-table-column
prop="three"
label="3"
width="130"
>
<template slot-scope="scope">
<el-input
v-model="scope.row.three"
:class="{ 'error-border': scope.row.error }"
@change="(value)=>ocrVerify(value,scope.row,scope.$index,scope.column.property)"
/>
<!-- 错误提示 -->
<div v-if="scope.row.error" class="error-message">
{{ scope.row.error }}
</div>
</template>
</el-table-column>
<el-table-column
prop="four"
label="4"
width="130"
>
<template slot-scope="scope">
<el-input
v-model="scope.row.four"
:class="{ 'error-border': scope.row.error }"
@change="(value)=>ocrVerify(value,scope.row,scope.$index,scope.column.property)"
/>
<!-- 错误提示 -->
<div v-if="scope.row.error" class="error-message">
{{ scope.row.error }}
</div>
</template>
</el-table-column>
<el-table-column
prop="five"
label="5"
width="130"
>
<template slot-scope="scope">
<el-input
v-model="scope.row.five"
:class="{ 'error-border': scope.row.error }"
@change="(value)=>ocrVerify(value,scope.row,scope.$index,scope.column.property)"
/>
<!-- 错误提示 -->
<div v-if="scope.row.error" class="error-message">
{{ scope.row.error }}
</div>
</template>
</el-table-column>
<el-table-column
prop="six"
label="6"
width="130"
>
<template slot-scope="scope">
<el-input
v-model="scope.row.six"
:class="{ 'error-border': scope.row.error }"
@change="(value)=>ocrVerify(value,scope.row,scope.$index,scope.column.property)"
/>
<!-- 错误提示 -->
<div v-if="scope.row.error" class="error-message">
{{ scope.row.error }}
</div>
</template>
</el-table-column>
<el-table-column
prop="seven"
label="7"
width="130"
>
<template slot-scope="scope">
<el-input
v-model="scope.row.seven"
:class="{ 'error-border': scope.row.error }"
@change="(value)=>ocrVerify(value,scope.row,scope.$index,scope.column.property)"
/>
<!-- 错误提示 -->
<div v-if="scope.row.error" class="error-message">
{{ scope.row.error }}
</div>
</template>
</el-table-column>
<el-table-column
prop="eight"
label="8"
width="130"
>
<template slot-scope="scope">
<el-input
v-model="scope.row.eight"
:class="{ 'error-border': scope.row.error }"
@change="(value)=>ocrVerify(value,scope.row,scope.$index,scope.column.property)"
/>
<!-- 错误提示 -->
<div v-if="scope.row.error" class="error-message">
{{ scope.row.error }}
</div>
</template>
</el-table-column>
<el-table-column
prop="nine"
label="9"
width="130"
>
<template slot-scope="scope">
<el-input
v-model="scope.row.nine"
:class="{ 'error-border': scope.row.error }"
@change="(value)=>ocrVerify(value,scope.row,scope.$index,scope.column.property)"
/>
<!-- 错误提示 -->
<div v-if="scope.row.error" class="error-message">
{{ scope.row.error }}
</div>
</template>
</el-table-column>
<el-table-column
prop="ten"
label="10"
width="130"
>
<template slot-scope="scope">
<el-input
v-model="scope.row.ten"
:class="{ 'error-border': scope.row.error }"
@change="(value)=>ocrVerify(value,scope.row,scope.$index,scope.column.property)"
/>
<!-- 错误提示 -->
<div v-if="scope.row.error" class="error-message">
{{ scope.row.error }}
</div>
</template>
</el-table-column>
<el-table-column
prop="X"
label="X"
width="130"
>
<template slot-scope="scope">
<el-input
v-model="scope.row.X"
:class="{ 'error-border': scope.row.error }"
@change="(value)=>ocrVerify(value,scope.row,scope.$index,scope.column.property)"
/>
<!-- 错误提示 -->
<div v-if="scope.row.error" class="error-message">
{{ scope.row.error }}
</div>
</template>
</el-table-column>
<el-table-column
prop="R"
label="R"
width="130"
>
<template slot-scope="scope">
<el-input
v-model="scope.row.R"
:class="{ 'error-border': scope.row.error }"
@change="(value)=>ocrVerify(value,scope.row,scope.$index,scope.column.property)"
/>
<!-- 错误提示 -->
<div v-if="scope.row.error" class="error-message">
{{ scope.row.error }}
</div>
</template>
</el-table-column>
<el-table-column
prop="res"
label="结果"
width="130"
fixed="right"
>
<template slot-scope="scope">
<el-input
v-model="scope.row.res"
:class="{ 'error-border': scope.row.error }"
@change="(value)=>ocrVerify(value,scope.row,scope.$index,scope.column)"
/>
<!-- 错误提示 -->
<div v-if="scope.row.error" class="error-message">
{{ scope.row.error }}
</div>
</template>
</el-table-column>
</el-table>
</el-form>
</template>
<script>
import Schema from 'async-validator'
export default {
props: {
ocrArray: {
default: '',
type: String
}
},
data() {
return {
dataTemplate: [{
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
X: undefined,
R: undefined,
res: undefined
}],
tableData: [
{
NO: 'A',
difference: '天津威晟',
measureInstrument: '卡尺',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
X: undefined,
R: undefined,
res: undefined,
error: '',
col: 0
},
{
NO: 'B',
difference: '天津威晟',
measureInstrument: '卡尺',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
X: undefined,
R: undefined,
res: undefined,
error: '',
col: 1
},
{
NO: 'C',
difference: '天津威晟',
measureInstrument: '卡尺',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
X: undefined,
R: undefined,
res: undefined,
error: '',
col: 2
},
{
NO: 'F',
difference: '天津威晟',
measureInstrument: '卡尺',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
X: undefined,
R: undefined,
res: undefined,
error: '',
col: 3
},
{
NO: 'E',
difference: '天津威晟',
measureInstrument: '卡尺',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
X: undefined,
R: undefined,
res: undefined,
error: '',
col: 4
},
{
NO: 'M',
difference: '天津威晟',
measureInstrument: '卡尺',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
X: undefined,
R: undefined,
res: undefined,
error: '',
col: 5
},
{
NO: 'M',
difference: '天津威晟',
measureInstrument: '卡尺',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
X: undefined,
R: undefined,
res: undefined,
error: '',
col: 6
},
{
NO: 'L',
difference: '天津威晟',
measureInstrument: '卡尺',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
X: undefined,
R: undefined,
res: undefined,
error: '',
col: 7
},
{
NO: 'N',
difference: '天津威晟',
measureInstrument: '卡尺',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
X: undefined,
R: undefined,
res: undefined,
error: '',
col: 8
},
{
NO: 'W1',
difference: '天津威晟',
measureInstrument: '卡尺',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
X: undefined,
R: undefined,
res: undefined,
error: '',
col: 9
},
{
NO: '重量',
difference: '天津威晟',
measureInstrument: '电子称',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
X: undefined,
R: undefined,
res: undefined,
error: '',
col: 10
},
{
NO: 'xxx',
difference: '天津威晟',
measureInstrument: '目测',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
X: undefined,
R: undefined,
res: undefined,
error: '',
col: 11
},
{
NO: '边缘强度',
difference: '天津威晟',
measureInstrument: '目测',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
X: undefined,
R: undefined,
res: undefined,
error: '',
col: 12
},
{
NO: '弯曲变形',
difference: '天津威晟',
measureInstrument: '钢板尺',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
X: undefined,
R: undefined,
res: undefined,
error: '',
col: 13
},
{
NO: '破坏强度',
difference: '天津威晟',
measureInstrument: '拉力计',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
X: undefined,
R: undefined,
res: undefined,
error: '',
col: 14
}
]
}
},
watch: {
ocrArray: {
handler(newValue, oldValue) {
// console.log('ocrArray11111111111111', this.ocrArray)
const ocrResArr = JSON.parse(this.ocrArray)
// 去除已识别的行数
ocrResArr.splice(0, 1)
// 识别的数组与对象的映射
const keys = Object.keys(this.dataTemplate[0])
const res = ocrResArr.map(subArr => {
const obj = {}
keys.forEach((key, index) => {
// 从索引 3 开始取值(即忽略前三个元素)
const value = subArr[index + 4]
obj[key] = value !== undefined ? value : undefined
})
return obj
})
this.ocrRender(res)
},
deep: true
}
},
methods: {
ocrRender(res) {
for (let i = 0; i < res.length; i++) {
this.tableData[i].one = res[i].one
this.tableData[i].two = res[i].two
this.tableData[i].three = res[i].three
this.tableData[i].four = res[i].four
this.tableData[i].five = res[i].five
this.tableData[i].six = res[i].six
this.tableData[i].seven = res[i].seven
this.tableData[i].eight = res[i].eight
this.tableData[i].nine = res[i].nine
this.tableData[i].ten = res[i].ten
this.tableData[i].X = res[i].X
this.tableData[i].R = res[i].R
this.tableData[i].res = res[i].res
}
},
ocrVerify(value, rowDatas, row, col) {
console.log('#####', row, '????', col)
// 定义校验规则
const schema = new Schema({
one: {
type: 'string',
required: true,
message: '字段不能为空'
}
// 其他规则...
})
// 执行校验
schema.validate({ one: value }, (errors) => {
console.log(value)
if (errors) {
console.log(errors)
// 将错误信息更新到当前行
rowDatas.error = errors[0].message
} else {
rowDatas.error = '' // 校验通过,清空错误
}
})
},
cellStyle({ row, column, rowIndex, columnIndex }) {
row.row = rowIndex
column.index = columnIndex
/* if (row.error.length > 0 && column.property && column) {
return { 'border': '2px red solid' }
}*/
}
}
}
</script>
<style scoped lang="scss">
</style>
<template>
<el-table
:data="tableData"
>
<el-table-column
prop="NO"
label="NO."
/>
<el-table-column
prop="specVal"
label="规格值(MM)"
/>
<el-table-column
prop="measureInstrument"
label="测量仪器"
/>
<el-table-column
prop="one"
label="1"
width="130"
>
<template slot-scope="scope">
<el-input v-model="scope.row.one" />
</template>
</el-table-column>
<el-table-column
prop="two"
label="2"
width="130"
>
<template slot-scope="scope">
<el-input v-model="scope.row.two" />
</template>
</el-table-column>
<el-table-column
prop="three"
label="3"
width="130"
>
<template slot-scope="scope">
<el-input v-model="scope.row.three" />
</template>
</el-table-column>
<el-table-column
prop="four"
label="4"
width="130"
>
<template slot-scope="scope">
<el-input v-model="scope.row.four" />
</template>
</el-table-column>
<el-table-column
prop="five"
label="5"
width="130"
>
<template slot-scope="scope">
<el-input v-model="scope.row.five" />
</template>
</el-table-column>
<el-table-column
prop="six"
label="6"
width="130"
>
<template slot-scope="scope">
<el-input v-model="scope.row.six" />
</template>
</el-table-column>
<el-table-column
prop="seven"
label="7"
width="130"
>
<template slot-scope="scope">
<el-input v-model="scope.row.seven" />
</template>
</el-table-column>
<el-table-column
prop="eight"
label="8"
width="130"
>
<template slot-scope="scope">
<el-input v-model="scope.row.eight" />
</template>
</el-table-column>
<el-table-column
prop="nine"
label="9"
width="130"
>
<template slot-scope="scope">
<el-input v-model="scope.row.nine" />
</template>
</el-table-column>
<el-table-column
prop="ten"
label="10"
width="130"
>
<template slot-scope="scope">
<el-input v-model="scope.row.ten" />
</template>
</el-table-column>
<el-table-column
prop="MAX"
label="MAX"
width="130"
>
<template slot-scope="scope">
<el-input v-model="scope.row.MAX" />
</template>
</el-table-column>
<el-table-column
prop="MIN"
label="MIN"
width="130"
>
<template slot-scope="scope">
<el-input v-model="scope.row.MIN" />
</template>
</el-table-column>
<el-table-column
prop="res"
label="结果"
width="130"
>
<template slot-scope="scope">
<el-input v-model="scope.row.res" />
</template>
</el-table-column>
</el-table>
</template>
<script>
export default {
props: {
ocrArray: {
default: '',
type: String
}
},
data() {
return {
dataTemplate: [{
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
MAX: undefined,
MIN: undefined,
res: undefined
}],
tableData: [
{
NO: '外观',
specVal: '见仕样书',
measureInstrument: '目测',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
MAX: undefined,
MIN: undefined,
res: undefined
},
{
NO: 'A',
specVal: '180+0-1.5',
measureInstrument: '卡尺',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
MAX: undefined,
MIN: undefined,
res: undefined
},
{
NO: 'B',
specVal: '60+1-0',
measureInstrument: '卡尺',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
MAX: undefined,
MIN: undefined,
res: undefined
},
{
NO: 'C',
specVal: '13+0.2',
measureInstrument: '卡尺',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
MAX: undefined,
MIN: undefined,
res: undefined
},
{
NO: 'E',
specVal: '10+0.2',
measureInstrument: '卡尺',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
MAX: undefined,
MIN: undefined,
res: undefined
},
{
NO: 'M',
specVal: '3.0+0.2',
measureInstrument: '卡尺',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
MAX: undefined,
MIN: undefined,
res: undefined
},
{
NO: 'L',
specVal: '4.0+0.5',
measureInstrument: '卡尺',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
MAX: undefined,
MIN: undefined,
res: undefined
},
{
NO: 'W1',
specVal: '9+1.0-0',
measureInstrument: '卡尺',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
MAX: undefined,
MIN: undefined,
res: undefined
},
{
NO: 'W2',
specVal: '11.5+0.5',
measureInstrument: '卡尺',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
MAX: undefined,
MIN: undefined,
res: undefined
},
{
NO: '重量',
specVal: '28+2g',
measureInstrument: '电子称',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
MAX: undefined,
MIN: undefined,
res: undefined
},
{
NO: '弯曲尺寸',
specVal: '7-8mm',
measureInstrument: '钢板尺',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
MAX: undefined,
MIN: undefined,
res: undefined
},
{
NO: '浇口强度(1)',
specVal: '>30N',
measureInstrument: '拉力器',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
MAX: undefined,
MIN: undefined,
res: undefined
},
{
NO: '浇口强度(2)',
specVal: '>30N',
measureInstrument: '拉力器',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
MAX: undefined,
MIN: undefined,
res: undefined
},
{
NO: '浇口强度(3)',
specVal: '>30N',
measureInstrument: '拉力器',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
MAX: undefined,
MIN: undefined,
res: undefined
},
{
NO: '浇口强度(4)',
specVal: '>30N',
measureInstrument: '拉力器',
one: undefined,
two: undefined,
three: undefined,
four: undefined,
five: undefined,
six: undefined,
seven: undefined,
eight: undefined,
nine: undefined,
ten: undefined,
MAX: undefined,
MIN: undefined,
res: undefined
}
]
}
},
watch: {
ocrArray: {
handler(newValue, oldValue) {
// console.log('ocrArray11111111111111', this.ocrArray)
const ocrResArr = JSON.parse(this.ocrArray)
ocrResArr.splice(0, 1)
const keys = Object.keys(this.dataTemplate[0])
const res = ocrResArr.map(subArr => {
const obj = {}
keys.forEach((key, index) => {
// 从索引 3 开始取值(即忽略前三个元素)
const value = subArr[index + 3]
obj[key] = value !== undefined ? value : undefined
})
return obj
})
for (let i = 0; i < res.length; i++) {
this.tableData[i].one = res[i].one
this.tableData[i].two = res[i].two
this.tableData[i].three = res[i].three
this.tableData[i].four = res[i].four
this.tableData[i].five = res[i].five
this.tableData[i].six = res[i].six
this.tableData[i].seven = res[i].seven
this.tableData[i].eight = res[i].eight
this.tableData[i].nine = res[i].nine
this.tableData[i].ten = res[i].ten
this.tableData[i].MAX = res[i].MAX
this.tableData[i].MIN = res[i].MIN
this.tableData[i].res = res[i].res
}
},
deep: true
}
}
}
</script>
<style scoped lang="scss">
</style>
<template>
<div class="basicInformation-module app-container">
<!-- 搜索区 -->
<el-form ref="queryForm" style="padding: 0 0 0 10px" :model="queryParams" :inline="true">
<el-form-item label="pn" prop="pn">
<el-input
v-model="queryParams.pn"
placeholder="pdf"
clearable
:maxlength="30"
size="small"
style="width: 150px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="dname" prop="dname">
<el-input
v-model="queryParams.dname"
placeholder="请输入名称"
clearable
size="small"
style="width: 150px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="dno" prop="dno">
<el-input
v-model="queryParams.dno"
placeholder="请输入dno"
clearable
size="small"
style="width: 150px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" style="padding: 8px 7px;" icon="el-icon-search" size="small" @click="handleQuery">查询</el-button>
<el-button style="padding: 8px 7px;" icon="el-icon-refresh" size="small" @click="resetQuery">重置</el-button>
</el-form-item>
<div style="float: right">
<el-form-item>
<el-button
type="primary"
style="padding: 8px 7px;"
size="small"
icon="el-icon-plus"
@click="handleAdd"
>新增</el-button>
</el-form-item>
</div>
</el-form>
<!-- 分割线 -->
<div class="placeholder" />
<!-- 表单区 -->
<div style="padding:5px 10px">
<div class="mb12 font-small-bold">订单检查</div>
<el-table v-loading="loading" border :data="basicinfoMationList">
<el-table-column type="index" label="序号" width="50" />
<el-table-column label="chCode" prop="chCode" :show-overflow-tooltip="true">
<template slot-scope="scope">
{{ scope.row.chCode || '-' }}
</template>
</el-table-column>
<el-table-column label="操作人" prop="createName" :show-overflow-tooltip="true" width="200px">
<template slot-scope="scope">
{{ scope.row.createName || '-' }}
</template>
</el-table-column>
<el-table-column label="操作时间" prop="updateDate" :show-overflow-tooltip="true" width="170px">
<template slot-scope="scope">
{{ parseTime(scope.row.updateDate, '{y}-{m}-{d} {h}:{i}') || '-' }}
</template>
</el-table-column>
<el-table-column label="操作" width="150px">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
style="color: #49cec9"
@click="handleUpdate(scope.row)"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
<!-- 分页区-->
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.page"
:limit.sync="queryParams.rows"
@pagination="getList"
/>
<!-- 新增修改弹出 -->
<el-dialog :title="title" :visible.sync="open" width="95%" append-to-body :close-on-click-modal="false" @close="cancel">
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="120px">
<el-row :gutter="20">
<el-col :span="6">
<el-form-item label="请选择订单类型">
<el-select v-model="type" placeholder="大类型">
<el-option label="a" value="a" />
<el-option label="b" value="b" />
</el-select>
</el-form-item>
</el-col>
<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-select>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="上传pdf文件">
<el-upload
action="http://localhost:8089/common2oss/upload?temp=temp"
multiple
:on-success="saveBusId"
>
<i class="el-icon-upload" />
<el-button type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">只能上传pdf文件,且不超过500kb</div>
</el-upload>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="识别结果">
<el-select v-model="wrSelected" placeholder="识别结果">
<el-option
v-for="val in wrVal"
:key="val.value"
:value="val.value"
:label="val.label"
/>
</el-select></el-form-item>
</el-col>
</el-row>
</el-form>
<div v-if="showSelectedTableA1">
<ACheckOrders :ocr-array="ocrArray" />
</div>
<div v-if="showSelectedTableA2">
<BCheckOrders :ocr-array="ocrArray" />
</div>
<div
slot="footer"
class="dialog-footer"
style="
display: flex;
justify-content: center;
gap: 10px;
padding-top: 12px;"
>
<el-button type="primary" @click="startOcr">开始识别</el-button>
<el-button type="primary" @click="submitForm"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { queryList, aliOcr } 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'
export default {
name: 'Index',
components: { ACheckOrders, BCheckOrders },
data() {
return {
title: '',
open: false,
form: {},
rules: {
file: [
{ required: true, message: '请输入文件', trigger: 'blur' },
{ pattern: /^[^`~!#$^&*()=|{}':;'\[\].<>/?~!#¥……&*()——|{}【】‘;:·@”“'。,、?]+$/, // 使用正则表达式匹配不含特殊字符的内容
message: '不能含有特殊字符',
trigger: 'blur'
}
],
dname: [
{ required: true, message: '请输入dname', trigger: 'blur' },
{ pattern: /^[^`~!#$^&*()=|{}':;'\[\].<>/?~!#¥……&*()——|{}【】‘;:·@”“'。,、?]+$/, // 使用正则表达式匹配不含特殊字符的内容
message: '不能含有特殊字符',
trigger: 'blur'
}
],
dno: [
{ required: true, message: '请输入dno', trigger: 'blur' },
{ pattern: /^[^`~!#$^&*()=|{}':;'\[\].<>/?~!#¥……&*()——|{}【】‘;:·@”“'。,、?]+$/, // 使用正则表达式匹配不含特殊字符的内容
message: '不能含有特殊字符',
trigger: 'blur'
}
]
},
total: 0,
loading: false,
// 查询参数
queryParams: {
page: 1,
rows: 10
},
// 表格绑定数据
basicinfoMationList: [],
showPdfTable01: false,
showPdfTable02: false,
type: '',
subType: '',
showSelectedTableA1: false,
showSelectedTableA2: false,
wrVal: [
{
value: 1,
label: '正确'
},
{
value: 0,
label: '错误'
}
],
wrSelected: '',
businessId: '',
ocrArray: '',
ocrData: []
}
},
/** 路由离开前存储筛选条件*/
beforeRouteLeave(to, from, next) {
this.$store.dispatch('searchSave/searchParamsSet', {
path: this.$route.path,
param: {
...this.queryParams
}
})
next()
},
created() {
if (this.$store.getters.searchParams[this.$route.path]) {
const { searchParams } = this.$store.getters
const { path } = this.$route
const param = JSON.parse(searchParams[path]) // 保留着的查询条件
this.queryParams = { ...param }
}
this.getList()
},
methods: {
// 回车跳转下一个输入框
focusNextInput(form) {
this.$nextTick(() => {
this.$refs[form].$refs.input.focus()
})
},
// 回车到下一个输入框方法
handelTab(i, e) {
const that = this
if (that.$refs['input' + i]) {
that.$nextTick(() => {
e.target.blur()
const index = i + 1
that.$refs['input' + index].focus()
})
}
},
// 删除
handleDelete(row) {
const id = row.businessId
this.$confirm('是否确认操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(res => {
deleteLogical(id).then(res => {
if (res.code === 200) {
this.$message.success('操作成功')
this.getList()
}
})
})
},
// 修改
handleUpdate(row) {
const id = row.businessId
getDetailById(id).then(res => {
this.form = res.data
this.open = true
this.title = '修改样品种类'
})
},
// 提交
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)
}
})
}
}
})
},
// 初始化获取数据
getList() {
this.loading = true
queryList(this.queryParams).then(res => {
res.rows.updateDate = parseTime(res.rows.updateDate, '{y}-{m}-{d}')
this.total = res.total
this.basicinfoMationList = res.rows
this.loading = false
})
},
// 查询
handleQuery() {
this.queryParams.page = 1
this.getList()
},
// 重置
resetQuery() {
this.queryParams = {
page: 1,
rows: 10,
pn: '',
dname: '',
dno: ''
}
this.getList()
},
handleAdd() {
this.open = true
this.title = '新增识别订单'
},
handleExport() {
},
startOcr() {
this.ocr(this.businessId)
},
cancel() {
this.open = false
this.reFrom()
},
// 清空表单
reFrom() {
this.form = {
businessId: undefined,
pn: '',
dname: '',
dno: '',
remarks: ''
}
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
}
},
saveBusId(res) {
this.businessId = res.data.businessId
},
ocr(businessId) {
aliOcr(businessId).then(res => {
this.ocrArray = res.data.chJson
// console.log(ocrArray)
})
},
selectHandler(val) {
switch (val) {
case 'a1':
this.showSelectedTableA1 = true
this.showSelectedTableA2 = false
break
case 'a2':
this.showSelectedTableA2 = true
this.showSelectedTableA1 = false
break
}
}
}
}
</script>
<style lang="scss" scoped>
.basicInformation-module{
font-size: 18px;
padding: 0;
.placeholder{
height: 1.3vh;
background-color: #F4F4F4;
margin-bottom: 10px
}
}
</style>
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