Merge branch 'main' into test

This commit is contained in:
faiz 2024-12-16 16:31:09 +08:00
commit d701c62d11
3 changed files with 173 additions and 117 deletions

View File

@ -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);
// 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++;
// }
//
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("");
// //
// 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);

View File

@ -1166,37 +1166,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) => {
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;

View File

@ -650,6 +650,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}$/;
@ -784,6 +785,7 @@ export default {
total: 0,
},
uid: "",
roterPre: roterPre,
listLoading: true,
multipleSelection: [],
ids: "",
@ -1033,35 +1035,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) {
@ -1071,6 +1075,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;
},