Browse Source

重复项优化

master
xuhuajiao 3 months ago
parent
commit
cc208f6d03
  1. 22
      src/api/collect/collect.js
  2. 66
      src/views/collectReorganizi/collectionLibrary/module/collectHeader.vue
  3. 311
      src/views/components/category/PreviewForm.vue

22
src/api/collect/collect.js

@ -385,6 +385,24 @@ export function FetchMaxItemNoByParentId(params) {
})
}
// 根据档号判断是否重复 --- 预归档库
export function FetchIsRepeatByArchivesNo(params) {
return request({
url: 'api/collect/isRepeatByArchivesNo',
method: 'get',
params
})
}
// 根据档号判断是否重复 --- 收集库
export function FetchIsRepeatAllByArchivesNo(params) {
return request({
url: 'api/collect/isRepeatAllByArchivesNo',
method: 'get',
params
})
}
export default {
collectAdd,
collectEdit,
@ -424,5 +442,7 @@ export default {
FetchEditMarkByFileId,
FetchMarkByFileId,
FetchInitFileMarkCategoryView,
FetchMaxItemNoByParentId
FetchMaxItemNoByParentId,
FetchIsRepeatByArchivesNo,
FetchIsRepeatAllByArchivesNo
}

66
src/views/collectReorganizi/collectionLibrary/module/collectHeader.vue

@ -160,6 +160,7 @@
@close-dialog="closeDialog"
@handleForm="handleForm"
@formLoadingShow="formLoadingShow"
@repeatDataShow="repeatDataShow"
/>
<div v-if="isAiAutoCategory" v-loading="aiResultCaLoading" style="flex: 1; margin-left: 10px; ">
<pre ref="typingContainer" v-highlightjs="displayedText">{{ displayedText }}</pre>
@ -276,7 +277,7 @@
<el-dialog class="tip-dialog" title="提示" :close-on-click-modal="false" :modal-append-to-body="false" append-to-body :visible.sync="moveVisible">
<div class="setting-dialog">
<div class="tip-content">
<p class="tipMsg">移出将把会所选条目返还到未整理列表</p>
<p class="tipMsg">操作将把所选条目放入未整理列表</p>
<span>你是否还要继续?</span>
</div>
<div slot="footer" class="dialog-footer">
@ -286,6 +287,44 @@
</div>
</el-dialog>
<!--档案号重复得list-->
<el-dialog title="档号重复" :close-on-click-modal="false" :modal-append-to-body="false" append-to-body :visible.sync="repeatVisible" :before-close="handleRepeatClose">
<div class="setting-dialog">
<div v-if="repeatResponseData.delcount === 0" class="double-click-btn" style="position: static; margin: -10px 0 10px 0;"><i class="iconfont icon-zhuyi-lan" /><span>建议修改当前输入的档号</span></div>
<div v-else class="double-click-btn" style="position: static; margin: -10px 0 10px 0;"><i class="iconfont icon-zhuyi-lan" /><span>建议删除回收站相关数据 或者 修改当前输入的档号</span></div>
<el-table
ref="table"
v-loading="repeatLoading"
class="archives-table"
:data="repeatData"
row-key="id"
>
<el-table-column label="所属门类" prop="createBy" />
<el-table-column v-if="repeatResponseData.delcount === 0" label="所属位置" prop="collectFormal">
<template slot-scope="scope">
<div v-if="scope.row.collectFormal === 1">收集库</div>
<div v-if="scope.row.collectFormal === 2">归档中</div>
<div v-if="scope.row.collectFormal === 3">管理库</div>
</template>
</el-table-column>
<el-table-column v-else label="所属位置" prop="isDeleteMan">
<template slot-scope="scope">
<div v-if="scope.row.isDeleteMan">回收站</div>
</template>
</el-table-column>
<el-table-column label="题名" prop="maintitle" />
<el-table-column label="创建人" prop="createBy" />
<el-table-column label="创建时间" prop="createTime" align="center" width="160">
<template slot-scope="scope">
<div v-if="scope.row.createTime">{{ scope.row.createTime | parseTime }}</div>
<div v-else>-</div>
</template>
</el-table-column>
</el-table>
</div>
</el-dialog>
<!-- 原文上传 -->
<UploadOriginal ref="uploadOriginalRef" :selected-category="selectedCategory" :arc-id="arcId" @close-dialog="closeDialog" />
<!-- 大文件上传 -->
@ -425,7 +464,11 @@ export default {
expandedRows: [],
aiResultCaLoading: true, // ailoading
isDialogClosed: false, //
reader: null //
reader: null, //
repeatVisible: false,
repeatLoading: false,
repeatResponseData: {},
repeatData: []
}
},
computed: {
@ -583,6 +626,7 @@ export default {
// -form/-api
handleForm(type, isPaper) {
this.formIsAddOrEdit = type
if (type === 'add') {
if (this.parentsData.parentsProjectId && this.isTitleType === 3) {
console.log('项目下的案卷')
@ -757,6 +801,24 @@ export default {
formLoadingShow(loadingType) {
this.archivesBtnLoading = loadingType
},
repeatDataShow(data) {
this.repeatVisible = true
this.repeatLoading = true
this.repeatData = []
if (data) {
this.repeatResponseData = data
this.repeatData.push(data.archivesSummary)
setTimeout(() => {
this.repeatLoading = false
}, 500)
}
},
handleRepeatClose() {
this.repeatResponseData = {}
this.repeatData = []
this.repeatLoading = false
this.repeatVisible = false
},
//
handleClose(done) {
this.formVisible = false

311
src/views/components/category/PreviewForm.vue

@ -83,19 +83,6 @@
</el-radio-group>
</el-form-item>
</el-col>
<!-- <el-col v-if="isDesFormType === 'arcives'">
<el-form-item label="AI辅助著录" class="pbysical-style">
<div class="upload-btn">
<input id="upFile" type="file" name="upFile" multiple @change="changeAiFile($event)">
<el-button size="small" type="primary"><i class="iconfont icon-shangchuan" />上传</el-button>
</div>
<div v-for="item in fileList" :key="item.name" class="file-list">
<i class="iconfont icon-xiaowenjian" />
{{ item.name }}
<i class="el-icon-close" @click="deleteFile(item)" />
</div>
</el-form-item>
</el-col> -->
</el-row>
</el-form>
@ -143,7 +130,7 @@
<script>
import { crud } from '@crud/crud'
import { FetchDoeditIsRepeat } from '@/api/archivesManage/archivesList'
import { collectAdd, collectEdit } from '@/api/collect/collect'
import { collectAdd, collectEdit, FetchIsRepeatByArchivesNo, FetchIsRepeatAllByArchivesNo } from '@/api/collect/collect'
import { prearchEdit, FetchMergeToFile, FetchReDoeditIsRepeat } from '@/api/prearchiveLibrary/prearchiveLibrary'
import { getNoFormatField } from '@/api/system/category/fileNoFormat'
import draggable from 'vuedraggable'
@ -250,7 +237,8 @@ export default {
archivesType: null,
activeIndex: null,
entityIndex: null,
fileList: []
fileList: [],
archivesSummaryResponse: {}
}
},
computed: {
@ -432,6 +420,58 @@ export default {
this.formPreviewData.map(item => {
if (item.isAutomatic) {
this.$set(this.addOrUpdateForm, item.fieldName, string)
// archive_year
if (item.fieldName === 'archive_no') {
const rule = {}
const validateArchiveNo = async(value) => {
let errorMessage = null
if (value === '') {
if (item.isRequired === null || item.isRequired === false) {
return
}
errorMessage = item.isInputClass === 'text' ? `请输入${item.fieldCnName}` : `请选择${item.fieldCnName}`
return errorMessage
}
if (getAutoFiledVal.length === this.autoMatic.length) {
let response
try {
if (this.isDesFormType === 'mergeFile') {
response = await FetchIsRepeatByArchivesNo({ archivesId: null, archivesNo: value })
if (response !== 0) {
errorMessage = '请注意,该档号已被使用'
}
} else {
response = await FetchIsRepeatAllByArchivesNo({
archivesId: this.archivesType === 'add' ? null : this.addOrUpdateForm.id,
archivesNo: value
})
if ((response.nodelcount !== 0 && response.delcount === 0) || (response.nodelcount === 0 && response.delcount !== 0)) {
errorMessage = '请注意,该档号已被使用'
}
this.archivesSummaryResponse = response
}
} catch (error) {
errorMessage = '验证档号重复时发生错误,请稍后再试'
}
}
return errorMessage
}
rule.validator = async(rule, value, callback) => {
const errorMessage = await validateArchiveNo(value)
if (errorMessage) {
rule.message = errorMessage
callback(new Error(errorMessage))
} else {
callback()
}
}
this.$set(this.rules, item.fieldName, [rule])
}
}
})
})
@ -753,22 +793,65 @@ export default {
trigger: item.isInputClass === 'text' ? 'blur' : 'change'
}
// archive_year
// if (item.fieldName !== 'archive_year' && item.isColumnLength) {
// rule.validator = (rule, value, callback) => {
// let errorMessage = null
// const maxLength = parseInt(item.isColumnLength)
// if (item.isRequired === null || item.isRequired === false) {
// if (value === '') {
// callback()
// return
// } else {
// if (maxLength && typeof value === 'string' && value.length > maxLength) {
// errorMessage = `${maxLength}${item.fieldCnName}`
// }
// }
// } else {
// if (value === '') {
// rule.message = item.isInputClass === 'text' ? `${item.fieldCnName}` : `${item.fieldCnName}`
// callback(new Error(errorMessage))
// } else {
// if (maxLength && typeof value === 'string' && value.length > maxLength) {
// errorMessage = `${maxLength}${item.fieldCnName}`
// }
// }
// }
// if (errorMessage) {
// rule.message = errorMessage
// callback(new Error(errorMessage))
// } else {
// callback()
// }
// }
// }
// archive_year
if (item.fieldName !== 'archive_year' && item.isColumnLength) {
const getErrorMessage = (value, maxLength, fieldCnName) => {
if (maxLength && typeof value === 'string' && value.length > maxLength) {
return `输入内容最多为${maxLength}个字符的${fieldCnName}`
}
return null
}
rule.validator = (rule, value, callback) => {
//
if (item.isRequired === null && value === '') {
const maxLength = parseInt(item.isColumnLength)
const isRequired = item.isRequired !== null && item.isRequired
if (!isRequired && value === '') {
callback()
return
}
let errorMessage = null
const maxLength = parseInt(item.isColumnLength)
if (maxLength && typeof value === 'string' && value.length > maxLength) {
errorMessage = `输入内容最多为${maxLength}个字符的${item.fieldCnName}`
if (isRequired && value === '') {
rule.message = item.isInputClass === 'text' ? `请输入${item.fieldCnName}` : `请选择${item.fieldCnName}`
callback(new Error(rule.message))
return
}
const errorMessage = getErrorMessage(value, maxLength, item.fieldCnName)
if (errorMessage) {
rule.message = errorMessage
callback(new Error(errorMessage))
@ -779,22 +862,69 @@ export default {
}
// archive_year
// if (item.fieldName === 'archive_year') {
// rule.validator = (rule, value, callback) => {
// let errorMessage = null
// if (item.isRequired === null || item.isRequired === false) {
// if (value === '') {
// callback()
// return
// } else {
// if (isNaN(Number(value))) {
// errorMessage = `${item.fieldCnName}`
// } else if (item.isColumnLength && String(value).length !== parseInt(item.isColumnLength)) {
// errorMessage = `${item.fieldCnName} ${item.isColumnLength} `
// }
// }
// } else {
// if (value === '') {
// rule.message = item.isInputClass === 'text' ? `${item.fieldCnName}` : `${item.fieldCnName}`
// callback(new Error(errorMessage))
// } else {
// if (isNaN(Number(value))) {
// errorMessage = `${item.fieldCnName}`
// } else if (item.isColumnLength && String(value).length !== parseInt(item.isColumnLength)) {
// errorMessage = `${item.fieldCnName} ${item.isColumnLength} `
// }
// }
// }
// if (errorMessage) {
// rule.message = errorMessage
// callback(new Error(errorMessage))
// } else {
// callback()
// }
// }
// }
if (item.fieldName === 'archive_year') {
//
const validateArchiveYear = (value) => {
if (isNaN(Number(value))) {
return `请输入有效的数字的${item.fieldCnName}`
}
if (item.isColumnLength && String(value).length !== parseInt(item.isColumnLength)) {
return `输入的${item.fieldCnName}必须是 ${item.isColumnLength} 个字符`
}
return null
}
rule.validator = (rule, value, callback) => {
//
if (item.isRequired === null && value === '') {
const isRequired = item.isRequired !== null && item.isRequired
if (!isRequired && value === '') {
callback()
return
}
let errorMessage = null
if (isNaN(Number(value))) {
errorMessage = `请输入有效的数字的${item.fieldCnName}`
} else if (item.isColumnLength && String(value).length !== parseInt(item.isColumnLength)) {
errorMessage = `输入的${item.fieldCnName}必须是 ${item.isColumnLength} 个字符`
if (isRequired && value === '') {
rule.message = item.isInputClass === 'text' ? `请输入${item.fieldCnName}` : `请选择${item.fieldCnName}`
callback(new Error(rule.message))
return
}
const errorMessage = validateArchiveYear(value)
if (errorMessage) {
rule.message = errorMessage
callback(new Error(errorMessage))
@ -855,9 +985,9 @@ export default {
this.addOrUpdateForm.fonds_affiliation = this.selectedCategory.fondsId
}
delete this.addOrUpdateForm.id
this.$refs[formName].validate((valid) => {
this.$refs[formName].validate((valid, fields) => {
if (valid) {
// this.$emit('formLoadingShow', true)
this.$emit('formLoadingShow', true)
//
if (this.isDesFormType === 'prearchiveLibrary') {
if (this.fileOriginal === null) {
@ -884,19 +1014,23 @@ export default {
} else if (this.isDesFormType === 'mergeFile') {
//
const params = {
'fondsAffiliation': this.user.fonds.id.toString(),
'archivesId': null,
'archivesIds': this.mergeFileArcIds,
'documentId': categoryId,
'categoryId': this.mergeFileCategory,
'archivesNo': this.addOrUpdateForm.archive_no,
'jsonString': JSON.stringify(this.addOrUpdateForm)
}
FetchMergeToFile(params).then(res => {
if (res) {
if (res.code !== 500) {
this.$message({ message: res, type: 'success', offset: 8 })
this.$emit('close-dialog')
this.crud.refresh()
this.$emit('formLoadingShow', false)
} else {
this.$message({ message: res.message, type: 'error', offset: 8 })
}
this.$emit('close-dialog')
this.crud.refresh()
this.$emit('formLoadingShow', false)
})
} else {
//
@ -949,11 +1083,11 @@ export default {
}
}
console.log(params)
console.log('this.addOrUpdateForm', this.addOrUpdateForm)
if (this.archivesType === 'add') {
collectAdd(params).then(res => {
if (res.code === 200) {
this.$message({ message: res.message, type: 'success', offset: 8 })
console.log('res', res)
if (res.code !== 500) {
this.$message({ message: res, type: 'success', offset: 8 })
this.$emit('close-dialog', parentsId)
if (arcAddType === 1) {
localStorage.setItem('savePrevFromData', JSON.stringify(this.addOrUpdateForm))
@ -963,12 +1097,16 @@ export default {
} else {
localStorage.removeItem('savePrevFromData')
}
} else {
this.$message({ message: res.message, type: 'error', offset: 8 })
this.$emit('close-dialog', parentsId)
}
this.$emit('formLoadingShow', false)
})
} else {
collectEdit(params).then(res => {
if (res.code === 200) {
console.log('res-collectEdit', res)
if (res.code !== 500) {
this.$message({ message: res.message, type: 'success', offset: 8 })
this.$emit('close-dialog', parentsId)
} else {
@ -981,6 +1119,18 @@ export default {
}
} else {
console.log('error submit!!')
if (this.isDesFormType === 'arcives') {
for (const field in fields) {
if (fields[field].length > 0) {
// console.log(` ${field} : ${fields[field][0].message}`)
if (field === 'archive_no') {
console.log('档号有问题')
this.$emit('repeatDataShow', this.archivesSummaryResponse)
}
}
}
}
return false
}
})
@ -992,7 +1142,6 @@ export default {
this.popoverTableData = []
this.popoverTableDataClassify = []
this.popoverTableDataFonds = []
done()
},
//
@ -1020,85 +1169,6 @@ export default {
}
})
},
async changeAiFile(e) {
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/'))
//
const existingImageFiles = this.fileList.filter(item => item.formatType === 'image')
const existingNonImageFiles = this.fileList.filter(item => item.formatType !== 'image')
//
if (existingImageFiles.length > 0 && nonImageFiles.length > 0) {
this.$message.error('已有图片文件,此次只能上传图片文件')
return
}
if (existingNonImageFiles.length > 0 && imageFiles.length > 0) {
this.$message.error('已有非图片文件,此次只能上传非图片文件')
return
}
//
const remainingImageSlots = 3 - existingImageFiles.length
const remainingNonImageSlots = 1 - existingNonImageFiles.length
//
if (imageFiles.length > remainingImageSlots) {
this.$message.error(`图片文件最多还能选择 ${remainingImageSlots}`)
return
}
//
if (nonImageFiles.length > remainingNonImageSlots) {
this.$message.error(`非图片文件最多还能选择 ${remainingNonImageSlots}`)
return
}
const validFiles = imageFiles.length > 0 ? imageFiles : nonImageFiles
for (const file of validFiles) {
//
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: ''
}
if (fileInfo.formatType === 'image') {
const fileBase64 = await this.getBase64(file)
const res = await this.getImgPx(fileBase64)
fileInfo.px = res.width + 'px*' + res.height + 'px'
}
this.fileList.push(fileInfo)
//
// reDocumentUpload(this.baseApi + '/api/re-document/uploadFile', file, this.selectedDocument.id).then(res => {
// if (res.data.code === 200) {
// this.filePath = res.data.data;
// this.uploadSave();
// }
// });
}
},
deleteFile(item) {
const index = this.fileList.indexOf(item)
if (index !== -1) {
this.fileList.splice(index, 1)
}
},
// -
uploadSave() {
this.nowDate = getCurrentTime()
@ -1122,7 +1192,6 @@ export default {
// this.$set(this.addOrUpdateForm, 'fileOriginal', this.fileNames)
this.fileJsonString = JSON.stringify(arrayUpload)
console.log(this.fileJsonString)
},
// base64
getBase64(file) {

Loading…
Cancel
Save