dtu_list_frm.html 14.8 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>DTU设备列表详情页</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-color: #F4F6F9;
          }
      </style>
  </head>
  <body>
    <div id="app">
      <template>
        <div class="group-device-info-title">
          <div style="margin-left:15px;margin-right:15.5px;">
            <el-row>
              <el-col :span=24>
                <el-row>
                  <el-col :span=24>
                    <div class="aui-row aui-row-flex top-14">
                      <div class="aui-col aui-col-span-1">
                        <div class="store01001-title-sign"  style="margin-top: 0.6rem;"></div>
                      </div>
                      <div class="aui-col aui-col-span-15">
                        <span class="store01001-device-details-name"  style="margin-top: 0.6rem;">{{row.imei}}</span>
                      </div>
                      <div class="aui-col aui-col-span-8 aui-row-flex-end">
                      </div>
                    </div>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span=1 :offset=1 style="margin-top: 10px;" >
                    <img src="../../image/icon_badgeDot_green.png" style="height: 6px;" />
                  </el-col>
                  <el-col :span=4><span class="group-normal-span">在线: {{ online_count }}</span></el-col>
                  <el-col :span=1>&nbsp;</el-col>
                  <el-col :span=1 :offset=1 style="margin-top: 10px;">
                    <img src="../../image/icon_badgeDot_red.png" style="height: 6px;" />
                  </el-col>
                  <el-col :span=4><span class="group-normal-span">离线: {{ offline_count }}</span></el-col>
                </el-row>
              </el-col>
            </el-row>
            <div class="group-device-info-line"></div>
          </div>
          <!-- handle.. -->
          <div class="device-list-outside">
            <div v-if="bind_list_data.length > 0" class="device-list-area">
              <div class="device-info-card" v-for="(bind_list_d, bind_list_i) in bind_list_data">
                <div v-if="" class="device-info-card-inside" @click="openDeviceDetailAlert(bind_list_d)">
                    <el-row :gutter="10">
                      <el-col :span=5>
                        <div class="card-img">
                          <img :src="bind_list_d.pic_url" />
                          <!-- <span class="ms"> {{ bind_list_d.name }}</span> -->
                        </div>
                      </el-col>
                      <el-col :span=19>
                        <el-row>
                          <el-col :span=20>
                            <span class="alarm-type" style="float: left;margin-left: 0px;">&nbsp;{{ bind_list_d.name }}&nbsp;</span>
                            <span class="store-name">&nbsp;{{ bind_list_d.imei }}</span>
                            <!-- <span class="store-name" v-else>&nbsp;{{ bind_list_d.storename }}</span> -->
                          </el-col>
                          <el-col v-if="bind_list_d.name != 'TY-140'" :span=4>
                            <div class="device-status-online" v-if="bind_list_d.status">
                              <span>在线</span>
                            </div>
                            <div class="device-status-offline" v-if="!bind_list_d.status">
                              <span>离线</span>
                            </div>
                          </el-col>
                          <el-col v-else :span=4>
                            <i class="el-icon-caret-right"></i>
                          </el-col>
                        </el-row>
                        <el-row>
                          <el-col :span=24 style="margin-top: 0.2rem;">
                            <span class="device-code">位置: {{ bind_list_d.location | locationFiltter }}</span>
                          </el-col>
                        </el-row>
                      </el-col>
                    </el-row>
                    <div class="split-line-s" style="margin-top: .3rem;margin-bottom: .1rem;"></div>
                    <el-row class="prop-interval"><!--放在外围-->
                      <div v-if="bind_list_d.gate_status != null">
                        <el-col :span=12 class="prop-interval">
                          <span class="prop-name">&nbsp;&nbsp;&nbsp;开关</span>
                          <span class="prop-value gate-value" v-if="bind_list_d.gate_status">合闸</span>
                          <span class="prop-value" style="color: #70C248;" v-else>分闸</span>
                        </el-col>
                        <el-col :span=0 class="prop-interval">
                          &nbsp;
                        </el-col>
                      </div>
                      <div v-for="(bind_list_params_d, bind_list_params_i) in bind_list_data[bind_list_i].indexParams">
                        <el-col :span=12 class="prop-interval">
                          <span class="prop-name">&nbsp;&nbsp;&nbsp;{{ bind_list_params_d.name }}</span>
                          <!-- <span v-if="bind_list_params_d.name.length >= 5" @click="showDetailMeasure(bind_list_params_d.name, bind_list_params_d.value)" class="prop-name" >&nbsp;&nbsp;&nbsp;{{ bind_list_params_d.name }}</span> -->
                          <span  class="prop-value">{{ bind_list_params_d.value }}</span>
                          <!-- <span v-if="bind_list_params_d.value.length >=5" @click="showDetailMeasure(bind_list_params_d.name, bind_list_params_d.value)" class="prop-value">{{ bind_list_params_d.value }}</span> -->
                        </el-col>
                        <el-col :span=0 class="prop-interval">
                          &nbsp;
                        </el-col>
                      </div>
                    </el-row>
                </div>
              </div>
            </div>
          </div>
        </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">
      var vm;
      apiready = function(){
        api.parseTapmode();
        $(function() {
          FastClick.attach(document.body);
        }); 

        //---------初始化vue
        vm = new Vue({
          el: '#app',
          data: {
            row: api.pageParam.row,
            bind_list: {
              user_id: api.getPrefs({sync: true,key: 'userID'}),
              group_id: '',
              params: {},
              type: "",
              limit: 20,
              page: 1,
              imei: "",
              dtu_imei: "",
            },
            bind_list_data: [],
            userType: Number(api.getPrefs({sync: true,key: 'userType'})),
            online_count: 0,
            offline_count: 0,
          },
           mounted() {
            //window.chooseProduct = this.chooseProduct;
          },
          created() {
            that = this
            api.setRefreshHeaderInfo({
              bgColor: '#F4F6F9',
              textColor: 'rgba(55,57,78,1)',
              textDown: '下拉刷新设备列表...',
              textUp: '松开刷新...'
            }, function(ret, err) {
              that.initDeviceList(true)
            });
            this.initDeviceList(true)
          },
          methods: {
            async initDeviceList(bol) {
              api.showProgress({
                  style: 'default',
                  animationType: 'fade',
                  title: '加载中...',
                  text: '',
                  modal: false
              });
              if (bol) {
                this.bind_list_data = []
                this.online_count = 0
                this.offline_count = 0
              }
              var user_perference = await get_product_perference(this.user_id)
              this.userPreferenceList = user_perference.data
              for (let i = 0; i < this.userPreferenceList.length; i++) {
                const productPref = JSON.parse(this.userPreferenceList[i]);
                const prefList = []
                productPref.data_index.forEach(d => {
                  prefList.push('"'+d+'"')
                });
                eval('this.bind_list.params["' + productPref.name +'"]=[' + prefList + ']')
              }
              this.bind_list.dtu_imei = this.row.imei
              let bind_list_data_ = []
              if (this.userType === 1) {
                bind_list_data_ = await get_bind_list_data(this.bind_list)  
              }else {
                bind_list_data_ = await get_enterprise_group_store(this.bind_list)
              }
              api.hideProgress();
              api.refreshHeaderLoadDone();
              let props_ = api.getPrefs({sync: true,key: 'props'})
              let props =  eval('(' + props_ + ')');
              list_rows = bind_list_data_.data.list.rows
              list_rows.forEach(d => {
                if (d.store != null) {
                  if (d.store.storeType.id === '01001') {
                    d.type = '01001'
                    let deviceInfos = {
                      pic_url: d.store.storeType.pic_url,
                      imei: d.imei,
                      name: d.store.storeType.name,
                      storename: d.storename,
                      indexParams: [{name: "电流", type: "etc_current", value: d.store.etc_current+"A"},
                                    {name: "剩余电流", type: "etc_rest_current", value: d.store.etc_rest_current+"mA"},
                                    {name: "电压", type: "etc_voltage", value: d.store.etc_voltage+"V"},
                                    {name: "频率", type:"etc_rate", value: d.store.etc_rate+"Hz"},
                                    {name: "线缆温度", type:"etc_line_temp", value: d.store.etc_line_temp+"℃"},
                                    {name: "内部温度", type:"etc_temp1", value: d.store.etc_temp1+"℃"}],
                      status: d.online,
                    }
                    if (d.store.gate_status === "1") {
                      deviceInfos.gate_status = true
                    }else if (d.store.gate_status === "0") {
                      deviceInfos.gate_status = false
                    }else{
                      deviceInfos.gate_status = null
                    }
                    deviceInfos.storeType = '01001'
                    this.bind_list_data.push(deviceInfos)
                  }
                }
                if (d.type != '01001') {
                  var indexParams_ = []
                  var normalInfos = {}
                  if (d.type === '05001') {
                    normalInfos = {
                      pic_url: 'http://iot.uccc.cc:9090/product/05001.png',
                      imei: d.imei,
                      name: 'TY-140',
                      storename: d.imei,
                      indexParams: [],
                      // status: d.online,
                      location: d.location,
                      storeType: d.type
                    }
                  }else {
                    var json_ = eval('d.store.store' + d.store.storeType.id)

                    for(var key in json_){
                      props.forEach(p => {
                        if (d.store.storeType.id === p.type_id && key === p.col_name) {
                          var v_ = eval('d.store.store' + d.store.storeType.id + '.' + key)
                          indexParams_.push({name: p.title, type: key, value: v_ + p.unit})
                        }
                      });
                    }
                    normalInfos = {
                      pic_url: d.store.storeType.pic_url,
                      imei: d.imei,
                      name: d.store.storeType.name,
                      storename: d.storename,
                      indexParams: indexParams_,
                      status: d.online,
                      // location: d.location,
                      storeType: d.store.storeType.id
                    }
                    if (this.userType === 1) {
                      normalInfos.location = d.address
                    } else if (this.userType === 2) {
                      normalInfos.location = d.location
                    }
                    if (d.store.storeType.id != '05001' && d.store.storeType.id != '01001') {
                      const gate_status = eval('d.store.store' + d.store.storeType.id + '.switch')
                      normalInfos.gate_status = gate_status
                    }
                    //--- indexParams排序
                    var _indexParams_ = jsonSort(normalInfos.indexParams)
                    normalInfos.indexParams = _indexParams_
                    //--- 
                  }
                  if (normalInfos.status) {
                    this.online_count ++;
                  }else {
                    this.offline_count++;
                  }
                  this.bind_list_data.push(normalInfos)
                }
              });
              this.hasNext = bind_list_data_.data.next
              api.hideProgress();
              api.refreshHeaderLoadDone();
            },
            openDeviceDetailAlert(row) {
              api.openFrame({
                name: 'coverPage',
                url: '../utils/coverPage_frm.html',
                bounces: false,
                rect: {
                  x: 0,
                  y: 0,
                  w: api.winWidth,
                  h: api.winHeight
                },
                bgColor: 'rgba(0, 0, 0, 0)',
                pageParam: {
                  value: row,
                },
                reload: true,
              });

              $("#app").bind('click',function(){
                api.closeFrame({
                name: 'detailAlertFrm',
                });
                $("#app").unbind();
              })
            }
          }
        })
      };
  </script>
</html>