到处格式,拆分时间

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

View File

@@ -237,7 +237,7 @@ export default {
let sheet = XLSX.utils.aoa_to_sheet(arr); let sheet = XLSX.utils.aoa_to_sheet(arr);
sheet['!merges'] = merges; 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> </script>
<style scoped lang="less"> <style scoped lang="less">
</style> </style>

View File

@@ -287,7 +287,13 @@ export default {
}) })
arr.push(th1,th2); arr.push(th1,th2);
this.data.forEach((d) => { 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); arr.push(td);
}); });
let sheet = XLSX.utils.aoa_to_sheet(arr); let sheet = XLSX.utils.aoa_to_sheet(arr);
@@ -300,4 +306,4 @@ export default {
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
</style> </style>

View File

@@ -276,11 +276,6 @@ export default {
dataIndex: "remark", dataIndex: "remark",
sorter: true, sorter: true,
}, },
{
title: "创建人",
dataIndex: "username",
sorter: true,
},
]; ];
const arr = []; const arr = [];
const th = columns.map((item) => item.title); const th = columns.map((item) => item.title);
@@ -292,7 +287,8 @@ export default {
arr.push(td); arr.push(td);
}); });
let sheet = XLSX.utils.aoa_to_sheet(arr); 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> </script>
<style scoped lang="less"> <style scoped lang="less">
</style> </style>

View File

@@ -275,7 +275,7 @@ export default {
}); });
let sheet = XLSX.utils.aoa_to_sheet(arr); let sheet = XLSX.utils.aoa_to_sheet(arr);
sheet['!merges'] = merges; 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> </script>
<style scoped lang="less"> <style scoped lang="less">
</style> </style>

View File

@@ -7,7 +7,12 @@
<!-- 搜索表单 --> <!-- 搜索表单 -->
<a-form layout="inline" :model="where" :labelCol="{ offset: 1}"> <a-form layout="inline" :model="where" :labelCol="{ offset: 1}">
<a-form-item label="起始日期:">
<a-date-picker valueFormat="YYYY-MM-DD 00:00:00" v-model:value="where.reportTimeStart"></a-date-picker>
</a-form-item>
<a-form-item label="结束日期:">
<a-date-picker valueFormat="YYYY-MM-DD 23:59:59" v-model:value="where.reportTimeEnd"></a-date-picker>
</a-form-item>
<a-form-item label="区域等级:"> <a-form-item label="区域等级:">
<a-select v-model:value="where.regionLevel" allowClear placeholder="未选择"> <a-select v-model:value="where.regionLevel" allowClear placeholder="未选择">
<a-select-option :value="'市级'">市级</a-select-option> <a-select-option :value="'市级'">市级</a-select-option>
@@ -25,9 +30,7 @@
<a-input v-model:value.trim="where.billName" placeholder="请输入" allow-clear /> <a-input v-model:value.trim="where.billName" placeholder="请输入" allow-clear />
</a-form-item> </a-form-item>
<a-form-item label="上报时间:">
<a-range-picker separator="~" v-model:value="reportTimeScope" />
</a-form-item>
<a-form-item class="ele-text-right" :wrapper-col="{span: 24}"> <a-form-item class="ele-text-right" :wrapper-col="{span: 24}">
<a-space> <a-space>
@@ -228,12 +231,6 @@
/* 刷新表格 */ /* 刷新表格 */
reload() { reload() {
this.where.reportTimeStart = null;
this.where.reportTimeEnd = null;
if (this.reportTimeScope && this.reportTimeScope.length == 2) {
this.where.reportTimeStart = this.reportTimeScope[0].format("Y-M-D H:m:s")
this.where.reportTimeEnd = this.reportTimeScope[1].format("Y-M-D H:m:s")
}
this.$refs.table.reload({ this.$refs.table.reload({
where: this.where where: this.where
}); });
@@ -342,7 +339,7 @@
this.$message.error(e.msg); this.$message.error(e.msg);
}).finally(() => hide()); }).finally(() => hide());
}, },
} }
} }
</script> </script>
@@ -390,4 +387,4 @@
.editable-cell:hover .editable-cell-icon { .editable-cell:hover .editable-cell-icon {
display: inline-block; display: inline-block;
} }
</style> </style>

View File

@@ -7,6 +7,12 @@
<!-- 搜索表单 --> <!-- 搜索表单 -->
<a-form layout="inline" :model="where" :labelCol="{ offset: 1}"> <a-form layout="inline" :model="where" :labelCol="{ offset: 1}">
<a-form-item label="起始日期:">
<a-date-picker valueFormat="YYYY-MM-DD 00:00:00" v-model:value="where.reportTimeStart"></a-date-picker>
</a-form-item>
<a-form-item label="结束日期:">
<a-date-picker valueFormat="YYYY-MM-DD 23:59:59" v-model:value="where.reportTimeEnd"></a-date-picker>
</a-form-item>
<a-form-item label="区域等级:"> <a-form-item label="区域等级:">
<a-select v-model:value="where.regionLevel" allowClear placeholder="未选择"> <a-select v-model:value="where.regionLevel" allowClear placeholder="未选择">
<a-select-option :value="'市级'">市级</a-select-option> <a-select-option :value="'市级'">市级</a-select-option>
@@ -24,9 +30,6 @@
<a-input v-model:value.trim="where.billName" placeholder="请输入" allow-clear /> <a-input v-model:value.trim="where.billName" placeholder="请输入" allow-clear />
</a-form-item> </a-form-item>
<a-form-item label="上报时间:">
<a-range-picker separator="~" v-model:value="reportTimeScope" />
</a-form-item>
<a-form-item class="ele-text-right" :wrapper-col="{span: 24}"> <a-form-item class="ele-text-right" :wrapper-col="{span: 24}">
<a-space> <a-space>
@@ -227,12 +230,7 @@
/* 刷新表格 */ /* 刷新表格 */
reload() { reload() {
this.where.reportTimeStart = null;
this.where.reportTimeEnd = null;
if (this.reportTimeScope && this.reportTimeScope.length == 2) {
this.where.reportTimeStart = this.reportTimeScope[0].format("Y-M-D H:m:s")
this.where.reportTimeEnd = this.reportTimeScope[1].format("Y-M-D H:m:s")
}
this.$refs.table.reload({ this.$refs.table.reload({
where: this.where where: this.where
}); });
@@ -341,7 +339,7 @@
this.$message.error(e.msg); this.$message.error(e.msg);
}).finally(() => hide()); }).finally(() => hide());
}, },
} }
} }
</script> </script>
@@ -389,4 +387,4 @@
.editable-cell:hover .editable-cell-icon { .editable-cell:hover .editable-cell-icon {
display: inline-block; display: inline-block;
} }
</style> </style>

View File

@@ -12,38 +12,33 @@
> >
<template #toolbar> <template #toolbar>
<!-- 搜索表单 --> <!-- 搜索表单 -->
<a-form :model="where" layout="inline" :labelCol="{ offset: 1 }"> <a-form :model="where" layout="inline" >
<a-row> <a-form-item label="起始日期:">
<a-col :lg="6" :md="12" :sm="24" :xs="24"> <a-date-picker valueFormat="YYYY-MM-DD 00:00:00" v-model:value="where.timeStart"></a-date-picker>
<a-form-item label="昼夜:"> </a-form-item>
<a-select <a-form-item label="结束日期:">
:options="timeSlotOptions" <a-date-picker valueFormat="YYYY-MM-DD 23:59:59" v-model:value="where.timeEnd"></a-date-picker>
v-model:value="where.timeSlot" </a-form-item>
placeholder="昼夜" <a-form-item label="昼夜:">
> <a-select
</a-select> :options="timeSlotOptions"
</a-form-item> v-model:value="where.timeSlot"
</a-col> placeholder="昼夜"
<a-col :lg="8" :md="12" :sm="24" :xs="24"> >
<a-form-item label="时间范围:"> </a-select>
<!-- <a-month-picker v-model:value="timeScope" placeholder="起始" /> --> </a-form-item>
<a-range-picker v-model:value="timeScope" format="YYYY-MM-DD" />
</a-form-item>
</a-col>
<a-col :lg="4" :md="12" :sm="24" :xs="24">
<a-form-item class="ele-text-right" :wrapper-col="{ span: 24 }"> <a-form-item class="ele-text-right" :wrapper-col="{ span: 24 }">
<a-space> <a-space>
<a-button type="primary" @click="reload">查询</a-button> <a-button type="primary" @click="reload">查询</a-button>
<a-button @click="reset">重置</a-button> <a-button @click="reset">重置</a-button>
<a-button @click="exportFile">导出excel</a-button> <a-button @click="exportFile">导出excel</a-button>
</a-space> </a-space>
</a-form-item> </a-form-item>
</a-col>
</a-row>
</a-form> </a-form>
<!-- <a-space> <!-- <a-space>
</a-space> --> </a-space> -->
</template> </template>
<template #Leq="{ text, record }"> <template #Leq="{ text, record }">
@@ -53,7 +48,8 @@
(where.timeSlot == '夜' && text <= 58) (where.timeSlot == '夜' && text <= 58)
" "
color="green" color="green"
>{{ text }}</a-tag >{{ text }}
</a-tag
> >
<a-tag <a-tag
v-else-if=" v-else-if="
@@ -61,7 +57,8 @@
(record.timeSlot == '夜' && text > 58 && text <= 60) (record.timeSlot == '夜' && text > 58 && text <= 60)
" "
color="blue" color="blue"
>{{ text }}</a-tag >{{ text }}
</a-tag
> >
<a-tag <a-tag
v-else-if=" v-else-if="
@@ -69,7 +66,8 @@
(record.timeSlot == '夜' && text > 60 && text <= 62) (record.timeSlot == '夜' && text > 60 && text <= 62)
" "
color="red" color="red"
>{{ text }}</a-tag >{{ text }}
</a-tag
> >
<a-tag <a-tag
v-else-if=" v-else-if="
@@ -77,7 +75,8 @@
(record.timeSlot == '夜' && text > 62 && text <= 64) (record.timeSlot == '夜' && text > 62 && text <= 64)
" "
color="red" color="red"
>{{ text }}</a-tag >{{ text }}
</a-tag
> >
<a-tag <a-tag
v-else-if=" v-else-if="
@@ -85,7 +84,8 @@
(record.timeSlot == '夜' && text > 64) (record.timeSlot == '夜' && text > 64)
" "
color="red" color="red"
>{{ text }}</a-tag >{{ text }}
</a-tag
> >
<template v-else color="#FFF">{{ text }}</template> <template v-else color="#FFF">{{ text }}</template>
</template> </template>
@@ -96,7 +96,8 @@
<script> <script>
import _ from "lodash"; import _ from "lodash";
import XLSX from "xlsx"; import XLSX from "xlsx";
import { pageRoadNoiseStatisticUrl } from "@/api/ecology/noise/road-sound"; import {pageRoadNoiseStatisticUrl} from "@/api/ecology/noise/road-sound";
const columns = [ const columns = [
{ {
title: "城区", title: "城区",
@@ -118,25 +119,25 @@ const columns = [
{ {
title: "LeqdB(A)", title: "LeqdB(A)",
dataIndex: "avgLeq", dataIndex: "avgLeq",
slots: { customRender: "Leq" }, slots: {customRender: "Leq"},
sorter: true, sorter: true,
}, },
{ // {
title: "SDdB(A)", // title: "SDdB(A)",
dataIndex: "avgSD", // dataIndex: "avgSD",
}, // },
{ // {
title: "L10dB(A)", // title: "L10dB(A)",
dataIndex: "avgL10", // dataIndex: "avgL10",
}, // },
{ // {
title: "L50dB(A)", // title: "L50dB(A)",
dataIndex: "avgL50", // dataIndex: "avgL50",
}, // },
{ // {
title: "L90dB(A)", // title: "L90dB(A)",
dataIndex: "avgL90", // dataIndex: "avgL90",
}, // },
]; ];
export default { export default {
name: "StatisticSoundRoadAverage", name: "StatisticSoundRoadAverage",
@@ -185,18 +186,7 @@ export default {
/* 刷新表格 */ /* 刷新表格 */
reload() { reload() {
this.$refs.table.reload({ this.$refs.table.reload({
where: { where: this.where
model: this.where.model,
timeStart:
this.timeScope.length == 2
? this.timeScope[0].format("Y-M-D")
: null,
timeEnd:
this.timeScope.length == 2
? this.timeScope[1].format("Y-M-D")
: null,
timeSlot: this.where.timeSlot,
},
}); });
let cloneColumns = _.cloneDeep(columns); let cloneColumns = _.cloneDeep(columns);
if (this.where.model == "area") { if (this.where.model == "area") {
@@ -255,4 +245,4 @@ export default {
</script> </script>
<style scoped> <style scoped>
</style> </style>

View File

@@ -121,6 +121,7 @@
import XLSX from "xlsx"; import XLSX from "xlsx";
import { pageRoadNoiseUrl, getColumnOptions,listAll } from "@/api/ecology/noise/road-sound"; import { pageRoadNoiseUrl, getColumnOptions,listAll } from "@/api/ecology/noise/road-sound";
import locale from "ant-design-vue/es/date-picker/locale/zh_CN"; import locale from "ant-design-vue/es/date-picker/locale/zh_CN";
import moment from "moment";
// import moment from "moment"; // import moment from "moment";
// import utils from "./utils"; // import utils from "./utils";
export default { export default {
@@ -141,6 +142,7 @@ export default {
title: "监测日期", title: "监测日期",
dataIndex: "monitorTime", dataIndex: "monitorTime",
sorter: true, sorter: true,
customRender:({text})=>moment(text).format("YYYY-MM-DD HH:mm")
}, },
{ {
title: "测点名称", title: "测点名称",
@@ -212,7 +214,7 @@ export default {
dataIndex: "indexLeq", dataIndex: "indexLeq",
slots: {customRender: "Leq"}, slots: {customRender: "Leq"},
sorter: true, sorter: true,
}, },
{ {
title: "SDdB(A)", title: "SDdB(A)",
@@ -505,8 +507,8 @@ export default {
dataIndex: "monitorMinute", dataIndex: "monitorMinute",
sorter: true, sorter: true,
}, },
{ {
title: "中小型车20min车流量", title: "中小型车20min车流量",
dataIndex: "smallTrafficFlow", dataIndex: "smallTrafficFlow",
@@ -522,7 +524,7 @@ export default {
dataIndex: "indexLeq", dataIndex: "indexLeq",
sorter: true, sorter: true,
}, },
{ {
title: "L10", title: "L10",
dataIndex: "indexL10", dataIndex: "indexL10",
@@ -625,4 +627,4 @@ export default {
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
</style> </style>

View File

@@ -1,267 +1,248 @@
<template> <template>
<div class=""> <div class="">
<a-form labelAlign="left" <a-form labelAlign="left"
layout="vertical" :model="where" :rules="whereRules" layout="inline" :model="where" :rules="whereRules"
:label-col="{ md: { span: 6 }, sm: { span: 24 } }"
:wrapper-col="{ md: { span: 18, }, sm: { span: 24 } }" >
<a-form-item label="起始日期:">
<a-input-number id="inputNumber" v-model:value="where.startYear" :min="1970" :max="2050" />
</a-form-item>
<a-form-item label="结束日期:">
<a-input-number id="inputNumber" v-model:value="where.endYear" :min="1970" :max="2050" />
</a-form-item>
<a-form-item label="昼夜:">
<a-select
:options="timeSlotOptions"
v-model:value="where.timeSlot"
placeholder="昼夜"
> >
<a-row> </a-select>
<a-col :lg="6" :md="12" :sm="24" :xs="24"> </a-form-item>
<a-form-item name="timeRange" label="时间范围:">
<a-range-picker
@panelChange="timeRangePanelChange"
v-model:value="timeRange"
format="YYYY"
:mode="['year', 'year']"
/>
</a-form-item>
</a-col>
<a-col :lg="6" :md="12" :sm="24" :xs="24">
<a-form-item label="昼夜:">
<a-select
:options="timeSlotOptions"
v-model:value="where.timeSlot"
placeholder="昼夜"
>
</a-select>
</a-form-item>
</a-col>
<a-col :lg="24" :md="24" :sm="24" :xs="24"> <a-form-item class="ele-text-left" :wrapper-col="{ span: 24 }">
<a-form-item class="ele-text-left" :wrapper-col="{ span: 24 }"> <a-space>
<a-space> <a-button type="primary" @click="reload">查询</a-button>
<a-button type="primary" @click="reload">查询</a-button> <a-button @click="reset">重置</a-button>
<a-button @click="reset">重置</a-button> <a-button @click="exportFile">导出Excel</a-button>
<a-button @click="exportFile">导出Excel</a-button> </a-space>
</a-space> </a-form-item>
</a-form-item> </a-form>
</a-col> <ele-pro-table
</a-row> v-if="hisYears.length > 0"
</a-form> ref="table"
<ele-pro-table row-key="id"
v-if="hisYears.length > 0" :datasource="url"
ref="table" :columns="columns"
row-key="id" :where="where"
:datasource="url" :needPage="false"
:columns="columns" :initLoad="false"
:where="where" :scroll="{ x: 'max-content' }"
:needPage="false" :method="'POST'"
:initLoad="false" @done="(d) => (data = d.data)"
:scroll="{ x: 'max-content' }" >
:method="'POST'" <template #toolbar>
@done="(d) => (data = d.data)" <!-- 搜索表单 -->
>
<template #toolbar>
<!-- 搜索表单 -->
<!-- <a-space> <!-- <a-space>
</a-space> --> </a-space> -->
</template> </template>
</ele-pro-table> </ele-pro-table>
</div> </div>
</template> </template>
<script> <script>
// import _ from "lodash"; // import _ from "lodash";
import XLSX from "xlsx"; import XLSX from "xlsx";
import { import {
pageRoadNoiseCompare, pageRoadNoiseCompare,
getHistoryyears, getHistoryyears,
} from "@/api/ecology/noise/road-sound"; } from "@/api/ecology/noise/road-sound";
export default { export default {
name: "StatisticSoundRoadCompare", name: "StatisticSoundRoadCompare",
components: {}, components: {},
data() { data() {
const groupTimeLengthOptions = [ const groupTimeLengthOptions = [
{ {
label: "年", label: "年",
value: "monitor_year", value: "monitor_year",
}, },
{ {
label: "季度", label: "季度",
value: "quarter", value: "quarter",
}, },
]; ];
const whereRules = {}; const whereRules = {};
return { return {
url: pageRoadNoiseCompare, url: pageRoadNoiseCompare,
data: [], data: [],
where: { where: {
groupModel: "area", groupModel: "area",
groupTimeLength: "monitor_year", groupTimeLength: "monitor_year",
reportTimeScope: [], reportTimeScope: [],
valueType: ["index_Leq"], valueType: ["index_Leq"],
timeSlot: "昼", timeSlot: "昼",
timeRange: [], timeRange: [],
regionLevel: "市级" regionLevel: "市级"
}, },
timeRange: [], timeRange: [],
whereRules, whereRules,
hisYears: [], hisYears: [],
timeScope: [], timeScope: [],
columns: [{title: "年", dataIndex: "year"}], columns: [{title: "年", dataIndex: "year"}],
groupTimeLengthOptions, groupTimeLengthOptions,
timeSlotOptions: [ timeSlotOptions: [
{ {
value: "昼", value: "昼",
label: "昼", label: "昼",
}, },
{ {
value: "夜", value: "夜",
label: "夜", label: "夜",
}, },
], ],
}; };
},
mounted() {
getHistoryyears().then((res) => {
this.hisYears = res.data.data;
this.$nextTick(() => {
this.reload();
});
});
},
methods: {
/* 刷新表格 */
reload() {
if (this.where.valueType.length == 0) {
this.$message.error("请至少选择一个类型");
return;
}
this.stableDone();
this.$refs.table.reload({
where: this.where,
});
}, },
mounted() { /* 重置搜索 */
getHistoryyears().then((res) => { reset() {
this.hisYears = res.data.data; this.where = {
this.$nextTick(() => { groupModel: "area",
this.reload(); groupTimeLength: "monitor_year",
}); reportTimeScope: [],
valueType: ["index_Leq"],
timeRange: [],
timeSlot: "昼",
regionLevel: "市级"
};
this.this.timeScope = [];
this.reload();
},
reportTimeScopeChange(d, dstr) {
console.log(d, dstr);
},
timeRangePanelChange(val) {
val[0] && (this.where.timeRange[0] = val[0].year());
val[1] && (this.where.timeRange[1] = val[1].year());
this.timeRange = val;
},
// 数据加载完成
stableDone() {
const columns = [];
if (this.where.groupModel == "area") {
columns.push({
title: "城区",
dataIndex: "area",
sorter: true,
}); });
} else if (this.where.groupModel == "place") {
columns.push({
title: "测点",
dataIndex: "area",
sorter: true,
});
} else if (this.where.groupModel == "city") {
columns.push({
title: "城市",
dataIndex: "area",
sorter: true,
});
}
this.hisYears.forEach((item) => {
if (
(!this.where.startYear || this.where.startYear <= item) &&
(!this.where.endYear || !this.where.endYear >= item)
) {
if (this.where.valueType.includes("index_Leq")) {
columns.push({
title: item + "年",
align: "center",
children: [
{
title: "Leq",
dataIndex: item + "Leq",
align: "center",
customRender: ({text}) => {
const val = text ? Number(text).toFixed(1) : "";
return val;
},
},
{
title: "等级",
align: "center",
dataIndex: item + "LeqLevel",
}
]
});
}
}
});
//
this.columns = columns;
}, },
methods: { exportFile() {
/* 刷新表格 */ const arr = [];
reload() { const th1 = [];
if (this.where.valueType.length == 0) { const th2 = [];
this.$message.error("请至少选择一个类型"); const merges = []; // 合并
return; const columnsTemp = []; // 树形结构整理成list
} this.columns.forEach((item, index) => {
if (item.children) {
// 结束时间必须大于开始时间 item.children.forEach(citem => {
if (this.where.timeRange && this.where.timeRange.length == 2) { th1.push(item.title)
if (this.where.timeRange[0] > this.where.timeRange[1]) { th2.push(citem.title)
this.$message.error("结束时间必须大于起始时间"); columnsTemp.push(citem)
return; })
} merges.push({s: {r: 0, c: th1.length - 2}, e: {r: 0, c: th1.length - 1}})
this.where.startYear = this.where.timeRange[0]; } else {
this.where.endYear = this.where.timeRange[1]; th1.push(item.title)
} th2.push("")
this.stableDone(); columnsTemp.push(item)
this.$refs.table.reload({ merges.push({s: {r: 0, c: index}, e: {r: 1, c: index}})
where: this.where, }
}); })
}, arr.push(th1, th2);
/* 重置搜索 */ this.data.forEach((d) => {
reset() { const td = columnsTemp.map((item) => {
this.where = { if (typeof d[item.dataIndex] == "number") {
groupModel: "area", return d[item.dataIndex].toFixed(1);
groupTimeLength: "monitor_year", }
reportTimeScope: [], return d[item.dataIndex];
valueType: ["index_Leq"], });
timeRange: [], arr.push(td);
timeSlot: "昼", });
regionLevel: "市级" let sheet = XLSX.utils.aoa_to_sheet(arr);
}; sheet['!merges'] = merges;
this.this.timeScope = []; this.$util.exportSheet(XLSX, sheet, new Date().getTime().toString());
this.reload();
},
reportTimeScopeChange(d, dstr) {
console.log(d, dstr);
},
timeRangePanelChange(val) {
val[0] && (this.where.timeRange[0] = val[0].year());
val[1] && (this.where.timeRange[1] = val[1].year());
this.timeRange = val;
},
// 数据加载完成
stableDone() {
const columns = [];
if (this.where.groupModel == "area") {
columns.push({
title: "城区",
dataIndex: "area",
sorter: true,
});
} else if (this.where.groupModel == "place") {
columns.push({
title: "测点",
dataIndex: "area",
sorter: true,
});
} else if (this.where.groupModel == "city") {
columns.push({
title: "城市",
dataIndex: "area",
sorter: true,
});
}
this.hisYears.forEach((item) => {
if (
(!this.where.timeRange[0] || this.where.timeRange[0] <= item) &&
(!this.where.timeRange[1] || this.where.timeRange[1] >= item)
) {
if (this.where.valueType.includes("index_Leq")) {
columns.push({
title: item + "年",
align:"center",
children: [
{
title:"Leq",
dataIndex: item + "Leq",
align:"center",
customRender: ({text}) => {
const val = text ? Number(text).toFixed(1) : "";
return val;
},
},
{
title:"等级",
align:"center",
dataIndex: item + "LeqLevel",
}
]
});
}
}
});
//
this.columns = columns;
},
exportFile() {
const arr = [];
const th1 = [];
const th2 = [];
const merges = []; // 合并
const columnsTemp = []; // 树形结构整理成list
this.columns.forEach((item,index)=>{
if(item.children){
item.children.forEach(citem=>{
th1.push(item.title)
th2.push(citem.title)
columnsTemp.push(citem)
})
merges.push({s: {r: 0, c: th1.length-2}, e: {r: 0, c: th1.length-1}})
}else{
th1.push(item.title)
th2.push("")
columnsTemp.push(item)
merges.push({s: {r: 0, c: index}, e: {r: 1, c: index}})
}
})
arr.push(th1,th2);
this.data.forEach((d) => {
const td = columnsTemp.map((item) => {
if (typeof d[item.dataIndex] == "number") {
return d[item.dataIndex].toFixed(1);
}
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());
},
}, },
},
}; };
</script> </script>
<style scoped> <style scoped>
</style> </style>

View File

@@ -7,6 +7,12 @@
<!-- 搜索表单 --> <!-- 搜索表单 -->
<a-form layout="inline" :model="where" :labelCol="{ offset: 1}"> <a-form layout="inline" :model="where" :labelCol="{ offset: 1}">
<a-form-item label="起始日期:">
<a-date-picker valueFormat="YYYY-MM-DD 00:00:00" v-model:value="where.reportTimeStart"></a-date-picker>
</a-form-item>
<a-form-item label="结束日期:">
<a-date-picker valueFormat="YYYY-MM-DD 23:59:59" v-model:value="where.reportTimeEnd"></a-date-picker>
</a-form-item>
<a-form-item label="区域等级:"> <a-form-item label="区域等级:">
<a-select v-model:value="where.regionLevel" allowClear placeholder="未选择"> <a-select v-model:value="where.regionLevel" allowClear placeholder="未选择">
<a-select-option :value="'市级'">市级</a-select-option> <a-select-option :value="'市级'">市级</a-select-option>
@@ -24,9 +30,6 @@
<a-input v-model:value.trim="where.billName" placeholder="请输入" allow-clear /> <a-input v-model:value.trim="where.billName" placeholder="请输入" allow-clear />
</a-form-item> </a-form-item>
<a-form-item label="上报时间:">
<a-range-picker separator="~" v-model:value="reportTimeScope" />
</a-form-item>
<a-form-item class="ele-text-right" :wrapper-col="{span: 24}"> <a-form-item class="ele-text-right" :wrapper-col="{span: 24}">
<a-space> <a-space>
@@ -223,16 +226,8 @@
}; };
}, },
methods: { methods: {
/* 刷新表格 */ /* 刷新表格 */
reload() { reload() {
this.where.reportTimeStart = null;
this.where.reportTimeEnd = null;
if (this.reportTimeScope && this.reportTimeScope.length == 2) {
this.where.reportTimeStart = this.reportTimeScope[0].format("Y-M-D H:m:s")
this.where.reportTimeEnd = this.reportTimeScope[1].format("Y-M-D H:m:s")
}
this.$refs.table.reload({ this.$refs.table.reload({
where: this.where where: this.where
}); });
@@ -341,7 +336,7 @@
this.$message.error(e.msg); this.$message.error(e.msg);
}).finally(() => hide()); }).finally(() => hide());
}, },
} }
} }
</script> </script>
@@ -389,4 +384,4 @@
.editable-cell:hover .editable-cell-icon { .editable-cell:hover .editable-cell-icon {
display: inline-block; display: inline-block;
} }
</style> </style>