From 773faa40b917f42ed304791acdabcc48a25e379f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=8F?= <1978476055@qq.com> Date: Mon, 16 Dec 2024 16:30:51 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95,=E7=94=A8=E6=88=B7,=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/order/list/index.vue | 132 +++++++++++---------- src/views/product/productExamine/index.vue | 76 ++++++++---- src/views/user/list/index.vue | 82 ++++++++----- 3 files changed, 173 insertions(+), 117 deletions(-) diff --git a/src/views/order/list/index.vue b/src/views/order/list/index.vue index 2f7d753..9164eee 100644 --- a/src/views/order/list/index.vue +++ b/src/views/order/list/index.vue @@ -572,12 +572,14 @@ import { fromList } from "@/libs/constants.js"; import timeOptions from "@/utils/timeOptions"; import * as FileSaver from "file-saver"; import Worker from "worker-loader!@/worker/calcWorker.js"; +import { roterPre } from "@/settings"; export default { components: { orderDetail, cardsData, userDetails }, data() { return { pickerOptions: timeOptions, orderId: 0, + roterPre: roterPre, tableData: { data: [], total: 0, @@ -759,66 +761,68 @@ export default { // document.body.removeChild(downloadLink); // }, async exports() { - 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; + // 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; + // 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; + let excelData = JSON.parse(JSON.stringify(this.tableFrom)); + this.exportRecord(excelData); }, /**订单列表 */ downData(excelData) { @@ -828,9 +832,9 @@ export default { }); }); }, - // 导出 - exportRecord() { - exportOrderApi(this.tableFrom) + + exportRecord(excelData) { + exportOrderApi(excelData) .then((res) => { const h = this.$createElement; this.$msgbox({ @@ -841,7 +845,9 @@ export default { h("span", null, '"查看~ '), ]), confirmButtonText: "我知道了", - }).then((action) => {}); + }).then((action) => { + this.$router.push({ path: this.roterPre + "/group/exportList" }); + }); }) .catch((res) => { this.$message.error(res.message); diff --git a/src/views/product/productExamine/index.vue b/src/views/product/productExamine/index.vue index ba356f0..8ae16cf 100644 --- a/src/views/product/productExamine/index.vue +++ b/src/views/product/productExamine/index.vue @@ -1157,37 +1157,63 @@ export default { this.$refs.editAttr.getAttrDetail(row.product_id); }, async exports() { - let excelData = JSON.parse(JSON.stringify(this.tableFrom)), - 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; + let excelData = JSON.parse(JSON.stringify(this.tableFrom)); + this.exportRecord(excelData); + // 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; }, /**订单列表 */ downData(excelData) { return new Promise((resolve, reject) => { - exportProductApi(excelData).then((res) => { - return resolve(res.data); - }); + exportProductApi(excelData) + .then((res) => { + return resolve(res.data); + }) + .catch((err) => { + this.$message.error(err); + }); }); }, + // 导出 + exportRecord() { + exportProductApi(this.tableFrom) + .then((res) => { + const h = this.$createElement; + this.$msgbox({ + title: "提示", + message: h("p", null, [ + h("span", null, '文件正在生成中,请稍后点击"'), + h("span", { style: "color: teal" }, "导出记录"), + h("span", null, '"查看~ '), + ]), + confirmButtonText: "我知道了", + }).then((action) => { + this.$router.push({ path: this.roterPre + "/group/exportList" }); + }); + }) + .catch((res) => { + this.$message.error(res.message); + }); + }, // 具体日期 onchangeTime(e) { this.timeVal = e; diff --git a/src/views/user/list/index.vue b/src/views/user/list/index.vue index 86baca6..c337b00 100644 --- a/src/views/user/list/index.vue +++ b/src/views/user/list/index.vue @@ -641,6 +641,7 @@ import newsCategory from "@/components/newsCategory/index.vue"; import userDetail from "./userDetails"; import userCreate from "./userCreate"; import couponList from "./couponList"; +import { roterPre } from "@/settings"; import createWorkBook from "@/utils/newToExcel.js"; const checkMobile = (rule, value, cb) => { const regMobile = /^[1][3,4,5,6,7,8,9][0-9]{9}$/; @@ -775,6 +776,7 @@ export default { total: 0, }, uid: "", + roterPre: roterPre, listLoading: true, multipleSelection: [], ids: "", @@ -1024,35 +1026,37 @@ export default { }, // 导出 async exportList() { - const loading = this.$loading({ - lock: true, - text: "正在拼命导出中,请耐心等待...", - spinner: "el-icon-loading", - background: "hsla(0, 0%, 100%, .9)", - }); - let excelData = JSON.parse(JSON.stringify(this.userFrom)), - 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 loading = this.$loading({ + // lock: true, + // text: "正在拼命导出中,请耐心等待...", + // spinner: "el-icon-loading", + // background: "hsla(0, 0%, 100%, .9)", + // }); + // let excelData = JSON.parse(JSON.stringify(this.userFrom)), + // 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; + let excelData = JSON.parse(JSON.stringify(this.userFrom)); + this.exportRecord(excelData); }, /**导出用户列表 */ downData(excelData) { @@ -1062,6 +1066,26 @@ export default { }); }); }, + exportRecord(excelData) { + exportUserApi(excelData) + .then((res) => { + const h = this.$createElement; + this.$msgbox({ + title: "提示", + message: h("p", null, [ + h("span", null, '文件正在生成中,请稍后点击"'), + h("span", { style: "color: teal" }, "导出记录"), + h("span", null, '"查看~ '), + ]), + confirmButtonText: "我知道了", + }).then((action) => { + this.$router.push({ path: this.roterPre + "/group/exportList" }); + }); + }) + .catch((res) => { + this.$message.error(res.message); + }); + }, sendSuccess() { this.visibleCoupon = false; },