diff --git a/src/api/system/sql.js b/src/api/system/sql.js index b7adc15..cf2f96e 100644 --- a/src/api/system/sql.js +++ b/src/api/system/sql.js @@ -36,4 +36,22 @@ export function FetchrestoreDatabase(params) { }) } -export default { add, FetchBackupName, del, FetchrestoreDatabase } +// 初始化自动备份数据库设置 +export function FetchDatabaseSaveSetting(params) { + return request({ + url: 'api/database/getDatabaseSaveSetting', + method: 'get', + params + }) +} + +// 保存自动备份数据库设置 +export function FetchSaveDatabaseSaveSetting(data) { + return request({ + url: 'api/database/saveDatabaseSaveSetting', + method: 'post', + data + }) +} + +export default { add, FetchBackupName, del, FetchrestoreDatabase, FetchDatabaseSaveSetting, FetchSaveDatabaseSaveSetting } diff --git a/src/utils/upload.js b/src/utils/upload.js index 1caa7cb..8ef1387 100644 --- a/src/utils/upload.js +++ b/src/utils/upload.js @@ -81,45 +81,48 @@ export function modelUpload(api, file, name) { // 收集库 - 批量挂接 // export function batchMountUpload(api, file, params) { export function batchMountUpload(api, params) { - var data = new FormData() - // for (const item in file) { // 现在 - // data.append('file', file[item]) - // } - data.append('categoryId', params.categoryId) - data.append('mountType', params.mountType) - data.append('checkRepeatType', params.checkRepeatType) - data.append('matchingMode', params.matchingMode) - data.append('fields', params.fields) - data.append('fondsId', params.fondsId) - data.append('upfilePath', params.upfilePath) + // var data = new FormData() + // data.append('categoryId', params.categoryId) + // data.append('mountType', params.mountType) + // data.append('checkRepeatType', params.checkRepeatType) + // data.append('matchingMode', params.matchingMode) + // data.append('fields', params.fields) + // data.append('fondsId', params.fondsId) + // data.append('upfilePath', params.upfilePath) + const jsonData = JSON.stringify(params) const config = { headers: { + 'Content-Type': 'application/json;charset=UTF-8', 'Authorization': getToken() - } + }, + transformRequest: [(data) => data] } - return axios.post(api, data, config) + return axios.post(api, jsonData, config) } // 收集库 - 远程挂接 export function remoteConnectiontUpload(api, params) { - var data = new FormData() - data.append('account', params.account) - data.append('cAddress', params.cAddress) - data.append('cPassword', params.cPassword) - data.append('cPort', params.cPort) - data.append('categoryId', params.categoryId) - data.append('checkRepeatType', params.checkRepeatType) - data.append('matchingMode', params.matchingMode) - data.append('fields', params.fields) - data.append('protocol', params.protocol) - data.append('zipFilePath', params.zipFilePath) - data.append('fondsId', params.fondsId) + // var data = new FormData() + // data.append('account', params.account) + // data.append('cAddress', params.cAddress) + // data.append('cPassword', params.cPassword) + // data.append('cPort', params.cPort) + // data.append('categoryId', params.categoryId) + // data.append('checkRepeatType', params.checkRepeatType) + // data.append('matchingMode', params.matchingMode) + // data.append('fields', params.fields) + // data.append('protocol', params.protocol) + // data.append('zipFilePath', params.zipFilePath) + // data.append('fondsId', params.fondsId) + const jsonData = JSON.stringify(params) const config = { headers: { + 'Content-Type': 'application/json;charset=UTF-8', 'Authorization': getToken() - } + }, + transformRequest: [(data) => data] } - return axios.post(api, data, config) + return axios.post(api, jsonData, config) } // 在线编研附件 diff --git a/src/views/collectReorganizi/batchConnection/module/detail.vue b/src/views/collectReorganizi/batchConnection/module/detail.vue index 978308c..a341dc5 100644 --- a/src/views/collectReorganizi/batchConnection/module/detail.vue +++ b/src/views/collectReorganizi/batchConnection/module/detail.vue @@ -20,7 +20,7 @@ - + diff --git a/src/views/collectReorganizi/batchConnection/module/form.vue b/src/views/collectReorganizi/batchConnection/module/form.vue index 62606c8..6bbae17 100644 --- a/src/views/collectReorganizi/batchConnection/module/form.vue +++ b/src/views/collectReorganizi/batchConnection/module/form.vue @@ -47,7 +47,8 @@ -->
- {{ item.file_name }} + + {{ item }}
@@ -240,13 +241,13 @@ export default { console.log('handleSuccessResource', filePath) console.log('handleSuccessResource', fileName) console.log('handleSuccessResource', jsonArrayToSend) - console.log('handleSuccessResource', jsonArrayToSend[0].fileJsonString) + // console.log('handleSuccessResource', jsonArrayToSend[0].fileJsonString) - const fileJson = JSON.parse(jsonArrayToSend[0].fileJsonString) - fileJson[0].file_path = filePath - fileJson[0].is_quote = null - fileJson[0].last_modified = jsonArrayToSend[0].last_modified - this.fileList = fileJson + // const fileJson = JSON.parse(jsonArrayToSend[0].fileJsonString) + // fileJson[0].file_path = filePath + // fileJson[0].is_quote = null + // fileJson[0].last_modified = jsonArrayToSend[0].last_modified + this.fileList = fileName this.upfilePath = filePath }, handleErrorResource(res) { @@ -305,9 +306,9 @@ export default { } else { const params = { 'account': this.form.filePath.account, - 'cAddress': this.form.filePath.caddress, - 'cPassword': this.form.filePath.cpassword, - 'cPort': this.form.filePath.cport, + 'caddress': this.form.filePath.caddress, + 'cpassword': this.form.filePath.cpassword, + 'cport': this.form.filePath.cport, 'categoryId': this.selectedCategory.id, 'fondsId': this.selectedCategory.fondsId, 'checkRepeatType': this.form.checkRepeatType, @@ -409,12 +410,17 @@ export default { if (val) { this.fileRemoteOptions = [] FetchFileByRemoteConnection({ 'id': val.id }).then(res => { - this.fileRemoteOptions = res.map(item => { - const json = {} - json.value = item - json.name = item - return json - }) + if (res) { + this.fileRemoteOptions = res.map(item => { + const json = {} + json.value = item + json.name = item + return json + }) + } else { + this.fileRemoteOptions = [] + } + this.fileRemoteLoading = false }) } diff --git a/src/views/components/category/PreviewForm.vue b/src/views/components/category/PreviewForm.vue index 0a7ff0d..56e9d69 100644 --- a/src/views/components/category/PreviewForm.vue +++ b/src/views/components/category/PreviewForm.vue @@ -1283,164 +1283,166 @@ export default { } console.log('this.addOrUpdateForm', this.addOrUpdateForm) - console.log('this.addOrUpdateForm.archive_no', this.addOrUpdateForm.archive_no) - - this.$refs[formName].validate((valid, fields) => { - if (valid) { - delete this.addOrUpdateForm.id - this.$emit('formLoadingShow', true) - // 预归档库 - if (this.isDesFormType === 'prearchiveLibrary') { - if (this.fileOriginal === null) { - this.$message({ message: '请上传电子原件', type: 'error', offset: 8 }) - this.$emit('formLoadingShow', false) - return false - } - // delete this.addOrUpdateForm.fileOriginal - const params = { - 'id': this.archivesType === 'edit' ? this.arcId : null, - 'ids': null, - 'documentId': categoryId, - 'delMan': null, - 'jsonString': JSON.stringify(this.addOrUpdateForm), - 'fileJsonString': this.fileJsonString, - 'fondsAffiliation': this.selectedDocument.fondsId + this.$nextTick(() => { + console.log('this.addOrUpdateForm.archive_no', this.addOrUpdateForm.archive_no) + + this.$refs[formName].validate((valid, fields) => { + if (valid) { + delete this.addOrUpdateForm.id + this.$emit('formLoadingShow', true) + // 预归档库 + if (this.isDesFormType === 'prearchiveLibrary') { + if (this.fileOriginal === null) { + this.$message({ message: '请上传电子原件', type: 'error', offset: 8 }) + this.$emit('formLoadingShow', false) + return false + } + // delete this.addOrUpdateForm.fileOriginal + const params = { + 'id': this.archivesType === 'edit' ? this.arcId : null, + 'ids': null, + 'documentId': categoryId, + 'delMan': null, + 'jsonString': JSON.stringify(this.addOrUpdateForm), + 'fileJsonString': this.fileJsonString, + 'fondsAffiliation': this.selectedDocument.fondsId - } - console.log('this.fileJsonString', JSON.parse(this.fileJsonString)) - console.log('params', params) - prearchEdit(params).then(res => { - if (res) { - this.$message({ message: res.message, type: 'success', offset: 8 }) - this.$emit('close-dialog') - this.crud.refresh() - this.fileOriginal = null } - this.$emit('formLoadingShow', false) - }) - } else if (this.isDesFormType === 'mergeFile') { + console.log('this.fileJsonString', JSON.parse(this.fileJsonString)) + console.log('params', params) + prearchEdit(params).then(res => { + if (res) { + this.$message({ message: res.message, type: 'success', offset: 8 }) + this.$emit('close-dialog') + this.crud.refresh() + this.fileOriginal = null + } + this.$emit('formLoadingShow', false) + }) + } else if (this.isDesFormType === 'mergeFile') { // 合并成件 - const params = { - 'fondsAffiliation': this.selectedCategory.fondsId, - 'archivesId': null, - 'archivesIds': this.mergeFileArcIds, - 'documentId': categoryId, - 'categoryId': this.mergeFileCategory, - 'archivesNo': this.addOrUpdateForm.archive_no, - 'jsonString': JSON.stringify(this.addOrUpdateForm) - } - console.log('合并成件this.selectedCategory', this.selectedCategory) - console.log('params', params) - FetchMergeToFile(params).then(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 { - // 收集库 - let parentsId = null - // 2 项目 3 案卷 /文件 4 卷内 6 文件 - if (this.isTitleType === 2) { - parentsId = null - } else if (this.isTitleType === 3) { - if (this.selectedCategory.arrangeType === 1) { - parentsId = null - } else { - parentsId = this.parentsData.parentsProjectId - } - } else if (this.isTitleType === 4) { - // 卷内 - parentsId = this.parentsData.parentsAnjuanId - } else if (this.isTitleType === 6) { - // 原文 - parentsId = this.parentsData.parentsJuanneiId - } - let params - if (quickPaperArcId && quickPaperArcId.length !== 0 && this.archivesType === 'add') { - // 快速组卷时,组卷的文件是数组,所以要archivesIds 而不是 archivesId,正好是新增文件,所以this.arcId = null不用担心 - params = { - 'archivesId': this.arcId, - 'archivesIds': quickPaperArcId, - 'categoryId': categoryId, - 'parentsId': parentsId, - 'categoryLevel': 2, - 'jsonString': JSON.stringify(this.addOrUpdateForm) - } - } else if (this.selectedCategory.arrangeType === 3 && this.activeIndex === 1 && this.archivesType === 'add') { - // 在项目下,未整理的文件只属于门类下,不属于任何项目或案卷,所以parentsId === null - params = { - 'archivesId': this.arcId, - 'archivesIds': null, - 'categoryId': categoryId, - 'parentsId': null, - 'categoryLevel': this.collectLevel, - 'jsonString': JSON.stringify(this.addOrUpdateForm) - } - } else { - params = { - 'archivesId': this.arcId, - 'archivesIds': null, - 'categoryId': categoryId, - 'parentsId': parentsId, - 'categoryLevel': this.collectLevel, + const params = { + 'fondsAffiliation': this.selectedCategory.fondsId, + 'archivesId': null, + 'archivesIds': this.mergeFileArcIds, + 'documentId': categoryId, + 'categoryId': this.mergeFileCategory, + 'archivesNo': this.addOrUpdateForm.archive_no, 'jsonString': JSON.stringify(this.addOrUpdateForm) } - } - console.log(params) - if (this.archivesType === 'add') { - collectAdd(params).then(res => { - console.log('res', res) + console.log('合并成件this.selectedCategory', this.selectedCategory) + console.log('params', params) + FetchMergeToFile(params).then(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)) - setTimeout(() => { - this.$emit('handleForm', 'add', 0) - }, 1000) - } else { - localStorage.removeItem('savePrevFromData') - } } else { this.$message({ message: res.message, type: 'error', offset: 8 }) - this.$emit('close-dialog', parentsId) } + this.$emit('close-dialog') + this.crud.refresh() this.$emit('formLoadingShow', false) }) } else { - collectEdit(params).then(res => { - console.log('res-collectEdit', res) - if (res.code !== 500) { - this.$message({ message: res, type: 'success', offset: 8 }) - this.$emit('close-dialog', parentsId) + // 收集库 + let parentsId = null + // 2 项目 3 案卷 /文件 4 卷内 6 文件 + if (this.isTitleType === 2) { + parentsId = null + } else if (this.isTitleType === 3) { + if (this.selectedCategory.arrangeType === 1) { + parentsId = null } else { - this.$message({ message: res.message, type: 'error', offset: 8 }) - this.$emit('close-dialog', parentsId) + parentsId = this.parentsData.parentsProjectId } - this.$emit('formLoadingShow', false) - }) + } else if (this.isTitleType === 4) { + // 卷内 + parentsId = this.parentsData.parentsAnjuanId + } else if (this.isTitleType === 6) { + // 原文 + parentsId = this.parentsData.parentsJuanneiId + } + let params + if (quickPaperArcId && quickPaperArcId.length !== 0 && this.archivesType === 'add') { + // 快速组卷时,组卷的文件是数组,所以要archivesIds 而不是 archivesId,正好是新增文件,所以this.arcId = null不用担心 + params = { + 'archivesId': this.arcId, + 'archivesIds': quickPaperArcId, + 'categoryId': categoryId, + 'parentsId': parentsId, + 'categoryLevel': 2, + 'jsonString': JSON.stringify(this.addOrUpdateForm) + } + } else if (this.selectedCategory.arrangeType === 3 && this.activeIndex === 1 && this.archivesType === 'add') { + // 在项目下,未整理的文件只属于门类下,不属于任何项目或案卷,所以parentsId === null + params = { + 'archivesId': this.arcId, + 'archivesIds': null, + 'categoryId': categoryId, + 'parentsId': null, + 'categoryLevel': this.collectLevel, + 'jsonString': JSON.stringify(this.addOrUpdateForm) + } + } else { + params = { + 'archivesId': this.arcId, + 'archivesIds': null, + 'categoryId': categoryId, + 'parentsId': parentsId, + 'categoryLevel': this.collectLevel, + 'jsonString': JSON.stringify(this.addOrUpdateForm) + } + } + console.log(params) + if (this.archivesType === 'add') { + collectAdd(params).then(res => { + 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)) + setTimeout(() => { + this.$emit('handleForm', 'add', 0) + }, 1000) + } 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 => { + console.log('res-collectEdit', res) + if (res.code !== 500) { + this.$message({ message: res, type: 'success', offset: 8 }) + this.$emit('close-dialog', parentsId) + } else { + this.$message({ message: res.message, type: 'error', offset: 8 }) + this.$emit('close-dialog', parentsId) + } + this.$emit('formLoadingShow', false) + }) + } } - } - } else { - console.log('error submit!!') - if (this.isDesFormType === 'arcives') { - for (const field in fields) { - if (fields[field].length > 0) { + } 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) + if (field === 'archive_no') { + console.log('档号有问题') + this.$emit('repeatDataShow', this.archivesSummaryResponse) + } } } } + return false } - return false - } + }) }) }, handleClose(done) { diff --git a/src/views/components/category/preUpload.vue b/src/views/components/category/preUpload.vue index 16fe685..6647da3 100644 --- a/src/views/components/category/preUpload.vue +++ b/src/views/components/category/preUpload.vue @@ -143,7 +143,7 @@ export default { }, // 新增计算属性:动态获取分片接口路径 chunkApiPath() { - return this.isBatchMount === 'true' ? '/api/collect/chunk' : '/api/minioUpload/chunk' + return this.isBatchMount === 'true' ? '/api/collect/chunkZip' : '/api/minioUpload/chunk' } }, @@ -534,91 +534,148 @@ export default { }) try { - const processFiles = validFiles.map(async(fileItem) => { + let response + if (this.isBatchMount === 'true') { + const fileItem = validFiles[0] const file = fileItem.file - const json = {} - const jsonArray = [] - const jsonString = {} - - if (file.type.startsWith('image')) { - const fileBase64 = await this.getBase64(file) - const imgRes = await this.getImgPx(fileBase64) - jsonString.file_dpi = `${imgRes.width}px*${imgRes.height}px` - } else { - jsonString.file_dpi = '' - } - - jsonString.file_name = file.name - jsonString.file_size = file.size - jsonString.file_type = file.name.split('.').pop() || '' - jsonString.last_modified = file.lastModified - jsonString.file_path = '' - jsonString.sequence = null - jsonString.archive_id = this.arcId - jsonString.create_time = nowDate - jsonString.id = null - jsonString.file_thumbnail = '' - jsonArray.push(jsonString) - - console.log('file.lastModified', file.lastModified) - - if (this.isBatchMount === 'true') { - json.categoryId = this.selectedCategory.id - } else { - json.documentId = this.selectedDocument.id - } - const totalChunks = Math.ceil(file.size / this.CHUNK_SIZE) const chunksExist = await this.checkAllChunksExist(fileItem.md5, totalChunks) + if (!chunksExist) { throw new Error(`【${file.name}】部分分片未上传完成,无法合并`) } - json.archivesId = this.arcId - json.identifier = fileItem.md5 - json.filename = file.name - json.totalChunks = totalChunks - json.totalSize = file.size - json.fileJsonString = JSON.stringify(jsonArray) - - return json - }) - - const jsonArray = await Promise.all(processFiles) - // 动态计算合并接口URL - const mergeApiUrl = this.isBatchMount === 'true' - ? `${this.baseApi}/api/collect/merge` - : `${this.baseApi}/api/minioUpload/merge` - // 调用合并接口 - const response = await axios.post(mergeApiUrl, jsonArray, { - headers: { - 'Authorization': getToken(), - 'Content-Type': 'application/json' + const mergeParams = { + identifier: fileItem.md5, + totalChunks: totalChunks, + filename: file.name } - }) - this.totalMergeEndTime = new Date().getTime() - const totalMergeDuration = this.getTimeDiff(this.totalMergeStartTime, this.totalMergeEndTime) - - if (response.data.code === 200) { - this.btnLoading = false - this.showMessage('所有文件上传并合并成功', 'success') - validFiles.forEach((fileItem) => { - fileItem.mergeEndTime = new Date().getTime() - const mergeDuration = this.getTimeDiff(fileItem.mergeStartTime, fileItem.mergeEndTime) - console.log(`【文件${fileItem.file.name}】合并结束时间:${this.formatTime(fileItem.mergeEndTime)},合并耗时:${mergeDuration}`) - fileItem.successMsg = '上传成功!' - fileItem.merging = false + // 调用合并接口(传递单个对象而非数组) + const mergeApiUrl = `${this.baseApi}/api/collect/mergeZip` + response = await axios.post(mergeApiUrl, mergeParams, { + headers: { + 'Authorization': getToken(), + 'Content-Type': 'application/json' + } }) - console.log(`【整体合并】所有文件合并完成,整体合并耗时:${totalMergeDuration}`) - this.$emit('onUploadSuccess', response.data.data, validFiles.map(f => f.file.name), jsonArray) - this.uploadMinioVisible = false - this.fileList = [] // 清空列表,避免下次打开弹框显示旧数据 + this.totalMergeEndTime = new Date().getTime() + const totalMergeDuration = this.getTimeDiff(this.totalMergeStartTime, this.totalMergeEndTime) + + if (response.data.code === 200) { + this.btnLoading = false + this.showMessage('所有文件上传并合并成功', 'success') + validFiles.forEach((fileItem) => { + fileItem.mergeEndTime = new Date().getTime() + const mergeDuration = this.getTimeDiff(fileItem.mergeStartTime, fileItem.mergeEndTime) + console.log(`【文件${fileItem.file.name}】合并结束时间:${this.formatTime(fileItem.mergeEndTime)},合并耗时:${mergeDuration}`) + fileItem.successMsg = '上传成功!' + fileItem.merging = false + }) + console.log(`【整体合并】所有文件合并完成,整体合并耗时:${totalMergeDuration}`) + this.$emit('onUploadSuccess', response.data.data, validFiles.map(f => f.file.name), '') + + this.uploadMinioVisible = false + this.fileList = [] // 清空列表,避免下次打开弹框显示旧数据 + } else { + this.btnLoading = false + throw new Error(response.data.msg || '合并失败') + } } else { - this.btnLoading = false - throw new Error(response.data.msg || '合并失败') + const processFiles = validFiles.map(async(fileItem) => { + const file = fileItem.file + const json = {} + const jsonArray = [] + const jsonString = {} + + if (file.type.startsWith('image')) { + const fileBase64 = await this.getBase64(file) + const imgRes = await this.getImgPx(fileBase64) + jsonString.file_dpi = `${imgRes.width}px*${imgRes.height}px` + } else { + jsonString.file_dpi = '' + } + + jsonString.file_name = file.name + jsonString.file_size = file.size + jsonString.file_type = file.name.split('.').pop() || '' + jsonString.last_modified = file.lastModified + jsonString.file_path = '' + jsonString.sequence = null + jsonString.archive_id = this.arcId + jsonString.create_time = nowDate + jsonString.id = null + jsonString.file_thumbnail = '' + jsonArray.push(jsonString) + + console.log('file.lastModified', file.lastModified) + + if (this.isBatchMount === 'true') { + json.categoryId = this.selectedCategory.id + } else { + json.documentId = this.selectedDocument.id + } + + const totalChunks = Math.ceil(file.size / this.CHUNK_SIZE) + const chunksExist = await this.checkAllChunksExist(fileItem.md5, totalChunks) + if (!chunksExist) { + throw new Error(`【${file.name}】部分分片未上传完成,无法合并`) + } + + json.archivesId = this.arcId + json.identifier = fileItem.md5 + json.filename = file.name + json.totalChunks = totalChunks + json.totalSize = file.size + json.fileJsonString = JSON.stringify(jsonArray) + + return json + }) + const jsonArray = await Promise.all(processFiles) + const mergeApiUrl = `${this.baseApi}/api/minioUpload/merge` + response = await axios.post(mergeApiUrl, jsonArray, { + headers: { + 'Authorization': getToken(), + 'Content-Type': 'application/json' + } + }) + + this.totalMergeEndTime = new Date().getTime() + const totalMergeDuration = this.getTimeDiff(this.totalMergeStartTime, this.totalMergeEndTime) + + if (response.data.code === 200) { + this.btnLoading = false + this.showMessage('所有文件上传并合并成功', 'success') + validFiles.forEach((fileItem) => { + fileItem.mergeEndTime = new Date().getTime() + const mergeDuration = this.getTimeDiff(fileItem.mergeStartTime, fileItem.mergeEndTime) + console.log(`【文件${fileItem.file.name}】合并结束时间:${this.formatTime(fileItem.mergeEndTime)},合并耗时:${mergeDuration}`) + fileItem.successMsg = '上传成功!' + fileItem.merging = false + }) + console.log(`【整体合并】所有文件合并完成,整体合并耗时:${totalMergeDuration}`) + this.$emit('onUploadSuccess', response.data.data, validFiles.map(f => f.file.name), jsonArray) + + this.uploadMinioVisible = false + this.fileList = [] // 清空列表,避免下次打开弹框显示旧数据 + } else { + this.btnLoading = false + throw new Error(response.data.msg || '合并失败') + } } + + // 动态计算合并接口URL + // const mergeApiUrl = this.isBatchMount === 'true' + // ? `${this.baseApi}/api/collect/merge` + // : `${this.baseApi}/api/minioUpload/merge` + // // 调用合并接口 + // const response = await axios.post(mergeApiUrl, jsonArray, { + // headers: { + // 'Authorization': getToken(), + // 'Content-Type': 'application/json' + // } + // }) } catch (err) { this.btnLoading = false this.totalMergeEndTime = new Date().getTime() diff --git a/src/views/components/category/preUpload2.vue b/src/views/components/category/preUpload2.vue new file mode 100644 index 0000000..5e503d6 --- /dev/null +++ b/src/views/components/category/preUpload2.vue @@ -0,0 +1,808 @@ + + + + + diff --git a/src/views/system/database/index.vue b/src/views/system/database/index.vue index 90f054d..9868f81 100644 --- a/src/views/system/database/index.vue +++ b/src/views/system/database/index.vue @@ -11,24 +11,35 @@ - - - - +
+ + + + + +
+

自动备份

+ + +
+
@@ -81,7 +92,7 @@ - +
@@ -99,6 +110,47 @@
+ + + + + +
+ + + + + + + + + + + + + + + +
+
@@ -153,6 +205,19 @@ export default { filename: [ { required: true, message: '备份名称不可为空', trigger: 'blur' } ] + }, + isEnable: true, + backupsVisible: false, + timeOptions: [ + { value: 7, label: '7天' }, + { value: 10, label: '10天' }, + { value: 30, label: '30天' } + ], + backupsForm: { + id: null, + backupTime: '00:00:00', + isAutoDelete: true, + backupSaveTime: 7 } } }, @@ -162,6 +227,7 @@ export default { ]) }, created() { + }, methods: { [CRUD.HOOK.beforeToCU](crud, form, btn) { @@ -187,6 +253,9 @@ export default { this.crud.query.endTime = null } }, + [CRUD.HOOK.afterRefresh]() { + this.getDatabaseSaveSetting() + }, // 提交前的验证 [CRUD.HOOK.afterValidateCU](crud) { console.log(crud.form) @@ -250,6 +319,64 @@ export default { console.log(err) }) }, + getDatabaseSaveSetting() { + crudSql.FetchDatabaseSaveSetting().then((res) => { + console.log(res) + if (res.code !== 500) { + let backupTimeStr = '00:00:00' + if (Array.isArray(res.backupTime) && res.backupTime.length >= 2) { + const hour = res.backupTime[0] ? res.backupTime[0].toString().padStart(2, '0') : '00' + const minute = res.backupTime[1] ? res.backupTime[1].toString().padStart(2, '0') : '00' + const second = res.backupTime[2] ? res.backupTime[2].toString().padStart(2, '0') : '00' + backupTimeStr = `${hour}:${minute}:${second}` + } + this.backupsForm.id = res.id + this.backupsForm.backupTime = backupTimeStr + this.backupsForm.isAutoDelete = res.isAutoDelete + this.backupsForm.backupSaveTime = res.backupSaveTime + this.isEnable = res.isEnable + } + }).catch((err) => { + // 补充异常捕获,避免接口报错导致页面无响应 + console.error('获取备份设置失败:', err) + this.$message({ + message: '获取备份设置失败,请重试', + type: 'error', + offset: 8 + }) + }) + }, + saveDatabaseSaveSetting() { + console.log('this.backupsForm', this.backupsForm) + // const timeParts = this.backupsForm.backupTime.split(':') + // const backupTimeObj = { + // hour: parseInt(timeParts[0], 10), // 小时 + // minute: parseInt(timeParts[1], 10), // 分钟 + // second: parseInt(timeParts[2], 10) // 秒 + // } + const requestParams = { + backupSaveTime: this.backupsForm.backupSaveTime, + backupTime: this.backupsForm.backupTime ? this.backupsForm.backupTime : '00:00:00', + id: this.backupsForm.id, + isAutoDelete: this.backupsForm.isAutoDelete, + isEnable: this.isEnable + } + + crudSql.FetchSaveDatabaseSaveSetting(requestParams).then((res) => { + console.log(res) + if (res.code !== 500) { + this.$message({ message: '设置成功', type: 'success', offset: 8 }) + } else { + this.$message({ message: res.message || '设置失败', type: 'error', offset: 8 }) + } + this.handleClose() + this.crud.toQuery() + }).catch((err) => { + console.error('设置失败:', err) + this.$message({ message: '网络异常,保存失败', type: 'error', offset: 8 }) + this.handleClose() + }) + }, handleClose() { if (this.$refs.verfiyForm) { this.verfiyForm.verifyCode = '' @@ -261,6 +388,12 @@ export default { this.crud.form.remarks = null this.formVisible = false } + if (this.$refs.backupsForm) { + this.backupsForm.backupTime = '00:00:00' + this.backupsForm.isAutoDelete = true + this.backupsForm.backupSaveTime = '7' + this.backupsVisible = false + } }, toDelete(data) { this.$confirm('此操作将删除当前所选数据' + '你是否还要继续?', '提示', { @@ -337,4 +470,19 @@ export default { ::v-deep div.el-dialog__footer { text-align: center; } +.backups-item{ + display: flex; + justify-content: flex-start; + align-items: center; + p{ + font-size: 14px; + padding-right: 10px; + line-height: 32px; + } +} +.backups-dialog{ + ::v-deep .el-dialog{ + width: 360px !important; + } +}