diff --git a/src/views/order/list/index.vue b/src/views/order/list/index.vue index 9164eee..ead0f17 100644 --- a/src/views/order/list/index.vue +++ b/src/views/order/list/index.vue @@ -835,7 +835,69 @@ export default { exportRecord(excelData) { exportOrderApi(excelData) - .then((res) => { + .then(async (res) => { + if (res.data.filename) { + const loading = this.$loading({ + lock: true, + text: "导出中...", + spinner: "el-icon-loading", + background: "hsla(0, 0%, 100%, .9)", + }); + let excelData = JSON.parse(JSON.stringify(this.tableFrom)), + data = []; + excelData.page = 1; + excelData.limit = 200; + let pageCount = 1; + let lebData = {}; + // let work; + for (let i = 0; i < pageCount; i++) { + lebData = await this.downData(excelData); + // if(work){ + // work.setContent(lebData.export) + // }else{ + // work = createWorkBook(lebData.header, lebData.title, data, lebData.foot,lebData.filename); + // } + //循环次数 + pageCount = Math.ceil(lebData.count / excelData.limit); + // 数据同步 + if (lebData.export.length) { + data = data.concat(lebData.export); + excelData.page++; + } + } + console.log("开始处理"); + // 获取计算开始的时间 + let start = performance.now(); + // 新建一个线程 + let worker = new Worker(); + // 线程之间通过postMessage进行通信 + worker.postMessage({ + header: lebData.header, + title: lebData.title, + data, + foot: lebData.foot, + filename: lebData.filename, + }); + // 监听message事件 + worker.addEventListener("message", (e) => { + // 关闭线程 + worker.terminate(); + // 获取计算结束的时间 + let end = performance.now(); + // 得到总的计算时间 + let durationTime = end - start; + + console.log("计算结果:", e.data); + let { blob, filename } = e.data; + FileSaver.saveAs(blob, filename + ".xlsx"); + loading.close(); + console.log(`代码执行了 ${durationTime} 毫秒`); + }); + // this.exportCsv(lebData.header,data,lebData.filename) + // createWorkBook(lebData.header, lebData.title, data, lebData.foot,lebData.filename) + // work.saveAndDowloade(lebData.filename) + return; + } const h = this.$createElement; this.$msgbox({ title: "提示", diff --git a/src/views/product/productExamine/index.vue b/src/views/product/productExamine/index.vue index 7629f05..3f80366 100644 --- a/src/views/product/productExamine/index.vue +++ b/src/views/product/productExamine/index.vue @@ -1203,9 +1203,32 @@ export default { }); }, // 导出 - exportRecord() { + exportRecord(excelData) { exportProductApi(this.tableFrom) - .then((res) => { + .then(async (res) => { + if (res.data.filename) { + let data = []; + excelData.page = 1; + excelData.limit = 200; + let pageCount = 1; + let lebData = {}; + for (let i = 0; i < pageCount; i++) { + lebData = await this.downData(excelData); + pageCount = Math.ceil(lebData.count / excelData.limit); + if (lebData.export.length) { + data = data.concat(lebData.export); + excelData.page++; + } + } + createWorkBook( + lebData.header, + lebData.title, + data, + lebData.foot, + lebData.filename + ); + return; + } const h = this.$createElement; this.$msgbox({ title: "提示", diff --git a/src/views/user/list/index.vue b/src/views/user/list/index.vue index 7c8e921..98e6801 100644 --- a/src/views/user/list/index.vue +++ b/src/views/user/list/index.vue @@ -1077,7 +1077,37 @@ export default { }, exportRecord(excelData) { exportUserApi(excelData) - .then((res) => { + .then(async (res) => { + if (res.data.filename) { + const loading = this.$loading({ + lock: true, + text: "正在拼命导出中,请耐心等待...", + spinner: "el-icon-loading", + background: "hsla(0, 0%, 100%, .9)", + }); + let data = []; + excelData.page = 1; + excelData.limit = 500; + let pageCount = 1; + let lebData = {}; + for (let i = 0; i < pageCount; i++) { + lebData = await this.downData(excelData); + pageCount = Math.ceil(lebData.count / excelData.limit); + if (lebData.export.length) { + data = data.concat(lebData.export); + excelData.page++; + } + } + createWorkBook( + lebData.header, + lebData.title, + data, + lebData.foot, + lebData.filename + ); + loading.close(); + return; + } const h = this.$createElement; this.$msgbox({ title: "提示",