statistic_frm.html 12.7 KB
<!DOCTYPE html>
<html>
  <head>
      <meta charset="utf-8">
      <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
      <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
      <meta name="referrer" content="no-referrer">
      <title>统计分析_frm</title>
      <link rel="stylesheet" type="text/css" href="http://iot.uccc.cc:9090/app/css/api.css"/>
      <link rel="stylesheet" type="text/css" href="http://iot.uccc.cc:9090/app/css/aui.css"/>
      <link rel="stylesheet" type="text/css" href="http://iot.uccc.cc:9090/app/css/style.css"/>
      <link rel="stylesheet" type="text/css" href="http://iot.uccc.cc:9090/app/css/element.css"/>
      <link rel="stylesheet" type="text/css" href="http://iot.uccc.cc:9090/app/css/home.css"/>
      <style>
          html,
          body{
            background: #F4F6F9;
          }
          .el-collapse-item__wrap{
            /* background-color: aqua; */
            height: 240px; 
        } 
      </style>
  </head>
  <body>
    <div id="app">
      <template>
        <div id="chart_area">
          <div class="store01001-info-title2">{{ measureTitle }}</div>
          <div style="margin-top: 15px;margin-left: 15.5px;margin-right: 14.5px;">
            <el-collapse v-model="activeName" accordion @change="collapseChange">
              <el-collapse-item name="1">
                <template slot="title">
                  <span class="device-type-title">当前测量:{{ curMeasure }}</span>
                </template>
                <div class="aui-margin-l-15 aui-margin-r-15" v-for="(list_d, list_i) in measureList">
                  <el-divider content-position="left">{{ list_d.name }}</el-divider>
                  <div class="product-info">
                    <el-row  :gutter="10">
                      <div v-for="(measure_d, measure_i) in measureList[list_i].values">
                        <el-col :span=measure_d.span  style="margin-bottom: 10px;">
                          <span class="product-select-normal" style="height: 1.5rem;line-height: 1.5rem;font-size:0.6rem;padding-left: 0.3rem;padding-right: 0.3rem;" @click="chooseMeasureType(measure_d)">{{ measure_d.buttonTitle }}</span>
                        </el-col>
                      </div>
                    </el-row>
                  </div>
                </div>
              </el-collapse-item>
            </el-collapse>
          </div>
          <div class="store01001-chart-panel">
            <div style="padding-left:10px;padding-right:10px;padding-bottom:10px;">
              <div style="height:1px;background:rgba(240,245,255,1);margin-top: 6px;margin-bottom:5px;"></div>
              <div class="tab-view-list" id="echarts_view" style="height:11.5rem;">
              </div>
              <div style="height:10px;"></div>
            </div>
          </div>
        </div>  
          <!-- <div style="height:30px;width:auto"></div> -->
      </template>
    </div>
  </body>
  <script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/api.js"></script>
  <script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/jquery-3.3.1.min.js"></script>
  <script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/vue.min.js"></script>
  <script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/common.js"></script>
  <script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/element.js"></script>
  <script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/ctrl.js"></script>
  <script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/fastclick.js"></script>
  <script type="text/javascript" src="http://iot.uccc.cc:9090/app/js/echarts.min.js"></script>  
  <script type="text/javascript">
    var vm,
        popup,
        that;

    apiready = function(){
      api.parseTapmode();
      $(function() {
        FastClick.attach(document.body);
      }); 

      //---------初始化vue
      vm = new Vue({
        el: '#app',
        data: {
          deviceImei: api.pageParam.imei,
          userId: api.getPrefs({sync: true,key: 'userID'}),
          token: api.getPrefs({sync: true,key: 'userToken'}), 
          measureTitle: '历史测量信息趋势变化',                   
          curMeasure: '电能',
          date: parseTime((new Date()).getTime()-1000*60*60*24*1,'{y}-{m}-{d}'),
          chooseMeasure: {buttonTitle: '电能', buttonUnit: 'kWh', buttonValue: 'r_elec', span: 8},
          activeName: '',
          measureList: [
            {
              name: "测量信息",
              values: [
                {buttonTitle: '电能', buttonUnit: 'kWh', buttonValue: 'r_elec', span: 8},
                {buttonTitle: '功率', buttonUnit: 'W', buttonValue: 'r_power', span: 8},
                {buttonTitle: '已备电时长', buttonUnit: 'Min', buttonValue: 'r_standby_power_time', span: 8},
                {buttonTitle: '已备电电量', buttonUnit: 'kWh', buttonValue: 'r_reserve_power', span: 8},
                {buttonTitle: '温度', buttonUnit: '℃', buttonValue: 'r_temp_val', span: 8},
                {buttonTitle: 'DC电压', buttonUnit: 'V', buttonValue: 'r_DC_voltage', span: 8},
                {buttonTitle: 'A相交流电压值', buttonUnit: 'V', buttonValue: 'A_AC_voltage', span: 8},
                {buttonTitle: 'B相交流电压值', buttonUnit: 'V', buttonValue: 'B_AC_voltage', span: 8},
                {buttonTitle: 'C相交流电压值', buttonUnit: 'V', buttonValue: 'C_AC_voltage', span: 8},
                {buttonTitle: '直流电流有效值', buttonUnit: 'A', buttonValue: 'r_DC_effe_val', span: 9},
                {buttonTitle: '交流电压频率', buttonUnit: 'Hz', buttonValue: 'r_AC_voltage_freq', span: 8}
              ]
            },
          ],
        },
        mounted() {
          //window.chooseProduct = this.chooseProduct;
        },
        created() {
          that = this
          api.addEventListener({
            name: 'chanegSearchDate'
          }, function(ret, err){
            console.log(JSON.stringify(ret));
            that.date = ret.value.selected_time
            that.chooseMeasureType(that.chooseMeasure)
          });
          setTimeout(() => {
            this.chooseMeasureType(this.chooseMeasure)
          }, 1000);
        },
        methods: {
          collapseChange(val) {
            console.log("1111");
            if (val === '1') {
              // api.sendEvent({
              //   name: 'pageDownEvent',
              // });
              api.setFrameAttr({
                name: 'statistic_frm',
                bounces: false,
              });
            }else if (val === '') {
              api.setFrameAttr({
                name: 'statistic_frm',
                bounces: true,
              });
              this.activeName = ''
            }
          },
          async chooseMeasureType(ret) {  //
            this.collapseChange('')
            this.curMeasure = ret.buttonTitle
            const params = {
              imei: this.deviceImei,
              token: this.token,
              chartType: ret.buttonValue,
              date: this.date
            }
            console.log(JSON.stringify(params));
            
            var echartDom = document.getElementById("echarts_view");
            api.showProgress({
              style: 'default',
              animationType: 'fade',
              title: '加载中...',
              text: '',
              modal: true
            });
            let dailyRes = await get_normal_daily_chart(params)
            api.hideProgress();
            if (dailyRes.success == 1) {
                var myChart = echarts.init(echartDom);
                var option = {
                  title: {
                      left: 'center',
                      text: ret.buttonTitle+'趋势变化图',
                  },
                  grid: {
                    //  top: 50,
                     x: 45,
                     x2: 20,
                     y: 50,
                  },
                  tooltip: {
                      trigger: 'axis',
                      position: 'top',
                      formatter: function (params) {
                            params = params[0];
                            return params.axisValue+'<br />'+params.marker+params.seriesName+'值 '+params.data+ ret.buttonUnit;
                        },
                  },
                  xAxis: {
                      type: 'category',
                      boundaryGap: false,
                      data: dailyRes.data.xdata.map(function(item){
                        return item.substring(11,16)
                      }),
                      axisLine: {
                          lineStyle: {
                              color: '#B0C8FF'
                          }
                      },
                      axisLabel: {
                        textStyle: {
                          color: function (value, index) {
                              return '#818295';
                          }
                        },
                        rotate:330
                      }
                  },
                  yAxis: {
                      type: 'value',
                      boundaryGap: [0, '100%'],
                      //y轴颜色
                      axisLine: {
                         lineStyle: {
                             color: '#fff'
                         }
                      },
                      axisLabel: {
                          formatter: '{value}'+ ret.buttonUnit,
                          textStyle: {
                            color: function (value, index) {
                                return value >= 0 ? '#818295' : 'red';
                            }
                          },
                          interval: 0,//让所有坐标值全部显示
                          rotate:30,//让坐标值旋转一定的角度
                      },
                      splitLine:{
                        show:true  ,
                        lineStyle:{
                          color:'#F0F5FF',
                          width: 1
                        }
                      }
                  },
                  dataZoom: [
                    {
                      type: 'slider',
                      fillerColor: '#B0C8FF',
                      backgroundColor: '#F0F5FF',
                      start: 0,
                      end: 100,
                      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: '90%',
                      handleStyle: {
                          color: '#5B7FF8',
                      },
                      dataBackground:{
                          lineStyle:{
                              color:'#B0C8FF'
                          },
                          areaStyle:{
                              color:'#F0F5FF',
                              opacity:1,
                          }
                      },
                      bottom:'0%'
                    },{
                        type: 'inside',//这个 dataZoom 组件是 inside 型 dataZoom 组件(能在坐标系内进行拖动,以及用滚轮(或移动触屏上的两指滑动)进行缩放)
                        xAxisIndex: 0,//控制x轴
                    }
                  ],
                  series: [{
                      data: dailyRes.data.ydata[ret.buttonValue],
                      name: ret.buttonTitle,
                      type:'line',
                      showSymbol: true,
                      hoverAnimation: false,
                      symbol: 'path://M30.9,53.2C16.8,53.2,5.3,41.7,5.3,27.6S16.8,2,30.9,2C45,2,56.4,13.5,56.4,27.6S45,53.2,30.9,53.2z M30.9,3.5C17.6,3.5,6.8,14.4,6.8,27.6c0,13.3,10.8,24.1,24.101,24.1C44.2,51.7,55,40.9,55,27.6C54.9,14.4,44.1,3.5,30.9,3.5z M36.9,35.8c0,0.601-0.4,1-0.9,1h-1.3c-0.5,0-0.9-0.399-0.9-1V19.5c0-0.6,0.4-1,0.9-1H36c0.5,0,0.9,0.4,0.9,1V35.8z M27.8,35.8 c0,0.601-0.4,1-0.9,1h-1.3c-0.5,0-0.9-0.399-0.9-1V19.5c0-0.6,0.4-1,0.9-1H27c0.5,0,0.9,0.4,0.9,1L27.8,35.8L27.8,35.8z',
                      symbolSize: 8,
                      // 折线颜色
                      itemStyle: {
                       normal: {
                           color: '#5B7FF8',
                           lineStyle: {
                               color: '#5B7FF8'
                           }
                       }
                      },
                  }]
                };    
                if (option && typeof option === "object") {
                  myChart.setOption(option, true);
                }
              }
          },
        }
      })
    }
  </script>
</html>