This commit is contained in:
parent
b38c70e90b
commit
39e06e08a7
|
@ -31,10 +31,10 @@
|
|||
<el-form-item label="时间选择:">
|
||||
<el-date-picker
|
||||
v-model="timeVal"
|
||||
value-format="yyyy/MM/dd"
|
||||
format="yyyy/MM/dd"
|
||||
value-format="yyyy/MM/dd HH:mm:ss"
|
||||
format="yyyy/MM/dd HH:mm:ss"
|
||||
size="small"
|
||||
type="daterange"
|
||||
type="datetimerange"
|
||||
placement="bottom-end"
|
||||
placeholder="自定义时间"
|
||||
style="width: 280px;"
|
||||
|
@ -539,21 +539,54 @@ export default {
|
|||
this.drawer = 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() {
|
||||
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++
|
||||
}
|
||||
}
|
||||
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
|
||||
},
|
||||
/**订单列表 */
|
||||
|
@ -640,6 +673,7 @@ export default {
|
|||
// 具体日期
|
||||
onchangeTime(e) {
|
||||
this.timeVal = e;
|
||||
console.log(e);
|
||||
this.tableFrom.date = e ? this.timeVal.join("-") : "";
|
||||
this.tableFrom.page = 1;
|
||||
this.getCardList()
|
||||
|
|
Loading…
Reference in New Issue