|
@@ -67,7 +67,7 @@ export default {
|
|
|
bindData:附件上传成功后对应需要绑定的数据信息,
|
|
|
hidemediastock:是否隐藏媒体库选择
|
|
|
*/
|
|
|
- props:['folderid','btntype','accept','bindData','hidemediastock','status','disabled','attachmentDisabled'],
|
|
|
+ props:['folderid','btntype','accept','bindData','hidemediastock','status','disabled','attachmentDisabled','bindDataFile','isFile'],
|
|
|
components:{
|
|
|
selectMedia
|
|
|
},
|
|
@@ -85,33 +85,47 @@ export default {
|
|
|
},
|
|
|
file: {},
|
|
|
filelist: [],
|
|
|
+ fileListNew: [],
|
|
|
count:0
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- handleChange (file, filelist) {
|
|
|
- console.log(file)
|
|
|
- this.$emit('upload')
|
|
|
+ handleChange (file, filelist,type) {
|
|
|
+ this.file = file
|
|
|
this.filelist = filelist
|
|
|
+ console.log(this.filelist,'FILE4444')
|
|
|
+ if (type != '附件'){
|
|
|
+ this.$emit('upload')
|
|
|
+ }
|
|
|
var index = file.raw.name.lastIndexOf(".");
|
|
|
var ext = file.name.substr(index + 1);
|
|
|
this.params.content.filename = file.raw.name
|
|
|
this.params.content.filetype = ext
|
|
|
- this.getUploadUrl(file, ext)
|
|
|
+ this.getUploadUrl(file, ext,type)
|
|
|
},
|
|
|
+ toUpload (type) {
|
|
|
+ console.log(this.fileListNew)
|
|
|
+ this.fileListNew.forEach(file=>{
|
|
|
+ let index = file.name.lastIndexOf(".");
|
|
|
+ let ext = file.name.substr(index + 1);
|
|
|
+ this.params.content.filename = file.name
|
|
|
+ this.params.content.filetype = ext
|
|
|
+ this.getUploadUrl(file, ext,type)
|
|
|
+ })
|
|
|
|
|
|
+ },
|
|
|
// 获取华为云上传地址
|
|
|
- async getUploadUrl (file, ext) {
|
|
|
+ async getUploadUrl (file, ext,type) {
|
|
|
this.params.content.parentid = this.folderid
|
|
|
const res = await this.$api.requested(this.params)
|
|
|
let url = res.data.uploadurl
|
|
|
let obsfilename = res.data.serialfilename
|
|
|
|
|
|
- this.upoladFileToServer(url, file, ext, obsfilename)
|
|
|
+ this.upoladFileToServer(url, file, ext, obsfilename,type)
|
|
|
},
|
|
|
|
|
|
// 上传到华为云
|
|
|
- async upoladFileToServer (url, file, ext, obsfilename) {
|
|
|
+ async upoladFileToServer (url, file, ext, obsfilename,type) {
|
|
|
console.log(file)
|
|
|
let THIS = this
|
|
|
let config = {
|
|
@@ -127,11 +141,17 @@ export default {
|
|
|
},
|
|
|
}
|
|
|
const res = await this.$upload.hw_upload(url, file.raw, config)
|
|
|
- this.createFileRecord(obsfilename)
|
|
|
+ if (type == '附件'){
|
|
|
+ this.createFileRecordNew(obsfilename)
|
|
|
+ }else {
|
|
|
+ this.createFileRecord(obsfilename)
|
|
|
+ }
|
|
|
+
|
|
|
},
|
|
|
|
|
|
// 上传成功以后生成附件记录
|
|
|
async createFileRecord (obsfilename,attinfos) {
|
|
|
+ this.fileListNew = []
|
|
|
let obj = {
|
|
|
"serialfilename": obsfilename
|
|
|
}
|
|
@@ -145,17 +165,39 @@ export default {
|
|
|
this.count++
|
|
|
console.log(this.count);
|
|
|
if (this.count == this.filelist.length) {
|
|
|
- this.$emit('onSuccess',res)
|
|
|
- this.count = 0
|
|
|
- this.$refs['my-upload'].clearFiles()
|
|
|
- this.filelist = []
|
|
|
- console.log('触发');
|
|
|
+ this.fileListNew = this.filelist
|
|
|
+ if (this.isFile){
|
|
|
+ this.$emit('onSuccess',res)
|
|
|
+ this.count = 0
|
|
|
+ this.$refs['my-upload'].clearFiles()
|
|
|
+ this.filelist = []
|
|
|
+ console.log('触发');
|
|
|
+ this.toUpload('附件')
|
|
|
+ }else {
|
|
|
+ this.$emit('onSuccess',res)
|
|
|
+ this.count = 0
|
|
|
+ this.$refs['my-upload'].clearFiles()
|
|
|
+ this.filelist = []
|
|
|
+ console.log('触发');
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
// if (res.code === 1) {
|
|
|
// this.$emit('onSuccess',res)
|
|
|
// }
|
|
|
},
|
|
|
-
|
|
|
+ async createFileRecordNew(obsfilename,attinfos){
|
|
|
+ let obj = {
|
|
|
+ "serialfilename": obsfilename
|
|
|
+ }
|
|
|
+ obj = Object.assign({},obj,this.bindDataFile)
|
|
|
+ let param = {
|
|
|
+ "classname": "system.attachment.huawei.OBS",
|
|
|
+ "method": "uploadSuccess",
|
|
|
+ "content":obj
|
|
|
+ }
|
|
|
+ const res = await this.$api.requested(param)
|
|
|
+ },
|
|
|
clearFiles () {
|
|
|
this.$refs['my-upload'].clearFiles()
|
|
|
this.filelist = []
|