ocr修改

This commit is contained in:
caoyang
2022-03-24 16:00:04 +08:00
parent 207450165f
commit b4441bec2b
4 changed files with 96 additions and 35 deletions
+87 -30
View File
@@ -169,15 +169,33 @@
<span class="title-text-text">{{item.db_field_txt}}</span> <span class="title-text-text">{{item.db_field_txt}}</span>
</div> </div>
<a-form-model-item class="itemModel" :prop="item.db_field_name"> <a-form-model-item class="itemModel" :prop="item.db_field_name">
<a-button v-if="formInline[item.db_field_name] === 'null' || formInline[item.db_field_name] === '' || <a-upload
formInline[item.db_field_name] == null" type="primary" class="button-text" name="file"
@click="clickButtonToUpload(item.db_field_name)"> :accept='accept'
{{ (formInline[item.db_field_name] === 'null' || formInline[item.db_field_name] === '' || :list-type="listType"
formInline[item.db_field_name] == null) ? $t('clickUpload') : $t('viewUploadedFiles') :file-list="myfileList"
}} :multiple="false"
</a-button> :action="uploadAction+'?state='+state"
<span v-if="!(formInline[item.db_field_name] === 'null' || formInline[item.db_field_name] === '' || :headers="headers"
formInline[item.db_field_name] == null)">{{fileName[item.db_field_name]}}</span> :before-upload="beforeUpload"
@change="handleChange"
>
<a-button>
<a-icon type="upload"/>
{{$t('UploadFile')}}
</a-button>
</a-upload>
<!-- <a-button v-if="formInline[item.db_field_name] === 'null' || formInline[item.db_field_name] === '' ||-->
<!-- formInline[item.db_field_name] == null" type="primary" class="button-text"-->
<!-- @click="clickButtonToUpload(item.db_field_name)">-->
<!-- {{ (formInline[item.db_field_name] === 'null' || formInline[item.db_field_name] === '' ||-->
<!-- formInline[item.db_field_name] == null) ? $t('clickUpload') : $t('viewUploadedFiles')-->
<!-- }}-->
<!-- </a-button>-->
<!-- <span v-if="!(formInline[item.db_field_name] === 'null' || formInline[item.db_field_name] === '' ||-->
<!-- formInline[item.db_field_name] == null)">{{fileName[item.db_field_name]}}</span>-->
</a-form-model-item> </a-form-model-item>
</div> </div>
</a-col> </a-col>
@@ -212,23 +230,25 @@
</a-col> </a-col>
</div> </div>
</a-row> </a-row>
<uploadFile ref="uploadFile" :accept="accept" :disabled="disabled" @uploadSuccess="uploadSuccess"></uploadFile> <!-- <uploadFile ref="uploadFile" :accept="accept" :disabled="disabled" @uploadSuccess="uploadSuccess"></uploadFile>-->
</a-form-model> </a-form-model>
</a-spin> </a-spin>
</template> </template>
<script> <script>
import uploadFile from '@/components/OcrUpload/index' // import uploadFile from '@/components/OcrUpload/index'
import PersonnelSelection from '@/components/PersonnelSelection/index' import PersonnelSelection from '@/components/PersonnelSelection/index'
import Standardselection from '@/components/Standardselection/index' import Standardselection from '@/components/Standardselection/index'
import { getAction, postAction } from '@/api/manage' import { getAction, postAction } from '@/api/manage'
import eventBUs from '../../common/event' import eventBUs from '../../common/event'
import moment from 'moment' import moment from 'moment'
import Vue from 'vue'
import { ACCESS_TOKEN } from '@/store/mutation-types'
export default { export default {
name: 'ocrAddForm', name: 'ocrAddForm',
components: { components: {
uploadFile, // uploadFile,
Standardselection, Standardselection,
PersonnelSelection PersonnelSelection
}, },
@@ -244,14 +264,17 @@
disabled: { disabled: {
type: Boolean, type: Boolean,
default: false default: false
},
accept:{
type:String,
} }
}, },
data() { data() {
return { return {
uploadAction: window._CONFIG['domianURL'] + '/sys/common/upload',
listType: 'text',
accept: 'application/pdf',
state: undefined,
formInline: {}, formInline: {},
myfileList: [],
headers: {},
isFormInline: false, isFormInline: false,
rules: {}, rules: {},
labelCol: { labelCol: {
@@ -267,16 +290,50 @@
validatorRules: {}, validatorRules: {},
confirmLoading: false, confirmLoading: false,
uploadName: '', uploadName: '',
fileName:{}, fileName: {}
} }
}, },
mounted() { mounted() {
const token = Vue.ls.get(ACCESS_TOKEN)
this.headers = { 'X-Access-Token': token }
this.getForm() this.getForm()
}, },
methods: { methods: {
handleChange(info) {
if (info.file.status !== 'uploading') {
// console.log(info.file, info.fileList)
}
if (info.file.status === 'done') {
console.log('info', info)
this.fileList = []
this.myfileList = info.fileList
this.formInline.attId = info.file.response.result.id
this.$message.success(`${info.file.name}上传成功`)
}else if (info.file.status === 'error') {
this.$message.error(`${info.file.name}上传失败`)
} else if (info.file.status === 'uploading') {
this.myfileList = info.fileList
// console.log(info.file, info.fileList)
}
},
beforeUpload(file, fileList) {
if (this.myfileList && this.myfileList.length >= 1) {
this.$message.warning('只能上传一个文件')
return false
} else {
// let thisFileType = this.thisFileType.replace(/\s+/g, "");
if (file.type == this.accept) {
this.fileTypeSatus = true
this.$message.destroy()
// 207M.doc文件大小超出100MB限制, 请压缩或降低文件质量!
this.errorMessage = file.name + '文件大小超出100MB限制, 请压缩或降低文件质量!'
}
}
},
sumber() { sumber() {
console.log('vilidate',this.formInline) console.log('vilidate', this.formInline)
this.$refs.ruleForm1.validate(valid => { this.$refs.ruleForm1.validate(valid => {
if (valid) { if (valid) {
let url = '' let url = ''
@@ -307,28 +364,28 @@
uploadSuccess(data) { uploadSuccess(data) {
// console.log(data) // console.log(data)
let attIdList = [] let attIdList = []
let attNameList=[] let attNameList = []
if(data && data.length>0){ if (data && data.length > 0) {
data.map(item => { data.map(item => {
attIdList.push(item.id || data.name) attIdList.push(item.id || data.name)
attNameList.push(item.fileName) attNameList.push(item.fileName)
}) })
/** 赋值给当前对应的表单文件 */ /** 赋值给当前对应的表单文件 */
this.formInline[this.uploadName] = attIdList.join(',') this.formInline[this.uploadName] = attIdList.join(',')
this.fileName[this.uploadName]=attNameList.join(',') this.fileName[this.uploadName] = attNameList.join(',')
this.formInline = { ...this.formInline } this.formInline = { ...this.formInline }
this.$refs.uploadFile.visible = false this.$refs.uploadFile.visible = false
// console.log('form',this.formInline) // console.log('form',this.formInline)
}else{ } else {
this.formInline[this.uploadName]='' this.formInline[this.uploadName] = ''
this.fileName[this.uploadName]='' this.fileName[this.uploadName] = ''
this.formInline = { ...this.formInline } this.formInline = { ...this.formInline }
// console.log('form',this.formInline) // console.log('form',this.formInline)
} }
}, },
//关闭上传弹框 //关闭上传弹框
closeUpload(){ closeUpload() {
// this.fileVisible = false // this.fileVisible = false
}, },
handleInput(value) { handleInput(value) {
@@ -349,13 +406,13 @@
message: res.db_field_txt + '不能为空', message: res.db_field_txt + '不能为空',
trigger: 'blur' trigger: 'blur'
}) })
if(res.db_field_name=='standNumber'){ if (res.db_field_name == 'standNumber') {
rule.push( rule.push(
{ min:1, max: 200, message: this.$t('cantExeed')+'200'+this.$t('characters'), trigger: 'blur' }, { min: 1, max: 200, message: this.$t('cantExeed') + '200' + this.$t('characters'), trigger: 'blur' }
) )
}else if(res.db_field_name=='standName'){ } else if (res.db_field_name == 'standName') {
rule.push( rule.push(
{ min:1, max: 200, message: this.$t('cantExeed')+'200'+this.$t('characters'), trigger: 'blur' }, { min: 1, max: 200, message: this.$t('cantExeed') + '200' + this.$t('characters'), trigger: 'blur' }
) )
} }
@@ -384,7 +441,7 @@
message: res.db_field_txt + '不能为空', message: res.db_field_txt + '不能为空',
trigger: 'change' trigger: 'change'
}) })
}else if (res.field_show_type === '7') { } else if (res.field_show_type === '7') {
rule.push({ rule.push({
required: true, required: true,
message: res.db_field_txt + '不能为空', message: res.db_field_txt + '不能为空',
@@ -429,7 +486,7 @@
} }
}) })
}, },
add(){ add() {
this.formInline = {} this.formInline = {}
} }
} }
@@ -287,6 +287,7 @@
}, },
//处理列表中的点击事件 //处理列表中的点击事件
detailClick(item) { detailClick(item) {
console.log('item.',item)
let newUrl = this.$router.resolve({ let newUrl = this.$router.resolve({
path: '/docManage/library/detail', path: '/docManage/library/detail',
query: item query: item
@@ -32,7 +32,6 @@
ref="fileForm" ref="fileForm"
@addFormClick="addFormClick" @addFormClick="addFormClick"
:flag="'2'" :flag="'2'"
:accept="accept"
v-if="fileVisible" v-if="fileVisible"
:url="url"> :url="url">
</addForm> </addForm>
@@ -78,7 +77,7 @@
</div> </div>
<doc-table v-if="drawVisible" :drawVisible="drawVisible" :drawTableSorce="drawTableSorce" @visible="docVisible" @exportVisible="exportVisible"></doc-table> <doc-table v-if="drawVisible" :drawVisible="drawVisible" :drawTableSorce="drawTableSorce" @visible="docVisible" @exportVisible="exportVisible"></doc-table>
<ocr-upload ref="uploadFile1" :disabled="disabled" :accept="accept" :listType='listType' @uploadSuccess="uploadSuccess"></ocr-upload> <!-- <ocr-upload ref="uploadFile1" :disabled="disabled" :accept="accept" :listType='listType' @uploadSuccess="uploadSuccess"></ocr-upload>-->
</a-card> </a-card>
</div> </div>
@@ -90,7 +89,7 @@
import TableData from '@/components/OcrTable/index' import TableData from '@/components/OcrTable/index'
import AddForm from '@/components/OcrAddForm/index' import AddForm from '@/components/OcrAddForm/index'
import DocTable from './modules/DocTable' import DocTable from './modules/DocTable'
import OcrUpload from '@/components/OcrUpload/index' // import OcrUpload from '@/components/OcrUpload/index'
import store from '@/store/' import store from '@/store/'
import { ACCESS_TOKEN } from '@/store/mutation-types' import { ACCESS_TOKEN } from '@/store/mutation-types'
import Vue from 'vue' import Vue from 'vue'
@@ -103,7 +102,7 @@
search, search,
TableData, TableData,
AddForm, AddForm,
OcrUpload, // OcrUpload,
DocTable DocTable
}, },
data(){ data(){
@@ -278,7 +278,11 @@
let newUrl = this.$router.resolve({ let newUrl = this.$router.resolve({
path: '/docManage/library/detail', path: '/docManage/library/detail',
query: { id:item.documentId } query: {
id:item.documentId ,
serial_number:item.serialNumber,
title:item.title
}
}) })
window.open(newUrl.href, '_blank') window.open(newUrl.href, '_blank')
} }