|
@ -36,8 +36,8 @@ |
|
|
<div v-if="selectedCategory.isType === 2" class="container-right"> |
|
|
<div v-if="selectedCategory.isType === 2" class="container-right"> |
|
|
<span class="right-top-line" /> |
|
|
<span class="right-top-line" /> |
|
|
<span class="left-bottom-line" /> |
|
|
<span class="left-bottom-line" /> |
|
|
<div> |
|
|
|
|
|
<el-form> |
|
|
|
|
|
|
|
|
<div style="display: flex; justify-content: flex-start;"> |
|
|
|
|
|
<!-- <el-form> |
|
|
<el-form-item label="电子原件" prop="aiFileOriginal" class="prearch-upload"> |
|
|
<el-form-item label="电子原件" prop="aiFileOriginal" class="prearch-upload"> |
|
|
<p class="input-style">{{ aiFileOriginal }}</p> |
|
|
<p class="input-style">{{ aiFileOriginal }}</p> |
|
|
<div class="upload-btn"> |
|
|
<div class="upload-btn"> |
|
@ -47,7 +47,19 @@ |
|
|
</el-button> |
|
|
</el-button> |
|
|
</div> |
|
|
</div> |
|
|
</el-form-item> |
|
|
</el-form-item> |
|
|
</el-form> |
|
|
|
|
|
|
|
|
</el-form> --> |
|
|
|
|
|
<div class="upload-btn"> |
|
|
|
|
|
<input id="upFile" type="file" name="upFile" multiple @change="changeFile($event)"> |
|
|
|
|
|
<el-button :loading="aiLoading" size="small" type="primary"><i :class="['iconfont', aiLoading ? 'icon-huoqu' : 'icon-shangchuan']" />{{ aiLoading ? 'AI辅助著录识别中' : '选择文件' }}</el-button> |
|
|
|
|
|
</div> |
|
|
|
|
|
<!-- margin-left: 10px; line-height: 34px; height: 106px; overflow: hidden; overflow-y: scroll; --> |
|
|
|
|
|
<div style="flex: 1; font-size: 12px; display: flex; line-height: 34px; "> |
|
|
|
|
|
<div v-for="item in fileList" :key="item.name" class="file-list" style="margin-left: 10px;"> |
|
|
|
|
|
<i class="iconfont icon-xiaowenjian" style="font-size: 14px;" /> |
|
|
|
|
|
{{ item.name }} |
|
|
|
|
|
<!-- <i class="el-icon-close" @click="deleteFile(item)" /> --> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
<div class="ai-category-main"> |
|
|
<div class="ai-category-main"> |
|
|
<div class="ai-des-left"> |
|
|
<div class="ai-des-left"> |
|
@ -72,8 +84,8 @@ |
|
|
<div class="des-title"> |
|
|
<div class="des-title"> |
|
|
<p>AI识别数据</p> |
|
|
<p>AI识别数据</p> |
|
|
</div> |
|
|
</div> |
|
|
<div ref="typingContainer" class="ai-des-json"> |
|
|
|
|
|
<pre v-if="aiJsonData" v-highlightjs="displayedText">{{ displayedText }}</pre> |
|
|
|
|
|
|
|
|
<div class="ai-des-json"> |
|
|
|
|
|
<pre v-if="aiJsonData" ref="typingContainer" v-highlightjs="displayedText">{{ displayedText }}</pre> |
|
|
</div> |
|
|
</div> |
|
|
<div v-if="typingFinished" style="text-align: right;"> |
|
|
<div v-if="typingFinished" style="text-align: right;"> |
|
|
<el-button @click="saveAiData">保存</el-button> |
|
|
<el-button @click="saveAiData">保存</el-button> |
|
@ -90,7 +102,7 @@ import crudCategory from '@/api/system/category/category' |
|
|
import CRUD, { presenter, header } from '@crud/crud' |
|
|
import CRUD, { presenter, header } from '@crud/crud' |
|
|
import PreviewForm from '@/views/components/category/PreviewForm' |
|
|
import PreviewForm from '@/views/components/category/PreviewForm' |
|
|
import { FetchInitCategoryInputFieldByPid, FetchCategoryMenu } from '@/api/system/category/category' |
|
|
import { FetchInitCategoryInputFieldByPid, FetchCategoryMenu } from '@/api/system/category/category' |
|
|
import { getCurrentTime } from '@/utils/index' |
|
|
|
|
|
|
|
|
// import { getCurrentTime } from '@/utils/index' |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
|
name: 'AICataloging', |
|
|
name: 'AICataloging', |
|
@ -127,12 +139,7 @@ export default { |
|
|
isDesFormType: 'arcives', |
|
|
isDesFormType: 'arcives', |
|
|
collectLevel: 3, |
|
|
collectLevel: 3, |
|
|
categoryMenu: [], |
|
|
categoryMenu: [], |
|
|
aiLoading: false, |
|
|
|
|
|
aiFileOriginal: null, |
|
|
aiFileOriginal: null, |
|
|
aiJsonData: null, |
|
|
|
|
|
displayedText: '', |
|
|
|
|
|
typingInterval: null, |
|
|
|
|
|
typingFinished: false, |
|
|
|
|
|
file: null, // 附件 change |
|
|
file: null, // 附件 change |
|
|
fileNames: '', // 附件 - name |
|
|
fileNames: '', // 附件 - name |
|
|
formatType: '', // 附件 - type |
|
|
formatType: '', // 附件 - type |
|
@ -141,7 +148,14 @@ export default { |
|
|
filePath: '', // 附件 - path |
|
|
filePath: '', // 附件 - path |
|
|
px: '', // 附件 - 分辨率 |
|
|
px: '', // 附件 - 分辨率 |
|
|
nowDate: '', // 当前时间 |
|
|
nowDate: '', // 当前时间 |
|
|
fileJsonString: null |
|
|
|
|
|
|
|
|
fileJsonString: null, |
|
|
|
|
|
aiLoading: false, |
|
|
|
|
|
fileList: [], |
|
|
|
|
|
aiJsonData: null, |
|
|
|
|
|
displayedText: '', |
|
|
|
|
|
typingInterval: null, |
|
|
|
|
|
typingFinished: false, |
|
|
|
|
|
currentLineIndex: 0 |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
computed: { |
|
|
computed: { |
|
@ -198,6 +212,7 @@ export default { |
|
|
children: item.categoryList.map(category => { |
|
|
children: item.categoryList.map(category => { |
|
|
return { |
|
|
return { |
|
|
label: category.cnName, |
|
|
label: category.cnName, |
|
|
|
|
|
cnName: category.cnName, |
|
|
id: category.id, |
|
|
id: category.id, |
|
|
arrangeType: category.arrangeType, |
|
|
arrangeType: category.arrangeType, |
|
|
isType: category.isType, |
|
|
isType: category.isType, |
|
@ -215,6 +230,7 @@ export default { |
|
|
return children.map(child => { |
|
|
return children.map(child => { |
|
|
return { |
|
|
return { |
|
|
label: child.cnName, |
|
|
label: child.cnName, |
|
|
|
|
|
cnName: child.cnName, |
|
|
id: child.id, |
|
|
id: child.id, |
|
|
isType: child.isType, |
|
|
isType: child.isType, |
|
|
pid: child.pid, |
|
|
pid: child.pid, |
|
@ -320,23 +336,110 @@ export default { |
|
|
}, |
|
|
}, |
|
|
// 选择附件 |
|
|
// 选择附件 |
|
|
async changeFile(e) { |
|
|
async changeFile(e) { |
|
|
this.file = e.target.files[0] |
|
|
|
|
|
this.fileSize = this.file.size |
|
|
|
|
|
this.formatType = this.file.type.substring(0, this.file.type.indexOf('/')) |
|
|
|
|
|
this.fileNames = this.file.name |
|
|
|
|
|
this.postfix = this.file.name.substring( |
|
|
|
|
|
this.fileNames.lastIndexOf('.') + 1, |
|
|
|
|
|
this.fileNames.length |
|
|
|
|
|
) |
|
|
|
|
|
if (this.formatType === 'image') { |
|
|
|
|
|
const fileBase64 = await this.getBase64(this.file) |
|
|
|
|
|
|
|
|
// 替换文件时清空 aiJsonData |
|
|
|
|
|
this.aiJsonData = null |
|
|
|
|
|
this.currentLineIndex = 0 |
|
|
|
|
|
this.displayedText = '' |
|
|
|
|
|
this.typingFinished = false |
|
|
|
|
|
this.typingInterval = null |
|
|
|
|
|
// if (this.typingInterval) { |
|
|
|
|
|
// clearInterval(this.typingInterval) |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
const selectedFiles = Array.from(e.target.files) |
|
|
|
|
|
const imageFiles = selectedFiles.filter(file => file.type.startsWith('image/')) |
|
|
|
|
|
const nonImageFiles = selectedFiles.filter(file => !file.type.startsWith('image/')) |
|
|
|
|
|
|
|
|
|
|
|
// 不允许同时选择图片和非图片文件 |
|
|
|
|
|
if (imageFiles.length > 0 && nonImageFiles.length > 0) { |
|
|
|
|
|
this.$message.error('不能同时选择图片和其他类型文件,请重新选择') |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const existingImageFiles = this.fileList.filter(item => item.formatType === 'image') |
|
|
|
|
|
const existingNonImageFiles = this.fileList.filter(item => item.formatType !== 'image') |
|
|
|
|
|
|
|
|
|
|
|
if (imageFiles.length > 0) { |
|
|
|
|
|
if (existingImageFiles.length > 0) { |
|
|
|
|
|
if (existingImageFiles.length + imageFiles.length > 3) { |
|
|
|
|
|
// 若加入新图片会超过 3 张,清空已有图片 |
|
|
|
|
|
this.fileList = this.fileList.filter(item => item.formatType !== 'image') |
|
|
|
|
|
} |
|
|
|
|
|
} else if (existingNonImageFiles.length > 0) { |
|
|
|
|
|
// 若已有非图片文件,清空已有非图片文件 |
|
|
|
|
|
this.fileList = this.fileList.filter(item => item.formatType === 'image') |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 检查图片文件数量 |
|
|
|
|
|
if (imageFiles.length > 3) { |
|
|
|
|
|
this.$message.error('图片文件最多只能选择 3 个,请重新选择') |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (const file of imageFiles) { |
|
|
|
|
|
// 检查文件是否已存在 |
|
|
|
|
|
if (this.fileList.some(item => item.name === file.name)) { |
|
|
|
|
|
this.$message.warning(`文件 ${file.name} 已存在,请勿重复上传`) |
|
|
|
|
|
continue |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const fileInfo = { |
|
|
|
|
|
file: file, |
|
|
|
|
|
size: file.size, |
|
|
|
|
|
formatType: file.type.substring(0, file.type.indexOf('/')), |
|
|
|
|
|
name: file.name, |
|
|
|
|
|
postfix: file.name.substring( |
|
|
|
|
|
file.name.lastIndexOf('.') + 1, |
|
|
|
|
|
file.name.length |
|
|
|
|
|
), |
|
|
|
|
|
px: '' |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const fileBase64 = await this.getBase64(file) |
|
|
const res = await this.getImgPx(fileBase64) |
|
|
const res = await this.getImgPx(fileBase64) |
|
|
this.px = res.width + 'px*' + res.height + 'px' |
|
|
|
|
|
} else { |
|
|
|
|
|
this.px = '' |
|
|
|
|
|
|
|
|
fileInfo.px = res.width + 'px*' + res.height + 'px' |
|
|
|
|
|
|
|
|
|
|
|
this.fileList.push(fileInfo) |
|
|
|
|
|
this.uploadSave() |
|
|
|
|
|
} |
|
|
|
|
|
} else if (nonImageFiles.length > 0) { |
|
|
|
|
|
if (existingNonImageFiles.length > 0) { |
|
|
|
|
|
// 若已有非图片文件,直接替换 |
|
|
|
|
|
this.fileList = this.fileList.filter(item => item.formatType === 'image') |
|
|
|
|
|
} else if (existingImageFiles.length > 0) { |
|
|
|
|
|
// 若已有图片文件,清空已有图片文件 |
|
|
|
|
|
this.fileList = this.fileList.filter(item => item.formatType !== 'image') |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 检查非图片文件数量 |
|
|
|
|
|
if (nonImageFiles.length > 1) { |
|
|
|
|
|
this.$message.error('非图片文件最多只能选择 1 个,请重新选择') |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (const file of nonImageFiles) { |
|
|
|
|
|
// 检查文件是否已存在 |
|
|
|
|
|
if (this.fileList.some(item => item.name === file.name)) { |
|
|
|
|
|
this.$message.warning(`文件 ${file.name} 已存在,请勿重复上传`) |
|
|
|
|
|
continue |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const fileInfo = { |
|
|
|
|
|
file: file, |
|
|
|
|
|
size: file.size, |
|
|
|
|
|
formatType: file.type.substring(0, file.type.indexOf('/')), |
|
|
|
|
|
name: file.name, |
|
|
|
|
|
postfix: file.name.substring( |
|
|
|
|
|
file.name.lastIndexOf('.') + 1, |
|
|
|
|
|
file.name.length |
|
|
|
|
|
), |
|
|
|
|
|
px: '' |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.fileList.push(fileInfo) |
|
|
this.uploadSave() |
|
|
this.uploadSave() |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
// 上传附件 |
|
|
// 上传附件 |
|
|
// reDocumentUpload(this.baseApi + '/api/re-document/uploadFile', this.file, this.selectedDocument.id).then(res => { |
|
|
// reDocumentUpload(this.baseApi + '/api/re-document/uploadFile', this.file, this.selectedDocument.id).then(res => { |
|
|
// if (res.data.code === 200) { |
|
|
// if (res.data.code === 200) { |
|
@ -348,26 +451,26 @@ export default { |
|
|
// 上传附件 - 选择上传即保存 |
|
|
// 上传附件 - 选择上传即保存 |
|
|
uploadSave() { |
|
|
uploadSave() { |
|
|
this.aiLoading = true |
|
|
this.aiLoading = true |
|
|
this.nowDate = getCurrentTime() |
|
|
|
|
|
const json = { |
|
|
|
|
|
'file_name': this.fileNames, |
|
|
|
|
|
'file_size': this.fileSize, |
|
|
|
|
|
'file_type': this.postfix, |
|
|
|
|
|
'file_path': this.filePath, |
|
|
|
|
|
'sequence': null, |
|
|
|
|
|
'archive_id': this.arcId, |
|
|
|
|
|
'file_dpi': this.px, |
|
|
|
|
|
'file_thumbnail': '', |
|
|
|
|
|
'create_time': this.nowDate, |
|
|
|
|
|
'id': null, |
|
|
|
|
|
'is_quote': null, |
|
|
|
|
|
'last_modified': this.file.lastModified |
|
|
|
|
|
} |
|
|
|
|
|
const arrayUpload = [] |
|
|
|
|
|
arrayUpload.push(json) |
|
|
|
|
|
this.aiFileOriginal = this.fileNames |
|
|
|
|
|
this.fileJsonString = JSON.stringify(arrayUpload) |
|
|
|
|
|
console.log(this.fileJsonString) |
|
|
|
|
|
|
|
|
// this.nowDate = getCurrentTime() |
|
|
|
|
|
// const json = { |
|
|
|
|
|
// 'file_name': this.fileNames, |
|
|
|
|
|
// 'file_size': this.fileSize, |
|
|
|
|
|
// 'file_type': this.postfix, |
|
|
|
|
|
// 'file_path': this.filePath, |
|
|
|
|
|
// 'sequence': null, |
|
|
|
|
|
// 'archive_id': this.arcId, |
|
|
|
|
|
// 'file_dpi': this.px, |
|
|
|
|
|
// 'file_thumbnail': '', |
|
|
|
|
|
// 'create_time': this.nowDate, |
|
|
|
|
|
// 'id': null, |
|
|
|
|
|
// 'is_quote': null, |
|
|
|
|
|
// 'last_modified': this.file.lastModified |
|
|
|
|
|
// } |
|
|
|
|
|
// const arrayUpload = [] |
|
|
|
|
|
// arrayUpload.push(json) |
|
|
|
|
|
// this.aiFileOriginal = this.fileNames |
|
|
|
|
|
// this.fileJsonString = JSON.stringify(arrayUpload) |
|
|
|
|
|
// console.log(this.fileJsonString) |
|
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
setTimeout(() => { |
|
|
const json = `{ |
|
|
const json = `{ |
|
@ -416,24 +519,28 @@ export default { |
|
|
|
|
|
|
|
|
this.aiJsonData = json |
|
|
this.aiJsonData = json |
|
|
this.startTypingEffect() |
|
|
this.startTypingEffect() |
|
|
this.aiLoading = false |
|
|
|
|
|
}, 3000) |
|
|
}, 3000) |
|
|
}, |
|
|
}, |
|
|
startTypingEffect() { |
|
|
startTypingEffect() { |
|
|
const lines = this.aiJsonData.split('\n') |
|
|
const lines = this.aiJsonData.split('\n') |
|
|
let currentLineIndex = 0 |
|
|
|
|
|
|
|
|
this.currentLineIndex = 0 |
|
|
this.displayedText = '' |
|
|
this.displayedText = '' |
|
|
this.typingFinished = false |
|
|
this.typingFinished = false |
|
|
|
|
|
|
|
|
this.typingInterval = setInterval(() => { |
|
|
this.typingInterval = setInterval(() => { |
|
|
if (currentLineIndex < lines.length) { |
|
|
|
|
|
this.displayedText += lines[currentLineIndex] + '\n' |
|
|
|
|
|
currentLineIndex++ |
|
|
|
|
|
|
|
|
if (this.currentLineIndex < lines.length) { |
|
|
|
|
|
this.displayedText += lines[this.currentLineIndex] + '\n' |
|
|
|
|
|
this.currentLineIndex++ |
|
|
} else { |
|
|
} else { |
|
|
clearInterval(this.typingInterval) |
|
|
clearInterval(this.typingInterval) |
|
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
setTimeout(() => { |
|
|
this.typingFinished = true |
|
|
this.typingFinished = true |
|
|
|
|
|
if (this.aiJsonData) { |
|
|
|
|
|
// this.$refs.previewForm.archivesType = 'add' |
|
|
this.$refs.previewForm.addOrUpdateForm = JSON.parse(this.aiJsonData) |
|
|
this.$refs.previewForm.addOrUpdateForm = JSON.parse(this.aiJsonData) |
|
|
|
|
|
this.aiLoading = false |
|
|
|
|
|
} |
|
|
}, 1000) |
|
|
}, 1000) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -493,6 +600,7 @@ export default { |
|
|
.ai-category-main{ |
|
|
.ai-category-main{ |
|
|
display: flex; |
|
|
display: flex; |
|
|
justify-content: flex-start; |
|
|
justify-content: flex-start; |
|
|
|
|
|
margin-top: 10px; |
|
|
|
|
|
|
|
|
.ai-des-left{ |
|
|
.ai-des-left{ |
|
|
width: 740px; |
|
|
width: 740px; |
|
@ -502,9 +610,8 @@ export default { |
|
|
flex: 1; |
|
|
flex: 1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.ai-des-form, |
|
|
|
|
|
.ai-des-json{ |
|
|
|
|
|
height: calc(100vh - 272px); |
|
|
|
|
|
|
|
|
.ai-des-form{ |
|
|
|
|
|
height: calc(100vh - 262px); |
|
|
overflow-y: auto; |
|
|
overflow-y: auto; |
|
|
padding-right: 10px; |
|
|
padding-right: 10px; |
|
|
} |
|
|
} |
|
@ -582,5 +689,7 @@ pre { |
|
|
border-radius: 4px; |
|
|
border-radius: 4px; |
|
|
white-space: pre-wrap; |
|
|
white-space: pre-wrap; |
|
|
word-wrap: break-word; |
|
|
word-wrap: break-word; |
|
|
|
|
|
height: calc(100vh - 300px); |
|
|
|
|
|
overflow-y: auto; |
|
|
} |
|
|
} |
|
|
</style> |
|
|
</style> |