年度对比数据格式化
This commit is contained in:
@@ -60,35 +60,35 @@ export default {
|
|||||||
selection: [],
|
selection: [],
|
||||||
// 表格列配置
|
// 表格列配置
|
||||||
columns: [
|
columns: [
|
||||||
{ title: "类别", dataIndex: "pointName", sorter: true },
|
// { title: "类别", dataIndex: "type", sorter: true },
|
||||||
{ title: "点位名称", dataIndex: "waterTemperature", sorter: true },
|
// { title: "点位名称", dataIndex: "pointName", sorter: true },
|
||||||
{
|
// {
|
||||||
title: "2020年",
|
// title: "2020年",
|
||||||
children: [
|
// children: [
|
||||||
{ title: "水质类别", dataIndex: "remark", sorter: true },
|
// { title: "水质类别", dataIndex: "remark", sorter: true },
|
||||||
{ title: "综合营养状态指数", dataIndex: "remark", sorter: true },
|
// { title: "综合营养状态指数", dataIndex: "remark", sorter: true },
|
||||||
{ title: "级别", dataIndex: "remark", sorter: true },
|
// { title: "级别", dataIndex: "remark", sorter: true },
|
||||||
{
|
// {
|
||||||
title: "超标项目(超标倍数)",
|
// title: "超标项目(超标倍数)",
|
||||||
dataIndex: "remark",
|
// dataIndex: "remark",
|
||||||
sorter: true,
|
// sorter: true,
|
||||||
},
|
// },
|
||||||
],
|
// ],
|
||||||
},
|
// },
|
||||||
|
|
||||||
{
|
// {
|
||||||
title: "2021年",
|
// title: "2021年",
|
||||||
children: [
|
// children: [
|
||||||
{ title: "水质类别", dataIndex: "remark", sorter: true },
|
// { title: "水质类别", dataIndex: "remark", sorter: true },
|
||||||
{ title: "综合营养状态指数", dataIndex: "remark", sorter: true },
|
// { title: "综合营养状态指数", dataIndex: "remark", sorter: true },
|
||||||
{ title: "级别", dataIndex: "remark", sorter: true },
|
// { title: "级别", dataIndex: "remark", sorter: true },
|
||||||
{
|
// {
|
||||||
title: "超标项目(超标倍数)",
|
// title: "超标项目(超标倍数)",
|
||||||
dataIndex: "remark",
|
// dataIndex: "remark",
|
||||||
sorter: true,
|
// sorter: true,
|
||||||
},
|
// },
|
||||||
],
|
// ],
|
||||||
},
|
// },
|
||||||
],
|
],
|
||||||
palceOptions: [],
|
palceOptions: [],
|
||||||
areaOptions: [],
|
areaOptions: [],
|
||||||
@@ -124,13 +124,66 @@ export default {
|
|||||||
this.$message.error(res.data.msg);
|
this.$message.error(res.data.msg);
|
||||||
this.datasource = []
|
this.datasource = []
|
||||||
}else{
|
}else{
|
||||||
this.datasource = res.data.data
|
// this.datasource = res.data.data
|
||||||
|
this.filterData(res.data.data)
|
||||||
}
|
}
|
||||||
}).catch(()=>{
|
}).catch(()=>{
|
||||||
this.loading = false;
|
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() {
|
reload() {
|
||||||
this.getPageData()
|
this.getPageData()
|
||||||
|
|||||||
Reference in New Issue
Block a user