Files
laws_weilai/jero-web/src/views/documentManage/ocr/index.vue
T
2022-02-17 13:47:22 +08:00

508 lines
15 KiB
Java

<template>
<div class="ocr">
<a-card>
<div class="table-page-search-wrapper">
<!-- <search :flag="'1'" :url="url"/>-->
<div class="ocr-search-header">
<a-form layout="inline" @keyup.enter.native="searchQuery(queryParams)">
<a-row :gutter="24">
<a-col :md="6" :sm="12">
<a-form-item :label="'编号'">
<j-input :placeholder="'请输入编号'" v-model="queryParams.standNumber"></j-input>
</a-form-item>
</a-col>
<a-col :md="6" :sm="12">
<a-form-item :label="'标题'">
<j-input :placeholder="'请输入标题'" v-model="queryParams.standName"></j-input>
</a-form-item>
</a-col>
<a-col :md="6" :sm="8">
<a-form-item :label="'转换结果'">
<a-select v-model="queryParams.transformation" :placeholder="$t('pleaseSelect')">
<a-select-option :value="item.value" v-for="(item) in transOptions">{{item.label}}</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :md="6" :sm="8">
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
<a-button type="primary" @click="searchQuery" icon="search">{{$t('query')}}</a-button>
<a-button @click="searchReset" icon="reload" style="margin-left: 8px">清空</a-button>
</span>
</a-col>
</a-row>
</a-form>
</div>
</div>
<div class="table-operator">
<a-button @click="handleUpload()" type="primary">上传</a-button>
<a-button @click="handleFileExport()" type="primary">调取已入库文件</a-button>
<a-button @click="handleDel()" type="primary">批量删除</a-button>
</div>
<!-- 上传弹框-->
<a-modal
class="show-content"
title="上传文件"
:visible="fileVisible"
:confirm-loading="confirmLoading"
@ok="handleOk"
@cancel="handleCancel"
v-if="fileVisible"
>
<a-form-model
class="tag-content"
ref="fileForm"
:model="form"
:rules="rules"
:label-col="labelCol"
:wrapper-col="wrapperCol"
>
<a-form-model-item ref="file" label="文件" prop="file">
<a-button type="primary" class="button-text"
@click="fileUpload()">
{{ (file === 'null' || file === '' ||
file == null) ? '点击上传' : '查看已上传文件'
}}
</a-button>
<!-- <a-button @click="fileUpload" type="primary">点击上传</a-button>-->
</a-form-model-item>
<a-form-model-item ref="standNumber" label="编号" prop="standNumber">
<a-input
v-model="form.standNumber"
placeholder="请输入编号"
/>
</a-form-model-item>
<a-form-model-item ref="standName" label="名称" prop="standName">
<a-input
v-model="form.standName"
placeholder="请输入名称"
/>
</a-form-model-item>
<a-form-model-item label="文本状态" prop="fileType">
<j-dict-select-tag type="list" v-model="form.fileType" dictCode="file_type" placeholder="请选择文本状态" />
</a-form-model-item>
</a-form-model>
</a-modal>
<!-- 同步弹框-->
<a-modal
class="show-content"
title="同步至文档库"
v-if="toVisible"
:visible="toVisible"
:confirm-loading="confirmLoading"
@ok="handleOkTo"
@cancel="handleCancelTo"
>
<p style="text-align: center">该文件未进行校验,确定要同步至文档库?</p>
</a-modal>
<!-- 校核弹框-->
<a-modal
class="show-content"
title="校核"
v-if="checkVisible"
:visible="checkVisible"
:confirm-loading="confirmLoading"
@ok="handleOkCheck"
@cancel="handleCancelCheck"
>
<p style="text-align: center">确定对该文件未进行校验?</p>
</a-modal>
<div class="table-detail">
<a-table bordered :data-source="dataSource" :columns="columns" :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }" class="tag-con-table" :pagination="false" >
<a slot="fileName" slot-scope="text, record" @click="fileDetail(record)">{{ text }}</a>
<template slot="action" slot-scope="text, record">
<a class="action action-syn" href="javascript:;" @click="actionSynchron(record)">同步至文档库</a>
<a class="action action-check" href="javascript:;" @click="actionCheck(record)">校核</a>
<a class="action action-down" href="javascript:;" @click="actionDown(record)">下载</a>
<a-popconfirm
v-if="dataSource.length"
title="Sure to delete?"
@confirm="() => actionDelete(record)"
>
<a class="action action-delete" href="javascript:;">删除</a>
</a-popconfirm>
</template>
</a-table>
<div class="page" v-if="dataSource.length > 0">
<a-pagination
:show-total="total => ` ${total} `"
show-quick-jumper
show-size-changer
:page-size.sync="queryParams.pageSize"
:total="total"
@change="onChangePage"
@showSizeChange="SizeChange"
/>
</div>
</div>
<addForm
ref="addFormRef"
:url="url"
:flag="'1'"
/>
<frameAssembly
:url="url"
ref="frameAssemblyRef"
/>
<doc-table v-if="drawVisible" :drawVisible="drawVisible" :drawTableSorce="drawTableSorce" @visible="docVisible"></doc-table>
<ocr-upload ref="uploadFile" :disabled="disabled" @uploadSuccess="uploadSuccess"></ocr-upload>
<!-- <uploadFile ref="uploadFile" @uploadSuccess="uploadSuccess"></uploadFile>-->
</a-card>
</div>
</template>
<script>
import { getAction, postAction, deleteAction } from '@/api/manage'
import search from '@/components/search/index'
import tableData from '@/components/tableDate/index'
import addForm from './modules/addForm'
import docTable from './modules/docTable'
import frameAssembly from '@/components/frameAssembly/index'
import ocrUpload from '@/components/ocrUpload/index'
// import uploadFile from '@/components/uploadFile/file'
export default {
name: 'ocr',
components:{
search,
tableData,
addForm,
frameAssembly,
ocrUpload,
docTable
},
data(){
return{
pageSize:10,
labelCol: { span:4 },
wrapperCol: { span: 18 },
disabled:false,
drawVisible:false,
toVisible:false, //同步弹框
checkVisible:false, //校核弹框
file:'',
form:{}, //表单数据
rules:{
file:[
{ required: true, message: '请选择文件', trigger: 'blur' },
],
standNumber:[
{ required: true, message: '请输入编号', trigger: 'blur' },
],
standName:[
{ required: true, message: '请输入名称', trigger: 'blur' },
],
fileType:[
{ required: true, message: '请选择文本状态', trigger: 'blur' },
]
},
url: {
seachList: 'document/bussDocumentLibraryEO/queryCondition', //搜索字段
tableList: 'document/bussDocumentLibraryEO/queryPageInfo', //表格数据
// getAddForm: 'document/bussDocumentLibraryEO/getAddForm', // 表单的字段
// addInfo: 'document/bussDocumentLibraryEO/addInfo', //新增
// updateInfo: 'document/bussDocumentLibraryEO/updateInfo', //编辑
// getDocumentInfo: 'document/bussDocumentLibraryEO/getDocumentInfoById', //查看
// deleteBatch: 'document/bussDocumentLibraryEO/deleteBatch' //删除
},
queryParams:{}, //搜索条件
transOptions:[
{
value:1,
label:'转换中',
},
{
value:2,
label:'转换完成',
},
{
value:3,
label:'转换失败',
}
],
//列表数据
dataSource:[],
columns: [
{
title:'标准编号',
key: 'standNumber',
align:"center",
dataIndex: 'standNumber'
},
{
title:'标准名称',
key: 'standName',
align:"center",
dataIndex: 'standName'
},
{
title:'文本状态',
key: 'fileType_dictText',
align:"center",
dataIndex: 'fileType_dictText'
},
{
title:'文件名称',
key: 'fileName',
align:"center",
dataIndex: 'fileName',
slots: { title: 'customTitle' },
scopedSlots: { customRender: 'fileName' },
},
{
title:'转换结果',
key: 'resultContent',
align:"center",
dataIndex: 'resultContent'
},
{
title:'转换时间',
key: 'createTime',
align:"center",
sorter: true,
dataIndex: 'createTime'
},
{
title:'同步情况',
key: 'syncState',
align:"center",
sorter: true,
dataIndex: 'syncState'
},
{
title: this.$t('operation'),
dataIndex: 'action',
scopedSlots: {customRender: 'action'},
align: "center",
width: 260
}
],
drawTableSorce:[
{
id: '1',
standNumber: 'sfsf1',
standName:'下拉单选',
fileType_dictText:'单选',
fileName:'123.pdf',
fileInfo:'1',
},
{
id: '2',
standNumber: 'sfsdfd2222',
standName:'aaaa选',
fileType_dictText:'sdf选',
fileName:'sss.word',
fileInfo:'2',
},
],
ipagination: {
defaultPageSize: 10,
defaultCurrent: 1,
pageSizeOptions: ['10', '20', '30', '40', '100'],
showQuickJumper: true,
showSizeChanger: true,
showTotal: (total, range) => `共 ${total} 条`
},
total:0,
selectedRowKeys:[],
fileVisible:false,
confirmLoading: false,
queryParams:{
pageNo:1,
pageSize:10
},
selectedIds:'', //选择行id
}
},
props:{
},
mounted() {
this.loadData()
},
methods:{
//获取列表数据
loadData(){
console.log('22222')
let params = this.queryParams
console.log('33333')
getAction(`ocr/ocrRecord/page`,params).then(res=> {
if(res.success){
this.total=res.result.total
this.dataSource= [ ...res.result.records ]
}
})
},
//搜索
searchQuery(){
},
//清空搜索
searchReset(){
},
//上传
handleUpload(){
this.fileVisible=true
},
//调取已入库文件
handleFileExport(){
this.drawVisible=true
},
//批量删除
handleDel(){
let param={
ids:this.selectedIds
}
if(this.selectedIds){
this.$confirm({
title: '确认要批量删除?',
content: '',
onOk:
async () => {
deleteAction(`ocr/ocrRecord/deleteBatch`, param).then(res => {
if (res.success) {
this.loadData()
this.selectedRowKeys=[]
}
})
},
onCancel() {},
});
}else{
this.$notification['warning']({
message: '请选择至少一条数据!',
description:'',
});
}
},
//同步
actionSynchron(){
this.toVisible=true
},
//校核
actionCheck(){
this.checkVisible=true
},
//下载
actionDown(){
},
//删除
actionDelete(record){
let params={
id:record.id
}
deleteAction(`ocr/ocrRecord/delete`,params).then(res=> {
if(res.success){
this.loadData()
// console.log('res',res)
}
})
},
onDelete(){
},
onSelectChange(selectedRowKeys,selectedRows){
this.selectedRowKeys = selectedRowKeys;
// console.log('selectedRows',selectedRowKeys,selectedRows)
let ids=[]
selectedRows.forEach(item=>{
ids.push(item.id)
})
this.selectedIds=ids.join(',')
// console.log('seIds',this.selectedIds)
},
//上传确定按钮
handleOk(){
this.$refs.fileForm.validate((valid)=>{
if(valid){
console.log('succ')
}
})
},
handleCancel(){
this.fileVisible=false
},
//上传文件
uploadSuccess(data) {
console.log('updata',data)
let attIdList = []
// data.map(item => {
// attIdList.push(item.id || data.name)
// })
// // /** 赋值给当前对应的表单文件 */
// this.file = attIdList.join(',')
},
fileUpload(){
this.$refs.uploadFile.visible=true
},
//同步至文档库确认
handleOkTo(){
this.toVisible=false
},
//同步至文档库取消
handleCancelTo(){
this.toVisible=false
},
//校核确认
handleOkCheck(){
this.checkVisible=false
},
//校核取消
handleCancelCheck(){
this.checkVisible=false
},
docVisible(val){
this.drawVisible=val
},
//点击页数
onChangePage(page,pageSize){
this.queryParams.pageNo = page
this.loadData()
},
//一页显示条数
SizeChange(page,pageSize){
this.queryParams.pageSize = pageSize
this.loadData()
},
//文件详情跳转
fileDetail(val){
console.log('valtext',val)
}
}
}
</script>
<style lang="less" scoped>
.ocr{
.table-detail{
.action{
margin-right: 10px;
}
.action-delete{
color:red;
}
.page{
text-align:right ;
margin-top:20px;
}
}
}
</style>
<style lang="less">
.show-content{
.ant-modal-footer{
text-align: center;
}
}
</style>