Initial commit
This commit is contained in:
@@ -0,0 +1,220 @@
|
||||
<template>
|
||||
<a-card :bordered="false">
|
||||
<div class="table-operator">
|
||||
<!-- 上传 -->
|
||||
<a-button icon="plus" type="primary" @click="handleAdd" v-has="'docTool:ocrTextRecognition:add'">{{$t('docTool.ocrTextRecognition.upload') }}</a-button>
|
||||
<!-- 批量删除 -->
|
||||
<a-button type="primary" icon="delete" ghost @click="batchDel" v-has="'docTool:ocrTextRecognition:batchDel'">{{$t('batchDelete')}}</a-button>
|
||||
</div>
|
||||
<div>
|
||||
<j-table
|
||||
:columns="columns"
|
||||
:dataSource="dataSource"
|
||||
:can-drag="true"
|
||||
rowKey="id"
|
||||
:row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
|
||||
:pagination="ipagination"
|
||||
:scroll="{x: '100%', y: yScrollHeight}"
|
||||
:loading="loading"
|
||||
:operation-list="operationList"
|
||||
@change="handleTableChange"
|
||||
@operationClick="operationClick">
|
||||
|
||||
<!--跳转标准详情-->
|
||||
<template v-slot:tag="{text, record}">
|
||||
<a-tooltip overlay-class-name="tooltip-style">
|
||||
<template slot="title">{{ text || text === 0 ? text : global.emptyLine }}</template>
|
||||
<div class="table-text" v-if="text || text === 0"><a-tag :color="getTagColor(record)">{{ text }}</a-tag></div>
|
||||
<div v-else class="table-text">{{ global.emptyLine }}</div>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
|
||||
</j-table>
|
||||
</div>
|
||||
<!-- 新增、编辑弹框 -->
|
||||
<ocr-text-recognition-modal ref="modalForm" @ok="modalFormOk"/>
|
||||
</a-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { JeroListMixin } from '@/mixins/JeroListMixin'
|
||||
import JTable from '@comp/jero/JTable'
|
||||
import OcrTextRecognitionModal from '@views/documentTool/ocrTextRecognition/modules/OcrTextRecognitionModal'
|
||||
import { downloadFile, getAction, postAction } from '@api/manage'
|
||||
|
||||
export default {
|
||||
name: 'OcrTextRecognition',
|
||||
components: { OcrTextRecognitionModal, JTable },
|
||||
mixins: [JeroListMixin],
|
||||
data () {
|
||||
return {
|
||||
url: {
|
||||
list: '/laws/ocr/OCRRestful/getAllOcrResult',
|
||||
deleteBatch: '/laws/ocr/OCRRestful/deleteOcrRecord'
|
||||
},
|
||||
columns: [
|
||||
{ // 序号
|
||||
title: this.$t('serialNumber'),
|
||||
key: 'rowIndex',
|
||||
width: 80,
|
||||
customRender: function (t, r, index) {
|
||||
return parseInt(index) + 1
|
||||
}
|
||||
},
|
||||
// { // 标准类别
|
||||
// title: this.$t('docTool.ocrTextRecognition.standardCategory'),
|
||||
// align: 'center',
|
||||
// width: 180,
|
||||
// dataIndex: 'fileType2',
|
||||
// scopedSlots: { customRender: 'text' }
|
||||
// },
|
||||
{ // 标准编号
|
||||
title: this.$t('docTool.ocrTextRecognition.standardNumber'),
|
||||
align: 'center',
|
||||
width: 180,
|
||||
dataIndex: 'standNumber',
|
||||
scopedSlots: { customRender: 'text' }
|
||||
},
|
||||
{ // 标准名称
|
||||
title: this.$t('docTool.ocrTextRecognition.standardName'),
|
||||
align: 'center',
|
||||
width: 180,
|
||||
dataIndex: 'standName',
|
||||
scopedSlots: { customRender: 'text' }
|
||||
},
|
||||
{ // 文本状态
|
||||
title: this.$t('docTool.ocrTextRecognition.textStatus'),
|
||||
align: 'center',
|
||||
width: 180,
|
||||
dataIndex: 'fileType',
|
||||
scopedSlots: { customRender: 'text' }
|
||||
},
|
||||
{ // 转换结果
|
||||
title: this.$t('docTool.ocrTextRecognition.conversionResults'),
|
||||
align: 'center',
|
||||
width: 180,
|
||||
dataIndex: 'resultContent',
|
||||
scopedSlots: { customRender: 'tag' }
|
||||
},
|
||||
{ // 消耗时间
|
||||
title: this.$t('docTool.ocrTextRecognition.timeConsuming'),
|
||||
align: 'center',
|
||||
width: 180,
|
||||
dataIndex: 'spendTime',
|
||||
scopedSlots: { customRender: 'text' }
|
||||
},
|
||||
{
|
||||
title: this.$t('operation'),
|
||||
scopedSlots: { customRender: 'action' },
|
||||
align: 'center',
|
||||
fixed: 'right',
|
||||
width: 200
|
||||
}
|
||||
],
|
||||
operationList: [
|
||||
// 获取文件
|
||||
{
|
||||
text: this.$t('docTool.ocrTextRecognition.getFile'),
|
||||
clickEvent: 'handleDownload',
|
||||
has: 'docTool:ocrTextRecognition:download',
|
||||
show: (record) => {
|
||||
return record.resultContent !== '转换中'
|
||||
}
|
||||
},
|
||||
// 编辑
|
||||
{
|
||||
text: this.$t('edit'),
|
||||
clickEvent: 'handleEdit',
|
||||
has: 'docTool:ocrTextRecognition:edit'
|
||||
}
|
||||
// 删除
|
||||
// {
|
||||
// text: this.$t('delete'),
|
||||
// clickEvent: 'handleDelete',
|
||||
// has: 'split:sarFileSplitInfo:release'
|
||||
// }
|
||||
]
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
console.log(this.$refs.modalForm)
|
||||
},
|
||||
methods: {
|
||||
loadData (arg) {
|
||||
if (!this.url.list) {
|
||||
this.$message.warning('请设置url.list属性!')
|
||||
return
|
||||
}
|
||||
// 加载数据 若传入参数1则加载第一页的内容
|
||||
if (arg === 1) {
|
||||
this.ipagination.current = 1
|
||||
}
|
||||
const params = this.getQueryParams()// 查询条件
|
||||
console.log(params)
|
||||
this.loading = true
|
||||
postAction(this.url.list, params).then((res) => {
|
||||
if (res.ok) {
|
||||
this.dataSource = res.data.list
|
||||
if (res.data.count) {
|
||||
this.ipagination.total = res.data.count
|
||||
} else {
|
||||
this.ipagination.total = 0
|
||||
}
|
||||
} else {
|
||||
this.$message.warning(res.message)
|
||||
}
|
||||
}).finally(() => {
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
handleDownload (data) {
|
||||
downloadFile(`/sys/common/download/${data.wordAttId}`, data.docRealName)
|
||||
},
|
||||
getTagColor (row) {
|
||||
if (row.resultContent === '转换成功') {
|
||||
return 'green'
|
||||
} else if (row.resultContent === '转换中') {
|
||||
return 'blue'
|
||||
} else {
|
||||
return 'red'
|
||||
}
|
||||
},
|
||||
batchDel: function () {
|
||||
if (!this.url.deleteBatch) {
|
||||
this.$message.warning('请设置url.deleteBatch属性!')
|
||||
return
|
||||
}
|
||||
if (this.selectedRowKeys.length <= 0) {
|
||||
this.$message.warning(this.$t('selectARecord'))
|
||||
} else {
|
||||
const ids = this.selectedRowKeys.join(',')
|
||||
const that = this
|
||||
this.$confirm({
|
||||
title: this.$t('confirmBatchDeletion'),
|
||||
content: this.$t('deleteAData'),
|
||||
onOk: function () {
|
||||
that.loading = true
|
||||
getAction(that.url.deleteBatch, { ids: ids }).then((res) => {
|
||||
if (res.ok) {
|
||||
// 重新计算分页问题
|
||||
that.reCalculatePage(that.selectedRowKeys.length)
|
||||
that.$message.success(res.message)
|
||||
that.loadData()
|
||||
that.onClearSelected()
|
||||
} else {
|
||||
that.$message.warning(res.message)
|
||||
}
|
||||
}).finally(() => {
|
||||
that.loading = false
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,176 @@
|
||||
<template>
|
||||
<j-modal
|
||||
:title="title"
|
||||
:width="800"
|
||||
:visible="visible"
|
||||
:confirmLoading="confirmLoading"
|
||||
@ok="handleOk"
|
||||
@cancel="handleCancel"
|
||||
:cancelText="$t('close')"
|
||||
switchFullscreen
|
||||
wrapClassName="ant-modal-cust-warp"
|
||||
style="top:5%;overflow-y: hidden">
|
||||
<a-spin :spinning="confirmLoading">
|
||||
<a-form :form="form" :label-col="{ span: 5 }" :wrapper-col="{ span: 16 }">
|
||||
<!--文件-->
|
||||
<a-form-item label="文件">
|
||||
<j-upload v-decorator="['attId', validatorRules.attId]"
|
||||
@change="changeAttIdFile"
|
||||
:number="1"
|
||||
return-id
|
||||
class="line-btn"
|
||||
accept=".pdf"
|
||||
file-type="pdf" />
|
||||
</a-form-item>
|
||||
<!--标准编号-->
|
||||
<a-form-item :label="$t('docTool.ocrTextRecognition.standardNumber')">
|
||||
<standard-selection :placeholder="$t('pleaseSelect') + $t('docTool.ocrTextRecognition.standardNumber')"
|
||||
@nameChange="changeStandardName" type="radio"
|
||||
v-decorator="['standNumber']" />
|
||||
</a-form-item>
|
||||
<!--标准名称-->
|
||||
<a-form-item :label="$t('docTool.ocrTextRecognition.standardName')">
|
||||
<a-input :placeholder="$t('pleaseEnter') + $t('docTool.ocrTextRecognition.standardName')"
|
||||
class="box-input" :maxLength="500"
|
||||
v-decorator="['standName']" />
|
||||
</a-form-item>
|
||||
<!--文本状态-->
|
||||
<a-form-item :label="$t('docTool.ocrTextRecognition.textStatus')">
|
||||
<a-select
|
||||
:placeholder="$t('pleaseSelect') + $t('docTool.ocrTextRecognition.textStatus')"
|
||||
v-decorator="['fileType', validatorRules.fileType]"
|
||||
show-search
|
||||
:filter-option="filterOption"
|
||||
>
|
||||
<a-select-option v-for="item in fileTypeList" :key="item.value" :value="item.value">{{ item.text || item.label }}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-spin>
|
||||
</j-modal>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import StandardSelection from '@comp/selection/StandardSelection'
|
||||
import { getFileInfo } from '@api/api'
|
||||
import { postAction } from '@api/manage'
|
||||
import pick from 'lodash.pick'
|
||||
export default {
|
||||
name: 'OcrTextRecognitionModal',
|
||||
components: { StandardSelection },
|
||||
data () {
|
||||
return {
|
||||
form: this.$form.createForm(this),
|
||||
title: '操作',
|
||||
visible: false,
|
||||
model: {},
|
||||
url: {
|
||||
add: '/laws/ocr/OCRRestful/addOcrRecord',
|
||||
edit: '/laws/ocr/OCRRestful/updateOcrRecord'
|
||||
},
|
||||
// 文本状态下拉
|
||||
fileTypeList: [
|
||||
{ label: '修改单', value: '修改单' },
|
||||
{ label: '草稿', value: '草稿' },
|
||||
{ label: '报批稿', value: '报批稿' },
|
||||
{ label: '发布稿(原文)', value: '发布稿(原文)' },
|
||||
{ label: '相关文件', value: '相关文件' },
|
||||
{ label: '关联文件', value: '关联文件' },
|
||||
{ label: '征求意见稿', value: '征求意见稿' },
|
||||
{ label: '发布稿(译文)', value: '发布稿(译文)' },
|
||||
{ label: '送审稿', value: '送审稿' }
|
||||
],
|
||||
confirmLoading: false,
|
||||
validatorRules: {
|
||||
// 文件
|
||||
attId: {
|
||||
rules: [
|
||||
{ required: true, trigger: 'change', message: this.$t('uploadFile.pleaseUpload') + this.$t('docTool.ocrTextRecognition.file') }
|
||||
]
|
||||
},
|
||||
// 文本状态
|
||||
fileType: {
|
||||
rules: [
|
||||
{ required: true, trigger: 'change', message: this.$t('pleaseSelect') + this.$t('docTool.ocrTextRecognition.textStatus') }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
add () {
|
||||
this.edit()
|
||||
},
|
||||
edit (record) {
|
||||
this.model = Object.assign({}, record)
|
||||
console.log(record)
|
||||
this.visible = true
|
||||
this.$nextTick(() => {
|
||||
this.form.setFieldsValue(pick(this.model, 'attId', 'fileType', 'standName', 'standNumber'))
|
||||
})
|
||||
},
|
||||
close () {
|
||||
this.form.resetFields()
|
||||
this.$emit('close')
|
||||
this.visible = false
|
||||
},
|
||||
handleOk () {
|
||||
const that = this
|
||||
this.form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
this.confirmLoading = true
|
||||
const params = Object.assign({}, this.model, values)
|
||||
const url = this.model.id ? this.url.edit : this.url.add
|
||||
postAction(url, params).then((res) => {
|
||||
if (res.success) {
|
||||
that.$message.success(res.message)
|
||||
that.close()
|
||||
} else {
|
||||
that.$message.warning(res.message)
|
||||
}
|
||||
}).finally(() => {
|
||||
that.confirmLoading = false
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
handleCancel () {
|
||||
this.close()
|
||||
},
|
||||
changeStandardName (value) {
|
||||
this.form.setFieldsValue({
|
||||
standName: value
|
||||
})
|
||||
},
|
||||
filterOption (input, option) {
|
||||
return (
|
||||
option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
||||
)
|
||||
},
|
||||
// 文件上传,通过id获取文件名
|
||||
changeAttIdFile (fileId) {
|
||||
this.getFileInfo(fileId).then(res => {
|
||||
if (res && res.fileName) {
|
||||
this.model.fileName = res.fileName
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 通过文件的id获取文件的相关信息
|
||||
* @param id
|
||||
*/
|
||||
getFileInfo (id) {
|
||||
return getFileInfo({ id: id }).then(res => {
|
||||
if (res.success) {
|
||||
return res.result
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user