派生自 wuyushui/SewerAndRainNetwork

chenyabin
2021-04-12 23e134520785efe3bbce4e759776e360a7967b62
Merge remote-tracking branch 'origin/develop' into develop
1个文件已添加
4个文件已修改
463 ■■■■■ 已修改文件
src/components/BaseNav/PublicBounced/GasComponents/Echarts.vue 355 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/BaseNav/PublicBounced/GasComponents/PublicChart.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/BaseNav/PublicBounced/PublicBounced.vue 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/BaseNav/SolidWaste/directive/dir.js 37 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/dragBoxes.js 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/BaseNav/PublicBounced/GasComponents/Echarts.vue
@@ -1,5 +1,5 @@
<template>
  <div style="width:100%;height:2rem;margin-top: 0.3rem" ref="echarts"></div>
  <div style="width:5rem;height:2rem;margin-top: 0.3rem" ref="echarts"></div>
</template>
<script>
@@ -12,202 +12,247 @@
  name: 'ECharts',
  data () {
    return {
      myChart: [],
      result: [],
      days: dayjs(new Date()).format('YYYYMMDDHHmmss'),
      value: '',
      myChart: [],
      // x轴数据
      xAxis: [],
      seriesData: [],
      aseries: ''
      seriesName: []
    }
  },
  mounted () {
    this.$nextTick(() => {
      this.initEchartsData()
      this.upDateEchartsData()
    })
  },
  methods: {
    drawChart () {
    // 初始化数据
    async initEchartsData () {
      const endTime = dayjs().add(1, 's')
      const data = {
        $tagCodeList: 'TJIP45.yyqAI90305,TJIP45.yyqAI90303,TJIP45.yyqFI_90310N,TJIP45.yyqAI90304,TJIP45.yyqAIR001',
        $startTime: this.dayjs,
        $endTime: endTime,
        $step: 15
      }
      const result = (await mapApi.DataItems(data)).data
      for (var i = 0; i < result.length; i++) {
        // console.log(result[i])
        this.xAxis.push(result[i].ReadTime)
        this.seriesData.push(result[i].TagValue)
        this.seriesName = result[i].UnionTagCode
      }
      this.upDateEchartsinit()
    },
    // 实时数据刷新
    upDateEchartsData () {
      // const interValHander =
      setInterval(async () => {
        const endTime = dayjs().add(1, 's')
        const data = {
          $tagCodeList: 'TJIP45.yyqAI90305,TJIP45.yyqAI90303,TJIP45.yyqFI_90310N,TJIP45.yyqAI90304,TJIP45.yyqAIR001',
          $startTime: this.dayjs,
          $endTime: endTime,
          $step: 15
        }
        const result = (await mapApi.DataItems(data)).data
        for (var i = 0; i < result.length; i++) {
          // console.log(result[i])
          // this.xAxis.shift()
          this.xAxis.push(result[i].ReadTime)
          this.seriesData.push(result[i].TagValue)
          this.seriesName = result[i].UnionTagCode
        }
        this.upDateEchartsinit()
      }, 1500)
    },
    // 初始化echarts
    upDateEchartsinit () {
      this.myChart = this.$echarts.init(this.$refs.echarts)
      const option = {
        tooltip: {
          trigger: 'axis'
      // 图表的配置项数据
      const xAxisData = this.xAxis
      const legendData = [this.seriesName, 'TJIP45.lscl2tb552AISA11201B', 'TJIP45.lscl2tb552AISA11202A', 'TJIP45.lscl2tbAIA-10505-1', 'TJIP45.lscl2tbAIA-10505-2']
      const seriesData = [
        {
          name: this.seriesName,
          type: 'line',
          stack: '总量',
          data: this.seriesData
        },
        legend: {
          data: ['邮件营销', '联盟广告', '视频广告', '直接访问', '搜索引擎']
        {
          name: 'TJIP45.lscl2tb552AISA11201B',
          type: 'line',
          stack: '总量',
          data: [2.20, 1.82, 1.91, 2.34, 2.90, 3.30, 3.10]
        }
      ]
      const option = {
        title: {
          // text: '实时数据',
          target: 'blank',
          left: '5%',
          textStyle: {
            color: '#fff',
            fontSize: 15,
            bottom: 20
          }
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross',
            label: {
              color: '#1a4245'
            }
          }
          // formatter: function (params) {
          //   // console.log(params)
          //   var UnionTagCode = params[0].seriesName + '<br />'
          //   for (var i = 0; i < params.length; i++) {
          //     var seriesName = params[i].seriesName
          //     // 值
          //     var value = params[i].value[1]
          //
          //     // var valueFliter = formatter(value)
          //     var valueFliter = value
          //
          //     var maker = params[i].marker
          //     var colo = ''
          //     switch (seriesName) {
          //       case 'TJIP45.lscl2tb552AI10710':
          //         colo = '#fff21c'
          //         break
          //       default:
          //         colo = 'red'
          //         break
          //     }
          //     maker = '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:' + colo + ';"></span>'
          //     UnionTagCode += maker + seriesName + ':' + valueFliter + '<br />'
          //   }
          //   return UnionTagCode
          // }
        },
        grid: {
          containLabel: false
          top: '20%'
        },
        toolbox: {
          show: false,
          feature: {
            saveAsImage: {
              show: false
            }
            saveAsImage: {}
          }
        },
        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
          }
        }],
        legend: {
          data: legendData,
          textStyle: {
            color: '#ffffff',
            fontSize: 12
          }
        },
        xAxis: {
          type: 'category',
          // type: 'time',
          boundaryGap: false,
          axisLabel: {
            margin: 6,
            interval: 0,
            textStyle: {
              color: '#fff'
            }
          },
          splitLine: {
            show: true,
            lineStyle: {
              type: 'dashed'
            }
          },
          axisTick: {
            show: false
          },
          // data: this.seriesData,
          data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
          axisLine: {
            lineStyle: {
              color: '#FFFFFF',
              // width: 1
              show: false
              width: 1
            }
          }
          },
          data: xAxisData
        },
        yAxis: {
        yAxis: [{
          type: 'value',
          boundaryGap: [0, '100%'],
          name: 'yname',
          // max: function (value) {
          //   var 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
          //   }); //排序
          //   var 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'
            }
          },
          splitLine: {
            show: false
          }, // y轴 网格线不显示,
          axisLine: {
            lineStyle: {
              color: '#FFFFFF',
              width: 1
            }
          }
        },
        series: [
          {
            name: '模拟数据',
            type: 'line',
            // showSymbol: false,
            // hoverAnimation: false,
            data: this.seriesData
        }, {
          type: 'value',
          name: 'dataUnit',
          axisLabel: {
            formatter: '{value}',
            textStyle: {
              color: '#fff'
            }
          },
          {
            name: '联盟广告',
            type: 'line',
            stack: '总量',
            data: [220, 182, 191, 234, 290, 330, 310]
          splitLine: {
            show: false
          },
          {
            name: '视频广告',
            type: 'line',
            stack: '总量',
            data: [150, 232, 201, 154, 190, 330, 410]
          },
          {
            name: '直接访问',
            type: 'line',
            stack: '总量',
            data: [320, 332, 301, 334, 390, 330, 320]
          },
          {
            name: '搜索引擎',
            type: 'line',
            stack: '总量',
            data: [820, 932, 901, 934, 1290, 1330, 1320]
          axisLine: {
            lineStyle: {
              color: '#FFFFFF',
              width: 1
            }
          }
        ]
        }],
        series: seriesData
      }
      this.myChart.setOption(option)
    },
    async echartsData () {
      const addDays = dayjs().add(300, 'day')
      const data = {
        $tagCodeList: 'TJIP45.yyqAI90305,TJIP45.yyqAI90303,TJIP45.yyqFI_90310N,TJIP45.yyqAI90304,TJIP45.yyqAIR001',
        $startTime: this.dayjs,
        $endTime: addDays,
        $step: 15
      }
      const result = await mapApi.DataItems(data)
      this.result = result.data
      for (let i = 0; i < result.length; i++) {
        //   // console.log(result[i])
        // const seriesData = []
        const aseries = []
        // let nameData = ''
        this.seriesData.push(result[i].ReadTime)
        aseries.push(result[i].TagValue)
        // nameData = result[i].UnionTagCode
        this.aseries = result[i].UnionTagCode
      }
      this.myChart.setOption({
        series: [{
          data: this.seriesData
        }]
      })
    },
    // 数据的请求
    requestEcharts () {
      setInterval(async () => {
        const addDays = dayjs().add(300, 'day')
        const data = {
          $tagCodeList: 'TJIP45.yyqAI90305,TJIP45.yyqAI90303,TJIP45.yyqFI_90310N,TJIP45.yyqAI90304,TJIP45.yyqAIR001',
          $startTime: this.dayjs,
          $endTime: addDays,
          $step: 15
        }
        const result = await mapApi.DataItems(data)
        this.result = result.data
        for (let i = 0; i < result.length; i++) {
          //   // console.log(result[i])
          // const seriesData = []
          const aseries = []
          // let nameData = ''
          this.seriesData.push(result[i].ReadTime)
          aseries.push(result[i].TagValue)
          // nameData = result[i].UnionTagCode
          this.aseries = result[i].UnionTagCode
        }
        this.myChart.setOption({
          series: [{
            data: this.seriesData
          }]
        })
      }, 3000)
    }
  },
  mounted () {
    this.$nextTick(() => {
      this.requestEcharts()
      this.drawChart()
      this.echartsData()
    })
  }
}
</script>
<style scoped lang="less">
.Infomation {
  margin-left: 10px;
  height: 0.2rem;
}
.el-tag {
  height: 25px;
  width: 140px;
  line-height: 25px;
  margin-right: 10px;
  font-size: 10px;
  background-color: rgba(0, 255, 246, 0.14);
  color: #00d0f9;
  border: none;
  padding: 0 15px;
}
.form-echrts {
  width: 100%;
  height: 1rem;
  border-top: 1px solid #396d83;
  //margin: 10px 10px 10px 10px;
  .el-dialog-div {
    //height: 50vh!important;
    overflow: auto;
    //overflow: hidden;
  }
  #echarts {
    margin: 0;
    padding: 0;
    //height: 3rem;
    //border: 1px solid #396d83;
    //margin: 10px 10px 10px 10px;
  }
}
</style>
src/components/BaseNav/PublicBounced/GasComponents/PublicChart.vue
@@ -5,7 +5,7 @@
        <div class="border_corner border_corner_left_bottom"></div>
        <div class="border_corner border_corner_right_bottom"></div>
        <ul class="tab">
            <li @click='tabTaggle("ECharts")'>实时数据</li>
            <li @click='tabTaggle("Echarts")'>实时数据</li>
            <li @click='tabTaggle("EChartsHour")'>小时数据</li>
            <li @click='tabTaggle("EChartsDate")'>日数据</li>
            <li @click='tabTaggle("ECharts")'>人工数据</li>
src/components/BaseNav/PublicBounced/PublicBounced.vue
@@ -1,7 +1,6 @@
<template>
  <div class="public-bounced map-background" v-drag v-if="flag">
    <!--    <Echarts></Echarts>-->
    <div class="public-bounced-title panel-title">
    <div class="public-bounced-title panel-title" ref="publicBounced">
      <span>{{ displayContentTitle }}</span>
      <i class="el-icon-circle-close" @click="closePopup"></i>
    </div>
@@ -16,7 +15,7 @@
                        :value="value"
                        :getQueryOnlineMonData="getQueryOnlineMonData"
                        :getWasteWaterMonitoringDetails='getWasteWaterMonitoringDetails'
>
          >
          </public-chart>
        </div>
      </div>
@@ -29,9 +28,7 @@
<script>
// import Echarts from '@components/BaseNav/PublicBounced/GasComponents/Echarts'
import '@/components/BaseNav/SolidWaste/directive/dir'
import '@/utils/dragBoxes'
import PublicTabs from '@components/BaseNav/PublicBounced/GasComponents/PublicTabs'
import PublicTable from '@components/BaseNav/PublicBounced/GasComponents/PublicTable'
import PublicVideo from '@components/BaseNav/PublicBounced/GasComponents/PublicVideo'
@@ -60,6 +57,11 @@
      getQueryOnlineMonData: []
      // getGasQueryOnlineMonData: []
    }
  },
  mounted () {
    this.$nextTick(() => {
      console.log(this.$refs.publicBounced)
    })
  },
  methods: {
    closePopup () {
@@ -107,6 +109,7 @@
  left: 20%;
  .public-bounced-title {
    cursor: move;
    height: 0.1rem;
    padding: 10px 0;
    display: flex;
@@ -120,14 +123,15 @@
    }
    i {
        color: #C0C4CC;
        margin: 0 15px;
        font-size: 22px;
        cursor: pointer;
      color: #C0C4CC;
      margin: 0 15px;
      font-size: 22px;
      cursor: pointer;
    }
      i:hover{
          color: #00fff6;
      }
    i:hover {
      color: #00fff6;
    }
  }
  .public-bounced-content {
src/components/BaseNav/SolidWaste/directive/dir.js
@@ -1,45 +1,31 @@
import Vue from 'vue'
// 使用Vue.directive()定义一个全局指令
// 1.参数一:指令的名称,定义时指令前面不需要写v-
// 2.参数二:是一个对象,该对象中有相关的操作函数
// 3.在调用的时候必须写v-
const drag = Vue.directive('drag', {
  // 1.指令绑定到元素上回立刻执行bind函数,只执行一次
  // 2.每个函数中第一个参数永远是el,表示绑定指令的元素,el参数是原生js对象
  // 3.通过el.focus()是无法获取焦点的,因为只有插入DOM后才生效
  bind: function (el) {
    el.style.cursor = 'move' // 鼠标样式变move样式
  },
  // inserted表示一个元素,插入到DOM中会执行inserted函数,只触发一次
  inserted: function (el) {
    el.onmousedown = function (e) {
  bind (el, binding, vnode, oldVnode) {
    const dialogHeaderEl = el.querySelector('.public-bounced-title')
    dialogHeaderEl.onmousedown = function (e) {
      var distX = e.pageX - el.offsetLeft
      var distY = e.pageY - el.offsetTop
      // console.log('元素本身的高:' + el.clientHeight + ',元素本身的宽:' + el.clientWidth)
      if (e.preventDefault) {
        e.preventDefault()
      } else {
        e.returnValue = false
      }
      // 解决快速拖动滞后问题
      document.onmousemove = function (e) {
        // 用鼠标的位置减去鼠标相对元素的位置,得到元素的位置
        let left = e.clientX - distX
        let top = e.clientY - distY
        if (left <= 0) {
          left = 5 // 设置成5是为了不离边缘太近
        } else if (left > document.documentElement.clientWidth - el.clientWidth) {
          // document.documentElement.clientWidth 屏幕的可视宽度
          left = document.documentElement.clientWidth - el.clientWidth - 5
          left = 5
        } else if (left > document.documentElement.clientWidth - dialogHeaderEl.clientWidth) {
          left = document.documentElement.clientWidth - dialogHeaderEl.clientWidth - 5
        }
        if (top <= 0) {
          top = 5
        } else if (top > document.documentElement.clientHeight - el.clientHeight) {
          top = document.documentElement.clientHeight - el.clientHeight - 5
        } else if (top > document.documentElement.clientHeight - dialogHeaderEl.clientHeight) {
          top = document.documentElement.clientHeight - dialogHeaderEl.clientHeight - 5
        }
        el.style.left = left + 'px'
        el.style.top = top + 'px'
      }
@@ -47,9 +33,6 @@
        document.onmousemove = document.onmouseup = null
      }
    }
  },
  // 当VNode更新的时候会执行updated,可以触发多次
  updated: function (el) {
  }
})
export default drag
src/utils/dragBoxes.js
New file
@@ -0,0 +1,39 @@
/* eslint */
import Vue from 'vue'
const drag = Vue.directive('drag', {
  bind (el, binding, vnode, oldVnode) {
    const dialogHeaderEl = el.querySelector('.public-bounced-title')
    dialogHeaderEl.onmousedown = function (e) {
      var distX = e.pageX - el.offsetLeft
      var distY = e.pageY - el.offsetTop
      if (e.preventDefault) {
        e.preventDefault()
      } else {
        e.returnValue = false
      }
      document.onmousemove = function (e) {
        let left = e.clientX - distX
        let top = e.clientY - distY
        if (left <= 0) {
          left = 5
        } else if (left > document.documentElement.clientWidth - dialogHeaderEl.clientWidth) {
          left = document.documentElement.clientWidth - dialogHeaderEl.clientWidth - 5
        }
        if (top <= 0) {
          top = 5
        } else if (top > document.documentElement.clientHeight - dialogHeaderEl.clientHeight) {
          top = document.documentElement.clientHeight - dialogHeaderEl.clientHeight - 5
        }
        el.style.left = left + 'px'
        el.style.top = top + 'px'
      }
      document.onmouseup = function () {
        document.onmousemove = document.onmouseup = null
      }
    }
  }
})
export default drag