首页 > 其他分享 >vue Excel导入,下载Excel模板,导出Excel

vue Excel导入,下载Excel模板,导出Excel

时间:2022-09-29 15:57:43浏览次数:51  
标签:vue file Excel 导入 result exportfileList 模板

vue  Excel导入,下载Excel模板,导出Excel

<template>
    <div style="display: flex;">
      <el-button
        @click="handleDownload"
        class="button_search"
        type="primary"
        size="medium" >下载模板</el-button>
      <el-upload
        style="display: inline-block"
        :action="uploadUrl_file"
        name="file"
        :headers="{ 'x-token': token }"
        :file-list="exportfileList"
        :on-success="handleFileSuccess"
        :on-error="handleFileError"
        :show-file-list="true">
        <el-button
          class="button_search"
          type="primary"
          size="medium"
        >导入</el-button>
      </el-upload>
    </div>
</template>

<script>
  const rootpath = process.env.VUE_APP_BASE_API; 
  import { getToken } from "@/utils/auth";
  var busiContractorImport = "/business/fourth/excel/import.do"; //导入接口
  export default {
    name: 'importExcel',
    data(){
      return{
        uploadUrl_file:'',
        token: getToken() ,
        exportfileList: [],
        showShade:false
      }
    },
    mounted() {
      let vm = this;
      vm.uploadUrl_file = rootpath + busiContractorImport +"?excelHandler=dictCheckContentByMyselfImportHandler"; //上传地址
    },
    methods:{
      // 下载模板
      handleDownload() {
     // 把模板放在 : public/excel/隐患排查自建自建隐患库 window.open("excel/隐患排查自建隐患库.xlsx"); }, // 导入 handleFileError(result, file, exportfileList) { this.$notify.error("导入失败,错误:" + result); this.showShade = false; this.exportfileList = []; }, handleFileSuccess(result, file, exportfileList) { var that = this; var code = result.code; if (code === "0") { that.$notify({ title: "成功", message: "导入成功", type: "success", duration: 2000 }); that.$emit("importExcel") } else { that.$notify.error({ title: "导入失败", message: result.msg, duration: 2000 }); } that.showShade = false; that.exportfileList = []; }, } }; </script> <style scoped> </style>

 

标签:vue,file,Excel,导入,result,exportfileList,模板
From: https://www.cnblogs.com/Jishuyang/p/16741847.html

相关文章

  • ImageUtils   excel 中 emf 转图片(解决图片上部分显示不全问题)  图片转文字
    excel中ActiveX工具中的textbox ,以及公式解析后为emf图片,emf转图片(解决图片上部分显示不全问题)图片转文字importcom.alibaba.fastjson.JSON;impo......
  • vue3中element-plus引入ElLoading并修改颜色
    在vue3中引入element-plus的loading跟vue2差别还是有的写法:<scriptsetup>import{ElLoading}from'element-plus'//使用constloading=ref(false)//loading......
  • vue +echarts+ docxtemplater导出word和图表图片
    1.下载插件//--安装docxtemplaternpminstalldocxtemplaterpizzip--save//--安装jszip-utilsnpminstalljszip-utils--save//--安装jszipnpminstallj......
  • Vue2,Vue3,React,vue-cli和Vite创建和启动
    vue2-project创建项目vuecreatexxx名字下依赖包npminstall启动项目npmrunserve项目打包npmrunbuildvue3-project创建项目vuecreatexxx名字下依......
  • Vue 手动配置路由
    不用一键创建项目的方式 手动引用 1.安装路由组件(vue2)npmivue-router@3 2.创建路由映射js创建src/router/index.js//引用Vue和路由组件importVuef......
  • 如何监听Vue或js项目报错的4种方式
    背景onerrorelement.onerrorerrorHandlererrorCapturederror传播规则(划重点)如何监听异步错误总结背景在开发Vue项目时,使用浏览器调试可以比较清晰的看到报的什......
  • EXCEL如何实现分类
    目的:根据第二列的不同计划线分类来筛选出第一列的料号第一步:选中两列第二步:点击插入,选择"数据透视表"效果图图一:两列都选择行图二:一列设置为筛选器,一列设置为......
  • vue项目环境搭建
    vue项目环境搭建安装Nodejs环境地址:https://nodejs.org/en/download/安装包管理工具#推荐安装yarnnpminstall--globalyarn#或者安装cnpmnpmconfigsetregis......
  • vue 类似苹果手机的悬浮球
    悬浮球效果3种位置展示悬浮球组件代码<template><divclass="ys-float-btn":style="{'width':itemWidth+'px','height':itemHeight+'px','left':left+'px','......
  • vue组件中如何首次加载就触发watch
    watch:{"val":{immediate:true,//首次加载的时候执行函数deep:true,//深入观察数组值的变化,inputVal:function(){}}} ......