<template>
|
<div class="echarts-box">
|
<div class="tab-scroll">
|
<PublicDataStandard :dataStandard="dataStandard"></PublicDataStandard>
|
</div>
|
<div class="echarts-form">
|
<span class="demonstration">开始时间:</span>
|
<el-date-picker v-model="formData.timeStart" value-format="yyyy-MM-dd" type="datetime" size="mini"></el-date-picker>
|
<span class="demonstration">结束时间:</span>
|
<el-date-picker v-model="formData.timeEnd" value-format="yyyy-MM-dd" type="datetime" size="mini"></el-date-picker>
|
<span class="demonstration">采样点数:</span>
|
<el-select v-model="formData.region" placeholder="请选择" size="mini">
|
<el-option v-for="(item,index) in formData.regionList" :key="index" :label="item" :value="item"></el-option>
|
</el-select>
|
<el-button @click="querySearch()">查询</el-button>
|
<el-popover
|
placement="top"
|
width="100%"
|
popper-class="popoverBoxStyle"
|
trigger="click">
|
<dynamic-table :tableData="tableData" :tableHeader="tableConfig" v-if="tableData"></dynamic-table>
|
<el-button slot="reference">明细表</el-button>
|
</el-popover>
|
</div>
|
<div class="echarts-chart">
|
<div ref="echartsDay"></div>
|
</div>
|
<span class="time-select">{{ formData.timeStart }}日—{{ formData.timeEnd }}日</span>
|
</div>
|
</template>
|
|
<script>
|
import dayjs from 'dayjs'
|
import PublicDataStandard from '../PublicDataStandard'
|
import mapApi from '@/api/mapApi'
|
import DynamicTable from '../../../views/popup/DynamicHeader/DynamicTable' // 多级表头
|
|
export default {
|
name: 'WasteWaterDayChart',
|
components: {
|
PublicDataStandard,
|
DynamicTable
|
},
|
data () {
|
return {
|
// tab栏传递接收数据
|
dataStandard: [],
|
tableData: null,
|
formData: {
|
region: '25',
|
regionList: [25, 50, 75, 100],
|
timeStart: dayjs().subtract(1, 'month').format('YYYY-MM-DD'),
|
timeEnd: dayjs().format('YYYY-MM-DD')
|
},
|
chart: null,
|
dataType: 1,
|
jcdID: 1,
|
bzz: null,
|
bzzList: [],
|
// 表头数据
|
tableConfig: [
|
{
|
id: 100,
|
label: '排放点',
|
prop: 'OnLineMonEmissPointName'
|
},
|
{
|
id: 200,
|
label: '监测时间',
|
prop: 'MonTimeStr'
|
},
|
{
|
id: 300,
|
label: 'COD',
|
prop: 'PoltmtrlName',
|
children: [
|
{
|
id: 310,
|
label: '实测排放量(kg/h)',
|
prop: 'COD_EmissQty'
|
},
|
{
|
id: 320,
|
label: '实测浓度(mg/l)',
|
prop: 'COD_MonQty'
|
},
|
{
|
id: 330,
|
label: '标准值(mg/l)',
|
prop: 'COD_StdValue'
|
}
|
]
|
},
|
{
|
id: 400,
|
label: '氨氮',
|
prop: 'PoltmtrlName',
|
children: [
|
{
|
id: 410,
|
label: '实测排放量(kg/h)',
|
prop: '氨氮_EmissQty'
|
},
|
{
|
id: 420,
|
label: '实测浓度(mg/l)',
|
prop: '氨氮_MonQty'
|
},
|
{
|
id: 430,
|
label: '标准值(mg/l)',
|
prop: '氨氮_StdValue'
|
}
|
]
|
},
|
{
|
id: 500,
|
label: 'PH',
|
prop: 'PoltmtrlName',
|
children: [
|
{
|
id: 510,
|
label: '实测排放量(kg/h)',
|
prop: 'pH_EmissQty'
|
},
|
{
|
id: 520,
|
label: '实测浓度(mg/l)',
|
prop: 'pH_MonQty'
|
},
|
{
|
id: 530,
|
label: '标准值(mg/l)',
|
prop: 'pH_StdValue'
|
}
|
]
|
},
|
{
|
id: 600,
|
label: '废水流量',
|
prop: '',
|
children: [
|
{
|
id: 610,
|
label: '实测流量(m³/h)',
|
prop: '废水流量_MonQty'
|
}
|
]
|
}
|
]
|
}
|
},
|
mounted () {
|
this.$nextTick(() => {
|
this.draw24Chart()
|
})
|
},
|
methods: {
|
querySearch () {
|
this.draw24Chart()
|
},
|
async draw24Chart () {
|
const data = {
|
poltSourceId: '',
|
poltMtrlId: '',
|
emissTypeId: '',
|
onLineMonEmissPointId: 23,
|
monItemId: '28,31,35', // 监测项 COD、氨氮、PH
|
beginTime: this.formData.timeStart,
|
endTime: this.formData.timeEnd,
|
dataType: this.dataType
|
}
|
const result = (await mapApi.getQueryOnlineMonData(data)).Result.DataInfo
|
this.get24HourDate(result)
|
},
|
get24HourDate (res) {
|
if (res.length > 0) {
|
this.dataStandard = []
|
this.tableData = this.analysisResult(res) // 小时明细表解析结果
|
// 处理数据开始
|
const d = res
|
const nameList = [] // 存放图例
|
const dateList = [] // 存放时间
|
const dataList = [] // 存放数据
|
let data
|
const bzh = []
|
|
for (let i = 0; i < d.length; i++) {
|
if (d[i].MonItemId === '29') {
|
continue
|
}
|
const MonTimeStr = d[i].MonTimeStr
|
|
const d1 = MonTimeStr.split('/')
|
// let d2=d1[2].split(' ');
|
let strDate
|
if (d1[1] > 9) {
|
// if(d2[0]>9){
|
strDate = MonTimeStr.substring(8, 10) + '日'
|
// }else {
|
// strDate=MonTimeStr.substring(8,9)+"日";
|
// }
|
} else {
|
// if(d2[0]>9){
|
strDate = MonTimeStr.substring(7, 9) + '日'
|
// }else {
|
// strDate=MonTimeStr.substring(7,8)+"日";
|
// }
|
}
|
|
if (nameList.length === 0) {
|
nameList.push(d[i].PoltmtrlName.trim())
|
dateList.push(strDate)
|
this.dataStandard.push({
|
current: {
|
name: d[i].PoltmtrlName.trim(),
|
val: ''
|
},
|
standard: {
|
name: '标准',
|
val: ''
|
}
|
})
|
bzh.push(d[i].StdValue)
|
data = {
|
name: d[i].PoltmtrlName.trim(),
|
data: []
|
}
|
if (d[i].MonQty !== null) {
|
data.data.push(d[i].MonQty)
|
}
|
dataList.push(data)
|
} else if (nameList.indexOf(d[i].PoltmtrlName.trim()) < 0) {
|
nameList.push(d[i].PoltmtrlName)
|
bzh.push(d[i].StdValue)
|
this.dataStandard.push({
|
current: {
|
name: d[i].PoltmtrlName.trim(),
|
val: ''
|
},
|
standard: {
|
name: '标准',
|
val: ''
|
}
|
})
|
data = {
|
name: d[i].PoltmtrlName.trim(),
|
data: []
|
}
|
if (d[i].MonQty !== null) {
|
data.data.push(d[i].MonQty)
|
}
|
dataList.push(data)
|
} else {
|
if (dateList.indexOf(strDate) < 0) {
|
dateList.push(strDate)
|
}
|
for (let j = 0; j < dataList.length; j++) {
|
if (d[i].PoltmtrlName.trim() === dataList[j].name) {
|
if (d[i].MonQty !== null)dataList[j].data.push(d[i].MonQty)
|
}
|
}
|
}
|
}
|
// 处理数据结束
|
|
const lengList = []
|
let objTemp
|
|
for (let l = 0; l < nameList.length; l++) {
|
let obj
|
let iconurl
|
if (nameList[l] === 'COD') {
|
iconurl = 'image://../assets/imgs/legend/SO2.png'
|
} else if (nameList[l] === '氨氮') {
|
iconurl = 'image://../assets/imgs/legend/NOX.png'
|
} else if (nameList[l] === '总磷') {
|
iconurl = 'image://../assets/imgs/legend/YanChen.png'
|
} else if (nameList[l] === '总氮') {
|
iconurl = 'image://../assets/imgs/legend/zongdan.png'
|
} else {
|
iconurl = 'image://../assets/imgs/legend/VOCs.png'
|
}
|
|
if (nameList[l] === '废水' || nameList[l] === '废水流量') { // 将废水流量排到数组最后
|
objTemp = {
|
name: nameList[l],
|
icon: iconurl,
|
textStyle: {
|
color: '#ccc'
|
},
|
itemWidth: 20,
|
itemHeight: 5
|
}
|
} else {
|
obj = {
|
name: nameList[l],
|
icon: iconurl,
|
textStyle: {
|
color: '#ccc'
|
},
|
itemWidth: 20,
|
itemHeight: 5
|
}
|
lengList.push(obj)
|
}
|
|
this.bzz = {
|
name: nameList[l],
|
bzhui: bzh[l]
|
}
|
this.bzzList.push(this.bzz)
|
}
|
lengList.push(objTemp)
|
|
const legend = lengList
|
const xdata = dateList.reverse()
|
const ydatas = []
|
|
for (let j = 0; j < nameList.length; j++) {
|
let zdcbcolor, zxcolor
|
if (nameList[j] === 'COD') {
|
zdcbcolor = 'red'
|
zxcolor = '#fff21c'
|
} else if (nameList[j] === '氨氮') {
|
zdcbcolor = 'red'
|
zxcolor = '#00B0F0'
|
} else if (nameList[j] === '总磷') {
|
zdcbcolor = 'red'
|
zxcolor = '#f48183'
|
} else if (nameList[j] === '总氮') {
|
zdcbcolor = 'red'
|
zxcolor = '#d9f2f4'
|
} else {
|
zdcbcolor = 'red'
|
zxcolor = '#9ACD32'
|
}
|
|
let sdata = []
|
|
for (let k = 0; k < dataList.length; k++) {
|
if (nameList[j].trim() === dataList[k].name.trim()) {
|
sdata = dataList[k].data.reverse()
|
}
|
}
|
|
const ydata = {
|
name: nameList[j],
|
data: sdata,
|
zdcbcolor: zdcbcolor,
|
zxcolor: zxcolor,
|
bzz: bzh[j]
|
}
|
ydatas.push(ydata)
|
}
|
for (var t = 0; t < this.dataStandard.length; t++) {
|
this.dataStandard[t].current.val = ydatas[t].data[ydatas[t].data.length - 1].toFixed(2)
|
this.dataStandard[t].standard.val = ydatas[t].bzz
|
}
|
const yname = '浓度(mg/l)'
|
this.effChartShow(legend, xdata, ydatas, yname, this.jcdID, this.datatype)
|
}
|
},
|
effChartShow (legend, xdata, ydatas, yname, jcdID, datatype) {
|
this.chart = this.$echarts.init(this.$refs.echartsDay)
|
this.chart.clear()
|
this.chart.clear()
|
let dataUnit = ''
|
if (datatype === 1) {
|
dataUnit = '流量(m³/d)'
|
} else {
|
dataUnit = '流量(m³/h)'
|
}
|
const bzzList = this.bzzList
|
const serLists = []
|
for (let i = 0; i < ydatas.length; i++) {
|
const zdcbcolor = ydatas[i].zxcolor
|
const bz = ydatas[i].bzz
|
let obj
|
if (bz) {
|
obj = {
|
name: ydatas[i].name,
|
symbol: 'circle', // 折点形状
|
symbolSize: 10, // 大小
|
smooth: false, // 直线 ,true 为曲线
|
itemStyle: {
|
normal: {
|
color: function (c) { // 根据value 显示不同的折点颜色
|
let biaozhuiz
|
for (let i = 0; i < bzzList.length; i++) {
|
if (bzzList[i].name === c.seriesName) {
|
biaozhuiz = bzzList[i].bzhui
|
}
|
}
|
if (c.value) {
|
if (c.value[1] > biaozhuiz) {
|
return zdcbcolor
|
} else if (c.value[1] > biaozhuiz * 0.9) {
|
return '#FFA500'
|
} else {
|
return '#33c95f'
|
}
|
}
|
},
|
lineStyle: { // 折线的颜色
|
color: ydatas[i].zxcolor,
|
width: 5
|
},
|
borderColor: 'black', // 折点边框的颜色
|
label: { // 显示值
|
show: false
|
}
|
}
|
},
|
type: 'line',
|
data: ydatas[i].data,
|
markLine: { // 平均值 , 和 指标上限
|
symbol: 'none',
|
data: [{
|
label: {
|
normal: {
|
position: 'end',
|
formatter: ''// ydatas[i].name+'标准值' //+'{c}'
|
}
|
},
|
name: '标准值',
|
yAxis: bz,
|
lineStyle: {
|
color: ydatas[i].zxcolor,
|
type: 'dashed',
|
width: 2
|
}
|
}
|
]
|
}
|
}
|
} else {
|
obj = {
|
name: ydatas[i].name,
|
symbol: 'circle', // 折点形状
|
symbolSize: 10, // 大小
|
smooth: false, // 直线 ,true 为曲线
|
yAxisIndex: 1,
|
itemStyle: {
|
normal: {
|
color: function (c) { // 根据value 显示不同的折点颜色
|
let biaozhuiz
|
for (let i = 0; i < bzzList.length; i++) {
|
if (bzzList[i].name === c.seriesName) {
|
biaozhuiz = bzzList[i].bzhui
|
}
|
}
|
if (c.value[1] > biaozhuiz) {
|
return zdcbcolor
|
} else if (c.value[1] > biaozhuiz * 0.9) {
|
return '#FFA500'
|
} else {
|
return '#33c95f'
|
}
|
},
|
lineStyle: { // 折线的颜色
|
color: ydatas[i].zxcolor,
|
width: 5
|
},
|
borderColor: 'black', // 折点边框的颜色
|
label: { // 显示值
|
show: false
|
}
|
}
|
},
|
type: 'line',
|
data: ydatas[i].data
|
}
|
}
|
serLists.push(obj)
|
}
|
const option = {
|
/* title: {
|
text: title,
|
}, */
|
tooltip: { // 提示框
|
trigger: 'axis',
|
axisPointer: {
|
type: 'cross',
|
label: {
|
color: '#1a4245'
|
}
|
},
|
formatter: function (params) {
|
let s = params[0].name + '<br />'
|
for (let i = 0; i < params.length; i++) {
|
// let name = params[i].name
|
// 图表title名称
|
const seriesName = params[i].seriesName
|
// 值
|
const value = params[i].value
|
|
// let valueFliter = formatter(value)
|
const valueFliter = parseFloat(value).toFixed(2)
|
|
let maker = params[i].marker
|
if (seriesName === 'COD') {
|
maker = '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:#fff21c;"></span>'
|
} else if (seriesName === '氨氮') {
|
maker = '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:#00B0F0;"></span>'
|
} else if (seriesName === '总磷') {
|
maker = '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:#f48183;"></span>'
|
} else if (seriesName === '总氮') {
|
maker = '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:#d9f2f4;"></span>'
|
} else {
|
maker = '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:#9ACD32;"></span>'
|
}
|
s += maker + seriesName + ':' + valueFliter + '<br />'
|
}
|
return s
|
}
|
},
|
toolbox: { // 打印等工具
|
show: false,
|
feature: {
|
saveAsImage: {}
|
}
|
},
|
grid: { // 网格
|
top: '20%'
|
// left: '5%'
|
},
|
legend: {
|
data: legend
|
},
|
dataZoom: [{
|
type: 'inside',
|
start: 0,
|
end: 100
|
}, {
|
start: 0,
|
end: 100,
|
show: false,
|
handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
|
handleSize: '80%',
|
handleStyle: {
|
color: '#fff',
|
shadowBlur: 3,
|
shadowColor: 'rgba(0, 0, 0, 0.6)',
|
shadowOffsetX: 2,
|
shadowOffsetY: 2
|
}
|
}],
|
xAxis: { // x 轴设置
|
type: 'category',
|
boundaryGap: false,
|
axisLabel: { // x轴全部显示
|
// rotate: 20,
|
// interval: 0,
|
textStyle: {
|
color: '#fff'
|
}
|
},
|
splitLine: { // 网格垂直线为 虚线
|
show: true,
|
lineStyle: {
|
type: 'dashed'
|
}
|
},
|
axisTick: { // x 轴刻度显示
|
show: false
|
},
|
axisLine: {
|
lineStyle: {
|
color: '#FFFFFF',
|
width: 1// 这里是为了突出显示加上的
|
}
|
},
|
data: xdata
|
},
|
yAxis: [{
|
type: 'value',
|
name: yname,
|
// max: function (value) {
|
// let max_val_list = [] // 所有显示折线的标准值
|
// if (bzzList && bzzList.length > 0) {
|
// $.each(bzzList, function (index, item) {
|
// max_val_list.push(item.bzhui)
|
// })
|
// }
|
// max_val_list = max_val_list.sort(function (a, b) {
|
// return a - b
|
// }) // 排序
|
// let ma = value.max > max_val_list[max_val_list.length - 1] ? value.max + 5 : max_val_list[max_val_list.length - 1]
|
// return parseInt(ma)
|
// },
|
axisLabel: {
|
formatter: '{value}',
|
textStyle: {
|
color: '#fff'
|
}
|
},
|
axisPointer: {
|
snap: true
|
},
|
splitLine: {
|
show: false
|
}, // y轴 网格线不显示,
|
axisLine: {
|
lineStyle: {
|
color: '#FFFFFF',
|
width: 1// 这里是为了突出显示加上的
|
}
|
}
|
}, {
|
type: 'value',
|
name: dataUnit,
|
axisLabel: {
|
formatter: '{value}',
|
textStyle: {
|
color: '#fff'
|
}
|
},
|
axisPointer: {
|
snap: true
|
},
|
splitLine: {
|
show: false
|
}, // y轴 网格线不显示,
|
// inverse: true,
|
// nameLocation: 'start',
|
// max:500,
|
axisLine: {
|
lineStyle: {
|
color: '#FFFFFF',
|
width: 1// 这里是为了突出显示加上的
|
}
|
}
|
}],
|
series: serLists
|
}
|
this.chart.setOption(option)
|
window.onresize = this.chart.resize
|
},
|
analysisResult (result) {
|
// 处理表格头
|
const json = {}
|
const arr = []
|
// 处理表格内容
|
const bodyDataList = []
|
const dataMap = {}
|
for (let i = 0; i < result.length; i++) {
|
json[result[i].PoltmtrlName] = result[i].PoltmtrlName
|
const rgdata = result[i]
|
const timeTag = rgdata.MonTimeStr
|
if (!dataMap[timeTag]) {
|
dataMap[timeTag] = { MonTimeStr: '' + rgdata.MonTimeStr }
|
}
|
// 往数据中添加属性数据
|
const el = dataMap[timeTag]
|
el.OnLineMonEmissPointName = rgdata.OnLineMonEmissPointName
|
el[rgdata.PoltmtrlName + '_EmissQty'] = rgdata.EmissQty ? rgdata.EmissQty.toFixed(2) : '--'
|
el[rgdata.PoltmtrlName + '_MonQty'] = rgdata.MonQty ? rgdata.MonQty.toFixed(2) : '--'
|
el[rgdata.PoltmtrlName + '_StdValue'] = rgdata.StdValue ? rgdata.StdValue.toFixed(2) : '--'
|
}
|
let FSLLtemp = null
|
for (var key in json) {
|
if (key === '废水流量' || key === '废水') {
|
FSLLtemp = key
|
} else {
|
arr.push(key)
|
}
|
}
|
if (FSLLtemp != null) {
|
arr.push(FSLLtemp)
|
}
|
for (var p in dataMap) {
|
bodyDataList.push(dataMap[p])
|
}
|
return bodyDataList
|
}
|
}
|
}
|
</script>
|
|
<style scoped lang="less">
|
|
</style>
|