Browse Source

文件上传完善

master
xuhuajiao 3 months ago
parent
commit
53f65cb9a2
  1. 8
      src/views/collectReorganizi/batchConnection/module/form.vue
  2. 2
      src/views/collectReorganizi/collectionLibrary/mixins/index.js
  3. 7
      src/views/collectReorganizi/collectionLibrary/module/collectHeader.vue
  4. 179
      src/views/collectReorganizi/collectionLibrary/module/uploadOriginal/bigUpload.vue
  5. 24
      src/views/components/category/PreviewForm.vue
  6. 279
      src/views/components/category/preUpload.vue
  7. 22
      src/views/prearchiveLibrary/index.vue

8
src/views/collectReorganizi/batchConnection/module/form.vue

@ -236,18 +236,18 @@ export default {
opened() { opened() {
this.getFieldCommon() this.getFieldCommon()
}, },
handleSuccessResource(res, fileName, jsonArrayToSend) {
console.log('handleSuccessResource', res[0])
handleSuccessResource(filePath, fileName, jsonArrayToSend) {
console.log('handleSuccessResource', filePath)
console.log('handleSuccessResource', fileName) console.log('handleSuccessResource', fileName)
console.log('handleSuccessResource', jsonArrayToSend) console.log('handleSuccessResource', jsonArrayToSend)
console.log('handleSuccessResource', jsonArrayToSend[0].fileJsonString) console.log('handleSuccessResource', jsonArrayToSend[0].fileJsonString)
const fileJson = JSON.parse(jsonArrayToSend[0].fileJsonString) const fileJson = JSON.parse(jsonArrayToSend[0].fileJsonString)
fileJson[0].file_path = res[0]
fileJson[0].file_path = filePath
fileJson[0].is_quote = null fileJson[0].is_quote = null
fileJson[0].last_modified = jsonArrayToSend[0].last_modified fileJson[0].last_modified = jsonArrayToSend[0].last_modified
this.fileList = fileJson this.fileList = fileJson
this.upfilePath = res[0]
this.upfilePath = filePath
}, },
handleErrorResource(res) { handleErrorResource(res) {
console.log('handleErrorResource', res) console.log('handleErrorResource', res)

2
src/views/collectReorganizi/collectionLibrary/mixins/index.js

@ -49,7 +49,7 @@ export const collectionLibraryCrud = {
}, },
handleSearch(categoryLevel) { handleSearch(categoryLevel) {
const queryResult = this.hasValue(this.query) const queryResult = this.hasValue(this.query)
console.log(queryResult)
// console.log(queryResult)
if (localStorage.getItem('currentPage') && !queryResult) { if (localStorage.getItem('currentPage') && !queryResult) {
this.page.page = parseInt(localStorage.getItem('currentPage')) this.page.page = parseInt(localStorage.getItem('currentPage'))
} else { } else {

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

@ -1016,13 +1016,10 @@ export default {
this.$refs.uploadOriginalRef.uploadTitle = '普通上传' this.$refs.uploadOriginalRef.uploadTitle = '普通上传'
this.$refs.uploadOriginalRef.uploadVisible = true this.$refs.uploadOriginalRef.uploadVisible = true
} else if (uploadType === 1) { } else if (uploadType === 1) {
this.$refs.uploadBigRef.uploadBigVisible = true
this.isCatalogUpload = false
this.$refs.uploadBigRef.updateUploadOptions(1)
this.$refs.uploadBigRef.fileList = [] this.$refs.uploadBigRef.fileList = []
} else if (uploadType === 2) { } else if (uploadType === 2) {
this.$refs.uploadBigRef.uploadTitle = '原文目录上传'
this.$refs.uploadBigRef.uploadBigVisible = true
this.isCatalogUpload = true
this.$refs.uploadBigRef.updateUploadOptions(2)
this.$refs.uploadBigRef.fileList = [] this.$refs.uploadBigRef.fileList = []
} }
if (this.$refs.uploadOriginalRef.uploadVisible) { if (this.$refs.uploadOriginalRef.uploadVisible) {

179
src/views/collectReorganizi/collectionLibrary/module/uploadOriginal/bigUpload.vue

@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<!--上传组件--> <!--上传组件-->
<el-dialog class="big-file" :close-on-click-modal="false" :modal-append-to-body="false" append-to-body :visible.sync="uploadBigVisible" :before-close="handleCloseDialog" @opened="opened">
<el-dialog class="big-file" :close-on-click-modal="false" :modal-append-to-body="false" append-to-body :visible.sync="uploadBigVisible" :before-close="handleCloseDialog">
<template #title> <template #title>
{{ uploadTitle }} {{ uploadTitle }}
<span style="color: red;font-size: 12px; ">单个文件不可超过10GB</span> <span style="color: red;font-size: 12px; ">单个文件不可超过10GB</span>
@ -10,6 +10,7 @@
<div class="uploader-big"> <div class="uploader-big">
<uploader <uploader
ref="uploader" ref="uploader"
:key="uploaderKey"
:auto-start="false" :auto-start="false"
:options="options" :options="options"
:file-status-text="statusText" :file-status-text="statusText"
@ -20,7 +21,7 @@
> >
<uploader-unsupport /> <uploader-unsupport />
<uploader-drop> <uploader-drop>
<p>将文件拖到此处或点击上传</p>
<p>{{ !isCatalogUpload ? '将文件拖到此处,或点击上传(可多文件上传)' : "将ZIP包拖到此处, 或点击上传(只可单文件上传)" }}</p>
<uploader-btn :attrs="attrs"> <uploader-btn :attrs="attrs">
<slot> <slot>
<i class="iconfont icon-tianjiawenjian upload-icon" /> <i class="iconfont icon-tianjiawenjian upload-icon" />
@ -68,6 +69,43 @@
<el-button type="text" @click="repeatFileVisible = false">取消</el-button> <el-button type="text" @click="repeatFileVisible = false">取消</el-button>
</div> </div>
</el-dialog> </el-dialog>
<!-- 目录上传报错 -->
<el-dialog class="catalog-dialog" title="目录上传-失败列表" :close-on-click-modal="false" :modal-append-to-body="false" append-to-body :visible.sync="catalogErrorVisible">
<div class="setting-dialog">
<div style="margin-bottom: 20px; display:flex; justify-content: flex-start;">
<p style="margin-right: 20px;">总条数 <span style=" font-weight: bold;">{{ resultCatalog && resultCatalog.mountFile.total }} </span> </p>
<p style="margin-right: 20px;">成功 <span style="color:#1AAE93; font-weight: bold;">{{ resultCatalog && resultCatalog.mountFile.successNum }} </span> </p>
<p>失败 <span style="color:#f00; font-weight: bold; ">{{ resultCatalog && resultCatalog.mountFile.failNum }}</span> </p>
</div>
<!-- <div v-for="(item,index) in resultCatalog && resultCatalog.failArchives" :key="index" class="file-list" style="margin-bottom: 10px;">
<i class="iconfont icon-xiaowenjian" />
{{ item }}
</div> -->
<el-table class="archives-table" :data="catalogInfoData" style="min-width: 100%" height="calc(100vh - 676px)">
<el-table-column type="expand">
<template #default="{ row }">
<el-row style="padding-left: 20px;">
<el-col :span="24" style="line-height: 30px;">
<div v-for="(file, index) in row.children" :key="index"><i class="iconfont icon-xiaowenjian" />{{ file }}</div>
</el-col>
</el-row>
</template>
</el-table-column>
<el-table-column prop="archives" label="档案/电子原文" />
<el-table-column prop="description" label="失败原因" />
<!-- <el-table-column prop="update_by" label="电子原文" min-width="60" />
<el-table-column prop="update_time" label="状态" width="180">
<template slot-scope="scope">
<div>{{ scope.row.update_time | parseTime }}</div>
</template>
</el-table-column> -->
</el-table>
</div>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="catalogErrorVisible = false">确定</el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
@ -130,7 +168,8 @@ export default {
} }
}, },
attrs: { attrs: {
accept: ''
accept: '',
multiple: true
}, },
// //
statusText: { statusText: {
@ -147,7 +186,14 @@ export default {
// //
repeatFileVisible: false, repeatFileVisible: false,
repeatFileData: [], repeatFileData: [],
originFileData: []
originFileData: [],
uploaderKey: 0,
resultCatalog: {
mountFile: {},
failArchives: []
},
catalogErrorVisible: false,
catalogInfoData: []
} }
}, },
computed: { computed: {
@ -160,19 +206,37 @@ export default {
}, },
methods: { methods: {
opened() { opened() {
this.updateUploadOptions()
this.$nextTick(() => {
if (!this.isCatalogUpload) {
this.uploadTitle = '文件上传'
this.attrs = { accept: '', multiple: true }
this.options.singleFile = false
} else {
this.uploadTitle = '原文目录上传'
this.attrs = { accept: '.zip', multiple: false }
this.options.singleFile = true
}
this.uploaderKey++
console.log('this.isCatalogUpload', this.isCatalogUpload)
this.uploadBigVisible = true
})
}, },
updateUploadOptions() {
if (this.isCatalogUpload) {
// 使 Object.assign
this.attrs = Object.assign({}, this.attrs, { accept: '.zip' })
this.options.singleFile = true
} else {
// 使
this.attrs = { ...this.attrs, accept: '' }
updateUploadOptions(uploadType) {
console.log('uploadType', uploadType)
if (uploadType === 1) {
this.isCatalogUpload = false
this.uploadTitle = '文件上传'
this.attrs = { accept: '' }
this.options.singleFile = false this.options.singleFile = false
} else {
this.isCatalogUpload = true
this.uploadTitle = '原文目录上传'
this.attrs = { accept: '.zip' }
this.options.singleFile = true
} }
console.log('this.attrs.accept', this.attrs.accept) console.log('this.attrs.accept', this.attrs.accept)
this.uploaderKey++
this.uploadBigVisible = true
}, },
// //
getFileList() { getFileList() {
@ -266,19 +330,55 @@ export default {
'Authorization': getToken() 'Authorization': getToken()
} }
}).then((res) => { }).then((res) => {
console.log(res)
if (res.data.code === 200 && res.data.data[0] !== '') {
if (this.isCatalogUpload) {
console.log('merge', res.data.data)
if (res.data.code === 200) {
if (this.isCatalogUpload && res.data.data.length === 1 && res.data.data[0] !== '') {
//
catalogUpload(this.baseApi + '/api/collect/catalogUpload', catalogUpload(this.baseApi + '/api/collect/catalogUpload',
res.data.data[0], res.data.data[0],
this.selectedCategory.fondsId this.selectedCategory.fondsId
).then(res => { ).then(res => {
if (res.data.code === 200) { if (res.data.code === 200) {
this.$message({ message: '操作成功', type: 'success', offset: 8 })
this.resultCatalog = res.data.data
if (this.resultCatalog.mountFile.total === this.resultCatalog.mountFile.successNum) {
this.$message({ message: '目录上传操作成功', type: 'success', offset: 8 })
} else if (this.resultCatalog.mountFile.total === this.resultCatalog.mountFile.failNum) {
this.catalogErrorVisible = true
} else {
this.catalogErrorVisible = true
}
this.catalogInfoData = []
this.resultCatalog.failArchives.forEach(item => {
const parts = item.split(':')
if (parts.length === 2) {
const field = parts[0]
let fileStr = parts[1]
//
fileStr = fileStr.replace(/\[|\]/g, '')
//
const fileArray = fileStr.split(',').map(file => file.trim())
// field
const match = field.match(/^([\w-·]+)(.*)$/)
let archives = ''
let description = ''
if (match) {
archives = match[1]
description = match[2]
}
this.catalogInfoData.push({
archives,
description,
children: fileArray
})
}
})
console.log('catalogInfoData', this.catalogInfoData)
this.$emit('close-dialog')
} else { } else {
this.$message({ message: '操作失败', type: 'error', offset: 8 })
console.log('result1', res.data)
console.log('result2', res.data.message)
this.$message({ message: res.data.message, type: 'error', offset: 8 })
} }
this.$emit('close-dialog')
this.handleCloseDialog() this.handleCloseDialog()
}) })
} else { } else {
@ -330,22 +430,29 @@ export default {
this.repeatFileVisible = false this.repeatFileVisible = false
}, },
async filesAdded(file, fileList, event) { async filesAdded(file, fileList, event) {
//
await this.getFileList()
if (!this.isCatalogUpload) {
//
await this.getFileList()
file.forEach((e) => {
this.fileList.push(e)
const existingFileNames = this.originFileData.map(file => file.file_name)
file.forEach((e) => {
this.fileList.push(e)
const existingFileNames = this.originFileData.map(file => file.file_name)
this.repeatFileData = this.fileList.filter(file => existingFileNames.includes(file.name))
console.log('filteredFileList', this.repeatFileData)
this.repeatFileData = this.fileList.filter(file => existingFileNames.includes(file.name))
console.log('filteredFileList', this.repeatFileData)
if (this.repeatFileData.length === 0) {
if (this.repeatFileData.length === 0) {
this.computeMD5(e)
} else {
this.repeatFileVisible = true
}
})
} else {
file.forEach((e) => {
this.fileList.push(e)
this.computeMD5(e) this.computeMD5(e)
} else {
this.repeatFileVisible = true
}
})
})
}
}, },
computeMD5(file) { computeMD5(file) {
const maxMessage = '上传文件大小不能超过 10GB!' const maxMessage = '上传文件大小不能超过 10GB!'
@ -441,7 +548,10 @@ export default {
this.fileList = [] this.fileList = []
this.$refs.uploader.files = [] this.$refs.uploader.files = []
this.$refs.uploader.fileList = [] this.$refs.uploader.fileList = []
this.attrs = { ...this.attrs, accept: '' }
// isCatalogUpload attrs
this.isCatalogUpload = false
this.attrs = { accept: '', multiple: true }
this.uploaderKey++
} }
} }
} }
@ -564,4 +674,9 @@ export default {
} }
} }
// .catalog-dialog{
// ::v-deep .el-dialog{
// width: 560px !important;
// }
// }
</style> </style>

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

@ -73,7 +73,7 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row v-if="isDesFormType === 'prearchiveLibrary'" class="preview-form-bottom prearch-bottom">
<el-row v-if="isDesFormType === 'prearchiveLibrary'" class="preview-form-bottom prearch-bottom-new">
<el-col> <el-col>
<el-form-item label="电子原件" prop="fileOriginal" class="prearch-upload"> <el-form-item label="电子原件" prop="fileOriginal" class="prearch-upload">
<!-- <p :class="['input-style', fileOriginal === null ? 'error-box' :'']">{{ fileOriginal }}</p> --> <!-- <p :class="['input-style', fileOriginal === null ? 'error-box' :'']">{{ fileOriginal }}</p> -->
@ -83,7 +83,7 @@
<input id="upFile" type="file" name="upFile" @change="changeFile($event)"> <input id="upFile" type="file" name="upFile" @change="changeFile($event)">
<el-button size="small" type="primary"><i class="iconfont icon-shangchuan" />上传</el-button> <el-button size="small" type="primary"><i class="iconfont icon-shangchuan" />上传</el-button>
</div> --> </div> -->
<PreUpload :selected-document="selectedDocument" :arc-id="arcId" @onUploadSuccess="handleSuccessResource" @onUploadError="handleErrorResource" />
<PreUpload ref="preUploadRefs" :selected-document="selectedDocument" :arc-id="arcId" @onUploadSuccess="handleSuccessResource" @onUploadError="handleErrorResource" />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@ -284,15 +284,18 @@ export default {
mounted() { mounted() {
}, },
methods: { methods: {
handleSuccessResource(res, fileName, jsonArrayToSend) {
console.log('handleSuccessResource', res[0])
preUplpadClose() {
this.$refs.preUploadRefs.handleClearData()
},
handleSuccessResource(filePath, fileName, jsonArrayToSend) {
console.log('handleSuccessResource', filePath)
console.log('handleSuccessResource', fileName) console.log('handleSuccessResource', fileName)
console.log('handleSuccessResource', jsonArrayToSend) console.log('handleSuccessResource', jsonArrayToSend)
console.log('handleSuccessResource', jsonArrayToSend[0].fileJsonString) console.log('handleSuccessResource', jsonArrayToSend[0].fileJsonString)
this.fileOriginal = fileName this.fileOriginal = fileName
const fileJson = JSON.parse(jsonArrayToSend[0].fileJsonString) const fileJson = JSON.parse(jsonArrayToSend[0].fileJsonString)
fileJson[0].file_path = '/' + res[0]
fileJson[0].file_path = '/' + filePath
fileJson[0].is_quote = null fileJson[0].is_quote = null
fileJson[0].last_modified = jsonArrayToSend[0].last_modified fileJson[0].last_modified = jsonArrayToSend[0].last_modified
this.fileJsonString = JSON.stringify(fileJson) this.fileJsonString = JSON.stringify(fileJson)
@ -1064,7 +1067,6 @@ export default {
'fondsAffiliation': this.selectedDocument.fondsId 'fondsAffiliation': this.selectedDocument.fondsId
} }
console.log('params', params) console.log('params', params)
console.log('archivesType', this.archivesType)
prearchEdit(params).then(res => { prearchEdit(params).then(res => {
if (res) { if (res) {
this.$message({ message: res.message, type: 'success', offset: 8 }) this.$message({ message: res.message, type: 'success', offset: 8 })
@ -1392,10 +1394,10 @@ export default {
} }
.prearch-bottom{ .prearch-bottom{
// position: fixed;
// bottom: 72px;
// left: 0;
// background: #fff;
position: fixed;
bottom: 72px;
left: 0;
background: #fff;
width: 100%; width: 100%;
padding: 20px 0 0 20px; padding: 20px 0 0 20px;
} }
@ -1476,7 +1478,7 @@ export default {
} }
.library-form{ .library-form{
height: calc(100vh - 473px) !important;
height: calc(100vh - 458px) !important;
overflow: hidden; overflow: hidden;
overflow-y: scroll; overflow-y: scroll;
} }

279
src/views/components/category/preUpload.vue

@ -5,7 +5,6 @@
:options="initOptions" :options="initOptions"
:file-status-text="fileStatusText" :file-status-text="fileStatusText"
:auto-start="false" :auto-start="false"
class="uploader-app" class="uploader-app"
@file-added="onFileAdded" @file-added="onFileAdded"
@file-success="onUploadSuccess" @file-success="onUploadSuccess"
@ -147,6 +146,7 @@ export default {
clearInterval(this.queryTimer) clearInterval(this.queryTimer)
}, },
methods: { methods: {
clickUploader(e) { clickUploader(e) {
this.$refs.uploadBtn.$el.click() this.$refs.uploadBtn.$el.click()
}, },
@ -273,32 +273,151 @@ export default {
this.skip = false this.skip = false
} }
}, },
// handleUploadConfirm() {
// if (this.$refs.uploader.fileList.length === 0) {
// this.$message({ message: '!', type: 'error', offset: 8 })
// return false
// }
// this.nowDate = getCurrentTime()
// const jsonArrayToSend = []
// this.isSyncUpload = true
// // 使 Promise.all
// Promise.all(this.$refs.uploader.fileList.map(async(item) => {
// console.log('item', item)
// const json = {}
// const jsonArray = []
// const jsonString = {}
// if (item.file.type.substring(0, item.file.type.indexOf('/')) === 'image') {
// const fileBase64 = await this.getBase64(item.file)
// const imgRes = await this.getImgPx(fileBase64)
// item.file.px = imgRes.width + 'px*' + imgRes.height + 'px'
// } else {
// item.file.px = ''
// }
// jsonString.file_name = item.file.name
// jsonString.file_size = item.file.size
// jsonString.file_type = item.file.name.substring(item.name.lastIndexOf('.') + 1, item.file.name.length)
// json.last_modified = item.file.lastModified
// jsonString.file_path = ''
// jsonString.sequence = null
// jsonString.archive_id = this.arcId
// jsonString.file_dpi = item.file.px
// jsonString.file_thumbnail = ''
// jsonString.create_time = this.nowDate
// jsonString.id = null
// jsonArray.push(jsonString)
// if (this.isBatchMount === 'true') {
// json.categoryId = this.selectedCategory.id
// } else {
// json.documentId = this.selectedDocument.id
// }
// json.archivesId = this.arcId
// json.identifier = item.uniqueIdentifier
// json.filename = item.name
// json.totalChunks = item.chunks.length - 1
// json.totalSize = item.size
// json.fileJsonString = JSON.stringify(jsonArray)
// jsonArrayToSend.push(json)
// })).then(() => {
// console.log('jsonArrayToSend', jsonArrayToSend)
// if (this.$refs.uploader.fileList.every(item => item.completed) && this.isUpload) {
// if (this.isBatchMount === 'true') {
// //
// axios.post(this.baseApi + '/api/collect/merge', jsonArrayToSend, {
// headers: {
// 'Authorization': getToken()
// }
// }).then((res) => {
// console.log(res)
// if (res.data.code === 200 && res.data.data.length === 1 && res.data.data[0] !== '') {
// this.$message({ message: '', type: 'success', offset: 8 })
// this.$emit('onUploadSuccess', res.data.data[0], this.fileName, jsonArrayToSend)
// } else {
// this.$message({ message: '', type: 'error', offset: 8 })
// }
// this.isSyncUpload = false
// setTimeout(() => {
// this.isUpload = false
// }, 2000)
// }).catch(err => {
// this.isSyncUpload = false
// setTimeout(() => {
// this.isUpload = false
// }, 2000)
// this.$emit('onUploadError', err)
// this.$message({ message: '', type: 'error', offset: 8 })
// clearInterval(this.queryTimer)
// })
// } else {
// //
// axios.post(this.baseApi + '/api/re-document/merge', jsonArrayToSend, {
// headers: {
// 'Authorization': getToken()
// }
// }).then((res) => {
// console.log(res)
// if (res.data.code === 200 && res.data.data.length === 1 && res.data.data[0] !== '') {
// this.$message({ message: '', type: 'success', offset: 8 })
// this.$emit('onUploadSuccess', res.data.data[0], this.fileName, jsonArrayToSend)
// } else {
// this.$message({ message: '', type: 'error', offset: 8 })
// }
// this.isSyncUpload = false
// }).catch(err => {
// this.isSyncUpload = false
// setTimeout(() => {
// this.isUpload = false
// }, 2000)
// this.$emit('onUploadError', err)
// this.$message({ message: '', type: 'error', offset: 8 })
// clearInterval(this.queryTimer)
// })
// }
// } else {
// this.isSyncUpload = false
// setTimeout(() => {
// this.isUpload = false
// }, 2000)
// this.$message({ message: '!', type: 'error', offset: 8 })
// }
// })
// },
handleUploadConfirm() { handleUploadConfirm() {
//
if (this.$refs.uploader.fileList.length === 0) { if (this.$refs.uploader.fileList.length === 0) {
this.$message({ message: '请选择要上传的文件!', type: 'error', offset: 8 })
this.showMessage('请选择要上传的文件!', 'error')
return false return false
} }
this.nowDate = getCurrentTime() this.nowDate = getCurrentTime()
const jsonArrayToSend = [] const jsonArrayToSend = []
this.isSyncUpload = true this.isSyncUpload = true
// 使 Promise.all
Promise.all(this.$refs.uploader.fileList.map(async(item) => {
console.log('item', item)
//
const processFile = async(item) => {
const json = {} const json = {}
const jsonArray = [] const jsonArray = []
const jsonString = {} const jsonString = {}
if (item.file.type.substring(0, item.file.type.indexOf('/')) === 'image') {
//
if (item.file.type.startsWith('image')) {
const fileBase64 = await this.getBase64(item.file) const fileBase64 = await this.getBase64(item.file)
const imgRes = await this.getImgPx(fileBase64) const imgRes = await this.getImgPx(fileBase64)
item.file.px = imgRes.width + 'px*' + imgRes.height + 'px'
item.file.px = `${imgRes.width}px*${imgRes.height}px`
} else { } else {
item.file.px = '' item.file.px = ''
} }
// jsonString
jsonString.file_name = item.file.name jsonString.file_name = item.file.name
jsonString.file_size = item.file.size jsonString.file_size = item.file.size
jsonString.file_type = item.file.name.substring(item.name.lastIndexOf('.') + 1, item.file.name.length)
jsonString.file_type = item.file.name.split('.').pop()
json.last_modified = item.file.lastModified json.last_modified = item.file.lastModified
jsonString.file_path = '' jsonString.file_path = ''
jsonString.sequence = null jsonString.sequence = null
@ -308,14 +427,15 @@ export default {
jsonString.create_time = this.nowDate jsonString.create_time = this.nowDate
jsonString.id = null jsonString.id = null
jsonArray.push(jsonString) jsonArray.push(jsonString)
console.log('isBatchMount', this.isBatchMount)
console.log('isBatchMount', typeof this.isBatchMount)
// id
if (this.isBatchMount === 'true') { if (this.isBatchMount === 'true') {
json.categoryId = this.selectedCategory.id json.categoryId = this.selectedCategory.id
} else { } else {
json.documentId = this.selectedDocument.id json.documentId = this.selectedDocument.id
} }
// json
json.archivesId = this.arcId json.archivesId = this.arcId
json.identifier = item.uniqueIdentifier json.identifier = item.uniqueIdentifier
json.filename = item.name json.filename = item.name
@ -324,69 +444,75 @@ export default {
json.fileJsonString = JSON.stringify(jsonArray) json.fileJsonString = JSON.stringify(jsonArray)
jsonArrayToSend.push(json) jsonArrayToSend.push(json)
})).then(() => {
console.log('jsonArrayToSend', jsonArrayToSend)
if (this.$refs.uploader.fileList.every(item => item.completed) && this.isUpload) {
if (this.isBatchMount === 'true') {
axios.post(this.baseApi + '/api/collect/merge', jsonArrayToSend, {
headers: {
'Authorization': getToken()
}
}).then((res) => {
console.log(res)
if (res.data.code === 200 && res.data.data[0] !== '') {
this.$message({ message: '文件上传成功', type: 'success', offset: 8 })
this.$emit('onUploadSuccess', res.data.data, this.fileName, jsonArrayToSend)
} else {
this.$message({ message: '文件上传失败', type: 'error', offset: 8 })
}
this.isSyncUpload = false
setTimeout(() => {
this.isUpload = false
}, 2000)
}).catch(err => {
this.isSyncUpload = false
setTimeout(() => {
this.isUpload = false
}, 2000)
this.$emit('onUploadError', err)
this.$message({ message: '上传服务器失败', type: 'error', offset: 8 })
clearInterval(this.queryTimer)
})
}
// 使 Promise.all
Promise.all(this.$refs.uploader.fileList.map(processFile))
.then(() => {
console.log('jsonArrayToSend', jsonArrayToSend)
//
if (this.$refs.uploader.fileList.every(item => item.completed) && this.isUpload) {
const apiUrl = this.isBatchMount === 'true'
? `${this.baseApi}/api/collect/merge`
: `${this.baseApi}/api/re-document/merge`
//
this.sendRequest(apiUrl, jsonArrayToSend)
.then((res) => {
if (res.data.code === 200 && res.data.data.length === 1 && res.data.data[0] !== '') {
this.showMessage('文件上传成功', 'success')
this.$emit('onUploadSuccess', res.data.data[0], this.fileName, jsonArrayToSend)
} else {
this.showMessage('文件上传失败', 'error')
}
this.isSyncUpload = false
if (this.isBatchMount === 'true') {
setTimeout(() => {
this.isUpload = false
}, 2000)
}
})
.catch((err) => {
this.handleRequestError(err)
})
} else { } else {
axios.post(this.baseApi + '/api/re-document/merge', jsonArrayToSend, {
headers: {
'Authorization': getToken()
}
}).then((res) => {
console.log(res)
if (res.data.code === 200 && res.data.data !== '') {
this.$message({ message: '文件上传成功', type: 'success', offset: 8 })
this.$emit('onUploadSuccess', res.data.data, this.fileName, jsonArrayToSend)
} else {
this.$message({ message: '文件上传失败', type: 'error', offset: 8 })
}
this.isSyncUpload = false
}).catch(err => {
this.isSyncUpload = false
setTimeout(() => {
this.isUpload = false
}, 2000)
this.$emit('onUploadError', err)
this.$message({ message: '上传服务器失败', type: 'error', offset: 8 })
clearInterval(this.queryTimer)
})
this.isSyncUpload = false
setTimeout(() => {
this.isUpload = false
}, 2000)
this.showMessage('请耐心等待文件上传完成后再保存!', 'error')
} }
} else {
this.isSyncUpload = false
setTimeout(() => {
this.isUpload = false
}, 2000)
this.$message({ message: '请耐心等待文件上传完成后再保存!', type: 'error', offset: 8 })
})
.catch((err) => {
this.handleRequestError(err)
})
},
//
showMessage(message, type) {
this.$message({ message, type, offset: 8 })
},
//
sendRequest(url, data) {
return axios.post(url, data, {
headers: {
'Authorization': getToken()
} }
}) })
}, },
//
handleRequestError(err) {
this.isSyncUpload = false
setTimeout(() => {
this.isUpload = false
}, 2000)
this.$emit('onUploadError', err)
this.showMessage('上传服务器失败', 'error')
clearInterval(this.queryTimer)
},
// //
onFileError(rootFile, file, response, chunk) { onFileError(rootFile, file, response, chunk) {
this.$message({ message: '上传失败', type: 'error', offset: 8 }) this.$message({ message: '上传失败', type: 'error', offset: 8 })
@ -414,6 +540,23 @@ export default {
resolve({ width, height }) resolve({ width, height })
} }
}) })
},
handleClearData() {
this.isStartUpload = false
this.md5ProgressText = 0
this.isMd5Upload = false
this.isUpload = false
this.uploadProcessNum = 0
this.uploadSpeed = 0
this.fileName = ''
this.isSyncUpload = false
const uploaderInstance = this.$refs.uploader.uploader
console.log('uploaderInstance.fileList222', uploaderInstance.fileList)
uploaderInstance.fileList.forEach(file => file.cancel())
uploaderInstance.fileList = []
uploaderInstance.files = []
this.$refs.uploader.files = []
this.$refs.uploader.fileList = []
} }
} }
} }

22
src/views/prearchiveLibrary/index.vue

@ -76,7 +76,7 @@
<!-- 移动 --> <!-- 移动 -->
<moveFile ref="moveForm" :selected-document="selectedDocument" @refresh="crud.refresh" /> <moveFile ref="moveForm" :selected-document="selectedDocument" @refresh="crud.refresh" />
<!-- 合并成件 --> <!-- 合并成件 -->
<el-dialog class="dialog-middle" :modal-append-to-body="false" :close-on-click-modal="false" :before-close="handleClose" :visible="mergeVisible" title="合并成件">
<el-dialog class="dialog-middle" :modal-append-to-body="false" :close-on-click-modal="false" :before-close="closeDialog" :visible="mergeVisible" title="合并成件">
<span class="dialog-right-top" /> <span class="dialog-right-top" />
<span class="dialog-left-bottom" /> <span class="dialog-left-bottom" />
<div class="setting-dialog"> <div class="setting-dialog">
@ -103,7 +103,7 @@
</el-dialog> </el-dialog>
<!--新增 / 编辑 表单组件--> <!--新增 / 编辑 表单组件-->
<el-dialog class="preview-dialog" :modal-append-to-body="false" :close-on-click-modal="false" append-to-body :before-close="handleClose" :visible="formVisible" :title="formTitle">
<el-dialog class="preview-dialog" :modal-append-to-body="false" :close-on-click-modal="false" append-to-body :before-close="closeDialog" :visible="formVisible" :title="formTitle">
<span class="dialog-right-top" /> <span class="dialog-right-top" />
<span class="dialog-left-bottom" /> <span class="dialog-left-bottom" />
<div class="setting-dialog"> <div class="setting-dialog">
@ -433,14 +433,20 @@ export default {
isDisabled: node.isType !== 2 isDisabled: node.isType !== 2
} }
}, },
handleClose(done) {
this.mergeVisible = false
this.formVisible = false
done()
},
// handleClose(done) {
// this.mergeVisible = false
// this.formVisible = false
// this.$refs.previewForm.preUplpadClose()
// done()
// },
closeDialog() { closeDialog() {
this.formVisible = false this.formVisible = false
this.mergeVisible = false this.mergeVisible = false
if (this.$refs.previewForm.$refs['addOrUpdateForm']) {
this.$refs.previewForm.$refs['addOrUpdateForm'].clearValidate()
this.$refs.previewForm.$refs['addOrUpdateForm'].resetFields()
}
this.$refs.previewForm.preUplpadClose()
} }
} }
} }
@ -448,7 +454,7 @@ export default {
<style lang='scss' scoped> <style lang='scss' scoped>
.preview-dialog .el-dialog .preview-content { .preview-dialog .el-dialog .preview-content {
height: calc(100vh - 290px) !important;
height: calc(100vh - 264px) !important;
} }

Loading…
Cancel
Save