Files
laws_chery_client/src/views/documentTool/ocrTextRecognition/OcrTextRecognition.vue
T
2024-08-14 17:10:00 +08:00

251 lines
8.8 KiB
Vue

<template>
<a-card :bordered="false">
<div class="table-page-search-wrapper">
<a-form layout="inline" @keyup.enter.native="searchQuery">
<a-row :gutter="24">
<!--标准号/标准名称-->
<a-col :md="6" :sm="12">
<a-form-item :label="$t('standardSelect.standardNumOrName')">
<a-input :placeholder="$t('pleaseEnter') + $t('standardSelect.standardNumOrName')"
v-model="queryParam.standardNumberAndName"></a-input>
</a-form-item>
</a-col>
<!--转换状态-->
<a-col :md="6" :sm="12">
<a-form-item :label="$t('docTool.ocrTextRecognition.conversionStatus')">
<j-dict-select-tag
class="box-input"
v-model="queryParam.resultContent"
:placeholder="$t('pleaseSelect') + $t('docTool.ocrTextRecognition.conversionStatus')"
:type="'select'"
:triggerChange="false"
dictCode="transition_status" />
</a-form-item>
</a-col>
<div style="float: right;overflow: hidden;margin-right: 11px" class="table-page-search-submitButtons">
<a-button type="primary" @click="searchQuery" icon="search" style="margin-left: 8px" v-has="'split:sarFileSplitInfo:search'">
{{ $t('query') }}
</a-button>
<a-button type="primary" @click="searchReset" icon="reload" ghost>{{ $t('reset') }}</a-button>
</div>
</a-row>
</a-form>
</div>
<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"
@change="handleTableChange">
<template v-slot:action="{text, record}">
<!--获取文件-->
<a @click="handleDownload(record)"
v-has="'docTool:ocrTextRecognition:download'"
:disabled="record.resultContent !== OcrConvertStateEnums.CONVERTED.value">{{ $t('docTool.ocrTextRecognition.getFile') }}</a>
</template>
<!--转换状态-->
<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>
<!--跳转详情-->
<template v-slot:toDetail="{text, record}">
<a-tooltip overlay-class-name="tooltip-style">
<template slot="title">{{ text || text === 0 ? text : global.emptyLine }}</template>
<div class="table-text can-click-table-text" v-if="text || text === 0" @click="toStandardDetail(record)">{{ text }}</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 } from '@api/manage'
import { OcrConvertStateEnums } from '@/enums/commonEnums'
export default {
name: 'OcrTextRecognition',
components: { OcrTextRecognitionModal, JTable },
mixins: [JeroListMixin],
data () {
return {
OcrConvertStateEnums,
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: 'toDetail' }
},
{ // 标准名称
title: this.$t('docTool.ocrTextRecognition.standardName'),
align: 'center',
width: 180,
dataIndex: 'standName',
scopedSlots: { customRender: 'toDetail' }
},
{ // 文本状态
title: this.$t('docTool.ocrTextRecognition.textStatus'),
align: 'center',
width: 180,
dataIndex: 'fileType_dictText',
scopedSlots: { customRender: 'dictText' }
},
{ // 转换结果
title: this.$t('docTool.ocrTextRecognition.conversionResults'),
align: 'center',
width: 180,
dataIndex: this.isChinese() ? 'resultContent_dictText' : 'resultContent_dictTextEn',
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
}
]
}
},
methods: {
// 跳转详情
toStandardDetail (record) {
const { standNumber } = record
this.$openPageNewSheet({
path: '/standardRegulationLibrary/foreignStandardDetailPage',
query: {
standardNumber: standNumber
}
})
},
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
getAction(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 === OcrConvertStateEnums.CONVERTED.value) {
return 'green'
} else if (row.resultContent === OcrConvertStateEnums.CONVERTING.value) {
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>