Merge branch 'xiaoman'
This commit is contained in:
@@ -47,6 +47,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import moment from "moment";
|
||||
import {
|
||||
// autonomyWaterFunctionTotalUrl,
|
||||
listWaterSiteMonthTotal
|
||||
@@ -324,17 +325,54 @@
|
||||
},
|
||||
/* 导出 */
|
||||
exportFile() {
|
||||
const columns = this.columns.filter(item => item.dataIndex);
|
||||
const arr = [];
|
||||
const th = columns.map((item) => item.title);
|
||||
arr.push(th);
|
||||
this.data.forEach((d) => {
|
||||
const td = columns.map((item) => d[item.dataIndex]);
|
||||
const th1 = [];
|
||||
const th2 = [];
|
||||
const merges = []; // 合并
|
||||
const columnsTemp = []; // 树形结构整理成list
|
||||
this.columns.forEach((item, index) => {
|
||||
if (item.children) {
|
||||
item.children.forEach((citem) => {
|
||||
th1.push(item.title)
|
||||
th2.push(citem.title)
|
||||
columnsTemp.push(citem)
|
||||
})
|
||||
merges.push({
|
||||
s: {
|
||||
r: 0,
|
||||
c: th1.length - item.children.length
|
||||
},
|
||||
e: {
|
||||
r: 0,
|
||||
c: th1.length - 1
|
||||
}
|
||||
})
|
||||
} else {
|
||||
th1.push(item.title)
|
||||
th2.push("")
|
||||
columnsTemp.push(item)
|
||||
merges.push({
|
||||
s: {
|
||||
r: 0,
|
||||
c: index
|
||||
},
|
||||
e: {
|
||||
r: 1,
|
||||
c: index
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
arr.push(th1, th2);
|
||||
this.datasource.forEach((d) => {
|
||||
const td = columnsTemp.map((item) => d[item.dataIndex]);
|
||||
arr.push(td);
|
||||
});
|
||||
|
||||
let sheet = XLSX.utils.aoa_to_sheet(arr);
|
||||
this.$util.exportSheet(XLSX, sheet, new Date().getTime().toString());
|
||||
sheet['!merges'] = merges;
|
||||
this.$util.exportSheet(XLSX, sheet, moment(this.where.timeStart).format("YYYY年MM月DD日") + "至" + moment(this.where
|
||||
.timeEnd).format("YYYY年MM月DD日") + "统计数据");
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user