<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() }