派生自 wuyushui/SewerAndRainNetwork

徐旺旺
2021-05-30 f8865d1c7f36c4ffa66002e0dd3a9d5e99e4fe6b
src/components/base-page/WasteWater/WasteWaterHoursChart.vue
@@ -13,7 +13,14 @@
        <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-button>明细表</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="echartsHour"></div>
@@ -26,56 +33,21 @@
import PublicDataStandard from '../PublicDataStandard'
import dayjs from 'dayjs'
import mapApi from '../../../api/mapApi'
import DynamicTable from '../../../views/popup/DynamicHeader/DynamicTable' // 多级表头
export default {
  name: 'WasteWaterHoursChart',
  components: {
    PublicDataStandard
    PublicDataStandard,
    DynamicTable
  },
  data () {
    return {
      // tab栏传递接收数据
      dataStandard: [
        {
          current: {
            name: '氮氧化物',
            val: 29.93
          },
          standard: {
            name: '标准',
            val: 100
          }
        },
        {
          current: {
            name: '二氧化硫',
            val: 17.34
          },
          standard: {
            name: '标准',
            val: 50
          }
        },
        {
          current: {
            name: '烟尘',
            val: 6.93
          },
          standard: {
            name: '标准',
            val: 30
          }
        },
        {
          current: {
            name: '废气流量',
            val: 123
          },
          standard: {
            name: '',
            val: null
          }
        }],
      dataStandard: [],
      popUpName: '',
      tableData: null,
      mingxiBoxHtml: '',
      formData: {
        region: '25',
        regionList: [25, 50, 75, 100],
@@ -87,7 +59,98 @@
      dataType: 2,
      bzz: null,
      bzzList: [],
      bz: ''
      bz: '',
      // 表头数据
      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 () {
@@ -105,18 +168,20 @@
        poltMtrlId: '',
        emissTypeId: '',
        onLineMonEmissPointId: 23,
        monItemId: 28,
        monItemId: '28,31,35', // 监测项  COD、氨氮、PH
        beginTime: this.formData.startTime,
        endTime: this.formData.endTime,
        dataType: this.dataType
      }
      const result = (await mapApi.getQueryOnlineMonData(data)).Result.DataInfo
      // console.log(result)
      this.popUpName = result[0].OnLineMonEmissPointName
      this.get24HourDate(result)
    },
    // 绘制小时数据折线图
    get24HourDate (result) {
      if (result.length > 0) {
        this.dataStandard = []
        this.tableData = this.analysisResult(result) // 小时明细表解析结果
        const d = result
        const nameList = [] // 存放图例
        const dateList = [] // 存放时间
@@ -170,24 +235,43 @@
              }
            }
          }
          if (nameList.length === 0) {
            nameList.push(d[i].PoltmtrlName.trim())
            this.dataStandard.push({
              current: {
                name: d[i].PoltmtrlName.trim(),
                val: 29.93
              },
              standard: {
                name: '标准',
                val: 100
              }
            })
            dateList.push(strDate)
            if ((d[i].PoltmtrlName === '废水流量' || d[i].PoltmtrlName === '废水') && d[i].MonQty < 0) {
              d[i].MonQty = 0
            }
            data.push(d[i].MonQty)
            if (d[i].MonQty !== null)data.push(d[i].MonQty)
            bzh.push(d[i].StdValue)
          } else if (nameList.indexOf(d[i].PoltmtrlName.trim()) < 0) {
            nameList.push(d[i].PoltmtrlName)
            this.dataStandard.push({
              current: {
                name: d[i].PoltmtrlName.trim(),
                val: 29.93
              },
              standard: {
                name: '标准',
                val: 100
              }
            })
            bzh.push(d[i].StdValue)
            dataList.push(data)
            data = []
            if ((d[i].PoltmtrlName === '废水流量' || d[i].PoltmtrlName === '废水') && d[i].MonQty < 0) {
              d[i].MonQty = 0
            }
            data.push(d[i].MonQty)
            if (d[i].MonQty !== null)data.push(d[i].MonQty)
          } else if (i === d.length - 1) {
            if ((d[i].PoltmtrlName === '废水流量' || d[i].PoltmtrlName === '废水') && d[i].MonQty < 0) {
              d[i].MonQty = 0
@@ -202,10 +286,9 @@
            if ((d[i].PoltmtrlName === '废水流量' || d[i].PoltmtrlName === '废水') && d[i].MonQty < 0) {
              d[i].MonQty = 0
            }
            data.push(d[i].MonQty)
            if (d[i].MonQty !== null)data.push(d[i].MonQty)
          }
        }
        const newList = []
        for (let i = 0; i < dataList.length; i++) {
@@ -291,7 +374,10 @@
        // console.log(ydatas)
        const yname = '浓度(mg/l)'
        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
        }
        this.effChartShow(legend, xdata, ydatas, yname, this.jcdID, this.datatype)
      }
    },
@@ -570,6 +656,43 @@
      }
      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
    }
  }
}