zoukankan      html  css  js  c++  java
  • vue 文件导出功能

    带token形式的导出


    接口的js:
    // 采购管理-订货通知 export function orderInform (orderId,userId) { return `${window.g_api.BASE_API}/order-item-pricing/inform?orderId=${orderId}&userId=${userId}` } 页面代码: window.open( orderInform( this.orderInformationDisplayStorage[0].id, window.localStorage.getItem("userIds") ), "_self", "width=0,height=0" );
    不带token:

    let params = {
            endDate: this.searchParams.endDate,
            startDate: this.searchParams.startDate,
            searchStr: this.searchParams.searchStr,
          };
    this.$confirm("是否导出?", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning"
          }).then(() => {
            window.open(`/hero-log/error/exportLogError?${this.website.tokenHeader}=${getToken()}&endDate=${params.endDate}&startDate=${params.startDate}&searchStr=${params.searchStr}`,'_self', 'width=0,height=0');
          });
    走正常请求的导出:
    
    
    api:
      /* 库存总览导出模板 */
      stockExport() {
        return request({
          url: "/stock/export",
          method: "get",
        }).then((res) => {
          return this.backErr(res);
        });
      },
    
    html:
    stockExport() {
          inventory.stockExport().then((res) => {
            window.open(res.data, "_self", "width=0,height=0");
          });
        },

    最后一种方式,根据自己需求实现导出

    res.data.data.forEach((element) => {
                  const iframe = document.createElement("iframe");
                  iframe.src = element;
                  iframe.style.display = "none";
                  document.body.appendChild(iframe);
                  this.$emit("confirmExportSuccess");
                });
  • 相关阅读:
    React项目(垃圾分类后台管理)
    React 学习笔记
    xml学习
    .NET Core部署Windows服务
    .NET 生成PDF流
    无线数传电台是什么
    电流电压采集模块如何进行数据传输的
    Spring5快乐教程(十)AspectJ注解实现AOP
    Spring5快乐教程(九)注解编程详解
    Spring5快乐教程(八)注解编程详解
  • 原文地址:https://www.cnblogs.com/web-aqin/p/15040335.html
Copyright © 2011-2022 走看看