道路交通导出

This commit is contained in:
weicw
2022-01-28 06:40:39 +08:00
parent aa1b583a32
commit 377c3a05cb

View File

@@ -85,7 +85,9 @@
<a-space>
<a-button type="primary" @click="reload">查询</a-button>
<a-button @click="reset" style="background: #FFA200FF; border-color: #FFA200FF;color: #FFFFFF">重置</a-button>
<a-button @click="exportFile" style="background: #2FA524FF; border-color: #2FA524FF;color: #FFFFFF">导出Excel</a-button>
<a-button @click="exportCityFile" style="background: #2FA524FF; border-color: #2FA524FF;color: #FFFFFF">市级模板导出</a-button>
<a-button @click="exportCountyFile" style="background: #2FA524FF; border-color: #2FA524FF;color: #FFFFFF">县级模板导出</a-button>
</a-space>
</a-form-item>
</a-col>
@@ -415,7 +417,98 @@ export default {
};
this.reload();
},
exportFile() {
exportCityFile() {
const columns = [
{
title: "监测日期及时间",
dataIndex: "monitorTime",
},
{
title: "点位编码",
dataIndex: "placeCode",
},
{
title: "测点名称",
dataIndex: "place",
},
{
title: "所属路段",
dataIndex: "road",
},
{
title: "所属城区",
dataIndex: "area",
},
{
title: "路长(米)",
dataIndex: "roadLength",
},
{
title: "路宽(米)",
dataIndex: "roadWidth",
},
{
title: "中小型车流量(辆/20分钟",
dataIndex: "smallTrafficFlow",
},
{
title: "大型车流量(辆/20分钟",
dataIndex: "largeTrafficFlow",
},
{
title: "Leq dB(A)",
dataIndex: "indexLeq",
},
{
title: "SD",
dataIndex: "indexSd",
},
{
title: "L10 dB(A)",
dataIndex: "indexL10",
},
{
title: "L50 dB(A)",
dataIndex: "indexL50",
},
{
title: "L90 dB(A)",
dataIndex: "indexL90",
},
{
title: "Lmin dB(A)",
dataIndex: "indexLmin",
},
{
title: "Lmax dB(A)",
dataIndex: "indexLmax",
},
];
const arr = [];
const th = columns.map((item) => item.title);
arr.push(th);
listAll(this.where).then(res=>{
if(res.data.code == 0){
res.data.data.forEach((d) => {
const td = columns.map((item) => {
let val = d[item.dataIndex];
if(["indexLeq","indexL10","indexL50","indexL90","indexLmax","indexLmin","indexSd"].includes(item.dataIndex)){
val = Number(val).toFixed(1);
}else if(item.dataIndex == "monitorTime"){
return moment(val).format("YYYY-MM-DD HH:mm")
}
return val;
});
arr.push(td);
});
let sheet = XLSX.utils.aoa_to_sheet(arr);
this.$util.exportSheet(XLSX, sheet, new Date().getTime().toString());
}
})
},
exportCountyFile() {
const columns = [
{
title: "行政区划代码",