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");
                });
  • 相关阅读:
    MFC中的菜单(Menu)
    MFC中获取系统无任何操作的时间
    MFC中使用快捷键Accelerator
    Git的安装和使用
    给pdf添加目录
    练习题2
    练习题1
    主键和外键
    数据库知识点
    多表查询
  • 原文地址:https://www.cnblogs.com/web-aqin/p/15040335.html
Copyright © 2011-2022 走看看