到处格式,拆分时间

This commit is contained in:
weicw
2021-11-09 09:17:49 +08:00
parent 9b52b7abac
commit eda3eb3de1
11 changed files with 378 additions and 468 deletions

View File

@@ -67,7 +67,6 @@ import XLSX from "xlsx";
import {pageAcidRainUrl, getColumnOptions} from "@/api/ecology/atmosphere/acid";
import locale from "ant-design-vue/es/date-picker/locale/zh_CN";
import moment from "moment";
import { tableColumns } from "./colums";
// import utils from "./utils";
export default {
name: "StatisticSoundZoneBase",
@@ -258,120 +257,66 @@ export default {
exportFile() {
const columns = [
{
title: "行政代码",
dataIndex: "regionCode",
sorter: true,
},
{
title: "市(县,区)",
dataIndex: "address",
slots: {customRender: "Address"},
},
{
title: "采样点",
dataIndex: "place",
sorter: true,
},
{
title: "点位类型",
dataIndex: "placeType",
sorter: true,
},
{
title: "采样开始时间",
dataIndex: "monitorStartTime",
customRender: ({text}) => moment(text, "YYYY/MM/DD HH:mm:ss").format("YYYY-MM-DD HH:mm")
},
{
title: "采样结束时间",
dataIndex: "monitorEndTime",
customRender: ({text}) => moment(text, "YYYY/MM/DD HH:mm:ss").format("YYYY-MM-DD HH:mm")
},
{
title: "降水类型",
dataIndex: "precipitationType",
sorter: true,
},
{
title: "降水量",
dataIndex: "precipitation",
sorter: true,
},
{
title: "pH",
dataIndex: "ph",
sorter: true,
},
{
title: "电导率",
dataIndex: "conductivity",
sorter: true,
},
{
title: "SO42",
dataIndex: "so42",
sorter: true,
},
{
title: "NO3",
dataIndex: "no3",
sorter: true,
},
{
title: "F",
dataIndex: "f",
sorter: true,
},
{
title: "CL",
dataIndex: "cl",
sorter: true,
},
{
title: "NH4",
dataIndex: "nh4",
sorter: true,
},
{
title: "Ca2",
dataIndex: "ca",
sorter: true,
},
{
title: "Mg2",
dataIndex: "mg",
sorter: true,
},
{
title: "Na",
dataIndex: "na",
sorter: true,
},
{
title: "K",
dataIndex: "k",
sorter: true,
},
{
title: "系统编码",
dataIndex: "systemCode",
sorter: true,
},
{title: "",dataIndex: "regionCode",customRender:()=>"450100",},
{title: "",dataIndex: "address"},
{title: "",dataIndex: "place", },
{title: "",dataIndex: "placeType",},
{title: "年",dataIndex: "monitorStartTime", customRender: ({text}) => moment(text, "YYYY/MM/DD HH:mm:ss").year()},
{title: "月",dataIndex: "monitorStartTime", customRender: ({text}) => moment(text, "YYYY/MM/DD HH:mm:ss").month()},
{title: "日",dataIndex: "monitorStartTime", customRender: ({text}) => moment(text, "YYYY/MM/DD HH:mm:ss").days()},
{title: "时",dataIndex: "monitorStartTime", customRender: ({text}) => moment(text, "YYYY/MM/DD HH:mm:ss").hour()},
{title: "分",dataIndex: "monitorStartTime", customRender: ({text}) => moment(text, "YYYY/MM/DD HH:mm:ss").minute()},
{title: "年",dataIndex: "monitorEndTime", customRender: ({text}) => moment(text, "YYYY/MM/DD HH:mm:ss").year()},
{title: "月",dataIndex: "monitorEndTime", customRender: ({text}) => moment(text, "YYYY/MM/DD HH:mm:ss").month()},
{title: "日",dataIndex: "monitorEndTime", customRender: ({text}) => moment(text, "YYYY/MM/DD HH:mm:ss").days()},
{title: "时",dataIndex: "monitorEndTime", customRender: ({text}) => moment(text, "YYYY/MM/DD HH:mm:ss").hour()},
{title: "分",dataIndex: "monitorEndTime", customRender: ({text}) => moment(text, "YYYY/MM/DD HH:mm:ss").minute()},
{title: "",dataIndex: "precipitationType", },
{ title: "(mm)",dataIndex: "precipitation",sorter: true, },
{title: "",dataIndex: "ph", },
{title: "(mS/m)",dataIndex: "conductivity", },
{title: "SO42-", dataIndex: "so42",},
{title: "NO3-",dataIndex: "no3",},
{ title: "F-", dataIndex: "f",},
{title: "CL-", dataIndex: "cl",},
{title: "NH4",dataIndex: "nh4", },
{ title: "Ca2", dataIndex: "ca",},
{title: "Mg2",dataIndex: "mg", },
{title: "Na",dataIndex: "na",},
{title: "K", dataIndex: "k"},
{title: "",dataIndex: "systemCode",},
];
const arr = [];
const th = columns.map((item) => item.title);
arr.push(th);
const arr = [["酸雨监测结果报告表"]];
const th1 = ["行政代码","市(县,区)","采样点","点位类型","采样开始时间","","","","","采样结束时间","","","","","降水类型","降水量","pH","电导率","离子组分mg/l)","","","","","","","","","系统编码"];
const th2 = columns.map((item) => item.title);
arr.push(th1);
arr.push(th2);
const merges = []; // 合并
merges.push({s: {r: 0, c: 0}, e: {r: 0, c: 27}});
merges.push({s: {r: 1, c: 0}, e: {r: 2, c: 0}});
merges.push({s: {r: 1, c: 1}, e: {r: 2, c: 1}});
merges.push({s: {r: 1, c: 2}, e: {r: 2, c: 2}});
merges.push({s: {r: 1, c: 3}, e: {r: 2, c: 3}});
merges.push({s: {r: 1, c: 4}, e: {r: 1, c: 8}});
merges.push({s: {r: 1, c: 9}, e: {r: 1, c: 13}});
merges.push({s: {r: 1, c: 14}, e: {r: 2, c: 14}});
// merges.push({s: {r: 1, c: 16}, e: {r: 2, c: 16}});
merges.push({s: {r: 1, c: 16}, e: {r: 2, c: 16}});
merges.push({s: {r: 1, c: 18}, e: {r: 1, c: 26}});
merges.push({s: {r: 1, c: 27}, e: {r: 2, c: 27}});
this.data.forEach((d) => {
const td = columns.map((item) => {
if (item.dataIndex == "address") {
return d.area ? d.area : d.county ? d.county : d.city
}else if(item.customRender){
return item.customRender({text:d[item.dataIndex]});
}
return d[item.dataIndex];
});
arr.push(td);
});
let sheet = XLSX.utils.aoa_to_sheet(arr);
sheet['!merges'] = merges;
this.$util.exportSheet(XLSX, sheet, new Date().getTime().toString());
},
},
@@ -379,4 +324,4 @@ export default {
</script>
<style scoped lang="less">
</style>
</style>

View File

@@ -237,7 +237,7 @@ export default {
let sheet = XLSX.utils.aoa_to_sheet(arr);
sheet['!merges'] = merges;
this.$util.exportSheet(XLSX, sheet, moment(this.where.timeStart).format("YYYY年MM月DD日") + "至" + moment(this.where.timeEnd).format("YYYY年MM月DD日"));
this.$util.exportSheet(XLSX, sheet, moment(this.where.timeStart).format("YYYY年MM月DD日") + "至" + moment(this.where.timeEnd).format("YYYY年MM月DD日") + "城区浓度统计");
},
},
@@ -246,4 +246,4 @@ export default {
</script>
<style scoped lang="less">
</style>
</style>

View File

@@ -287,7 +287,13 @@ export default {
})
arr.push(th1,th2);
this.data.forEach((d) => {
const td = columnsTemp.map((item) => d[item.dataIndex]);
const td = columnsTemp.map((item) => {
if(item.customRender){
return item.customRender({text:d[item.dataIndex]});
}
return d[item.dataIndex];
});
arr.push(td);
});
let sheet = XLSX.utils.aoa_to_sheet(arr);
@@ -300,4 +306,4 @@ export default {
</script>
<style scoped lang="less">
</style>
</style>

View File

@@ -276,11 +276,6 @@ export default {
dataIndex: "remark",
sorter: true,
},
{
title: "创建人",
dataIndex: "username",
sorter: true,
},
];
const arr = [];
const th = columns.map((item) => item.title);
@@ -292,7 +287,8 @@ export default {
arr.push(td);
});
let sheet = XLSX.utils.aoa_to_sheet(arr);
this.$util.exportSheet(XLSX, sheet, new Date().getTime().toString());
this.$util.exportSheet(XLSX, sheet, moment(this.where.timeStart).format("YYYY年MM月DD日") + "至" + moment(this.where.timeEnd).format("YYYY年MM月DD日") + "基础数据");
}
})
@@ -302,4 +298,4 @@ export default {
</script>
<style scoped lang="less">
</style>
</style>

View File

@@ -275,7 +275,7 @@ export default {
});
let sheet = XLSX.utils.aoa_to_sheet(arr);
sheet['!merges'] = merges;
this.$util.exportSheet(XLSX, sheet, moment(this.where.timeStart).format("YYYY年MM月DD日") + "至" + moment(this.where.timeEnd).format("YYYY年MM月DD日"));
this.$util.exportSheet(XLSX, sheet, moment(this.where.timeStart).format("YYYY年MM月DD日") + "至" + moment(this.where.timeEnd).format("YYYY年MM月DD日")+ "统计数据");
},
},
@@ -283,4 +283,4 @@ export default {
</script>
<style scoped lang="less">
</style>
</style>