This commit is contained in:
weicw
2021-08-19 17:14:58 +08:00
parent e2cc8520f7
commit a70ffbecae
3 changed files with 297 additions and 185 deletions

View File

@@ -46,6 +46,7 @@
methods: { methods: {
/* 导入本地excel文件 */ /* 导入本地excel文件 */
importFile(file) { importFile(file) {
const hide = this.$message.loading('导入中..', 0);
try { try {
let reader = new FileReader(); let reader = new FileReader();
reader.onload = (e) => { reader.onload = (e) => {
@@ -105,8 +106,10 @@
// 上传到服务器 // 上传到服务器
Promise.all(tasks).then(() => { Promise.all(tasks).then(() => {
this.$refs.noise.reload() this.$refs.noise&&this.$refs.noise.reload()
this.$refs.place.reload() this.$refs.place&&this.$refs.place.reload()
}).finally(()=>{
hide();
}) })
// console.log(billData); // console.log(billData);

View File

@@ -1,21 +1,6 @@
<template> <template>
<div class=""> <div class="">
<ele-pro-table <a-form :model="where" :rules="whereRules" :labelCol="{ offset: 1 }">
v-if="hisYears.length > 0"
ref="table"
row-key="id"
:datasource="url"
:columns="columns"
:where="where"
:needPage="false"
:initLoad="false"
:scroll="{ x: 'max-content' }"
:method="'POST'"
@done="d=>data = d.data"
>
<template #toolbar>
<!-- 搜索表单 -->
<a-form :model="where" layout="inline" :labelCol="{ offset: 1 }">
<a-row> <a-row>
<a-col :lg="6" :md="12" :sm="24" :xs="24"> <a-col :lg="6" :md="12" :sm="24" :xs="24">
<a-form-item label="统计模块:"> <a-form-item label="统计模块:">
@@ -37,6 +22,16 @@
</a-select> </a-select>
</a-form-item> </a-form-item>
</a-col> </a-col>
<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>
</a-col>
<a-col :lg="6" :md="12" :sm="24" :xs="24"> <a-col :lg="6" :md="12" :sm="24" :xs="24">
<a-form-item label="昼夜:"> <a-form-item label="昼夜:">
<a-select <a-select
@@ -47,14 +42,14 @@
</a-select> </a-select>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :lg="6" :md="12" :sm="24" :xs="24">
<a-col :lg="12" :md="12" :sm="24" :xs="24">
<a-form-item label="类型:"> <a-form-item label="类型:">
<a-select <a-select
v-model:value="where.valueType" v-model:value="where.valueType"
:options="valueTypeOptions" :options="valueTypeOptions"
mode="multiple" mode="multiple"
placeholder="Please select" placeholder="至少选择一项"
style="width: 400px"
> >
</a-select> </a-select>
</a-form-item> </a-form-item>
@@ -69,17 +64,33 @@
</a-form-item> </a-form-item>
</a-col> --> </a-col> -->
<a-col :lg="4" :md="12" :sm="24" :xs="24"> <a-col :lg="12" :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-col>
</a-row> </a-row>
</a-form> </a-form>
<ele-pro-table
v-if="hisYears.length > 0"
ref="table"
row-key="id"
:datasource="url"
:columns="columns"
:where="where"
:needPage="false"
:initLoad="false"
:scroll="{ x: 'max-content' }"
:method="'POST'"
@done="(d) => (data = d.data)"
>
<template #toolbar>
<!-- 搜索表单 -->
<!-- <a-space> <!-- <a-space>
</a-space> --> </a-space> -->
@@ -101,9 +112,9 @@ export default {
components: {}, components: {},
data() { data() {
const groupModelOptions = [ const groupModelOptions = [
{label: "测点",value: "place"}, { label: "测点", value: "place" },
{label: "城区",value: "area"}, { label: "城区", value: "area" },
{label: "市",value: "city"}, { label: "市", value: "city" },
]; ];
const groupTimeLengthOptions = [ const groupTimeLengthOptions = [
{ {
@@ -124,7 +135,7 @@ export default {
}, },
{ {
label: "SD", label: "SD",
value: "index_Sd", value: "index_SD",
}, },
{ {
label: "L10", label: "L10",
@@ -147,19 +158,23 @@ export default {
value: "index_Lmax", value: "index_Lmax",
}, },
]; ];
const whereRules = {};
return { return {
url: pageRoadNoiseCompare, url: pageRoadNoiseCompare,
data: [], data: [],
where: { where: {
groupModel: "area", groupModel: "area",
groupTimeLength: "monitor_year", groupTimeLength: "monitor_year",
timeSlot: "昼",
reportTimeScope: [], reportTimeScope: [],
valueType: ["index_Leq"], valueType: ["index_Leq"],
timeRange:[]
}, },
timeRange: [],
whereRules,
hisYears: [], hisYears: [],
timeScope: [], timeScope: [],
columns: [{title:'年',dataIndex: 'year'}], columns: [{ title: "年", dataIndex: "year" }],
groupModelOptions, groupModelOptions,
groupTimeLengthOptions, groupTimeLengthOptions,
valueTypeOptions: ref(valueTypeOptions), valueTypeOptions: ref(valueTypeOptions),
@@ -178,15 +193,27 @@ export default {
mounted() { mounted() {
getHistoryyears().then((res) => { getHistoryyears().then((res) => {
this.hisYears = res.data.data; this.hisYears = res.data.data;
this.$nextTick(()=>{ this.$nextTick(() => {
this.reload() this.reload();
}) });
}); });
}, },
methods: { methods: {
/* 刷新表格 */ /* 刷新表格 */
reload() { reload() {
this.stableDone() if (this.where.valueType.length == 0) {
this.$message.error("请至少选择一个类型");
return;
}
// 结束时间必须大于开始时间
if (this.where.timeRange && this.where.timeRange.length == 2) {
if (this.where.timeRange[0] > this.where.timeRange[1]) {
this.$message.error("结束时间必须大于起始时间");
return;
}
}
this.stableDone();
this.$refs.table.reload({ this.$refs.table.reload({
where: this.where, where: this.where,
}); });
@@ -195,15 +222,19 @@ export default {
reset() { reset() {
this.where = { this.where = {
model: "place", model: "place",
timeSlot: "昼",
}; };
this.this.timeScope = []; this.this.timeScope = [];
this.reload(); this.reload();
}, },
reportTimeScopeChange(d, dstr) { reportTimeScopeChange(d, dstr) {
console.log(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() { stableDone() {
const columns = []; const columns = [];
if (this.where.groupModel == "area") { if (this.where.groupModel == "area") {
@@ -226,37 +257,127 @@ export default {
}); });
} }
this.hisYears.forEach((item) => {
if (this.where.groupTimeLength == "quarter") { if (this.where.groupTimeLength == "quarter") {
columns.push({ columns.push({
title: "季度", title: item + "年第一季度Leq",
dataIndex: "quarter", dataIndex: item+'1'+"Leq",
sorter: true,
customRender: ({ text }) => {
switch (text) {
case 1:
return "第一季度";
case 2:
return "第二季度";
case 3:
return "第三季度";
case 4:
return "第四季度";
default:
return "";
}
},
}); });
} columns.push({
title: item + "年第二季度Leq",
this.hisYears.forEach((item) => { dataIndex: item+'2'+"Leq",
});
columns.push({
title: item + "年第三季度Leq",
dataIndex: item+'3'+"Leq",
});
columns.push({
title: item + "年第四季度Leq",
dataIndex: item+'4'+"Leq",
});
columns.push({
title: item + "年第一季度SD",
dataIndex: item+'1'+"Sd",
});
columns.push({
title: item + "年第二季度SD",
dataIndex: item+'2'+"Sd",
});
columns.push({
title: item + "年第三季度SD",
dataIndex: item+'3'+"Sd",
});
columns.push({
title: item + "年第四季度SD",
dataIndex: item+'4'+"Sd",
});
columns.push({
title: item + "年第一季度L10",
dataIndex: item+'1'+"L10",
});
columns.push({
title: item + "年第二季度L10",
dataIndex: item+'2'+"L10",
});
columns.push({
title: item + "年第三季度L10",
dataIndex: item+'3'+"L10",
});
columns.push({
title: item + "年第四季度L10",
dataIndex: item+'4'+"L10",
});
columns.push({
title: item + "年第一季度L50",
dataIndex: item+'1'+"L50",
});
columns.push({
title: item + "年第二季度L50",
dataIndex: item+'2'+"L50",
});
columns.push({
title: item + "年第三季度L50",
dataIndex: item+'3'+"L50",
});
columns.push({
title: item + "年第四季度L50",
dataIndex: item+'4'+"L50",
});
columns.push({
title: item + "年第一季度L90",
dataIndex: item+'1'+"L90",
});
columns.push({
title: item + "年第二季度L90",
dataIndex: item+'2'+"L90",
});
columns.push({
title: item + "年第三季度L90",
dataIndex: item+'3'+"L90",
});
columns.push({
title: item + "年第四季度L90",
dataIndex: item+'4'+"L90",
});
columns.push({
title: item + "年第一季度Lmin",
dataIndex: item+'1'+"Lmin",
});
columns.push({
title: item + "年第二季度Lmin",
dataIndex: item+'2'+"Lmin",
});
columns.push({
title: item + "年第三季度Lmin",
dataIndex: item+'3'+"Lmin",
});
columns.push({
title: item + "年第四季度Lmin",
dataIndex: item+'4'+"Lmin",
});
columns.push({
title: item + "年第一季度Lmax",
dataIndex: item+'1'+"Lmax",
});
columns.push({
title: item + "年第二季度Lmax",
dataIndex: item+'2'+"Lmax",
});
columns.push({
title: item + "年第三季度Lmax",
dataIndex: item+'3'+"Lmax",
});
columns.push({
title: item + "年第四季度Lmax",
dataIndex: item+'4'+"Lmax",
});
} else {
if (this.where.valueType.includes("index_Leq")) { if (this.where.valueType.includes("index_Leq")) {
columns.push({ columns.push({
title: item + "年Leq", title: item + "年Leq",
dataIndex: item + "Leq", dataIndex: item + "Leq",
customRender: ({ text }) => { customRender: ({ text }) => {
const val = text ? Number(text).toFixed(2) : ""; const val = text ? Number(text).toFixed(2) : "";
console.log(val);
return val; return val;
}, },
}); });
@@ -267,7 +388,6 @@ export default {
dataIndex: item + "Sd", dataIndex: item + "Sd",
customRender: ({ text }) => { customRender: ({ text }) => {
const val = text ? Number(text).toFixed(2) : ""; const val = text ? Number(text).toFixed(2) : "";
console.log(val);
return val; return val;
}, },
}); });
@@ -278,7 +398,6 @@ export default {
dataIndex: item + "L10", dataIndex: item + "L10",
customRender: ({ text }) => { customRender: ({ text }) => {
const val = text ? Number(text).toFixed(2) : ""; const val = text ? Number(text).toFixed(2) : "";
console.log(val);
return val; return val;
}, },
}); });
@@ -290,7 +409,6 @@ export default {
dataIndex: item + "L50", dataIndex: item + "L50",
customRender: ({ text }) => { customRender: ({ text }) => {
const val = text ? Number(text).toFixed(2) : ""; const val = text ? Number(text).toFixed(2) : "";
console.log(val);
return val; return val;
}, },
}); });
@@ -301,7 +419,6 @@ export default {
dataIndex: item + "L90", dataIndex: item + "L90",
customRender: ({ text }) => { customRender: ({ text }) => {
const val = text ? Number(text).toFixed(2) : ""; const val = text ? Number(text).toFixed(2) : "";
console.log(val);
return val; return val;
}, },
}); });
@@ -312,7 +429,6 @@ export default {
dataIndex: item + "Lmin", dataIndex: item + "Lmin",
customRender: ({ text }) => { customRender: ({ text }) => {
const val = text ? Number(text).toFixed(2) : ""; const val = text ? Number(text).toFixed(2) : "";
console.log(val);
return val; return val;
}, },
}); });
@@ -323,25 +439,21 @@ export default {
dataIndex: item + "Lmax", dataIndex: item + "Lmax",
customRender: ({ text }) => { customRender: ({ text }) => {
const val = text ? Number(text).toFixed(2) : ""; const val = text ? Number(text).toFixed(2) : "";
console.log(val);
return val; return val;
}, },
}); });
} }
}
}); });
// //
console.log(columns);
this.columns = columns; this.columns = columns;
}, },
exportFile() { exportFile() {
const arr = []; const arr = [];
const th = this.columns.map(item=>item.title); const th = this.columns.map((item) => item.title);
arr.push(th);
arr.push(th)
this.data.forEach((d) => { this.data.forEach((d) => {
const td = this.columns.map(item=>d[item.dataIndex]); const td = this.columns.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);

View File

@@ -11,14 +11,11 @@
<!-- <a-tab-pane key="quarter" tab="季度报告"> <!-- <a-tab-pane key="quarter" tab="季度报告">
<quarter-statistic></quarter-statistic> <quarter-statistic></quarter-statistic>
</a-tab-pane> --> </a-tab-pane> -->
<a-tab-pane key="year-compare" tab="报告"> <a-tab-pane key="year-compare" tab="年度报告">
<compare></compare> <compare></compare>
</a-tab-pane> </a-tab-pane>
</a-tabs> </a-tabs>
</a-card> </a-card>
</div> </div>
</template> </template>