| | |
| | | <template> |
| | | <div class="center"> |
| | | <div class="center" v-loading.fullscreen="successLoading"> |
| | | <el-upload |
| | | class="upload-demo" |
| | | :action="action" |
| | |
| | | data() { |
| | | return { |
| | | msg: "拖动上传", |
| | | successLoading: false, |
| | | fileList: [], |
| | | headers: { |
| | | token: localStorage.getItem("token"), |
| | |
| | | type: Number, |
| | | }, |
| | | }, |
| | | created() { |
| | | |
| | | }, |
| | | methods: { |
| | | // 超出文件上传个数回调 |
| | | handleExceed(files, fileList) { |
| | |
| | | }, |
| | | // 上传成功回调 |
| | | fileSuccess(res, f, fl) { |
| | | this.successLoading = false |
| | | this.$emit("fileSuccess", res, this.type); |
| | | }, |
| | | |
| | | // 过滤文件 |
| | | beforeAvatarUpload(file) { |
| | | this.successLoading = true |
| | | let fileName = file.name.substring(file.name.lastIndexOf(".") + 1); |
| | | const extension = fileName === "xls"; |
| | | const extension2 = fileName === "xlsx"; |
| | | if (!extension && !extension2) { |
| | | |
| | | this.successLoading = false |
| | | this.$message({ |
| | | message: "上传文件只能是 xls、xlsx格式!", |
| | | type: "warning", |
| | |
| | | .center { |
| | | float: left; |
| | | } |
| | | |
| | | </style> |