This commit is contained in:
faiz 2024-05-23 10:36:15 +08:00
parent b38c70e90b
commit 39e06e08a7
1 changed files with 38 additions and 4 deletions

View File

@ -31,10 +31,10 @@
<el-form-item label="时间选择:"> <el-form-item label="时间选择:">
<el-date-picker <el-date-picker
v-model="timeVal" v-model="timeVal"
value-format="yyyy/MM/dd" value-format="yyyy/MM/dd HH:mm:ss"
format="yyyy/MM/dd" format="yyyy/MM/dd HH:mm:ss"
size="small" size="small"
type="daterange" type="datetimerange"
placement="bottom-end" placement="bottom-end"
placeholder="自定义时间" placeholder="自定义时间"
style="width: 280px;" style="width: 280px;"
@ -539,21 +539,54 @@ export default {
this.drawer = v; this.drawer = v;
this.userDawer = v; this.userDawer = v;
}, },
// csv
exportCsv(columns, dataList, fileName) {
let title = columns.map(item => item);
let keyArray = columns.map(item => item.key);
let str = [];
console.log(dataList);
console.log(title);
str.push(title.join(',') + '\n');
for (let i = 0; i < dataList.length; i++) {
const temp = [];
for (let j = 0; j < keyArray.length; j++) {
console.log(dataList[i][j]);
temp.push(dataList[i][j]);
}
str.push(temp.join(',') + '\n');
}
console.log(str)
let uri = 'data:text/csv;charset=utf-8,\ufeff' + encodeURIComponent(str.join(''));
let downloadLink = document.createElement('a');
downloadLink.href = uri;
downloadLink.download = fileName;
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
},
async exports() { async exports() {
let excelData = JSON.parse(JSON.stringify(this.tableFrom)), data = [] let excelData = JSON.parse(JSON.stringify(this.tableFrom)), 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;
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){
// work.setContent(lebData.export)
// }else{
// 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++
} }
} }
createWorkBook(lebData.header, lebData.title, data, lebData.foot,lebData.filename); this.exportCsv(lebData.header,data,lebData.filename)
// createWorkBook(lebData.header, lebData.title, data, lebData.foot,lebData.filename)
// work.saveAndDowloade(lebData.filename)
return return
}, },
/**订单列表 */ /**订单列表 */
@ -640,6 +673,7 @@ export default {
// //
onchangeTime(e) { onchangeTime(e) {
this.timeVal = e; this.timeVal = e;
console.log(e);
this.tableFrom.date = e ? this.timeVal.join("-") : ""; this.tableFrom.date = e ? this.timeVal.join("-") : "";
this.tableFrom.page = 1; this.tableFrom.page = 1;
this.getCardList() this.getCardList()