zoukankan      html  css  js  c++  java
  • vue 实现excel导出功能

    <el-button size="small" type="primary" @click="excel" :disabled="loading">报表导出</el-button>
    async excel() {
                let apis = [{ url: 'getDetailExcel', name: '生产明细表' }, { url: 'getNodeExcel', name: '生产节点表' }, { url: 'getTotalExcel', name: '生产明细合计表' }]
                let params = {}
                for (var key in this.listQuery) {
                    if (this.listQuery.hasOwnProperty(key)) {
                        var el = this.listQuery[key];
                        if (el) {
                            params[key] = el
                        }
                    }
                }
                this.loading = true;
                let res = await this.$http({
                    method: "get",
                    url: `${this.$api}/production/${apis[this.activeName - 0].url}`,
                    responseType: 'blob',
                    params: params
                })
                this.loading = false;
                if (!res) {
                    this.$message.warning("服务器异常");
                }
                let url = window.URL.createObjectURL(res.data)
                let link = document.createElement('a')
                link.style.display = 'none'
                link.href = url
                link.setAttribute('download', apis[this.activeName - 0].name + '.xlsx')
                document.body.appendChild(link)
                link.click()
            }
  • 相关阅读:
    修改滚动条样式
    svg转png
    封装普通数据为树菜单结构数据模式
    js调用打印机打印
    jq 上传下载进度条
    html内容溢出部分...
    html调用html的方法
    4 人类社会及其发展规律
    7 社会主义
    8 共产主义
  • 原文地址:https://www.cnblogs.com/ivday/p/9933905.html
Copyright © 2011-2022 走看看