|
|
@ -52,14 +52,16 @@ |
|
|
<span v-else class="default-placeholder-text">{{ getPlaceholder() }}</span> |
|
|
<span v-else class="default-placeholder-text">{{ getPlaceholder() }}</span> |
|
|
</div> |
|
|
</div> |
|
|
<template v-else-if="type === 'attachment'"> |
|
|
<template v-else-if="type === 'attachment'"> |
|
|
<el-upload class="upload-demo" :action="uploadFileUrl" :on-preview="handlePreview" |
|
|
|
|
|
|
|
|
<el-upload ref="uploadRef" class="upload-demo" :action="uploadFileUrl" :on-preview="handlePreview" |
|
|
:headers="headers" |
|
|
:headers="headers" |
|
|
|
|
|
:before-remove="beforeRemove" |
|
|
:on-remove="handleRemove" multiple :limit="10" |
|
|
:on-remove="handleRemove" multiple :limit="10" |
|
|
:on-success="handleSuccess" |
|
|
:on-success="handleSuccess" |
|
|
:before-upload="beforeUpload" |
|
|
|
|
|
:on-exceed="handleExceed" :file-list="fileList"> |
|
|
|
|
|
|
|
|
:on-change="handleChange" |
|
|
|
|
|
:on-exceed="handleExceed" :file-list="fileList" |
|
|
|
|
|
:auto-upload="false"> |
|
|
<el-button :class="getFillTypeStyle() + (orangeBg ? ' orange-bg' : '')" 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> |
|
|
|
|
|
|
|
|
<div slot="tip" class="el-upload__tip">支持扩展名:.rar .zip .doc .docx .pdf .jpg,文件大小不超过2MB</div> |
|
|
</el-upload> |
|
|
</el-upload> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
@ -203,7 +205,7 @@ export default { |
|
|
visible: false,//是否显示弹窗 |
|
|
visible: false,//是否显示弹窗 |
|
|
checkboxValue: this.getChecked(),//是否选中 |
|
|
checkboxValue: this.getChecked(),//是否选中 |
|
|
uuid: getuuid(), // 唯一标识符,用于EventBus事件匹配 |
|
|
uuid: getuuid(), // 唯一标识符,用于EventBus事件匹配 |
|
|
regentType: ['sj', 'gsp', 'mix', 'xj', 'xb', 'gyzj', 'mjy', 'yq','jcb'], //试剂/仪器/供试品等类型 |
|
|
|
|
|
|
|
|
regentType: ['sj', 'gsp', 'mix', 'xj', 'xb', 'gyzj', 'mjy', 'yq'], //试剂/仪器/供试品等类型 |
|
|
selectRegentInfo: {},//选择的试剂/仪器/供试品等信息 |
|
|
selectRegentInfo: {},//选择的试剂/仪器/供试品等信息 |
|
|
fileList: [],//上传的文件列表 |
|
|
fileList: [],//上传的文件列表 |
|
|
uploadFileUrl: process.env.VUE_APP_BASE_API + "/file/upload", |
|
|
uploadFileUrl: process.env.VUE_APP_BASE_API + "/file/upload", |
|
|
@ -253,6 +255,53 @@ export default { |
|
|
this.selectRegentInfo = data; |
|
|
this.selectRegentInfo = data; |
|
|
console.log(data,"yq") |
|
|
console.log(data,"yq") |
|
|
}, |
|
|
}, |
|
|
|
|
|
// 删除前确认 |
|
|
|
|
|
beforeRemove(file) { |
|
|
|
|
|
return this.$confirm(`确定移除 ${file.name} ?`) |
|
|
|
|
|
}, |
|
|
|
|
|
// 文件状态改变时的钩子,添加文件、上传成功、上传失败时都会被调用 |
|
|
|
|
|
handleChange(file, fileList) { |
|
|
|
|
|
// 如果是新添加的文件(status为ready),进行验证 |
|
|
|
|
|
if (file.status === 'ready') { |
|
|
|
|
|
const isAllowedType = ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', |
|
|
|
|
|
'application/x-rar-compressed', 'application/zip', |
|
|
|
|
|
'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'].includes(file.raw.type) |
|
|
|
|
|
const isLt2M = file.size / 1024 / 1024 < 2 |
|
|
|
|
|
|
|
|
|
|
|
if (!isAllowedType) { |
|
|
|
|
|
this.$message.error(`文件 ${file.name} 格式不支持!只能上传 JPG/PNG/GIF/PDF/RAR/ZIP/DOC/DOCX 格式的文件`) |
|
|
|
|
|
// 从fileList中移除该文件 |
|
|
|
|
|
const index = fileList.indexOf(file); |
|
|
|
|
|
if (index > -1) { |
|
|
|
|
|
fileList.splice(index, 1); |
|
|
|
|
|
} |
|
|
|
|
|
this.fileList = [...fileList]; |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
if (!isLt2M) { |
|
|
|
|
|
this.$message.error(`文件 ${file.name} 大小超过2MB!`) |
|
|
|
|
|
// 从fileList中移除该文件 |
|
|
|
|
|
const index = fileList.indexOf(file); |
|
|
|
|
|
if (index > -1) { |
|
|
|
|
|
fileList.splice(index, 1); |
|
|
|
|
|
} |
|
|
|
|
|
this.fileList = [...fileList]; |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 验证通过,手动提交上传 |
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
|
// 找到对应的upload组件并提交 |
|
|
|
|
|
const uploadComponent = this.$refs.uploadRef; |
|
|
|
|
|
if (uploadComponent) { |
|
|
|
|
|
uploadComponent.submit(); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 更新fileList |
|
|
|
|
|
this.fileList = fileList; |
|
|
|
|
|
}, |
|
|
handleSuccess(res, file, fileList) { |
|
|
handleSuccess(res, file, fileList) { |
|
|
if(res.code == 200){ |
|
|
if(res.code == 200){ |
|
|
this.fileList = fileList; |
|
|
this.fileList = fileList; |
|
|
@ -263,6 +312,12 @@ export default { |
|
|
this.$message.success('文件上传成功'); |
|
|
this.$message.success('文件上传成功'); |
|
|
} else { |
|
|
} else { |
|
|
this.$message.error(res.message || '文件上传失败'); |
|
|
this.$message.error(res.message || '文件上传失败'); |
|
|
|
|
|
// 上传失败,从列表中移除 |
|
|
|
|
|
const index = fileList.indexOf(file); |
|
|
|
|
|
if (index > -1) { |
|
|
|
|
|
fileList.splice(index, 1); |
|
|
|
|
|
this.fileList = [...fileList]; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
getFileList(fileList) { |
|
|
getFileList(fileList) { |
|
|
@ -292,33 +347,13 @@ export default { |
|
|
// 触发保存记录 |
|
|
// 触发保存记录 |
|
|
this.onCommonHandleSaveRecord(); |
|
|
this.onCommonHandleSaveRecord(); |
|
|
|
|
|
|
|
|
this.$message.info(`文件 ${file.name} 已移除`); |
|
|
|
|
|
|
|
|
this.$message.success(`文件 ${file.name} 已移除`); |
|
|
}, |
|
|
}, |
|
|
handlePreview(file) { |
|
|
handlePreview(file) { |
|
|
// 预览文件,如果是图片则直接打开,否则下载 |
|
|
|
|
|
if (file.url) { |
|
|
if (file.url) { |
|
|
|
|
|
|
|
|
window.open(process.env.VUE_APP_FILE_DOMAIN + file.url, '_blank'); |
|
|
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) { |
|
|
handleExceed(files, fileList) { |
|
|
this.$message.warning(`当前限制选择 10 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`); |
|
|
this.$message.warning(`当前限制选择 10 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`); |
|
|
}, |
|
|
}, |
|
|
@ -352,7 +387,6 @@ export default { |
|
|
mjy: "5",//麻精药 |
|
|
mjy: "5",//麻精药 |
|
|
xj: "9",//细菌 |
|
|
xj: "9",//细菌 |
|
|
xb: "11",//细胞 |
|
|
xb: "11",//细胞 |
|
|
jcb: "13",//检测板 |
|
|
|
|
|
} |
|
|
} |
|
|
params = { |
|
|
params = { |
|
|
...params, |
|
|
...params, |
|
|
|