大更新
This commit is contained in:
@@ -4,12 +4,12 @@ const tableColumns = [
|
||||
{title: "降雨量(mm)",dataIndex: "precipitation",sorter: true,},
|
||||
{title: "pH值(无量纲)",dataIndex: "ph",sorter: true,},
|
||||
{title: "电导率(mS/m)",dataIndex: "conductivity",sorter: true,},
|
||||
{title: "氟离子",dataIndex: "fluorine",sorter: true,},
|
||||
{title: "氯离子",dataIndex: "chlorine",sorter: true,},
|
||||
{title: "硫酸根离子",dataIndex: "sulfateRadical",sorter: true,},
|
||||
{title: "硝酸根离子",dataIndex: "nitrate",sorter: true,},
|
||||
{title: "氟离子",dataIndex: "f",sorter: true,},
|
||||
{title: "氯离子",dataIndex: "cl",sorter: true,},
|
||||
{title: "硫酸根离子",dataIndex: "so42",sorter: true,},
|
||||
{title: "硝酸根离子",dataIndex: "no3",sorter: true,},
|
||||
{title: "钠离子",dataIndex: "na",sorter: true,},
|
||||
{title: "铵根离子",dataIndex: "ammoniumRadical",sorter: true,},
|
||||
{title: "铵根离子",dataIndex: "nh4",sorter: true,},
|
||||
{title: "钾离子",dataIndex: "k",sorter: true,},
|
||||
{title: "镁离子",dataIndex: "mg",sorter: true,},
|
||||
{title: "钙离子",dataIndex: "ca",sorter: true,},
|
||||
|
||||
@@ -2,15 +2,23 @@
|
||||
<div class="ele-body">
|
||||
<a-card style="width: 100%" :bordered="false">
|
||||
<template #title>
|
||||
<a-select
|
||||
ref="select"
|
||||
v-model:value="regionLevel"
|
||||
style="width: 120px"
|
||||
>
|
||||
<a-select-option value="city">市</a-select-option>
|
||||
<a-select-option value="county">县</a-select-option>
|
||||
</a-select>
|
||||
<a-space>
|
||||
<a-upload
|
||||
:before-upload="importFileCity"
|
||||
:showUploadList="false"
|
||||
accept=".xls,.xlsx,.csv"
|
||||
:before-upload="importFileCity"
|
||||
:showUploadList="false"
|
||||
accept=".xls,.xlsx,.csv"
|
||||
>
|
||||
<a-button>数据导入</a-button>
|
||||
</a-upload>
|
||||
|
||||
<a-button @click="download">模板下载</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
<a-tabs v-model:activeKey="activeKey">
|
||||
@@ -27,7 +35,8 @@ import XLSX from "xlsx";
|
||||
import utils from "./utils";
|
||||
import {Modal} from "ant-design-vue";
|
||||
import RainBill from "./rain-bill.vue";
|
||||
import {saveAcidRainBill} from "@/api/ecology/acid";
|
||||
import {saveAcidRainBill} from "@/api/ecology/atmosphere/acid"
|
||||
import {downloadTemplate} from "@/utils/excel-util";
|
||||
|
||||
export default {
|
||||
name: "RainCollectIndex",
|
||||
@@ -37,93 +46,117 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
activeKey: "rain",
|
||||
regionLevel: "city",
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
download() {
|
||||
let filename = "酸雨-"
|
||||
if (this.regionLevel == "city") {
|
||||
filename += "市"
|
||||
} else if (this.regionLevel == "county") {
|
||||
filename += "县"
|
||||
} else {
|
||||
filename += "站点"
|
||||
}
|
||||
downloadTemplate(filename)
|
||||
},
|
||||
/* 导入本地excel文件 */
|
||||
async importFileCity(file) {
|
||||
const hide = this.$message.loading("导入中..", 0);
|
||||
|
||||
let reader = new FileReader();
|
||||
reader.onload = async (e) => {
|
||||
try {
|
||||
let data = new Uint8Array(e.target.result);
|
||||
let workbook = XLSX.read(data, {
|
||||
type: "array",
|
||||
});
|
||||
let sheetNames = workbook.SheetNames;
|
||||
// 解析成二维数组
|
||||
let aoa = XLSX.utils.sheet_to_json(workbook.Sheets[sheetNames[0]], {
|
||||
header: 1,
|
||||
});
|
||||
try {
|
||||
|
||||
const reportDate = aoa[2][0].replace(/[^\d]+/g, "-");
|
||||
let data = new Uint8Array(e.target.result);
|
||||
let workbook = XLSX.read(data, {
|
||||
type: "array",
|
||||
});
|
||||
let sheetNames = workbook.SheetNames;
|
||||
// 解析成二维数组
|
||||
let aoa = XLSX.utils.sheet_to_json(workbook.Sheets[sheetNames[0]], {
|
||||
header: 1,
|
||||
});
|
||||
|
||||
const acidList = aoa.filter((item) => {
|
||||
return item.length >= 16 && item[0] && !item[0].includes("编号");
|
||||
});
|
||||
// 解析成对象数组
|
||||
const billName = aoa[0][0] + aoa[1][0];
|
||||
const billData = await utils.toObjData(acidList, new Date(reportDate).getFullYear());
|
||||
|
||||
if (
|
||||
!billData ||
|
||||
billData.length == 0
|
||||
// (!billData2 || billData2.length == 0)
|
||||
) {
|
||||
hide();
|
||||
Modal.error({
|
||||
title: "导入失败",
|
||||
content: "找不到数据",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const acidList = aoa.filter((item) => {
|
||||
if (this.regionLevel == "city") {
|
||||
return item.length >= 20 && item[0] && !item[0].includes("编号");
|
||||
} else if (this.regionLevel == "county") {
|
||||
console.log(item.length,item[0])
|
||||
return item.length >= 27 && item[0] && item[0] != "行政代码";
|
||||
}
|
||||
});
|
||||
// 解析成对象数组
|
||||
const billName =file.name;
|
||||
let billData = undefined
|
||||
if (this.regionLevel == "city") {
|
||||
const reportDate = aoa[2][0].replace(/[^\d]+/g, "-");
|
||||
|
||||
const tasks = [];
|
||||
if (billData.length > 0) {
|
||||
tasks.push(
|
||||
saveAcidRainBill({
|
||||
// reportTime: new Date(reportDate).getTime(),
|
||||
billName: billName,
|
||||
regionLevel: "市级",
|
||||
acidRainList: billData,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// 上传到服务器
|
||||
Promise.all(tasks)
|
||||
.then((res) => {
|
||||
if (res[0].data.code == 0) {
|
||||
Modal.success({
|
||||
title: "导入成功",
|
||||
content: `成功导入${billData.length}条数据`,
|
||||
});
|
||||
this.$refs.rain && this.$refs.rain.reload();
|
||||
} else {
|
||||
Modal.error({
|
||||
title: "导入失败",
|
||||
content: "数据上传出错",
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
Modal.error({
|
||||
title: "导入失败",
|
||||
content: "数据上传出错",
|
||||
});
|
||||
})
|
||||
.finally(() => {
|
||||
hide();
|
||||
});
|
||||
} catch (error) {
|
||||
hide();
|
||||
Modal.error({
|
||||
title: "导入失败",
|
||||
content: error.message,
|
||||
});
|
||||
billData = await utils.toObjData(acidList, new Date(reportDate).getFullYear());
|
||||
} else if (this.regionLevel == "county") {
|
||||
billData = utils.toCountyObjData(acidList);
|
||||
}
|
||||
// console.log(billData);
|
||||
|
||||
if (
|
||||
!billData ||
|
||||
billData.length == 0
|
||||
// (!billData2 || billData2.length == 0)
|
||||
) {
|
||||
hide();
|
||||
Modal.error({
|
||||
title: "导入失败",
|
||||
content: "找不到数据",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const tasks = [];
|
||||
if (billData.length > 0) {
|
||||
tasks.push(
|
||||
saveAcidRainBill({
|
||||
// reportTime: new Date(reportDate).getTime(),
|
||||
billName: billName,
|
||||
regionLevel: this.regionLevel == "city"?"市级":"县级",
|
||||
acidRainList: billData,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// 上传到服务器
|
||||
Promise.all(tasks)
|
||||
.then((res) => {
|
||||
if (res[0].data.code == 0) {
|
||||
Modal.success({
|
||||
title: "导入成功",
|
||||
content: `成功导入${billData.length}条数据`,
|
||||
});
|
||||
this.$refs.rain && this.$refs.rain.reload();
|
||||
} else {
|
||||
Modal.error({
|
||||
title: "导入失败",
|
||||
content: "数据上传出错",
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
Modal.error({
|
||||
title: "导入失败",
|
||||
content: "数据上传出错",
|
||||
});
|
||||
})
|
||||
.finally(() => {
|
||||
hide();
|
||||
});
|
||||
} catch (error) {
|
||||
hide();
|
||||
Modal.error({
|
||||
title: "导入失败",
|
||||
content: error.message,
|
||||
});
|
||||
}
|
||||
// console.log(billData);
|
||||
};
|
||||
reader.readAsArrayBuffer(file);
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@
|
||||
removeBatchAcidRainBill,
|
||||
updateAcidRainBill,
|
||||
verifyAcidRainBill
|
||||
} from "@/api/ecology/acid";
|
||||
} from "@/api/ecology/atmosphere/acid";
|
||||
import moment from "moment";
|
||||
export default {
|
||||
name: 'RainCollectNoiseBill',
|
||||
@@ -144,11 +144,11 @@
|
||||
},
|
||||
|
||||
},
|
||||
// {
|
||||
// title: '区域等级',
|
||||
// dataIndex: 'regionLevel',
|
||||
// sorter: true,
|
||||
// },
|
||||
{
|
||||
title: '区域等级',
|
||||
dataIndex: 'regionLevel',
|
||||
sorter: true,
|
||||
},
|
||||
{
|
||||
title: '条目',
|
||||
dataIndex: 'recordSize',
|
||||
|
||||
@@ -157,7 +157,7 @@ import {
|
||||
updateAcidRain,
|
||||
getAcidRainBill,
|
||||
getColumnOptions,
|
||||
} from "@/api/ecology/acid";
|
||||
} 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";
|
||||
|
||||
@@ -2,6 +2,39 @@ import moment from "moment"
|
||||
import axios from "axios";
|
||||
import {listAllUrl} from "@/api/ecology/atmosphere/acid-rain-plcae"
|
||||
export default {
|
||||
toCountyObjData(excelData){
|
||||
return excelData.map(item => {
|
||||
|
||||
const row = {
|
||||
regionCode: item[0],
|
||||
city: (typeof item[1] == "string" && item[1].includes("市"))?item[1].sub(0,item[1].lastIndexOf("市")): "南宁市",
|
||||
county: (typeof item[1] == "string" && item[1].includes("县"))?item[1].sub(0,item[1].lastIndexOf("县")): "",
|
||||
area: (typeof item[1] == "string" && item[1].includes("区"))?item[1].sub(0,item[1].lastIndexOf("区")): "南宁区",
|
||||
place: item[2],
|
||||
placeType: item[3],
|
||||
monitorStartTime: moment(`${item[4]}-${item[5]}-${item[6]} ${item[7]}:${item[8]}:00`).valueOf(),
|
||||
monitorEndTime: moment(`${item[9]}-${item[10]}-${item[11]} ${item[12]}:${item[13]}:00`).valueOf(),
|
||||
monitorTime: moment(`${item[4]}-${item[5]}-${item[6]} ${item[7]}:${item[8]}:00`).valueOf(),
|
||||
precipitationType: item[14],
|
||||
precipitation: item[15],
|
||||
ph: item[16],
|
||||
conductivity: item[17],
|
||||
so42: item[18],
|
||||
no3: item[19],
|
||||
f: item[20],
|
||||
cl: item[21],
|
||||
nh4: item[22],
|
||||
ca: item[23],
|
||||
mg: item[24],
|
||||
na: item[25],
|
||||
k: item[26],
|
||||
systemCode: item[27],
|
||||
|
||||
}
|
||||
|
||||
return row;
|
||||
})
|
||||
},
|
||||
async toObjData(excelData,monitorYear) {
|
||||
const res = await axios.get(listAllUrl,{params:{year:monitorYear}})
|
||||
if(res.data.code !=0){
|
||||
@@ -12,22 +45,21 @@ export default {
|
||||
const monitorTime = moment(monitorYear + "."+item[1],"Y.M.D");
|
||||
const monitorStartTime = moment(`${monitorYear}.${item[2]}.${item[3]} ${item[4]}:${item[5]}`,"Y.M.D H:m");
|
||||
const monitorEndTime = moment(`${monitorYear}.${item[6]}.${item[7]} ${item[8]}:${item[9]}`,"Y.M.D H:m");
|
||||
console.log(item);
|
||||
const row = {
|
||||
city: "南宁市",
|
||||
place: dict.find(p=>p.placeCode = item[0].split("~")[0]).place,
|
||||
placeType:dict.find(p=>p.placeCode = item[0].split("~")[0]).attribute,
|
||||
place: dict.find(p=>p.placeCode == item[0].split("~")[0]).place,
|
||||
placeType:dict.find(p=>p.placeCode == item[0].split("~")[0]).attribute,
|
||||
code: item[0],
|
||||
precipitationType:item[10],
|
||||
precipitation:item[11],
|
||||
ph:item[12],
|
||||
conductivity:item[13],
|
||||
fluorine:item[14],
|
||||
chlorine:item[15],
|
||||
sulfateRadical:item[16],
|
||||
nitrate:item[17],
|
||||
f:item[14],
|
||||
cl:item[15],
|
||||
so42:item[16],
|
||||
no3:item[17],
|
||||
na:item[18],
|
||||
ammoniumRadical:item[19],
|
||||
nh4:item[19],
|
||||
k:item[20],
|
||||
mg:item[21],
|
||||
ca:item[22],
|
||||
@@ -35,6 +67,7 @@ export default {
|
||||
monitorEndTime: monitorEndTime.valueOf(),
|
||||
monitorTime: monitorTime.valueOf(),
|
||||
}
|
||||
|
||||
return row;
|
||||
})
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
<script>
|
||||
// import _ from "lodash";
|
||||
import XLSX from "xlsx";
|
||||
import {pageAcidRainUrl, getColumnOptions} from "@/api/ecology/acid";
|
||||
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 utils from "./utils";
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
<script>
|
||||
import _ from "lodash";
|
||||
import XLSX from "xlsx";
|
||||
import {statisticCity, getColumnOptions} from "@/api/ecology/acid";
|
||||
import {statisticCity, getColumnOptions} from "@/api/ecology/atmosphere/acid";
|
||||
import locale from "ant-design-vue/es/date-picker/locale/zh_CN";
|
||||
import moment from "moment";
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
<script>
|
||||
import _ from "lodash";
|
||||
import XLSX from "xlsx";
|
||||
import {statisticCounty, getColumnOptions} from "@/api/ecology/acid";
|
||||
import {statisticCounty, getColumnOptions} from "@/api/ecology/atmosphere/acid";
|
||||
import locale from "ant-design-vue/es/date-picker/locale/zh_CN";
|
||||
import moment from "moment";
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<script>
|
||||
import _ from "lodash";
|
||||
import XLSX from "xlsx";
|
||||
import {statisticIon, getColumnOptions} from "@/api/ecology/acid";
|
||||
import {statisticIon, getColumnOptions} from "@/api/ecology/atmosphere/acid";
|
||||
import locale from "ant-design-vue/es/date-picker/locale/zh_CN";
|
||||
import moment from "moment";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user