zoukankan      html  css  js  c++  java
  • 前端和后端联调 导出excel功能

    方法代码:
    payExcelClick (params) {
    if (!params) {
    params = {
    pageSize: this.pageSize,
    queryForm: this.queryForm
    }
    } else {
    params.pageSize = this.pageSize
    params.queryForm = this.queryForm
    }
    payExcelClick(params).then(({status, data}) => {
    if (status === 200) {
    const blob = new Blob([data], { type: "application/x-xls" })
    const fileName = `合同_${new Date().getTime()}.xlsx`
    const elink = document.createElement('a')
    elink.download = fileName
    elink.style.display = 'none'
    elink.href = URL.createObjectURL(blob)
    document.body.appendChild(elink)
    elink.click()
    URL.revokeObjectURL(elink.href)
    document.body.removeChild(elink)
    } else {
    notify('获取信息失败', data.msg, 'error')
    }
    })
    },


    api:
    // 导出当前页的应收
    export function payExcelClick (params) {
    return request({
    url: '/xxxx/xxxx/xx/xxxx',
    method: 'post',
    headers: {
    "biz-source-param": "BLG"
    },
    responseType: "blob",
    data: params
    })
    }
  • 相关阅读:
    【BZOJ2806】【CTSC2012】—熟悉的文章(二分答案+广义后缀自动机+单调队列优化dp)
    2017-2-15
    2017-2-14
    2017-2-13
    CSS居中
    2017-2-10
    微信小程序
    2017-2-9
    2017-2-8
    基础知识再整理: 01
  • 原文地址:https://www.cnblogs.com/yeanling/p/12956962.html
Copyright © 2011-2022 走看看