diff --git a/src/views/water/drinking-water/statistic/city/base.vue b/src/views/water/drinking-water/statistic/city/base.vue index 9688ab5..7ddb94a 100644 --- a/src/views/water/drinking-water/statistic/city/base.vue +++ b/src/views/water/drinking-water/statistic/city/base.vue @@ -200,6 +200,7 @@ export default { const td = columns.map((item) => d[item.dataIndex]); arr.push(td); }); + arr.push([`饮用水源水质监测累积月份统计样品数:${this.count}个`]); let sheet = XLSX.utils.aoa_to_sheet(arr); this.$util.exportSheet(XLSX, sheet, new Date().getTime().toString()); }, diff --git a/src/views/water/drinking-water/statistic/city/waterQuality.vue b/src/views/water/drinking-water/statistic/city/waterQuality.vue index 4cfb2a3..0841d6c 100644 --- a/src/views/water/drinking-water/statistic/city/waterQuality.vue +++ b/src/views/water/drinking-water/statistic/city/waterQuality.vue @@ -74,7 +74,7 @@ export default { columns:[ {title:"城市名称",dataIndex:"city",}, {title:"水源地名称",dataIndex:"place",}, - {title:"期数",dataIndex:"sourceWaterName",}, + {title:"期数",dataIndex:"sourceWaterName",}, {title:"水源地性质",dataIndex:"waterSourceProperty",}, {title:"断面水质",align: 'center',children: [ {title: "本月", dataIndex: ""}, @@ -143,20 +143,38 @@ export default { }; this.reload(); }, + exportFile() { - const columns = [ - ...this.columns, - ]; + const columns = [...this.columns]; const arr = []; - const th = columns.map((item) => item.title); - arr.push(th); - this.data.forEach((d) => { - const td = columns.map((item) => d[item.dataIndex]); + let th1 = [] + let th2 = [] + const sColumns = [] + columns.forEach(item=>{ + th1.push(item.title) + if(Array.isArray(item.children) && item.children.length>0){ + item.children.forEach(single=>{ + th1.push('') + th2.push(single.title) + sColumns.push({dataIndex:single.dataIndex}) + }) + }else{ + th2.push('') + sColumns.push({dataIndex:item.dataIndex}) + } + }) + arr.push(th1) + arr.push(th2) + this.datasource.forEach((d) => { + const td = sColumns.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()); }, + + + }, }; diff --git a/src/views/water/drinking-water/statistic/county/base.vue b/src/views/water/drinking-water/statistic/county/base.vue index e482378..21a5efc 100644 --- a/src/views/water/drinking-water/statistic/county/base.vue +++ b/src/views/water/drinking-water/statistic/county/base.vue @@ -200,6 +200,7 @@ export default { const td = columns.map((item) => d[item.dataIndex]); arr.push(td); }); + arr.push([`饮用水源水质监测累积月份统计样品数:${this.count}个`]); let sheet = XLSX.utils.aoa_to_sheet(arr); this.$util.exportSheet(XLSX, sheet, new Date().getTime().toString()); },