0
点赞
收藏
分享

微信扫一扫

el-upload上传文件

爱做梦的夏夏 2022-03-25 阅读 41

el-upload上传文件

           <el-upload
                accept=".xlsx, .xls"
                ref="defaultUpload"
                action="/"
                :show-file-list="false"
                :auto-upload="false"
                :on-change="beforeUpload"
                list-type="text"
                file
              >
                <el-button size="small" type="primary" icon="el-icon-upload"
                  >上传</el-button
                >
              </el-upload>
    beforeUpload(file, fileList) {
      let formData = new FormData();
      formData.append("file", fileList[0].raw);
      this.$confirm("导入注册系统,会删除当前所有数据,是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          importSys(formData).then((res) => {
            if (res && res.code == "200") {
              this.gettableList();
              this.$message({
                type: "success",
                message: "导入注册系统成功!",
              });
            }
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消导入注册系统",
          });
        });
    },
举报

相关推荐

0 条评论