From 19ee1cfd3d64e846bf1ce24e90daa9312a132fc3 Mon Sep 17 00:00:00 2001
From: xuhuajiao <13476289682@163.com>
Date: Wed, 9 Apr 2025 17:44:44 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0=E6=95=B4?=
=?UTF-8?q?=E5=90=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/utils/upload.js | 13 +-
.../batchConnection/index.vue | 16 +-
.../batchConnection/module/form.vue | 71 ++-
.../module/collectHeader.vue | 7 +-
.../module/uploadOriginal/bigUpload.vue | 58 +-
.../module/uploadOriginal/index.vue | 2 +-
src/views/components/category/PreviewForm.vue | 37 +-
src/views/components/category/preUpload.vue | 549 ++++++++++++++++++
src/views/prearchiveLibrary/index.vue | 22 +-
9 files changed, 715 insertions(+), 60 deletions(-)
create mode 100644 src/views/components/category/preUpload.vue
diff --git a/src/utils/upload.js b/src/utils/upload.js
index 82f1619..8d31d10 100644
--- a/src/utils/upload.js
+++ b/src/utils/upload.js
@@ -47,7 +47,8 @@ export function archivesUpload(api, file, categoryId, archivesId, fileJsonString
// 收集库 - 目录上传
export function catalogUpload(api, file, fondsId) {
var data = new FormData()
- data.append('file', file)
+ // data.append('file', file)
+ data.append('upfilePath', file)
data.append('fondsId', fondsId)
const config = {
headers: { 'Authorization': getToken() }
@@ -78,17 +79,19 @@ export function modelUpload(api, file, name) {
}
// 收集库 - 批量挂接
-export function batchMountUpload(api, file, params) {
+// 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])
- }
+ // 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)
const config = {
headers: {
'Authorization': getToken()
diff --git a/src/views/collectReorganizi/batchConnection/index.vue b/src/views/collectReorganizi/batchConnection/index.vue
index 1485b1c..46a3947 100644
--- a/src/views/collectReorganizi/batchConnection/index.vue
+++ b/src/views/collectReorganizi/batchConnection/index.vue
@@ -2,9 +2,9 @@
-
+
-
+
@@ -104,7 +104,7 @@ export default {
},
data() {
return {
- currentCategory: null,
+ selectedCategory: null,
blurryTime: null,
formVisible: false
}
@@ -114,11 +114,11 @@ export default {
'baseApi'
]),
collectLevel() {
- if (this.currentCategory.arrangeType === 1) {
+ if (this.selectedCategory.arrangeType === 1) {
return 3
- } else if (this.currentCategory.arrangeType === 2) {
+ } else if (this.selectedCategory.arrangeType === 2) {
return 2
- } else if (this.currentCategory.arrangeType === 3) {
+ } else if (this.selectedCategory.arrangeType === 3) {
return 1
}
return null
@@ -153,7 +153,7 @@ export default {
this.crud.refresh()
},
handleNodeClick(data) {
- this.currentCategory = data
+ this.selectedCategory = data
if (data) {
this.crud.query.categoryId = data.id
this.crud.query.fondsId = data.fondsId
diff --git a/src/views/collectReorganizi/batchConnection/module/form.vue b/src/views/collectReorganizi/batchConnection/module/form.vue
index 626d512..c2c8863 100644
--- a/src/views/collectReorganizi/batchConnection/module/form.vue
+++ b/src/views/collectReorganizi/batchConnection/module/form.vue
@@ -40,20 +40,22 @@
/>
-
-
+
+
- {{ item.name }}
+ {{ item.file_name }}
+
+
+
@@ -107,12 +109,14 @@ import { FetchInitCategoryInputFieldByPid } from '@/api/system/category/category
import { FetchFindDetailsByProtocol, FetchFileByRemoteConnection } from '@/api/system/remoteConnection'
import { batchMountUpload, remoteConnectiontUpload } from '@/utils/upload'
import { mapGetters } from 'vuex'
+import PreUpload from '../../../components/category/preUpload.vue'
+
export default {
name: 'LocalHitch',
- components: { },
+ components: { PreUpload },
mixins: [crud()],
props: {
- currentCategory: {
+ selectedCategory: {
type: Object,
default: function() {
return {}
@@ -136,6 +140,7 @@ export default {
filePath: null,
fileRemote: null
},
+ upfilePath: null,
fileList: [],
typeOptions: [
{
@@ -213,11 +218,11 @@ export default {
'baseApi'
]),
collectLevel() {
- if (this.currentCategory.arrangeType === 1) {
+ if (this.selectedCategory.arrangeType === 1) {
return 3
- } else if (this.currentCategory.arrangeType === 2) {
+ } else if (this.selectedCategory.arrangeType === 2) {
return 2
- } else if (this.currentCategory.arrangeType === 3) {
+ } else if (this.selectedCategory.arrangeType === 3) {
return 1
}
return null
@@ -231,6 +236,22 @@ export default {
opened() {
this.getFieldCommon()
},
+ handleSuccessResource(res, fileName, jsonArrayToSend) {
+ console.log('handleSuccessResource', res[0])
+ console.log('handleSuccessResource', fileName)
+ console.log('handleSuccessResource', jsonArrayToSend)
+ console.log('handleSuccessResource', jsonArrayToSend[0].fileJsonString)
+
+ const fileJson = JSON.parse(jsonArrayToSend[0].fileJsonString)
+ fileJson[0].file_path = res[0]
+ fileJson[0].is_quote = null
+ fileJson[0].last_modified = jsonArrayToSend[0].last_modified
+ this.fileList = fileJson
+ this.upfilePath = res[0]
+ },
+ handleErrorResource(res) {
+ console.log('handleErrorResource', res)
+ },
handleFile(event) {
const files = event.target.files
for (let i = 0; i < files.length; i++) {
@@ -253,23 +274,23 @@ export default {
}
this.btnLoading = true
this.$refs['form'].validate((valid) => {
- console.log('this.currentCategory', this.currentCategory)
+ console.log('this.selectedCategory', this.selectedCategory)
if (valid) {
let newhitchRemark = this.hitchRemarkArray.map(item => item.replace(/^\$|\$$|\*$/g, ''))
newhitchRemark = newhitchRemark.filter(item => item !== '')
if (!this.connectionType) {
const params = {
- 'categoryId': this.currentCategory.id,
+ 'categoryId': this.selectedCategory.id,
'mountType': 1, // 挂接方式 1.本地挂接 2.远程挂接 3.上传目录 (目前只有1)
'checkRepeatType': this.form.checkRepeatType,
'matchingMode': this.form.matchingMode,
'fields': newhitchRemark,
- 'fondsId': this.currentCategory.fondsId
+ 'fondsId': this.selectedCategory.fondsId,
+ 'upfilePath': this.upfilePath
}
console.log(params)
batchMountUpload(this.baseApi + '/api/collect/batchMount',
- this.fileList,
params
).then(res => {
if (res.data.code === 200) {
@@ -287,8 +308,8 @@ export default {
'cAddress': this.form.filePath.caddress,
'cPassword': this.form.filePath.cpassword,
'cPort': this.form.filePath.cport,
- 'categoryId': this.currentCategory.id,
- 'fondsId': this.currentCategory.fondsId,
+ 'categoryId': this.selectedCategory.id,
+ 'fondsId': this.selectedCategory.fondsId,
'checkRepeatType': this.form.checkRepeatType,
'matchingMode': this.form.matchingMode,
'fields': newhitchRemark,
@@ -317,7 +338,7 @@ export default {
},
getFieldCommon() {
const params = {
- 'categoryId': this.currentCategory.id,
+ 'categoryId': this.selectedCategory.id,
'categoryLevel': this.collectLevel
}
FetchInitCategoryInputFieldByPid(params).then(data => {
@@ -461,5 +482,17 @@ export default {
}
}
}
+.upload-wm{
+ height: 100px;
+}
+::v-deep .uploader-big{
+ margin-left: 0 !important;
+}
+::v-deep .upload_process_box{
+ right: 0 !important;
+ left: 120px !important;
+ top: 0 !important;
+ width: 300px !important;
+}
diff --git a/src/views/collectReorganizi/collectionLibrary/module/collectHeader.vue b/src/views/collectReorganizi/collectionLibrary/module/collectHeader.vue
index 6e659de..85d8e52 100644
--- a/src/views/collectReorganizi/collectionLibrary/module/collectHeader.vue
+++ b/src/views/collectReorganizi/collectionLibrary/module/collectHeader.vue
@@ -1017,10 +1017,13 @@ export default {
this.$refs.uploadOriginalRef.uploadVisible = true
} else if (uploadType === 1) {
this.$refs.uploadBigRef.uploadBigVisible = true
+ this.isCatalogUpload = false
this.$refs.uploadBigRef.fileList = []
} else if (uploadType === 2) {
- this.$refs.uploadOriginalRef.uploadTitle = '原文目录上传'
- this.$refs.uploadOriginalRef.uploadVisible = true
+ this.$refs.uploadBigRef.uploadTitle = '原文目录上传'
+ this.$refs.uploadBigRef.uploadBigVisible = true
+ this.isCatalogUpload = true
+ this.$refs.uploadBigRef.fileList = []
}
if (this.$refs.uploadOriginalRef.uploadVisible) {
this.$refs.uploadOriginalRef.uploadType = uploadType
diff --git a/src/views/collectReorganizi/collectionLibrary/module/uploadOriginal/bigUpload.vue b/src/views/collectReorganizi/collectionLibrary/module/uploadOriginal/bigUpload.vue
index ec21f62..a4a3c50 100644
--- a/src/views/collectReorganizi/collectionLibrary/module/uploadOriginal/bigUpload.vue
+++ b/src/views/collectReorganizi/collectionLibrary/module/uploadOriginal/bigUpload.vue
@@ -1,7 +1,7 @@
-
+
{{ uploadTitle }}
单个文件不可超过10GB
@@ -21,7 +21,7 @@
将文件拖到此处,或点击上传
-
+
@@ -78,6 +78,7 @@ import axios from 'axios'
import SparkMD5 from 'spark-md5'
import { getToken } from '@/utils/auth'
import { getCurrentTime } from '@/utils/index'
+import { catalogUpload } from '@/utils/upload'
// https://juejin.cn/post/7040817922540830728
export default {
props: {
@@ -96,6 +97,7 @@ export default {
},
data() {
return {
+ isCatalogUpload: false,
uploadTitle: '文件上传',
btnLoading: false,
uploadBigVisible: false,
@@ -106,7 +108,6 @@ export default {
testChunks: true, // 是否分片
singleFile: false, // 多文件上传
uploadMethod: 'post', // 真正上传的时候使用的 HTTP 方法,默认 POST
- allowDuplicateUploads: false, // 上传过得文件不可以再上传
parseTimeRemaining: function(timeRemaining, parsedTimeRemaining) {
return parsedTimeRemaining
.replace(/\syears?/, '年')
@@ -129,7 +130,7 @@ export default {
}
},
attrs: {
- accept: 'image/*'
+ accept: ''
},
// 修改上传状态
statusText: {
@@ -158,6 +159,21 @@ export default {
this.options.target = this.baseApi + '/api/collect/upload'
},
methods: {
+ opened() {
+ this.updateUploadOptions()
+ },
+ updateUploadOptions() {
+ if (this.isCatalogUpload) {
+ // 使用 Object.assign 创建新的对象
+ this.attrs = Object.assign({}, this.attrs, { accept: '.zip' })
+ this.options.singleFile = true
+ } else {
+ // 使用展开运算符创建新的对象
+ this.attrs = { ...this.attrs, accept: '' }
+ this.options.singleFile = false
+ }
+ console.log('this.attrs.accept', this.attrs.accept)
+ },
// 电子原文列表
getFileList() {
const params = {
@@ -202,6 +218,7 @@ export default {
}
this.nowDate = getCurrentTime()
const jsonArrayToSend = []
+ console.log('this.$refs.uploader.fileList', this.$refs.uploader.fileList)
// 使用 Promise.all 确保所有异步操作完成
Promise.all(this.$refs.uploader.fileList.map(async(item) => {
@@ -250,19 +267,29 @@ export default {
}
}).then((res) => {
console.log(res)
- if (res.data.code === 200 && res.data.data !== '') {
- this.$message({ message: '所有文件上传成功', type: 'success', offset: 8 })
+ if (res.data.code === 200 && res.data.data[0] !== '') {
+ if (this.isCatalogUpload) {
+ catalogUpload(this.baseApi + '/api/collect/catalogUpload',
+ res.data.data[0],
+ this.selectedCategory.fondsId
+ ).then(res => {
+ if (res.data.code === 200) {
+ this.$message({ message: '操作成功', type: 'success', offset: 8 })
+ } else {
+ this.$message({ message: '操作失败', type: 'error', offset: 8 })
+ }
+ this.$emit('close-dialog')
+ this.handleCloseDialog()
+ })
+ } else {
+ this.$message({ message: '所有文件上传成功', type: 'success', offset: 8 })
+ this.$emit('close-dialog')
+ this.handleCloseDialog()
+ }
} else {
this.$message({ message: '部分或全部文件上传失败', type: 'error', offset: 8 })
+ this.handleCloseDialog()
}
- this.$emit('close-dialog')
- this.uploadBigVisible = false
- this.fileList = []
- this.btnLoading = false
- this.$refs.uploader.files = []
- this.$refs.uploader.fileList = []
- this.$refs.uploader.uploader.fileList = []
- this.$refs.uploader.uploader.files = []
})
} else {
this.submitted = false
@@ -369,6 +396,7 @@ export default {
file.size
} 用时:${new Date().getTime() - time} ms`
)
+ console.log('md5', md5)
spark.destroy() // 释放缓存
file.uniqueIdentifier = md5 // 将文件md5赋值给文件唯一标识
file.cmd5 = false // 取消计算md5状态
@@ -403,6 +431,7 @@ export default {
})
},
handleCloseDialog(done) {
+ this.btnLoading = false
this.uploadBigVisible = false
const uploaderInstance = this.$refs.uploader.uploader
console.log('uploaderInstance.fileList', uploaderInstance.fileList)
@@ -412,6 +441,7 @@ export default {
this.fileList = []
this.$refs.uploader.files = []
this.$refs.uploader.fileList = []
+ this.attrs = { ...this.attrs, accept: '' }
}
}
}
diff --git a/src/views/collectReorganizi/collectionLibrary/module/uploadOriginal/index.vue b/src/views/collectReorganizi/collectionLibrary/module/uploadOriginal/index.vue
index f8bcf4f..897a833 100644
--- a/src/views/collectReorganizi/collectionLibrary/module/uploadOriginal/index.vue
+++ b/src/views/collectReorganizi/collectionLibrary/module/uploadOriginal/index.vue
@@ -20,7 +20,7 @@
点击上传
-
+
上传限制文件类型:zip