From 277297fa8033d456ba97e46a5727d8ee522ea7c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BA=9E=E4=B8=9C=E6=9E=97?= Date: Wed, 8 Dec 2021 16:03:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=B4=E5=BA=A6=E5=AF=B9=E6=AF=94=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../statistic/inner/component/comparison.vue | 111 +++++++++++++----- 1 file changed, 82 insertions(+), 29 deletions(-) diff --git a/src/views/water/lake/statistic/inner/component/comparison.vue b/src/views/water/lake/statistic/inner/component/comparison.vue index 2305f2a..727826b 100644 --- a/src/views/water/lake/statistic/inner/component/comparison.vue +++ b/src/views/water/lake/statistic/inner/component/comparison.vue @@ -60,35 +60,35 @@ export default { selection: [], // 表格列配置 columns: [ - { title: "类别", dataIndex: "pointName", sorter: true }, - { title: "点位名称", dataIndex: "waterTemperature", sorter: true }, - { - title: "2020年", - children: [ - { title: "水质类别", dataIndex: "remark", sorter: true }, - { title: "综合营养状态指数", dataIndex: "remark", sorter: true }, - { title: "级别", dataIndex: "remark", sorter: true }, - { - title: "超标项目(超标倍数)", - dataIndex: "remark", - sorter: true, - }, - ], - }, + // { title: "类别", dataIndex: "type", sorter: true }, + // { title: "点位名称", dataIndex: "pointName", sorter: true }, + // { + // title: "2020年", + // children: [ + // { title: "水质类别", dataIndex: "remark", sorter: true }, + // { title: "综合营养状态指数", dataIndex: "remark", sorter: true }, + // { title: "级别", dataIndex: "remark", sorter: true }, + // { + // title: "超标项目(超标倍数)", + // dataIndex: "remark", + // sorter: true, + // }, + // ], + // }, - { - title: "2021年", - children: [ - { title: "水质类别", dataIndex: "remark", sorter: true }, - { title: "综合营养状态指数", dataIndex: "remark", sorter: true }, - { title: "级别", dataIndex: "remark", sorter: true }, - { - title: "超标项目(超标倍数)", - dataIndex: "remark", - sorter: true, - }, - ], - }, + // { + // title: "2021年", + // children: [ + // { title: "水质类别", dataIndex: "remark", sorter: true }, + // { title: "综合营养状态指数", dataIndex: "remark", sorter: true }, + // { title: "级别", dataIndex: "remark", sorter: true }, + // { + // title: "超标项目(超标倍数)", + // dataIndex: "remark", + // sorter: true, + // }, + // ], + // }, ], palceOptions: [], areaOptions: [], @@ -124,13 +124,66 @@ export default { this.$message.error(res.data.msg); this.datasource = [] }else{ - this.datasource = res.data.data + // this.datasource = res.data.data + this.filterData(res.data.data) } }).catch(()=>{ this.loading = false; }) }, + // 格式化数据 + filterData(data){ + let filterData = [] + let addCloumns = [] +console.log('data', data) + if(Array.isArray(data)){ + data.forEach((item,index)=>{ + filterData[index].type = item.type; + filterData[index].pointName = item.pointName; + + // 筛选出年份 + // if(Array.isArray(item.data)){ + // item.data.forEach((single,i)=>{ + // filterData[index]['comprehensiveNutrition'+i] = single.comprehensiveNutrition; + // filterData[index]['level'+i] = single.level; + // filterData[index]['overflow'+i] = single.overflow; + // filterData[index]['waterType'+i] = single.waterType; + // filterData[index]['year'+i] = single.year; + + // addCloumns[index].title = single.year + + // if(i==0){ + // addCloumns[index].children = [ + // { title: "水质类别", dataIndex: `waterType${i}`, sorter: true }, + // { title: "综合营养状态指数", dataIndex: `comprehensiveNutrition${i}`, sorter: true }, + // { title: "级别", dataIndex: `level${i}`, sorter: true }, + // { + // title: "超标项目(超标倍数)", + // dataIndex: `overflow${i}`, + // sorter: true, + // }, + // ] + // } + + // }) + // } + + }) + } + +console.log('addCloumns',addCloumns) +console.log('filterData',filterData) + + this.columns = [ + { title: "类别", dataIndex: "type", sorter: true }, + { title: "点位名称", dataIndex: "pointName", sorter: true }, + ...addCloumns + ] + this.datasource = filterData; + + }, + /* 刷新表格 */ reload() { this.getPageData()