对比数据导出
This commit is contained in:
2
.env
2
.env
@@ -1,3 +1,3 @@
|
|||||||
VUE_APP_VERSION=1.0.0
|
VUE_APP_VERSION=1.0.0
|
||||||
VUE_APP_NAME=生态环境监测数据综合分析平台
|
VUE_APP_NAME=生态环境监测数据综合分析平台
|
||||||
VUE_APP_API_BASE_URL=http://1.14.132.108:10002/api
|
VUE_APP_API_BASE_URL=http://101.132.173.65:10001/api
|
||||||
|
|||||||
@@ -90,6 +90,8 @@ export default {
|
|||||||
// ],
|
// ],
|
||||||
// },
|
// },
|
||||||
],
|
],
|
||||||
|
//扁平化表头,用于导出的数据组装
|
||||||
|
sColumns:[],
|
||||||
palceOptions: [],
|
palceOptions: [],
|
||||||
areaOptions: [],
|
areaOptions: [],
|
||||||
regionLevelOptions: [],
|
regionLevelOptions: [],
|
||||||
@@ -136,7 +138,7 @@ export default {
|
|||||||
filterData(data){
|
filterData(data){
|
||||||
let filterData = []
|
let filterData = []
|
||||||
let addCloumns = []
|
let addCloumns = []
|
||||||
|
let addSCloumns = []
|
||||||
if(Array.isArray(data)){
|
if(Array.isArray(data)){
|
||||||
|
|
||||||
data.forEach((item,index)=>{
|
data.forEach((item,index)=>{
|
||||||
@@ -159,6 +161,13 @@ export default {
|
|||||||
addCloumns[index].title = single.year
|
addCloumns[index].title = single.year
|
||||||
addCloumns[index].align = 'center'
|
addCloumns[index].align = 'center'
|
||||||
|
|
||||||
|
addSCloumns = [
|
||||||
|
{dataIndex: `waterType${i}`},
|
||||||
|
{ dataIndex: `comprehensiveNutrition${i}`},
|
||||||
|
{dataIndex: `level${i}`},
|
||||||
|
{dataIndex: `overflow${i}`}
|
||||||
|
]
|
||||||
|
|
||||||
addCloumns[index].children = [
|
addCloumns[index].children = [
|
||||||
{ title: "水质类别", dataIndex: `waterType${i}`, sorter: true,align:'center' },
|
{ title: "水质类别", dataIndex: `waterType${i}`, sorter: true,align:'center' },
|
||||||
{ title: "综合营养状态指数", dataIndex: `comprehensiveNutrition${i}`, sorter: true,align:'center' },
|
{ title: "综合营养状态指数", dataIndex: `comprehensiveNutrition${i}`, sorter: true,align:'center' },
|
||||||
@@ -182,6 +191,11 @@ export default {
|
|||||||
{ title: "点位名称", dataIndex: "pointName", sorter: true},
|
{ title: "点位名称", dataIndex: "pointName", sorter: true},
|
||||||
...addCloumns
|
...addCloumns
|
||||||
]
|
]
|
||||||
|
this.sColumns = [
|
||||||
|
{dataIndex: "type"},
|
||||||
|
{dataIndex: "pointName"},
|
||||||
|
...addSCloumns
|
||||||
|
]
|
||||||
this.datasource = filterData;
|
this.datasource = filterData;
|
||||||
|
|
||||||
},
|
},
|
||||||
@@ -203,10 +217,28 @@ export default {
|
|||||||
exportFile() {
|
exportFile() {
|
||||||
const columns = this.columns;
|
const columns = this.columns;
|
||||||
const arr = [];
|
const arr = [];
|
||||||
const th = columns.map((item) => item.title);
|
// const th = columns.map((item) => item.title);
|
||||||
arr.push(th);
|
// arr.push(th);
|
||||||
|
|
||||||
|
let th1 = []
|
||||||
|
let th2 = []
|
||||||
|
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)
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
th2.push('')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
arr.push(th1)
|
||||||
|
arr.push(th2)
|
||||||
this.data.forEach((d) => {
|
this.data.forEach((d) => {
|
||||||
const td = columns.map((item) => d[item.dataIndex]);
|
const td = this.sColumns.map((item) => d[item.dataIndex]);
|
||||||
arr.push(td);
|
arr.push(td);
|
||||||
});
|
});
|
||||||
let sheet = XLSX.utils.aoa_to_sheet(arr);
|
let sheet = XLSX.utils.aoa_to_sheet(arr);
|
||||||
|
|||||||
@@ -90,6 +90,8 @@ export default {
|
|||||||
// ],
|
// ],
|
||||||
// },
|
// },
|
||||||
],
|
],
|
||||||
|
//扁平化表头,用于导出的数据组装
|
||||||
|
sColumns:[],
|
||||||
palceOptions: [],
|
palceOptions: [],
|
||||||
areaOptions: [],
|
areaOptions: [],
|
||||||
regionLevelOptions: [],
|
regionLevelOptions: [],
|
||||||
@@ -136,7 +138,7 @@ export default {
|
|||||||
filterData(data){
|
filterData(data){
|
||||||
let filterData = []
|
let filterData = []
|
||||||
let addCloumns = []
|
let addCloumns = []
|
||||||
|
let addSCloumns = []
|
||||||
if(Array.isArray(data)){
|
if(Array.isArray(data)){
|
||||||
|
|
||||||
data.forEach((item,index)=>{
|
data.forEach((item,index)=>{
|
||||||
@@ -159,6 +161,13 @@ export default {
|
|||||||
addCloumns[index].title = single.year
|
addCloumns[index].title = single.year
|
||||||
addCloumns[index].align = 'center'
|
addCloumns[index].align = 'center'
|
||||||
|
|
||||||
|
addSCloumns = [
|
||||||
|
{dataIndex: `waterType${i}`},
|
||||||
|
{ dataIndex: `comprehensiveNutrition${i}`},
|
||||||
|
{dataIndex: `level${i}`},
|
||||||
|
{dataIndex: `overflow${i}`}
|
||||||
|
]
|
||||||
|
|
||||||
addCloumns[index].children = [
|
addCloumns[index].children = [
|
||||||
{ title: "水质类别", dataIndex: `waterType${i}`, sorter: true,align:'center' },
|
{ title: "水质类别", dataIndex: `waterType${i}`, sorter: true,align:'center' },
|
||||||
{ title: "综合营养状态指数", dataIndex: `comprehensiveNutrition${i}`, sorter: true,align:'center' },
|
{ title: "综合营养状态指数", dataIndex: `comprehensiveNutrition${i}`, sorter: true,align:'center' },
|
||||||
@@ -182,6 +191,11 @@ export default {
|
|||||||
{ title: "点位名称", dataIndex: "pointName", sorter: true},
|
{ title: "点位名称", dataIndex: "pointName", sorter: true},
|
||||||
...addCloumns
|
...addCloumns
|
||||||
]
|
]
|
||||||
|
this.sColumns = [
|
||||||
|
{dataIndex: "type"},
|
||||||
|
{dataIndex: "pointName"},
|
||||||
|
...addSCloumns
|
||||||
|
]
|
||||||
this.datasource = filterData;
|
this.datasource = filterData;
|
||||||
|
|
||||||
},
|
},
|
||||||
@@ -203,10 +217,28 @@ export default {
|
|||||||
exportFile() {
|
exportFile() {
|
||||||
const columns = this.columns;
|
const columns = this.columns;
|
||||||
const arr = [];
|
const arr = [];
|
||||||
const th = columns.map((item) => item.title);
|
// const th = columns.map((item) => item.title);
|
||||||
arr.push(th);
|
// arr.push(th);
|
||||||
|
|
||||||
|
let th1 = []
|
||||||
|
let th2 = []
|
||||||
|
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)
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
th2.push('')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
arr.push(th1)
|
||||||
|
arr.push(th2)
|
||||||
this.data.forEach((d) => {
|
this.data.forEach((d) => {
|
||||||
const td = columns.map((item) => d[item.dataIndex]);
|
const td = this.sColumns.map((item) => d[item.dataIndex]);
|
||||||
arr.push(td);
|
arr.push(td);
|
||||||
});
|
});
|
||||||
let sheet = XLSX.utils.aoa_to_sheet(arr);
|
let sheet = XLSX.utils.aoa_to_sheet(arr);
|
||||||
|
|||||||
Reference in New Issue
Block a user