到处格式,拆分时间

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());
},
},

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日") + "城区浓度统计");
},
},

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);

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日") + "基础数据");
}
})

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日")+ "统计数据");
},
},

View File

@@ -7,7 +7,12 @@
<!-- 搜索表单 -->
<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-select v-model:value="where.regionLevel" allowClear placeholder="未选择">
<a-select-option :value="'市级'">市级</a-select-option>
@@ -25,9 +30,7 @@
<a-input v-model:value.trim="where.billName" placeholder="请输入" allow-clear />
</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-space>
@@ -228,12 +231,6 @@
/* 刷新表格 */
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({
where: this.where
});

View File

@@ -7,6 +7,12 @@
<!-- 搜索表单 -->
<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-select v-model:value="where.regionLevel" allowClear placeholder="未选择">
<a-select-option :value="'市级'">市级</a-select-option>
@@ -24,9 +30,6 @@
<a-input v-model:value.trim="where.billName" placeholder="请输入" allow-clear />
</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-space>
@@ -227,12 +230,7 @@
/* 刷新表格 */
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({
where: this.where
});

View File

@@ -12,9 +12,13 @@
>
<template #toolbar>
<!-- 搜索表单 -->
<a-form :model="where" layout="inline" :labelCol="{ offset: 1 }">
<a-row>
<a-col :lg="6" :md="12" :sm="24" :xs="24">
<a-form :model="where" layout="inline" >
<a-form-item label="起始日期:">
<a-date-picker valueFormat="YYYY-MM-DD 00:00:00" v-model:value="where.timeStart"></a-date-picker>
</a-form-item>
<a-form-item label="结束日期:">
<a-date-picker valueFormat="YYYY-MM-DD 23:59:59" v-model:value="where.timeEnd"></a-date-picker>
</a-form-item>
<a-form-item label="昼夜:">
<a-select
:options="timeSlotOptions"
@@ -23,15 +27,8 @@
>
</a-select>
</a-form-item>
</a-col>
<a-col :lg="8" :md="12" :sm="24" :xs="24">
<a-form-item label="时间范围:">
<!-- <a-month-picker v-model:value="timeScope" placeholder="起始" /> -->
<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-space>
<a-button type="primary" @click="reload">查询</a-button>
@@ -39,8 +36,6 @@
<a-button @click="exportFile">导出excel</a-button>
</a-space>
</a-form-item>
</a-col>
</a-row>
</a-form>
<!-- <a-space>
@@ -53,7 +48,8 @@
(where.timeSlot == '夜' && text <= 58)
"
color="green"
>{{ text }}</a-tag
>{{ text }}
</a-tag
>
<a-tag
v-else-if="
@@ -61,7 +57,8 @@
(record.timeSlot == '夜' && text > 58 && text <= 60)
"
color="blue"
>{{ text }}</a-tag
>{{ text }}
</a-tag
>
<a-tag
v-else-if="
@@ -69,7 +66,8 @@
(record.timeSlot == '夜' && text > 60 && text <= 62)
"
color="red"
>{{ text }}</a-tag
>{{ text }}
</a-tag
>
<a-tag
v-else-if="
@@ -77,7 +75,8 @@
(record.timeSlot == '夜' && text > 62 && text <= 64)
"
color="red"
>{{ text }}</a-tag
>{{ text }}
</a-tag
>
<a-tag
v-else-if="
@@ -85,7 +84,8 @@
(record.timeSlot == '夜' && text > 64)
"
color="red"
>{{ text }}</a-tag
>{{ text }}
</a-tag
>
<template v-else color="#FFF">{{ text }}</template>
</template>
@@ -97,6 +97,7 @@
import _ from "lodash";
import XLSX from "xlsx";
import {pageRoadNoiseStatisticUrl} from "@/api/ecology/noise/road-sound";
const columns = [
{
title: "城区",
@@ -121,22 +122,22 @@ const columns = [
slots: {customRender: "Leq"},
sorter: true,
},
{
title: "SDdB(A)",
dataIndex: "avgSD",
},
{
title: "L10dB(A)",
dataIndex: "avgL10",
},
{
title: "L50dB(A)",
dataIndex: "avgL50",
},
{
title: "L90dB(A)",
dataIndex: "avgL90",
},
// {
// title: "SDdB(A)",
// dataIndex: "avgSD",
// },
// {
// title: "L10dB(A)",
// dataIndex: "avgL10",
// },
// {
// title: "L50dB(A)",
// dataIndex: "avgL50",
// },
// {
// title: "L90dB(A)",
// dataIndex: "avgL90",
// },
];
export default {
name: "StatisticSoundRoadAverage",
@@ -185,18 +186,7 @@ export default {
/* 刷新表格 */
reload() {
this.$refs.table.reload({
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,
},
where: this.where
});
let cloneColumns = _.cloneDeep(columns);
if (this.where.model == "area") {

View File

@@ -121,6 +121,7 @@
import XLSX from "xlsx";
import { pageRoadNoiseUrl, getColumnOptions,listAll } from "@/api/ecology/noise/road-sound";
import locale from "ant-design-vue/es/date-picker/locale/zh_CN";
import moment from "moment";
// import moment from "moment";
// import utils from "./utils";
export default {
@@ -141,6 +142,7 @@ export default {
title: "监测日期",
dataIndex: "monitorTime",
sorter: true,
customRender:({text})=>moment(text).format("YYYY-MM-DD HH:mm")
},
{
title: "测点名称",

View File

@@ -1,22 +1,16 @@
<template>
<div class="">
<a-form labelAlign="left"
layout="vertical" :model="where" :rules="whereRules"
:label-col="{ md: { span: 6 }, sm: { span: 24 } }"
:wrapper-col="{ md: { span: 18, }, sm: { span: 24 } }"
layout="inline" :model="where" :rules="whereRules"
>
<a-row>
<a-col :lg="6" :md="12" :sm="24" :xs="24">
<a-form-item name="timeRange" label="时间范围:">
<a-range-picker
@panelChange="timeRangePanelChange"
v-model:value="timeRange"
format="YYYY"
:mode="['year', 'year']"
/>
<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-col>
<a-col :lg="6" :md="12" :sm="24" :xs="24">
<a-form-item label="昼夜:">
<a-select
:options="timeSlotOptions"
@@ -25,9 +19,7 @@
>
</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-space>
<a-button type="primary" @click="reload">查询</a-button>
@@ -35,8 +27,6 @@
<a-button @click="exportFile">导出Excel</a-button>
</a-space>
</a-form-item>
</a-col>
</a-row>
</a-form>
<ele-pro-table
v-if="hisYears.length > 0"
@@ -132,15 +122,6 @@ export default {
return;
}
// 结束时间必须大于开始时间
if (this.where.timeRange && this.where.timeRange.length == 2) {
if (this.where.timeRange[0] > this.where.timeRange[1]) {
this.$message.error("结束时间必须大于起始时间");
return;
}
this.where.startYear = this.where.timeRange[0];
this.where.endYear = this.where.timeRange[1];
}
this.stableDone();
this.$refs.table.reload({
where: this.where,
@@ -193,8 +174,8 @@ export default {
this.hisYears.forEach((item) => {
if (
(!this.where.timeRange[0] || this.where.timeRange[0] <= item) &&
(!this.where.timeRange[1] || this.where.timeRange[1] >= item)
(!this.where.startYear || this.where.startYear <= item) &&
(!this.where.endYear || !this.where.endYear >= item)
) {
if (this.where.valueType.includes("index_Leq")) {
columns.push({

View File

@@ -7,6 +7,12 @@
<!-- 搜索表单 -->
<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-select v-model:value="where.regionLevel" allowClear placeholder="未选择">
<a-select-option :value="'市级'">市级</a-select-option>
@@ -24,9 +30,6 @@
<a-input v-model:value.trim="where.billName" placeholder="请输入" allow-clear />
</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-space>
@@ -223,16 +226,8 @@
};
},
methods: {
/* 刷新表格 */
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({
where: this.where
});