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");
                });
  • 相关阅读:
    【线段树合并】联通分量计数
    莫队算法
    Ubuntu实用软件安装[转]
    装系统·折腾记
    Qt环境配置 + Qt使用教程
    Google题解
    隐含马尔科夫模型
    Pythonの坑
    C++11并发编程个人小结
    微软2017年预科生计划在线编程笔试
  • 原文地址:https://www.cnblogs.com/web-aqin/p/15040335.html
Copyright © 2011-2022 走看看