|
@@ -74,7 +74,8 @@ export default {
|
|
|
oss_url: '',
|
|
|
dataObj: {},
|
|
|
uploadImageUrl: '',
|
|
|
- waitUploadList: []
|
|
|
+ waitUploadList: [],
|
|
|
+ fileName: ''
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -163,7 +164,7 @@ export default {
|
|
|
const result = await new Promise((resolve, reject) => {
|
|
|
getOssConfig().then(res => {
|
|
|
const fileKey = this.createName(fileName)
|
|
|
- res.data.name = fileName
|
|
|
+ res.data.name = this.fileName ? this.fileName : fileName
|
|
|
res.data.key = res.data.dir + fileKey
|
|
|
resolve(res.data)
|
|
|
}).catch(res => {
|
|
@@ -199,17 +200,21 @@ export default {
|
|
|
spinner: 'el-icon-loading',
|
|
|
background: 'rgba(0, 0, 0, 0.7)'
|
|
|
})
|
|
|
- console.log(file)
|
|
|
+
|
|
|
+ const fileName = file.name.substring(0, file.name.lastIndexOf('.'))
|
|
|
+ const suffix = file.name.match(/.[^.]+$/)[0]
|
|
|
+ // 押金申请上传限制
|
|
|
+ if (this.startRestricting) {
|
|
|
+ console.log(this.restrictFilename.join(''))
|
|
|
+ if (fileName.includes(this.restrictFilename.join('')) === -1 || !suffix.includes('zip', 'rar', 'gz', 'apk')) {
|
|
|
+ this.fileName = `其他文件${suffix}`
|
|
|
+ console.log(this.fileName, '4454')
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
this.$emit('handleIsFileName', file.name)
|
|
|
this.dataObj = await this.getOssConfig(file.name)
|
|
|
this.waitUploadList.push(this.dataObj)
|
|
|
- if (this.startRestricting && !['zip', 'rar', 'gz', 'apk'].includes(file.name.split('.')[1])) {
|
|
|
- if (!this.restrictFilename.includes(file.name.split('.')[0])) {
|
|
|
- this.$errorMsg('请根据固定文件名称上传:' + this.restrictFilename.join())
|
|
|
- loading.close()
|
|
|
- return Promise.reject()
|
|
|
- }
|
|
|
- }
|
|
|
},
|
|
|
|
|
|
// 文件上传成功
|
|
@@ -220,6 +225,7 @@ export default {
|
|
|
spinner: 'el-icon-loading',
|
|
|
background: 'rgba(0, 0, 0, 0.7)'
|
|
|
})
|
|
|
+
|
|
|
if (this.uploadImageUrl) {
|
|
|
const index = findElem(this.fileList, 'url', this.uploadImageUrl)
|
|
|
this.$set(this.fileList, index, {
|
|
@@ -229,28 +235,13 @@ export default {
|
|
|
})
|
|
|
this.waitUploadList = []
|
|
|
} else {
|
|
|
- const index = findElem(this.waitUploadList, 'name', file.name)
|
|
|
-
|
|
|
- if (this.startRestricting) {
|
|
|
- if (this.fileList.length) {
|
|
|
- for (let i = 0; i < this.fileList.length; i++) {
|
|
|
- if (this.fileList[i].name.split('.')[0] === file.name.split('.')[0]) {
|
|
|
- this.fileList[i].name = this.waitUploadList[index].name
|
|
|
- this.fileList[i].url = this.waitUploadList[index].key
|
|
|
- this.fileList[i].hover = false
|
|
|
- this.waitUploadList.splice(index, 1)
|
|
|
- this.showFileList = true
|
|
|
- loading.close()
|
|
|
- return false
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ const index = findElem(this.waitUploadList, 'name', this.fileName ? this.fileName : file.name)
|
|
|
this.fileList.push({
|
|
|
name: this.waitUploadList[index].name,
|
|
|
url: this.waitUploadList[index].key,
|
|
|
hover: false
|
|
|
})
|
|
|
+
|
|
|
this.waitUploadList.splice(index, 1)
|
|
|
}
|
|
|
this.showFileList = true
|