修复列选择工具不刷新

This commit is contained in:
weicw
2021-08-18 17:36:40 +08:00
parent a4d087418b
commit 6c5aeb1e3e
4 changed files with 303 additions and 288 deletions

2
.env
View File

@@ -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://1.14.132.108:10002/api

View File

@@ -190,6 +190,11 @@ export default {
fullScreenTipVisible: false fullScreenTipVisible: false
}; };
}, },
watch:{
columns(val){
this.orgColumns = val
}
},
computed: { computed: {
// 表格尺寸下拉选中 // 表格尺寸下拉选中
selectedKeys() { selectedKeys() {

View File

@@ -479,9 +479,12 @@ export default {
}, },
columns() { columns() {
this.cols = this.columns; this.cols = this.columns;
this.$nextTick(()=>{
if (this.toolbar) { if (this.toolbar) {
this.$refs.toolbar.initColumnList(); this.$refs.toolbar.initColumnList();
} }
})
}, },
size() { size() {
this.tableSize = this.size; this.tableSize = this.size;

View File

@@ -1,33 +1,60 @@
<template> <template>
<div class=""> <div class="">
<ele-pro-table v-if="hisYears.length > 0" ref="table" row-key="id" :datasource="url" :columns="columns" <ele-pro-table
:where="where" :needPage="false" @done="stableDone" :scroll="{x: 'max-content'}" :method="'POST'"> 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'"
>
<template #toolbar> <template #toolbar>
<!-- 搜索表单 --> <!-- 搜索表单 -->
<a-form :model="where" layout="inline" :labelCol="{ offset: 1 }"> <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="统计模块:">
<a-select :options="groupModelOptions" v-model:value="where.groupModel" placeholder="统计模块"> <a-select
:options="groupModelOptions"
v-model:value="where.groupModel"
placeholder="统计模块"
>
</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="6" :md="12" :sm="24" :xs="24">
<a-form-item label="时间细度:"> <a-form-item label="时间细度:">
<a-select :options="groupTimeLengthOptions" v-model:value="where.groupTimeLength" placeholder=""> <a-select
:options="groupTimeLengthOptions"
v-model:value="where.groupTimeLength"
placeholder=""
>
</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="6" :md="12" :sm="24" :xs="24">
<a-form-item label="昼夜:"> <a-form-item label="昼夜:">
<a-select :options="timeSlotOptions" v-model:value="where.timeSlot" placeholder="昼夜"> <a-select
:options="timeSlotOptions"
v-model:value="where.timeSlot"
placeholder="昼夜"
>
</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="6" :md="12" :sm="24" :xs="24">
<a-form-item label="类型:"> <a-form-item label="类型:">
<a-select v-model:value="where.valueType" :options="valueTypeOptions" mode="multiple" <a-select
placeholder="Please select" style="width: 600px"> v-model:value="where.valueType"
:options="valueTypeOptions"
mode="multiple"
placeholder="Please select"
style="width: 400px"
>
</a-select> </a-select>
</a-form-item> </a-form-item>
</a-col> </a-col>
@@ -41,7 +68,6 @@
</a-form-item> </a-form-item>
</a-col> --> </a-col> -->
<a-col :lg="4" :md="12" :sm="24" :xs="24"> <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>
@@ -63,105 +89,114 @@
<script> <script>
// import _ from "lodash"; // import _ from "lodash";
import { import { ref } from "vue";
ref import XLSX from "xlsx";
} from 'vue';
import XLSX from 'xlsx';
import { import {
pageRoadNoiseCompare, pageRoadNoiseCompare,
getHistoryyears getHistoryyears,
} from "@/api/ecology/road-sound" } from "@/api/ecology/road-sound";
export default { export default {
name: 'StatisticSoundRoadCompare', name: "StatisticSoundRoadCompare",
components: {}, components: {},
data() { data() {
const groupModelOptions = []; const groupModelOptions = [
const groupTimeLengthOptions = [{ {label: "测点",value: "place"},
{label: "城区",value: "area"},
{label: "市",value: "city"},
];
const groupTimeLengthOptions = [
{
label: "年", label: "年",
value: "monitor_year" value: "monitor_year",
}, },
{ {
label: "季度", label: "季度",
value: "quarter" value: "quarter",
} },
] ];
// const valueTypeOptions = ['Leq','SD','L10','L50','L90','Lmin','Lmax']; // const valueTypeOptions = ['Leq','SD','L10','L50','L90','Lmin','Lmax'];
const valueTypeOptions = [{ const valueTypeOptions = [
label: 'Leq', {
value: 'index_Leq' label: "Leq",
value: "index_Leq",
}, },
{ {
label: 'SD', label: "SD",
value: 'index_Sd' value: "index_Sd",
}, },
{ {
label: 'L10', label: "L10",
value: 'index_L10' value: "index_L10",
}, },
{ {
label: 'L50', label: "L50",
value: 'index_L50' value: "index_L50",
}, },
{ {
label: 'L90', label: "L90",
value: 'index_L90' value: "index_L90",
}, },
{ {
label: 'Lmin', label: "Lmin",
value: 'index_Lmin' value: "index_Lmin",
}, },
{ {
label: 'Lmax', label: "Lmax",
value: 'index_Lmax' value: "index_Lmax",
}, },
] ];
return { return {
url: pageRoadNoiseCompare, url: pageRoadNoiseCompare,
data: [], data: [],
where: { where: {
groupModel: "area", groupModel: "area",
groupTimeLength: "monitor_year", groupTimeLength: "monitor_year",
timeSlot: '昼', timeSlot: "昼",
reportTimeScope: [], reportTimeScope: [],
valueType: ['index_Leq'] valueType: ["index_Leq"],
}, },
hisYears: [], hisYears: [],
timeScope: [], timeScope: [],
columns:[], columns: [{title:'年',dataIndex: 'year'}],
groupModelOptions, groupModelOptions,
groupTimeLengthOptions, groupTimeLengthOptions,
valueTypeOptions: ref(valueTypeOptions), valueTypeOptions: ref(valueTypeOptions),
timeSlotOptions: [{ timeSlotOptions: [
{
value: "昼", value: "昼",
label: "昼" label: "昼",
}, { },
{
value: "夜", value: "夜",
label: "夜" label: "夜",
}] },
],
}; };
}, },
mounted() { mounted() {
getHistoryyears().then(res => { getHistoryyears().then((res) => {
this.hisYears = res.data.data this.hisYears = res.data.data;
this.$nextTick(()=>{
this.reload()
}) })
});
}, },
methods: { methods: {
/* 刷新表格 */ /* 刷新表格 */
reload() { reload() {
this.stableDone()
this.$refs.table.reload({ this.$refs.table.reload({
where: this.where where: this.where,
}); });
}, },
/* 重置搜索 */ /* 重置搜索 */
reset() { reset() {
this.where = { this.where = {
model: "place", model: "place",
timeSlot: "昼" timeSlot: "昼",
}; };
this.this.timeScope = [] this.this.timeScope = [];
this.reload(); this.reload();
}, },
@@ -174,30 +209,28 @@
columns.push({ columns.push({
title: "城区", title: "城区",
dataIndex: "area", dataIndex: "area",
sorter: true sorter: true,
}) });
} else if (this.where.groupModel == "place") { } else if (this.where.groupModel == "place") {
columns.push({ columns.push({
title: "测点", title: "测点",
dataIndex: "area", dataIndex: "area",
sorter: true sorter: true,
}) });
} else if (this.where.groupModel == "city") { } else if (this.where.groupModel == "city") {
columns.push({ columns.push({
title: "城市", title: "城市",
dataIndex: "area", dataIndex: "area",
sorter: true sorter: true,
}) });
} }
if (this.where.groupTimeLength == 'quarter') { if (this.where.groupTimeLength == "quarter") {
columns.push({ columns.push({
title: "季度", title: "季度",
dataIndex: "quarter", dataIndex: "quarter",
sorter: true, sorter: true,
customRender: ({ customRender: ({ text }) => {
text
}) => {
switch (text) { switch (text) {
case 1: case 1:
return "第一季度"; return "第一季度";
@@ -211,144 +244,118 @@
default: default:
return ""; return "";
} }
} },
}) });
} }
this.hisYears.forEach((item) => {
this.hisYears.forEach(item => {
console.log(this.where.valueType)
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: ({ customRender: ({ text }) => {
text const val = text ? Number(text).toFixed(2) : "";
}) => { console.log(val);
const val = text ? Number(text).toFixed(2) : ''
console.log(val)
return val; return val;
} },
});
})
} }
if (this.where.valueType.includes("index_SD")) { if (this.where.valueType.includes("index_SD")) {
columns.push({ columns.push({
title: item + "年SD", title: item + "年SD",
dataIndex: item + "Sd", dataIndex: item + "Sd",
customRender: ({ customRender: ({ text }) => {
text const val = text ? Number(text).toFixed(2) : "";
}) => { console.log(val);
const val = text ? Number(text).toFixed(2) : ''
console.log(val)
return val; return val;
} },
});
})
} }
if (this.where.valueType.includes("index_L10")) { if (this.where.valueType.includes("index_L10")) {
columns.push({ columns.push({
title: item + "年L10", title: item + "年L10",
dataIndex: item + "L10", dataIndex: item + "L10",
customRender: ({ customRender: ({ text }) => {
text const val = text ? Number(text).toFixed(2) : "";
}) => { console.log(val);
const val = text ? Number(text).toFixed(2) : ''
console.log(val)
return val; return val;
} },
});
})
} }
if (this.where.valueType.includes("index_L50")) { if (this.where.valueType.includes("index_L50")) {
columns.push({ columns.push({
title: item + "年L50", title: item + "年L50",
dataIndex: item + "L50", dataIndex: item + "L50",
customRender: ({ customRender: ({ text }) => {
text const val = text ? Number(text).toFixed(2) : "";
}) => { console.log(val);
const val = text ? Number(text).toFixed(2) : ''
console.log(val)
return val; return val;
} },
});
})
} }
if (this.where.valueType.includes("index_L90")) { if (this.where.valueType.includes("index_L90")) {
columns.push({ columns.push({
title: item + "年L90", title: item + "年L90",
dataIndex: item + "L90", dataIndex: item + "L90",
customRender: ({ customRender: ({ text }) => {
text const val = text ? Number(text).toFixed(2) : "";
}) => { console.log(val);
const val = text ? Number(text).toFixed(2) : ''
console.log(val)
return val; return val;
} },
});
})
} }
if (this.where.valueType.includes("index_Lmin")) { if (this.where.valueType.includes("index_Lmin")) {
columns.push({ columns.push({
title: item + "年Lmin", title: item + "年Lmin",
dataIndex: item + "Lmin", dataIndex: item + "Lmin",
customRender: ({ customRender: ({ text }) => {
text const val = text ? Number(text).toFixed(2) : "";
}) => { console.log(val);
const val = text ? Number(text).toFixed(2) : ''
console.log(val)
return val; return val;
} },
});
})
} }
if (this.where.valueType.includes("index_Lmax")) { if (this.where.valueType.includes("index_Lmax")) {
columns.push({ columns.push({
title: item + "年Lmax", title: item + "年Lmax",
dataIndex: item + "Lmax", dataIndex: item + "Lmax",
customRender: ({ customRender: ({ text }) => {
text const val = text ? Number(text).toFixed(2) : "";
}) => { console.log(val);
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() {
let array = [ let array = [
['测点', '路段', '城区', '路长', '路宽', '平均Leq', '平均SD'] ["测点", "路段", "城区", "路长", "路宽", "平均Leq", "平均SD"],
]; ];
this.data.forEach(d => { this.data.forEach((d) => {
array.push([d.place, d.road, d.area, d.roadLength, d.roadWidth, d.avgLeq, d.avgSD]); array.push([
d.place,
d.road,
d.area,
d.roadLength,
d.roadWidth,
d.avgLeq,
d.avgSD,
]);
}); });
let sheet = XLSX.utils.aoa_to_sheet(array); let sheet = XLSX.utils.aoa_to_sheet(array);
// sheet['!merges'] = [
// {s: {r: 0, c: 1}, e: {r: 0, c: 5}}, // 合并第0行第1列到第0行第5列
// {s: {r: 0, c: 0}, e: {r: 1, c: 0}}, // 合并第0行第0列到第1行第0列
// {s: {r: 0, c: 6}, e: {r: 1, c: 6}} // 合并第0行第6列到第1行第6列
// ];
this.$util.exportSheet(XLSX, sheet, '道路交通噪声统计表');
}
}
} this.$util.exportSheet(XLSX, sheet, new Date().getTime());
},
},
};
</script> </script>
<style scoped> <style scoped>
</style> </style>