| | |
| | | import * as DateFormatter from '@/utils/DateFormatter'; |
| | | import {mapGetters} from 'vuex'; |
| | | import * as dataExport from "@/api/exportExcel" |
| | | |
| | | export default { |
| | | data() { |
| | |
| | | }, |
| | | }, |
| | | methods:{ |
| | | fetchData() {}, |
| | | // 导出 |
| | | handleExport() {}, |
| | | handleExport(api, fileName, params) { |
| | | console.log(fileName) |
| | | let loading = this.$loading({ |
| | | lock: true, |
| | | text: '导出中,请稍候...', |
| | | spinner: 'el-icon-loading', |
| | | background: 'rgba(0, 0, 0, 0.7)', |
| | | }); |
| | | // 判断总条数是否大于最大支持条数 |
| | | dataExport[api](params) |
| | | .then((res) => { |
| | | const blob = new Blob([res], {type: 'application/vnd.ms-excel'}); |
| | | if ('download' in document.createElement('a')) { |
| | | // 非IE下载 |
| | | const elink = document.createElement('a'); |
| | | elink.download = `${fileName}.xls`; |
| | | elink.style.display = 'none'; |
| | | elink.href = URL.createObjectURL(blob); |
| | | document.body.appendChild(elink); |
| | | elink.click(); |
| | | URL.revokeObjectURL(elink.href); |
| | | document.body.removeChild(elink); |
| | | } else { |
| | | // IE10+下载 |
| | | navigator.msSaveBlob(blob, `${fileName}.xls`); |
| | | } |
| | | this.$message.success('导出成功!'); |
| | | loading.close(); |
| | | }) |
| | | .catch(() => { |
| | | loading.close(); |
| | | }); |
| | | }, |
| | | // 新增 |
| | | handleAdd() { |
| | | this.editSetting.id = null; |