|
@@ -31,7 +31,7 @@
|
|
|
import FileItem from './file/index2'
|
|
|
export default {
|
|
|
components: {FileItem},
|
|
|
- props:['folderid','bindData','type','accept'],
|
|
|
+ props:['folderid','bindData','type','accept','bindDataFile','isFile'],
|
|
|
name: '',
|
|
|
data() {
|
|
|
return {
|
|
@@ -92,35 +92,41 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- toUpload (callback) {
|
|
|
+ toUpload (callback,type) {
|
|
|
+ console.log('输出',this.fileList)
|
|
|
if (this.fileList.length == 0) callback()
|
|
|
this.fileList.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,callback)
|
|
|
+ this.getUploadUrl(file, ext,callback,type)
|
|
|
})
|
|
|
},
|
|
|
|
|
|
// 获取华为云上传地址
|
|
|
- async getUploadUrl (file, ext,callback) {
|
|
|
+ async getUploadUrl (file, ext,callback,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,callback)
|
|
|
+ this.upoladFileToServer(url, file, ext, obsfilename,callback,type)
|
|
|
},
|
|
|
|
|
|
// 上传到华为云
|
|
|
- async upoladFileToServer (url, file, ext, obsfilename,callback) {
|
|
|
+ async upoladFileToServer (url, file, ext, obsfilename,callback,type) {
|
|
|
let THIS = this
|
|
|
let config = {
|
|
|
headers: ext === 'pdf' ? { 'Content-Type': 'application/pdf' } : ext === 'svg'?{ 'Content-Type': 'image/svg+xml' } : { 'Content-Type': 'application/octet-stream' },
|
|
|
}
|
|
|
let res = await this.$upload.hw_upload(url, file.raw, config)
|
|
|
- this.createFileRecord(obsfilename,callback)
|
|
|
+ if (type == '附件'){
|
|
|
+ this.createFileRecordNew(obsfilename,callback)
|
|
|
+ }else {
|
|
|
+ this.createFileRecord(obsfilename,callback)
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
},
|
|
|
|
|
@@ -139,10 +145,30 @@ export default {
|
|
|
if (res.code === 1) {
|
|
|
callback()
|
|
|
this.$emit('onSuccess',res)
|
|
|
+ this.toUpload(callback,'附件')
|
|
|
+ // this.fileList = []
|
|
|
+ // this.fileLinkList = []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async createFileRecordNew(obsfilename,callback){
|
|
|
+ console.log(this.fileList,'2111')
|
|
|
+ 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)
|
|
|
+ if (res.code === 1) {
|
|
|
+ callback()
|
|
|
+ // this.$emit('onSuccess',res)
|
|
|
this.fileList = []
|
|
|
this.fileLinkList = []
|
|
|
}
|
|
|
- },
|
|
|
+ }
|
|
|
},
|
|
|
};
|
|
|
</script>
|