code init

This commit is contained in:
chenxiaoxi
2021-05-25 18:06:45 +08:00
parent 02698d6dab
commit f54a8d4fa1
1367 changed files with 540755 additions and 21713 deletions
@@ -0,0 +1,806 @@
<!--标准内容自动识别-->
<template>
<div class="standardRecognition">
<div class="action-bar">
<div slot="left">
<!-- <el-button type="primary" @click="changeData">转化</Button>-->
<el-button size="mini" round @click="uploadPdf" v-btn-permission="'MFQVKD5T76BL5VVZC3U2'"
><i class="iconfont">&#xe65d;</i>上传</el-button
>
<el-button size="mini" round @click="delData" v-btn-permission="'QJ2GMGUUE5ZZ9PL37BHM'"
><i class="iconfont">&#xe61b;</i>删除</el-button
>
</div>
</div>
<div class="content">
<div style="position: absolute; height: 100%; width: calc(100% - 20px)">
<el-table
border
:data="standRecoList"
style="width: 100%"
height="100%"
@selection-change="standSelectChange"
:header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }"
>
<el-table-column type="selection" align="center" width="50">
</el-table-column>
<el-table-column
prop="name"
:label="this.$t('m.serialNumber')"
type="index"
width="50"
align="center"
>
</el-table-column>
<el-table-column
prop="fileType"
:label="this.$t('m.dataType')"
align="center"
width="150"
>
<template slot-scope="scope">
{{
scope.row.fileType === "1"
? "国内标准法规"
: scope.row.fileType === "2"
? "海外标准法规"
: scope.row.fileType === "3"
? "政策"
: scope.row.fileType === "4"
? "企业标准"
: "标准"
}}
<!-- {{ scope.row.fileType === '标准' }}-->
</template>
</el-table-column>
<el-table-column
prop="standNumber"
:label="this.$t('m.standardNumberAndPolicyNumber')"
align="center"
>
</el-table-column>
<el-table-column
prop="standName"
:label="this.$t('m.standardNameAndPolicyName')"
align="center"
>
</el-table-column>
<el-table-column :label="this.$t('m.textState')" width="150" align="center">
<template slot-scope="scope">
{{
scope.row.fileType === "STAND_FILE"
? "标准文本"
: scope.row.fileType === "DRAFT_FILE"
? "草案"
: scope.row.fileType === "OPINION_FILE"
? "征求意见稿"
: scope.row.fileType === "SENT_SCREEN_FILE"
? "送审稿"
: scope.row.fileType === "APPROVAL_FILE"
? "报批稿"
: "关联文件"
}}
</template>
</el-table-column>
<el-table-column
prop="resultContent"
:label="this.$t('m.conversionResults')"
align="center"
width="120"
>
<template slot-scope="scope">
<el-tag :type="scope.row.resultContent === '转换成功' ? 'success' : (scope.row.resultContent === '转换中' ? undefined : 'danger')" size="small">{{ scope.row.resultContent }}</el-tag>
</template>
</el-table-column>
<el-table-column
prop="spendTime"
:label="this.$t('m.timeConsuming')"
align="center"
sortable
width="120"
>
</el-table-column>
<el-table-column label="操作" align="center" width="50" fixed="right">
<template slot-scope="scope">
<div @click.stop style="display: inline-block">
<el-dropdown trigger="click" @command="handleCommand">
<i class="iconfont">&#xe61e;</i>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="[scope.row, '获取文件']" v-btn-permission="'RFGHJXQLEBEC37EWCPMQ'"
>获取文件</el-dropdown-item
>
<el-dropdown-item :command="[scope.row, '编辑']" v-btn-permission="'4ZCETHNBRFJQH8J8Q3Y5'"
>编辑</el-dropdown-item
>
<el-dropdown-item :command="[scope.row, '删除']" v-btn-permission="'QJ2GMGUUE5ZZ9PL37BHM'"
>删除</el-dropdown-item
>
<el-dropdown-item :command="[scope.row, '在线编辑']" v-btn-permission="'M93G5FCWKBBPU8GMQ4EF'"
>在线编辑</el-dropdown-item
>
</el-dropdown-menu>
</el-dropdown>
</div>
</template>
</el-table-column>
</el-table>
</div>
</div>
<loading :loading="loading">正在获取中……</loading>
<pagination
:total="total"
:pageChange="page"
:pageSizeChange="pageSize"
@pageChange="pageChange"
@pageSizeChange="pageSizeChange"
></pagination>
<el-dialog
:visible.sync="uploadModal"
:title="title"
:label-width="100"
width="525px"
:before-close="cancel"
>
<el-form
:model="uploadFilesdfEo"
class="label-input-form"
ref="uploadFilesdfEo"
:rules="upFileRules"
>
<el-form-item label="文件" label-width="145px" prop="fileName">
<el-upload
:limit="1"
:on-exceed="uploadNum"
show-upload-list
:show-file-list="showUploadlist"
:on-success="uploadSuccess"
:on-remove="removeOneFile"
:action="uploadPath"
:default-file-list="defaultFileList"
:format="['pdf', 'PDF']"
:before-upload="beforeUpload"
name="file"
ref="importFileAboutStand"
>
<el-button
type="primary"
class="common-button-primary"
round
>{{ $t("m.upload")+' PDF'}}</el-button
>
</el-upload>
</el-form-item>
<el-form-item
label="标准号/政策号"
prop="standNumber"
label-width="145px"
>
<el-input
class="bead-input"
v-model="uploadFilesdfEo.standNumber"
:placeholder="$t('m.pleaseEnterTheStandardNumberAndPolicyNumber')"
></el-input>
</el-form-item>
<el-form-item
label="标准名称/政策名称"
prop="standName"
label-width="145px"
>
<el-input
class="bead-input"
v-model="uploadFilesdfEo.standName"
:placeholder="$t('m.pleaseEnterTheStandardNameAndPolicyName')"
></el-input>
</el-form-item>
<el-form-item label="文本状态" prop="fileType" label-width="145px">
<el-select class="bead-input" v-model="uploadFilesdfEo.fileType">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
</el-form-item>
</el-form>
<div slot="footer">
<el-button size="mini" round @click="cancel" icon="el-icon-close"
>取消</el-button
>
<el-button
size="mini"
icon="el-icon-check"
round
class="common-button-primary add-button"
@click="uploadSave"
type="primary"
:loading="isSubmit"
>{{ btnName }}</el-button
>
<!-- <el-button @click="uploadSave" type="primary">转换</Button>-->
</div>
</el-dialog>
</div>
</template>
<script>
export default {
name: "StandardRecognition",
components: {},
data() {
return {
tableHeight: null,
loading: false,
uploadModal: false,
title: "",
total: 0,
page: 1,
pageSize: 10,
// uploadPath: '/api/ocr/OCRRestful/upload',
uploadPath: "api/att/attFile/upload",
defaultFileList: [],
// 记录上传文件相关信息
uploadFilesdfEo: {
standNumber: "",
standName: "",
fileType: "",
attId: "",
fileName: "",
// standId: ''
},
upFileRules: {
standNumber: [
{ required: true, message: "标准号/政策号不能为空", trigger: "blur" },
],
standName: [
{
required: true,
message: "标准名称/政策名称不能为空",
trigger: "blur",
},
],
fileType: [
{ required: true, message: "文本状态称不能为空", trigger: "blur" },
],
fileName: [
{ required: true, message: '文件不能为空', trigger: 'blur' }
]
},
options: [
{
value: "STAND_FILE",
label: "标准文本",
},
{
value: "DRAFT_FILE",
label: "草案",
},
{
value: "OPINION_FILE",
label: "征求意见稿",
},
{
value: "SENT_SCREEN_FILE",
label: "送审稿",
},
{
value: "APPROVAL_FILE",
label: "报批稿",
},
{
value: "RELEVANCE_FILE",
label: "关联文件",
},
],
// standRecoColumn: [
// {
// type: 'selection',
// width: 60,
// align: 'center'
// },
// {
// title: '序号',
// type: 'index',
// align: 'center'
// },
// {
// title: '资料类型',
// key: 'fileType',
// align: 'center',
// render: (h, params) => {
// let texts
// if (params.row.fileType === '1') {
// texts = '国内标准法规'
// } else if (params.row.fileType === '2') {
// texts = '海外标准法规'
// } else if (params.row.fileType === '3') {
// texts = '政策'
// } else if (params.row.fileType === '4') {
// texts = '企业标准'
// } else {
// texts = '标准'
// }
// return h('div', {
// class: {
// 'text-overflow-hidden': true
// },
// attrs: {
// title: texts
// }
// }, texts)
// }
// },
// {
// title: '标准号/政策号',
// key: 'standNumber',
// align: 'center'
// },
// {
// title: '标准名称/政策名称',
// key: 'standName',
// align: 'center'
// },
// {
// title: '文本状态',
// key: 'fileStatus',
// align: 'center',
// render: (h, params) => {
// let texts
// if (params.row.fileType === 'STAND_FILE') {
// texts = '标准文本'
// } else if (params.row.fileType === 'DRAFT_FILE') {
// texts = '草案'
// } else if (params.row.fileType === 'OPINION_FILE') {
// texts = '征求意见稿'
// } else if (params.row.fileType === 'SENT_SCREEN_FILE') {
// texts = '送审稿'
// } else if (params.row.fileType === 'APPROVAL_FILE') {
// texts = '报批稿'
// } else if (params.row.fileType === 'RELEVANCE_FILE') {
// texts = '关联文件'
// }
// return h('div', {
// class: {
// 'text-overflow-hidden': true
// },
// attrs: {
// title: texts
// }
// }, texts)
// }
// },
// {
// title: '转换结果',
// key: 'resultContent',
// align: 'center'
// },
// {
// title: '消耗时间',
// key: 'spendTime',
// align: 'center'
// },
// {
// title: '操作',
// key: 'action',
// width: 200,
// align: 'center',
// render: (h, params) => {
// return h('div', [
// h('Button', {
// props: {
// type: 'primary',
// size: 'small'
// },
// style: {
// marginRight: '5px'
// },
// on: {
// click: () => {
// this.downloadFile(params.row)
// }
// }
// }, '获取文件'),
// h('Button', {
// props: {
// type: 'warning',
// size: 'small'
// },
// style: {
// marginRight: '5px'
// },
// on: {
// click: () => {
// this.editOcrRecord(params.row)
// }
// }
// }, '编辑'),
// h('Dropdown', {
// props: {
// trigger: 'click'
// },
// on: {
// 'on-click': (value) => {}
// }
// }, [
// h('Button', {
// props: {
// type: 'primary',
// size: 'small'
// }
// }, '更多'),
// h('DropdownMenu', {
// slot: 'list'
// },
// this.dropdownItems.map(function (type) {
// return h('DropdownItem', {
// props: {
// name: type.val
// }
// }, type.val)
// })
// )
// ])
// ])
// }
// }
// ],
modalType: "",
standRecoList: [],
selectTableData: [],
dropdownItems: [
{ val: "收藏" },
{ val: "分享" },
{ val: "关联" },
{ val: "删除" },
],
btnName: "",
isSubmit: false,
showUploadlist: true, // 导入过程中新增数据时,如果数据报错,不出现导入列表
collect: "收藏",
};
},
props: {},
watch: {},
methods: {
handleCommand(command) {
switch (command[1]) {
case "获取文件":
this.downloadFile(command[0]);
break;
case "编辑":
this.editOcrRecord(command[0], "edit");
break;
case "删除":
this.delSingalData(command[0]);
break;
case "在线编辑":
this.downloadFile(command[0]);
break;
}
},
// 修改成表格样式后,选择项勾选改变
standSelectChange(data) {
this.selectTableData = [];
for (let i = 0; i < data.length; i++) {
this.selectTableData.push(data[i].id);
}
},
// 上传
uploadNum() {
this.$message({
message: '最多只能上传一份',
type: 'warning'
})
},
uploadPdf() {
this.modalType = "1";
this.title = "上传文件";
this.uploadModal = true;
this.btnName = "转换";
this.defaultFileList = [];
},
uploadSuccess(res, file, fileList) {
if (res.ok) {
// this.uploadFilesdfEo.id = res.data
this.uploadFilesdfEo.attId = res.data.id;
if (res.data.standNum != null && res.data.standNum !== "") {
this.uploadFilesdfEo.standNumber = res.data.standNum;
}
if (res.data.standName != null && res.data.standName !== "") {
this.uploadFilesdfEo.standName = res.data.standName;
}
// this.uploadFilesdfEo.fileName = res.data.name
// this.getTableData()
this.defaultFileList.push(file);
this.$message({
message: "文件上传成功",
type: "success",
});
// this.$refs['uploadFilesdfEo'].resetFields()
} else {
this.defaultFileList = [];
this.uploadFilesdfEo.attId = "";
this.$message.error(res.message);
fileList.pop();
}
},
removeOneFile(file, fileList) {
this.defaultFileList = [];
this.uploadFilesdfEo.attId = "";
},
beforeUpload(file) {
var filename = file.name;
var index1 = filename.lastIndexOf(".");
var index2 = filename.length;
var fileSuffix = filename.substring(index1, index2);
// const fileSuffix = file.name.split('.')[1] // 后缀名
// 判断上传文件格式
if (
fileSuffix === ".pdf" ||
fileSuffix === ".PDF"
) {
return true;
} else {
this.$message.error(
"文件" +
file.name +
"格式不正确,请上传pdf文件"
);
return false;
}
// 判断文件上传大小
// eslint-disable-next-line no-unreachable
if (file.size / 1024 / 1024 <= 200) {
return true;
} else {
this.$message.error("文件" + file.name + "大小不超过200M");
return false;
}
return true;
},
cancel() {
this.uploadFilesdfEo = {
standNumber: "",
standName: "",
fileType: "",
attId: "",
fileName: "",
}
this.defaultFileList = []
this.uploadModal = false;
this.$refs["importFileAboutStand"].clearFiles();
},
// 编辑
editOcrRecord(row) {
this.modalType = "2";
this.title = "编辑信息";
this.btnName = "保存";
this.uploadModal = true;
this.uploadFilesdfEo.standNumber = JSON.parse(
JSON.stringify(row)
).standNumber;
this.uploadFilesdfEo.standName = JSON.parse(
JSON.stringify(row)
).standName;
// this.uploadFilesdfEo.fileType = JSON.parse(JSON.stringify(row)).fileType
this.options.map((item) => {
if (item.value === JSON.parse(JSON.stringify(row)).fileType) {
this.uploadFilesdfEo.fileType = item.label;
}
});
this.uploadFilesdfEo.id = JSON.parse(JSON.stringify(row)).id;
this.uploadFilesdfEo.attId = "";
this.defaultFileList = [];
},
// 提交
uploadSave() {
this.$refs["uploadFilesdfEo"].validate((valid) => {
if (valid) {
if (this.modalType === "1") {
if (
this.uploadFilesdfEo.attId != null &&
this.uploadFilesdfEo.attId !== ""
) {
this.isSubmit = true;
this.uploadFilesdfEo.fileType = this.uploadFilesdfEo.fileType.toString();
this.$http.post(
"ocr/OCRRestful/addOcrRecord",
this.uploadFilesdfEo,
{
_this: this,
},
(res) => {
if (res.ok) {
this.isSubmit = false;
this.uploadModal = false;
this.getTableData();
} else {
this.isSubmit = false;
}
},
(e) => {
this.isSubmit = false;
}
);
} else {
this.$message.warning("转换文件不能为空");
}
} else if (this.modalType === "2") {
this.isSubmit = true;
this.$http.putData(
"ocr/OCRRestful/updateOcrRecord",
this.uploadFilesdfEo,
{
_this: this,
},
(res) => {
if (res.ok) {
this.isSubmit = false;
this.uploadModal = false;
this.getTableData();
} else {
this.isSubmit = false;
this.$message.error(res.message);
}
},
(e) => {
this.isSubmit = false;
}
);
}
}
});
},
// 获取选中数据
selectStanderChange(data) {
this.selectTableData = data;
},
// 获取doc文件
downloadFile(data) {
window.open(data.docRealFile);
},
// 删除
delSingalData(row) {
if (this.selectTableData.length === 0) {
this.$confirm("确认删除这些数据?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
confirmButtonClass: "common-button-primary",
roundButton: true,
type: "warning",
}).then(() => {
this.$http.delete(
"ocr/OCRRestful/deleteOcrRecord",
{
ids: row.id,
},
{
_this: this,
},
(res) => {
if (res.ok) {
this.getTableData();
} else {
this.getTableData();
// this.$message.error(res.message)
}
}
);
});
}
},
// 批量删除
delData() {
if (this.selectTableData.length === 0) {
this.$confirm("请选择一条数据进行删除", "提示", {
showCancelButton: false,
confirmButtonText: "确定",
cancelButtonText: "取消",
confirmButtonClass: "common-button-primary",
type: "warning",
roundButton: true,
});
} else {
this.$confirm("确认删除这些数据?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
confirmButtonClass: "common-button-primary",
roundButton: true,
}).then(() => {
let idsList = [];
this.selectTableData.map((item) => {
idsList.push(item);
});
this.$http.delete(
"ocr/OCRRestful/deleteOcrRecord",
{
ids: idsList.join(","),
},
{
_this: this,
},
(res) => {
if (res.ok) {
this.getTableData();
} else {
this.getTableData();
// this.$message.error(res.message)
}
}
);
});
}
},
// 转化
changeData() {},
// 分页点击后方法
pageChange(page) {
this.page = page;
this.getTableData();
},
// 分页每页显示数改变后方法
pageSizeChange(pageSize) {
this.pageSize = pageSize;
this.getTableData();
},
// 获取表格数据
getTableData() {
this.$http.post(
"ocr/OCRRestful/getAllOcrResult",
{
page: this.page,
pageSize: this.pageSize,
},
{
_this: this,
loading: "loading",
},
(res) => {
if (res.ok) {
this.standRecoList = res.data.list;
this.total = res.data.count;
}
},
e => {}
);
},
},
computed: {},
created() {},
mounted() {
this.getTableData();
},
destroyed() {},
};
</script>
<style lang="less" scope>
.standardRecognition {
height: 100%;
background: #fff;
display: flex;
flex-direction: column;
.action-bar {
margin-bottom: 5px;
}
.content {
flex: auto;
overflow: hidden;
position: relative;
margin-bottom: 10px;
}
.pagination {
position: static;
/deep/.pagination-slot {
padding: 0;
}
}
}
.bead-input {
/deep/ .el-input__inner {
border-radius: 20px;
}
}
</style>