getUrl() {
if (this.attachmentId === '') {
this.attachmentId = this.UTIL_.getUUID()
}
let reg=new RegExp('/','g')//g代表全部
let newMsg=this.localUrl.replace(reg,'&');
return`/sys/sysfile/auto/${this.attachmentId}/${newMsg}`
},
uploadOverrun: function() {
this.$message({
type: 'error',
message: '上传文件个数超出限制!最多上传5张图片!'
})
},
changeUpload: function(file, fileList) {
this.fileList = fileList
var URL = null;
if (window.createObjectURL != undefined) {
// basic
URL = window.createObjectURL(file.raw);
} else if (window.URL != undefined) {
// mozilla(firefox)
URL = window.URL.createObjectURL(file.raw);
} else if (window.webkitURL != undefined) {
// webkit or chrome
URL = window.webkitURL.createObjectURL(file.raw);
}
// 转换后的地址为 blob:http://xxx/7bf54338-74bb-47b9-9a7f-7a7093c716b5
this.localUrl = URL;
this.$refs.upload.submit()
this.fileRaw=file.raw
},
submitUpload: function(content) {
const formData = new FormData()
formData.append('file', content.file)
const config = {
'Content-Type': 'multipart/form-data'
}
this.$http.post(this.$http.adornUrl(this.getUrl()), formData, config)
.then(({ data }) => {
this.$refs.upload.clearFiles()
if (data && data.code === 0) {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500
})
this.getDataList()
} else {
this.$message.error(data.msg)
}
})
},
submitAssess: function() {
this.$refs.upload.submit()
},
viewFile() {
const { href } = this.$router.resolve({
name: 'viewfile',
params: {
formid: this.pattachmentId
}
})
var win = window.open(href, 'file-viewer', 'height=800, width=1200, location=no')
setTimeout(function() { win.document.title = '生产管理-文件查看器' }, 500)
},
viewImg(row){
this.$nextTick(() => {
// this.showImg(this.fileRaw);
this.showImg(row);
});
},
showImg (row) {
this.visibleImg = true;
this.localUrl = row.remarks;
this.isShowImgUpload = true;//呈现本地预览组件
},
}