zoukankan      html  css  js  c++  java
  • vue+element实现导入excel并拿到返回值

    <template>
      <div class="main">
        <el-col :span="2">
          <el-upload
            class="upload-demo"
            :action="upUrl"
            accept=".xls, .xlsx"
            :data="shu"
            :on-success="upSuccess"
            :on-error="upError"
            :limit="1"
          >
            <el-button type="primary" icon="el-icon-upload">导入Excel</el-button>
          </el-upload>
        </el-col>
        <!-- 测试弹窗按钮 -->
        <el-button type="text" @click="dialogVisible = true">点击打开 Dialog</el-button>
        <!-- 弹窗 -->
        <el-dialog title="提示" :visible.sync="dialogVisible" width="30%" :before-close="handleClose">
          <span>{{Info}}</span>
          <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
          </span>
        </el-dialog>

        <!-- 弹窗 结束 -->
      </div>
    </template>

    <script>
    import { commonGet, appServer, commonPost2 } from "@/api/api";
    export default {
      data() {
        return {
          upUrl: appServer() + "systemManagement/system/importTrExcel",
          excel: [],
          dialogVisible: false,
          Info: "",
          shu: {
            userName: this.$store.state.userName
          }
        };
      },
      methods: {
        upSuccess(res) {
          this.$message({
            type: res.type,
            message: res.msg
          });
          this.excel = res.data;
          window.console.log(this.excel);
          //   if (res.data.length > 0) {
          //     this.dialogVisible = true;
          //     switch (res.data) {
          //       case "res.data==1":
          //         this.Info = 拼接内容;
          //         break;
          //       case "res.data==2":
          //         this.Info = 拼接内容;
          //         break;
          //       case "res.data==3":
          //         this.Info = 拼接内容;
          //         break;
          //     }
          //   } else {
          //     this.$message({
          //       type: "indo",
          //       message: "自定义"
          //     });
          //   }
          // },
          // handleClose(done) {
          //   this.$confirm("确认关闭?")
          //     .then(_ => {
          //       done();
          //     })
          //     .catch(_ => {});
        },
        shu() {
          this.$store.state.userName;
        },
        upError() {
          this.$message({
            type: "error",
            message: "上传失败!"
          });
        }
      }
    };
    </script>

    <style scoped>
    </style>
     

    看到我的div了吗?在你那你就完蛋了
  • 相关阅读:
    Docker 镜像
    Docker 安装命令
    Docker 基本概念
    Redis 高可用之"持久化"
    Git 安装和使用
    oracle角色
    oracle权限
    审计
    手动创建数据库
    oracle口令文件认证
  • 原文地址:https://www.cnblogs.com/web-shu/p/12014595.html
Copyright © 2011-2022 走看看