|
|
|
@ -54,10 +54,11 @@ |
|
|
|
<template v-else-if="type === 'attachment'"> |
|
|
|
<el-upload class="upload-demo" :action="uploadFileUrl" :on-preview="handlePreview" |
|
|
|
:headers="headers" |
|
|
|
:on-remove="handleRemove" :before-remove="beforeRemove" multiple :limit="10" |
|
|
|
:on-remove="handleRemove" multiple :limit="10" |
|
|
|
:on-success="handleSuccess" |
|
|
|
:before-upload="beforeUpload" |
|
|
|
:on-exceed="handleExceed" :file-list="fileList"> |
|
|
|
<el-button size="small" type="primary">点击上传</el-button> |
|
|
|
<el-button :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')" size="small" type="primary">点击上传</el-button> |
|
|
|
<div slot="tip" class="el-upload__tip">支持扩展名:.rar .zip .doc .docx .pdf .jpg</div> |
|
|
|
</el-upload> |
|
|
|
</template> |
|
|
|
@ -296,28 +297,31 @@ export default { |
|
|
|
handlePreview(file) { |
|
|
|
// 预览文件,如果是图片则直接打开,否则下载 |
|
|
|
if (file.url) { |
|
|
|
const fileType = file.type || file.name.split('.').pop().toLowerCase(); |
|
|
|
const imageTypes = ['jpg', 'jpeg', 'png', 'gif', 'bmp']; |
|
|
|
|
|
|
|
if (imageTypes.includes(fileType)) { |
|
|
|
// 图片类型,新建窗口预览 |
|
|
|
window.open(process.env.VUE_APP_FILE_DOMAIN + file.url, '_blank'); |
|
|
|
} else { |
|
|
|
// 非图片类型,下载文件 |
|
|
|
const link = document.createElement('a'); |
|
|
|
link.href = file.url; |
|
|
|
link.download = file.name; |
|
|
|
link.target = '_blank'; |
|
|
|
link.click(); |
|
|
|
} |
|
|
|
window.open(process.env.VUE_APP_FILE_DOMAIN + file.url, '_blank'); |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
// 上传前校验 |
|
|
|
beforeUpload(file) { |
|
|
|
console.log(file,"fff") |
|
|
|
const isAllowedType = ['image/jpeg', 'image/png', 'image/gif', 'application/pdf'].includes(file.type) |
|
|
|
const isLt2M = file.size / 1024 / 1024 < 2 |
|
|
|
|
|
|
|
if (!isAllowedType) { |
|
|
|
this.$message.error('只能上传 JPG/PNG/GIF/PDF 格式的文件!') |
|
|
|
return false |
|
|
|
} |
|
|
|
if (!isLt2M) { |
|
|
|
this.$message.error('文件大小不能超过 2MB!') |
|
|
|
return false |
|
|
|
} |
|
|
|
|
|
|
|
return true |
|
|
|
}, |
|
|
|
handleExceed(files, fileList) { |
|
|
|
this.$message.warning(`当前限制选择 10 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`); |
|
|
|
}, |
|
|
|
beforeRemove(file, fileList) { |
|
|
|
return this.$confirm(`确定移除 ${file.name}?`); |
|
|
|
}, |
|
|
|
//试剂弹窗提交 |
|
|
|
onMixReagentSubmit(data) { |
|
|
|
if (data.uuid !== this.uuid) return; |
|
|
|
|