statistic_frm.html 14.2 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">
      <title>统计分析_frm</title>
      <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
      <link rel="stylesheet" type="text/css" href="../../css/aui.css"/>
      <link rel="stylesheet" type="text/css" href="../../css/statistic/statistic.css"/>
      <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
      <style>
          html,
          body{
            background: #F4F6F9;
          }
      </style>
  </head>
  <body>
    <div class="statistic-history-panel">
      <div class="statistic-history-title">历史测量信息趋势变化</div>

      <div class="chart-panel">
        <div style="margin-left:10px;margin-right:10px;">
          <div class="wrap">
            <div class="cont">
              <div class="aui-tab state" id="tab">
                  <div class="aui-tab-item ati aui-active">电流</div>
                  <div class="aui-tab-item ati">剩余电流</div>
                  <div class="aui-tab-item ati">电压</div>
                  <div class="aui-tab-item ati">频率</div>
                  <div class="aui-tab-item ati">线缆温度</div>
                  <div class="aui-tab-item ati">内部温度</div>
              </div>
            </div>
          </div>
          <div style="height:1px;background:rgba(240,245,255,1);margin-bottom:5px;"></div>
          <div class="tab-view-list" id="echarts_view" style="height:11.5rem;">
          </div>
        </div>
      </div>

      <div class="statistic-history-title">报警及动作历史数据</div>

      <div class="btn-panel">
        <div class="info-inside-panel">
          <div class="aui-row aui-row-flex padding-top-21" tapmode onclick="todayAlarmList();">
            <div class="aui-col aui-col-span-3 aui-row-flex-start">
              <img src="../../image/statistic/statistics-icon-1.png" style="width:22px;height:22px;margin-top:0.1rem;" />
            </div>
            <div class="aui-col aui-col-span-10 aui-row-flex-start">
              <span class="measure-obj" style="margin-left:-0.4rem;">今日报警总数</span>
            </div>
            <div class="aui-col aui-col-span-9 aui-row-flex-end">
              <div class="alarm-area"><span class="count-num" id="curAlarmCount">0</span></div>
            </div>
            <div class="aui-col aui-col-span-2 aui-row-flex-end">
              <i class="aui-iconfont aui-icon-right" style="margin-top:0.2rem;"></i>
            </div>
          </div>
          <div class="panel-line margin-top-21"></div>
          <div class="aui-row aui-row-flex padding-top-21" tapmode onclick="historyAlarmChart();">
            <div class="aui-col aui-col-span-3 aui-row-flex-start">
              <img src="../../image/statistic/statistics-icon-2.png" style="width:22px;height:22px;margin-top:0.1rem;" />
            </div>
            <div class="aui-col aui-col-span-12 aui-row-flex-start">
              <span class="measure-obj" style="margin-left:-0.4rem;">历史报警数据统计分析</span>
            </div>
            <div class="aui-col aui-col-span-7 aui-row-flex-end">
            </div>
            <div class="aui-col aui-col-span-2 aui-row-flex-end">
              <i class="aui-iconfont aui-icon-right" style="margin-top:0.2rem;"></i>
            </div>
          </div>
          <div class="panel-line margin-top-21"></div>
          <div class="aui-row aui-row-flex padding-top-21" tapmode onclick="todayProtectList();">
            <div class="aui-col aui-col-span-3 aui-row-flex-start">
              <img src="../../image/statistic/statistics-icon-3.png" style="width:22px;height:22px;margin-top:0.15rem;" />
            </div>
            <div class="aui-col aui-col-span-10 aui-row-flex-start">
              <span class="measure-obj" style="margin-left:-0.4rem;">今日动作总数</span>
            </div>
            <div class="aui-col aui-col-span-9 aui-row-flex-end">
              <div class="alarm-area" id="curProtectCount">0</div>
            </div>
            <div class="aui-col aui-col-span-2 aui-row-flex-end">
              <i class="aui-iconfont aui-icon-right" style="margin-top:0.2rem;"></i>
            </div>
          </div>
          <div class="panel-line margin-top-21"></div>
          <div class="aui-row aui-row-flex padding-top-21" tapmode onclick="historyProtectChart();">
            <div class="aui-col aui-col-span-3 aui-row-flex-start">
              <img src="../../image/statistic/statistics-icon-4.png" style="width:22px;height:22px;margin-top:0.1rem;" />
            </div>
            <div class="aui-col aui-col-span-12 aui-row-flex-start">
              <span class="measure-obj" style="margin-left:-0.4rem;">历史动作数据统计分析</span>
            </div>
            <div class="aui-col aui-col-span-7 aui-row-flex-end">
            </div>
            <div class="aui-col aui-col-span-2 aui-row-flex-end">
              <i class="aui-iconfont aui-icon-right" style="margin-top:0.2rem;"></i>
            </div>
          </div>
          <div style="height:21px;"></div>
        </div>
      </div>
    </div>
    <div class="margin-top-21" style="height:1rem;"></div>
  </body>
  <script type="text/javascript" src="../../script/api.js"></script>
  <script type="text/javascript" src="../../script/common.js"></script>
  <script type="text/javascript" src="../../script/aui-tab.js" ></script>
  <script type="text/javascript" src="../../script/echarts.min.js"></script>
  <script type="text/javascript">
      var search_date = '';
      var token;
      var userId;
      var defaultImei;
      var chartTypeArr = ["current","rest_current", "voltage", "rate", "line_temp","temp1"];
      var chartTypeUnitArr = ["A", "mA", "V","Hz", "℃", "℃"];
      var chartNameArr = ["电流", "剩余电流", "电压","频率", "线缆温度", "内部温度"];

      apiready = function(){
        api.parseTapmode();
        defaultImei = $api.getStorage('defaultDevice');
        token = $api.getStorage('userToken');
        userId = $api.getStorage('userID');
        //折线图方式切换
        var tab = new auiTab({
            element:document.getElementById("tab"),
        },function(ret){
          initChart(ret.index);
        })
        if (search_date == '') {
          var curDate = new Date();
          search_date = parseTime(new Date(curDate.getTime() - 24*60*60*1000),'{y}-{m}-{d}');
          api.sendEvent({
              name: 'initSearchDate',
              extra: {
                  selectTime: search_date,
              }
          });

        }

        api.addEventListener({
            name: 'chanegSearchDate'
        }, function(ret, err){
            if( ret && ret.value.selected_time ){
              search_date = ret.value.selected_time;
              initChart(1);
            }
        });

        initChart(1);
        initCount();
      };

      function initChart(index) {  //固定按日查询
        var echartDom = document.getElementById("echarts_view");
        var chartTitle = chartNameArr[index-1]+'趋势变化图';
        var chartTypeUnit = chartTypeUnitArr[index-1];
        var chartType = chartTypeArr[index-1];
        api.ajax({
          url:HOST + '/iot_api/v1/app/chart_history?imei=' + defaultImei + '&date=' + search_date + '&type=' + chartType,
          method: 'GET',
          headers: {
            'Content-Type': 'application/json;charset=utf-8',
            'token': token
          },
        }, function(ret, err) {
          if (ret.code == 0) {
            var myChart = echarts.init(echartDom);
            var option = {
              // legend: {
              //   data: chartName
              // }
              title: {
                  left: 'center',
                  text: chartTitle,
              },
              grid: {
                 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+chartTypeUnit;
                  },
            },
              xAxis: {
                  type: 'category',
                  boundaryGap: false,
                  data: ret.data.date.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}'+chartTypeUnit,
                      textStyle: {
                        color: function (value, index) {
                            return value >= 0 ? '#818295' : 'red';
                        }
                      }
                  },
                  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',
                      // shadowBlur: 1,
                      // shadowColor: 'rgba(0, 0, 0, 0.6)',
                      // shadowOffsetX: 2,
                      // shadowOffsetY: 2
                  },

                  dataBackground:{
                      lineStyle:{
                          color:'#F0F5FF'
                      },
                      areaStyle:{
                          color:'#F0F5FF',
                          opacity:1,
                      }
                  },
                  bottom:'0%'
                },{
                    type: 'inside',//这个 dataZoom 组件是 inside 型 dataZoom 组件(能在坐标系内进行拖动,以及用滚轮(或移动触屏上的两指滑动)进行缩放)
                    xAxisIndex: 0,//控制x轴
                }
              ],
              series: [{
                  data: ret.data[chartType],
                  name:chartTitle,
                  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);
            }
          }
        });
      }

      function historyAlarmChart() {
        api.openWin({
            name: 'historyAlarmChart_win',
            url: './historyAlarmChart_win.html',
        });

      }

      function historyProtectChart() {
        api.openWin({
            name: 'historyProtectChart_win',
            url: './historyProtectChart_win.html',
        });

      }

      function initCount() {
        api.ajax({
          url:HOST + '/iot_api/v1/app/get_warning_list?page=1&limit=1000&imei=' + defaultImei + '&status=未处理&user_id=' + userId + '&date=' + parseTime(new Date(),'{y}-{m}-{d}'),
          method: 'GET',
          headers: {
            'Content-Type': 'application/json;charset=utf-8',
            'token': token
          },
        }, function(ret, err) {
          $api.html($api.byId('curAlarmCount'), ret.data.count);
        });
        api.ajax({
          url:HOST + '/iot_api/v1/app/get_action_list?page=1&limit=1000&imei=' + defaultImei + '&user_id=' + userId + '&date=' + parseTime(new Date(),'{y}-{m}-{d}'),
          method: 'GET',
          headers: {
            'Content-Type': 'application/json;charset=utf-8',
            'token': token
          },
        }, function(ret, err) {
          $api.html($api.byId('curProtectCount'), ret.data.count);
          // console.log(JSON.stringify(ret));
        });
      }

      function todayAlarmList() {
        api.openWin({
            name:  'selfAlarm_win',
            url: '../selfAlarm/selfAlarm_win.html',
            slidBackEnabled: false,
            pageParam: {
              staticToAlarm: parseTime(new Date(),'{y}-{m}-{d}')
            }
        });
      }

      function todayProtectList() {
        api.openWin({
            name:  'protect_win',
            url: '../protect/protect_win.html',
            slidBackEnabled: false,
            pageParam: {
              staticToProtect: parseTime(new Date(),'{y}-{m}-{d}')
            }
        });
      }
  </script>
  </html>