4 changed files with 89 additions and 11 deletions
@ -1,21 +1,63 @@ |
|||
<template> |
|||
<!-- 新建任务 --> |
|||
<div class=''></div> |
|||
<!-- 新建任务 --> |
|||
<div class=''> |
|||
<el-upload ref="upload" class="upload-demo" :action="uploadUlr" :limit="1" :on-change="handleFileChange" |
|||
:auto-upload="false" accept=".xlsx"> |
|||
<template #trigger> |
|||
<el-button type="primary">上传报表模板</el-button> |
|||
</template> |
|||
</el-upload> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
export default { |
|||
data() { |
|||
return {}; |
|||
return { |
|||
uploadUlr: window.SITE_CONFIG["apiURL"] + "/oss/file/uploadvariedfile", |
|||
}; |
|||
}, |
|||
created() {}, |
|||
methods: {}, |
|||
components:{}, |
|||
computed:{}, |
|||
created() { }, |
|||
methods: { |
|||
handleFileChange(file, newFileList) { |
|||
const selectedFile = file.raw; |
|||
if (!(selectedFile instanceof File)) { |
|||
console.error('传入了非文件对象'); |
|||
return; |
|||
} |
|||
|
|||
if (selectedFile.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') { |
|||
console.log('文件是xlsx类型'); |
|||
} else { |
|||
console.error('不是xlsx文件'); |
|||
return; |
|||
} |
|||
}, |
|||
beforeImgUpload(file) { |
|||
console.log(file); |
|||
const isLt1M = file.size / 1024 / 1024 < 10; |
|||
const srcType = file.type; |
|||
const format = file.name.split(".").pop(); |
|||
if (!isLt1M) { |
|||
this.$message.error("上传文件大小不能超过 10MB!"); |
|||
return false; |
|||
} |
|||
if ( |
|||
srcType.indexOf("image") == -1 && |
|||
srcType.indexOf("video") == -1 && |
|||
["doc", "docx", "xls", "xlsx", "ppt", "pptx", "pdf"].indexOf(format) == |
|||
-1 |
|||
) { |
|||
this.$message.error("仅限图片、word和pdf文件!"); |
|||
return false; |
|||
} |
|||
return true; |
|||
}, |
|||
}, |
|||
components: {}, |
|||
computed: {}, |
|||
watch: {}, |
|||
} |
|||
</script> |
|||
|
|||
<style lang='scss' scoped> |
|||
|
|||
</style> |
|||
<style lang='scss' scoped></style> |
|||
|
|||
@ -0,0 +1,26 @@ |
|||
<template> |
|||
<!-- 确认模板 --> |
|||
<div class=''> |
|||
|
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
export default { |
|||
data() { |
|||
return {}; |
|||
}, |
|||
created() {}, |
|||
methods: { |
|||
|
|||
}, |
|||
components:{}, |
|||
computed:{}, |
|||
watch: {}, |
|||
} |
|||
</script> |
|||
|
|||
<style lang='scss' scoped> |
|||
|
|||
</style> |
|||
|
|||
Loading…
Reference in new issue