订单,用户,商品导出
This commit is contained in:
parent
4145acebe6
commit
773faa40b9
|
@ -572,12 +572,14 @@ import { fromList } from "@/libs/constants.js";
|
||||||
import timeOptions from "@/utils/timeOptions";
|
import timeOptions from "@/utils/timeOptions";
|
||||||
import * as FileSaver from "file-saver";
|
import * as FileSaver from "file-saver";
|
||||||
import Worker from "worker-loader!@/worker/calcWorker.js";
|
import Worker from "worker-loader!@/worker/calcWorker.js";
|
||||||
|
import { roterPre } from "@/settings";
|
||||||
export default {
|
export default {
|
||||||
components: { orderDetail, cardsData, userDetails },
|
components: { orderDetail, cardsData, userDetails },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
pickerOptions: timeOptions,
|
pickerOptions: timeOptions,
|
||||||
orderId: 0,
|
orderId: 0,
|
||||||
|
roterPre: roterPre,
|
||||||
tableData: {
|
tableData: {
|
||||||
data: [],
|
data: [],
|
||||||
total: 0,
|
total: 0,
|
||||||
|
@ -759,66 +761,68 @@ export default {
|
||||||
// document.body.removeChild(downloadLink);
|
// document.body.removeChild(downloadLink);
|
||||||
// },
|
// },
|
||||||
async exports() {
|
async exports() {
|
||||||
const loading = this.$loading({
|
// const loading = this.$loading({
|
||||||
lock: true,
|
// lock: true,
|
||||||
text: "导出中...",
|
// text: "导出中...",
|
||||||
spinner: "el-icon-loading",
|
// spinner: "el-icon-loading",
|
||||||
background: "hsla(0, 0%, 100%, .9)",
|
// background: "hsla(0, 0%, 100%, .9)",
|
||||||
});
|
// });
|
||||||
let excelData = JSON.parse(JSON.stringify(this.tableFrom)),
|
// let excelData = JSON.parse(JSON.stringify(this.tableFrom)),
|
||||||
data = [];
|
// data = [];
|
||||||
excelData.page = 1;
|
// excelData.page = 1;
|
||||||
excelData.limit = 200;
|
// excelData.limit = 200;
|
||||||
let pageCount = 1;
|
// let pageCount = 1;
|
||||||
let lebData = {};
|
// let lebData = {};
|
||||||
// let work;
|
// // let work;
|
||||||
for (let i = 0; i < pageCount; i++) {
|
// for (let i = 0; i < pageCount; i++) {
|
||||||
lebData = await this.downData(excelData);
|
// lebData = await this.downData(excelData);
|
||||||
// if(work){
|
// // if(work){
|
||||||
// work.setContent(lebData.export)
|
// // work.setContent(lebData.export)
|
||||||
// }else{
|
// // }else{
|
||||||
// work = createWorkBook(lebData.header, lebData.title, data, lebData.foot,lebData.filename);
|
// // work = createWorkBook(lebData.header, lebData.title, data, lebData.foot,lebData.filename);
|
||||||
// }
|
// // }
|
||||||
//循环次数
|
// //循环次数
|
||||||
pageCount = Math.ceil(lebData.count / excelData.limit);
|
// pageCount = Math.ceil(lebData.count / excelData.limit);
|
||||||
// 数据同步
|
// // 数据同步
|
||||||
if (lebData.export.length) {
|
// if (lebData.export.length) {
|
||||||
data = data.concat(lebData.export);
|
// data = data.concat(lebData.export);
|
||||||
excelData.page++;
|
// excelData.page++;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
console.log("开始处理");
|
// console.log("开始处理");
|
||||||
// 获取计算开始的时间
|
// // 获取计算开始的时间
|
||||||
let start = performance.now();
|
// let start = performance.now();
|
||||||
// 新建一个线程
|
// // 新建一个线程
|
||||||
let worker = new Worker();
|
// let worker = new Worker();
|
||||||
// 线程之间通过postMessage进行通信
|
// // 线程之间通过postMessage进行通信
|
||||||
worker.postMessage({
|
// worker.postMessage({
|
||||||
header: lebData.header,
|
// header: lebData.header,
|
||||||
title: lebData.title,
|
// title: lebData.title,
|
||||||
data,
|
// data,
|
||||||
foot: lebData.foot,
|
// foot: lebData.foot,
|
||||||
filename: lebData.filename,
|
// filename: lebData.filename,
|
||||||
});
|
// });
|
||||||
// 监听message事件
|
// // 监听message事件
|
||||||
worker.addEventListener("message", (e) => {
|
// worker.addEventListener("message", (e) => {
|
||||||
// 关闭线程
|
// // 关闭线程
|
||||||
worker.terminate();
|
// worker.terminate();
|
||||||
// 获取计算结束的时间
|
// // 获取计算结束的时间
|
||||||
let end = performance.now();
|
// let end = performance.now();
|
||||||
// 得到总的计算时间
|
// // 得到总的计算时间
|
||||||
let durationTime = end - start;
|
// let durationTime = end - start;
|
||||||
|
|
||||||
console.log("计算结果:", e.data);
|
// console.log("计算结果:", e.data);
|
||||||
let { blob, filename } = e.data;
|
// let { blob, filename } = e.data;
|
||||||
FileSaver.saveAs(blob, filename + ".xlsx");
|
// FileSaver.saveAs(blob, filename + ".xlsx");
|
||||||
loading.close();
|
// loading.close();
|
||||||
console.log(`代码执行了 ${durationTime} 毫秒`);
|
// console.log(`代码执行了 ${durationTime} 毫秒`);
|
||||||
});
|
// });
|
||||||
// this.exportCsv(lebData.header,data,lebData.filename)
|
// // this.exportCsv(lebData.header,data,lebData.filename)
|
||||||
// createWorkBook(lebData.header, lebData.title, data, lebData.foot,lebData.filename)
|
// // createWorkBook(lebData.header, lebData.title, data, lebData.foot,lebData.filename)
|
||||||
// work.saveAndDowloade(lebData.filename)
|
// // work.saveAndDowloade(lebData.filename)
|
||||||
return;
|
// return;
|
||||||
|
let excelData = JSON.parse(JSON.stringify(this.tableFrom));
|
||||||
|
this.exportRecord(excelData);
|
||||||
},
|
},
|
||||||
/**订单列表 */
|
/**订单列表 */
|
||||||
downData(excelData) {
|
downData(excelData) {
|
||||||
|
@ -828,9 +832,9 @@ export default {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 导出
|
|
||||||
exportRecord() {
|
exportRecord(excelData) {
|
||||||
exportOrderApi(this.tableFrom)
|
exportOrderApi(excelData)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const h = this.$createElement;
|
const h = this.$createElement;
|
||||||
this.$msgbox({
|
this.$msgbox({
|
||||||
|
@ -841,7 +845,9 @@ export default {
|
||||||
h("span", null, '"查看~ '),
|
h("span", null, '"查看~ '),
|
||||||
]),
|
]),
|
||||||
confirmButtonText: "我知道了",
|
confirmButtonText: "我知道了",
|
||||||
}).then((action) => {});
|
}).then((action) => {
|
||||||
|
this.$router.push({ path: this.roterPre + "/group/exportList" });
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch((res) => {
|
.catch((res) => {
|
||||||
this.$message.error(res.message);
|
this.$message.error(res.message);
|
||||||
|
|
|
@ -1157,37 +1157,63 @@ export default {
|
||||||
this.$refs.editAttr.getAttrDetail(row.product_id);
|
this.$refs.editAttr.getAttrDetail(row.product_id);
|
||||||
},
|
},
|
||||||
async exports() {
|
async exports() {
|
||||||
let excelData = JSON.parse(JSON.stringify(this.tableFrom)),
|
let excelData = JSON.parse(JSON.stringify(this.tableFrom));
|
||||||
data = [];
|
this.exportRecord(excelData);
|
||||||
excelData.page = 1;
|
// data = [];
|
||||||
excelData.limit = 200;
|
// excelData.page = 1;
|
||||||
let pageCount = 1;
|
// excelData.limit = 200;
|
||||||
let lebData = {};
|
// let pageCount = 1;
|
||||||
for (let i = 0; i < pageCount; i++) {
|
// let lebData = {};
|
||||||
lebData = await this.downData(excelData);
|
// for (let i = 0; i < pageCount; i++) {
|
||||||
pageCount = Math.ceil(lebData.count / excelData.limit);
|
// lebData = await this.downData(excelData);
|
||||||
if (lebData.export.length) {
|
// pageCount = Math.ceil(lebData.count / excelData.limit);
|
||||||
data = data.concat(lebData.export);
|
// if (lebData.export.length) {
|
||||||
excelData.page++;
|
// data = data.concat(lebData.export);
|
||||||
}
|
// excelData.page++;
|
||||||
}
|
// }
|
||||||
createWorkBook(
|
// }
|
||||||
lebData.header,
|
// createWorkBook(
|
||||||
lebData.title,
|
// lebData.header,
|
||||||
data,
|
// lebData.title,
|
||||||
lebData.foot,
|
// data,
|
||||||
lebData.filename
|
// lebData.foot,
|
||||||
);
|
// lebData.filename
|
||||||
return;
|
// );
|
||||||
|
// return;
|
||||||
},
|
},
|
||||||
/**订单列表 */
|
/**订单列表 */
|
||||||
downData(excelData) {
|
downData(excelData) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
exportProductApi(excelData).then((res) => {
|
exportProductApi(excelData)
|
||||||
return resolve(res.data);
|
.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) {
|
onchangeTime(e) {
|
||||||
this.timeVal = e;
|
this.timeVal = e;
|
||||||
|
|
|
@ -641,6 +641,7 @@ import newsCategory from "@/components/newsCategory/index.vue";
|
||||||
import userDetail from "./userDetails";
|
import userDetail from "./userDetails";
|
||||||
import userCreate from "./userCreate";
|
import userCreate from "./userCreate";
|
||||||
import couponList from "./couponList";
|
import couponList from "./couponList";
|
||||||
|
import { roterPre } from "@/settings";
|
||||||
import createWorkBook from "@/utils/newToExcel.js";
|
import createWorkBook from "@/utils/newToExcel.js";
|
||||||
const checkMobile = (rule, value, cb) => {
|
const checkMobile = (rule, value, cb) => {
|
||||||
const regMobile = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
|
const regMobile = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
|
||||||
|
@ -775,6 +776,7 @@ export default {
|
||||||
total: 0,
|
total: 0,
|
||||||
},
|
},
|
||||||
uid: "",
|
uid: "",
|
||||||
|
roterPre: roterPre,
|
||||||
listLoading: true,
|
listLoading: true,
|
||||||
multipleSelection: [],
|
multipleSelection: [],
|
||||||
ids: "",
|
ids: "",
|
||||||
|
@ -1024,35 +1026,37 @@ export default {
|
||||||
},
|
},
|
||||||
// 导出
|
// 导出
|
||||||
async exportList() {
|
async exportList() {
|
||||||
const loading = this.$loading({
|
// const loading = this.$loading({
|
||||||
lock: true,
|
// lock: true,
|
||||||
text: "正在拼命导出中,请耐心等待...",
|
// text: "正在拼命导出中,请耐心等待...",
|
||||||
spinner: "el-icon-loading",
|
// spinner: "el-icon-loading",
|
||||||
background: "hsla(0, 0%, 100%, .9)",
|
// background: "hsla(0, 0%, 100%, .9)",
|
||||||
});
|
// });
|
||||||
let excelData = JSON.parse(JSON.stringify(this.userFrom)),
|
// let excelData = JSON.parse(JSON.stringify(this.userFrom)),
|
||||||
data = [];
|
// data = [];
|
||||||
excelData.page = 1;
|
// excelData.page = 1;
|
||||||
excelData.limit = 500;
|
// excelData.limit = 500;
|
||||||
let pageCount = 1;
|
// let pageCount = 1;
|
||||||
let lebData = {};
|
// let lebData = {};
|
||||||
for (let i = 0; i < pageCount; i++) {
|
// for (let i = 0; i < pageCount; i++) {
|
||||||
lebData = await this.downData(excelData);
|
// lebData = await this.downData(excelData);
|
||||||
pageCount = Math.ceil(lebData.count / excelData.limit);
|
// pageCount = Math.ceil(lebData.count / excelData.limit);
|
||||||
if (lebData.export.length) {
|
// if (lebData.export.length) {
|
||||||
data = data.concat(lebData.export);
|
// data = data.concat(lebData.export);
|
||||||
excelData.page++;
|
// excelData.page++;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
createWorkBook(
|
// createWorkBook(
|
||||||
lebData.header,
|
// lebData.header,
|
||||||
lebData.title,
|
// lebData.title,
|
||||||
data,
|
// data,
|
||||||
lebData.foot,
|
// lebData.foot,
|
||||||
lebData.filename
|
// lebData.filename
|
||||||
);
|
// );
|
||||||
loading.close();
|
// loading.close();
|
||||||
return;
|
// return;
|
||||||
|
let excelData = JSON.parse(JSON.stringify(this.userFrom));
|
||||||
|
this.exportRecord(excelData);
|
||||||
},
|
},
|
||||||
/**导出用户列表 */
|
/**导出用户列表 */
|
||||||
downData(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() {
|
sendSuccess() {
|
||||||
this.visibleCoupon = false;
|
this.visibleCoupon = false;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue