|
|
@ -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 }) |
|
|
|
} 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) { |
|
|
|