index_frm.html 16.5 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>01001首页_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/home.css"/>
      <link rel="stylesheet" type="text/css" href="../../../css/element.css"/>
      <link rel="stylesheet" type="text/css" href="../../../css/style.css"/>

      <style>
        html,body{
          background: #F4F6F9;
        }
      </style>
  </head>
  <body>
    <div id="app">
      <template>
        <div class="store01001-panel-and-count">
          <div class="store01001-panel-area">
            <div class="store01001-device-name">{{ deviceName }}</div>
            <div class="store01001-device-imei">{{ deviceImei }}</div>
            <!--aui-hide-->
            <div class="store01001-status-list">
              <div class="aui-row aui-row-flex">
                  <div class="aui-col aui-col-span-7 aui-row-flex-center aui-row-flex-middle" style="height:111px;">
                    <div class="store01001-device-state">
                      <div class="store01001-cur-state-value">
                        <span v-if="deviceInfo.online">在线</span>
                        <span v-else>离线</span>
                      </div>
                      <div class="store01001-short-line"></div>
                      <div class="store01001-state-title">状态</div>
                    </div>
                  </div>
                  <div class="aui-col aui-col-span-10 aui-row-flex-center aui-row-flex-middle" style="height:111px;">
                    <img src="../../../image/top-middle.png" style="height:100%;" tapmode onclick="openHandlePage('deviceDetails')"/>
                  </div>
                  <div class="aui-col aui-col-span-7 aui-row-flex-center aui-row-flex-middle" style="height:111px;">
                    <div class="store01001-device-state">
                      <div class="store01001-cur-state-value" id="cur_state2">
                        <span v-if="deviceInfo.gate_status === '1'">合闸</span>
                        <span v-if="deviceInfo.gate_status === '0'">分闸</span>
                      </div>
                      <div class="store01001-short-line"></div>
                      <div class="store01001-state-title">开关</div>
                    </div>
                  </div>
              </div>
            </div>
            <div class="store01001-panel-count">
              <el-row>
                <!-- <el-col :span=1 style="height:72px;">&nbsp;</el-col> -->
                <div v-for="(d, i) in indexBtns">
                  <el-col :span=d.span style="height:72px;" >
                    <el-row tapmode @click.native="selectBtn(i)">
                      <el-col :span=24 style="margin-top:0.5rem;">
                        <img :src=d.img :id="'cache_btns_'+ i" style="margin: 0 auto;" />
                      </el-col>
                      <el-col :span=24>
                        <p class="store01001-btn-name">{{ d.name }}</p>
                      </el-col>
                    </el-row>
                  </el-col>
                </div>
              </el-row>    
            </div>
          </div>
        </div>
        <div class="store01001-info-title1">
          <el-row>
            <el-col :span=12 >
              <span>{{ operateTitle }}</span>
            </el-col>
            <el-col :span=12 >
              <span style="font-size:14px;float: right;">操作记录<i class="aui-iconfont aui-icon-right" @click="closeWin"></i></span>
            </el-col>
          </el-row>
          
        </div>
        <div class="operation-menu-list" >
          <el-row>
            <div v-for="(list_d, list_i) in operateList">
              <el-col :span=12 style="margin-top: 10px;">
                <div class="operation-panel" style="margin-right:5px;">
                  <div style="margin-left:15px;margin-right:15px;margin-bottom:10px;">
                    <div class="aui-row aui-row-flex">
                      <div class="aui-col aui-col-span-12 aui-row-flex-start" style="margin-top:12.5px;">
                        <img :src="list_d.url" style="height:44px;width:44px;">
                      </div>
                      <div class="aui-col aui-col-span-12 aui-row-flex-end" >
                          <div class="operation-btn" tapmode @click="deviceOperation(list_i+1 ,this, list_d.name ,'&S9+', list_d.command);"><span :id="'loading'+ (list_i+1)"> {{ list_d.name }}</span></div>
                      </div>
                    </div>
                  </div>
                </div>
              </el-col>  
            </div>
          </el-row>
        </div>      
        <div id="chart_area">
          <div class="store01001-info-title2">{{ measureTitle }}</div>
          <div class="store01001-chart-panel">
            <div style="padding-left:10px;padding-right:10px;padding-bottom:10px;">
              <div style="padding-top: 10px;" tapmode @click="showPopup">
                <span>{{ curMeasure }} &nbsp;</span><i></i>
              </div>
              <div style="height:1px;background:rgba(240,245,255,1);margin-top: 13.5px;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="../../../script/api.js"></script>
  <script type="text/javascript" src="../../../script/jquery-3.3.1.min.js"></script>
  <script type="text/javascript" src="../../../script/vue.min.js"></script>
  <script type="text/javascript" src="../../../script/common.js"></script>
  <script type="text/javascript" src="../../../script/element.js"></script>
  <script type="text/javascript" src="../../../script/ctrl.js"></script>
  <script type="text/javascript" src="../../../script/fastclick.js "></script>
  <script type="text/javascript" src="../../../script/aui-popup-wjb.js" ></script>
  <script type="text/javascript" src="../../../script/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: {
            deviceInfo: api.pageParam.deviceInfo,
            deviceImei: api.pageParam.imei,
            deviceName: filterDeviceName(api.pageParam.deviceInfo.bind.storename, api.pageParam.imei),
            indexBtns: [
            ],
            indexBtnsTemp: [
              {img: 'http://iot.uccc.cc:9090/product/01001/home_RemoteOperation_02.png', name: '设备信息', span: 5},
              {img: 'http://iot.uccc.cc:9090/product/01001/home_icon_menu05.png', name: '参数设置', span: 5},
              {img: 'http://iot.uccc.cc:9090/product/01001/home_icon_menu03.png', name: '报警信息', span: 4},
              {img: 'http://iot.uccc.cc:9090/product/01001/home_icon_menu02.png', name: '保护动作', span: 5},
              {img: 'http://iot.uccc.cc:9090/product/01001/home_icon_menu04.png', name: '统计分析', span: 5},
            ],
            operateTitle: '远程操作',
            operateList: [
              {
                name: "分闸",
                url: "http://iot.uccc.cc:9090/product/01001/lazha.png",
                command: "4"
              },
              {
                name: "自检",
                url: "http://iot.uccc.cc:9090/product/01001/home_RemoteOperation_02.png",
                command: "8"
              },
              {
                name: "复位",
                url: "http://iot.uccc.cc:9090/product/01001/home_RemoteOperation_03.png",
                command: "16"
              },
              {
                name: "消音",
                url: "http://iot.uccc.cc:9090/product/01001/home_RemoteOperation_05.png",
                command: "2"
              }
            ],  
            measureTitle: "测量信息",
            curMeasure: "电流",
            chartArr: [{text:'电流',value:'current',unit: 'A'},{text:'剩余电流',value:'rest_current',unit: 'mA'},
                       {text:'电压',value:'voltage',unit: 'V'},{text:'频率',value:'rate',unit: 'Hz'},
                       {text:'线缆温度',value:'line_temp',unit: '℃'},{text:'内部温度',value:'temp1',unit: '℃'}],
            userId: $api.getStorage('userID'),
            token: $api.getStorage('userToken'),
          },      
          mounted() {
            //window.chooseProduct = this.chooseProduct;
          },
          created() {
            this.initBtns()
            that = this
            setTimeout(() => {
              this.chooseMeasureType({buttonIndex: 1, buttonTitle: '电流', buttonValue: 'current', buttonUnit: 'A'})  
            }, 1000);

            this.selectBtn(0)
          },
          methods: {
            initBtns() {
              let btnTemp = this.indexBtnsTemp
              this.indexBtnsTemp.forEach((d, i) => {
                // 缓存图片
                let pic_url_ =  $api.getStorage(d.img)
                if (!pic_url_) {
                  api.imageCache({
                      url: d.img
                  }, function(ret, err) {
                      let url = ret.url;
                      $api.setStorage(d.img, url);
                      btnTemp[i].img = url
                  });
                }else {
                  btnTemp[i].img = pic_url_
                }
              })
              this.indexBtns = btnTemp
            },
            async chooseMeasureType(ret) {  //
              const params = {
                imei: this.deviceImei,
                token: this.token,
                chartType: ret.buttonValue
              }
              var echartDom = document.getElementById("echarts_view");
              let dailyRes = await get_daily_charts(params)
              console.log(JSON.stringify(dailyRes));
              if (dailyRes.code == 0) {
                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.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}'+ ret.buttonUnit,
                          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',
                      },
                      dataBackground:{
                          lineStyle:{
                              color:'#B0C8FF'
                          },
                          areaStyle:{
                              color:'#F0F5FF',
                              opacity:1,
                          }
                      },
                      bottom:'0%'
                    },{
                        type: 'inside',//这个 dataZoom 组件是 inside 型 dataZoom 组件(能在坐标系内进行拖动,以及用滚轮(或移动触屏上的两指滑动)进行缩放)
                        xAxisIndex: 0,//控制x轴
                    }
                  ],
                  series: [{
                      data: dailyRes.data[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);
                }
              }
            },
            showPopup() {
              popup = new auiPopup();
              popup.init({
                  frameBounces:true,//当前页面是否弹动,(主要针对安卓端)
                  location: 'bottom-right',//位置,top(默认:顶部中间),top-left top-right,bottom,bottom-left,bottom-right
                  buttons:  this.chartArr,
              },function(ret){
                  if(ret){
                    that.chooseMeasureType(ret)
                    that.curMeasure = ret.buttonTitle
                  }
              })              
            },
            //这里以后全部是配置对应的http地址...
            selectBtn(index) {
              console.log(index);
              switch (index) {
                case 0:
                  api.openWin({
                    name: 'deviceDetails_win',
                    url: './device_details_win.html',
                    bounces: true,
                    pageParam: {productId: api.pageParam.productId,
                                imei: api.pageParam.imei}
                  });
                  break;
              
                default:
                  break;
              }
            }
          }
        })
      };
  </script>
</html>