enterprise_detail_frm.html 16.6 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="../../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;">{{ groupInfo | storeNameFilter }}</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">在线: {{ groupInfo.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">离线: {{ groupInfo.count - groupInfo.online_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 && 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,
          that;
      apiready = function(){
        api.parseTapmode();
        $(function() {
          FastClick.attach(document.body);
        });

        //---------初始化vue
        vm = new Vue({
          el: '#app',
          data: {
            groupInfo: api.pageParam.groupInfo,
            queryParam: {
              limit: 10000,
              page: 1,
              userId: api.getPrefs({sync: true,key: 'userID'}),
              parentId: api.pageParam.groupInfo.parentId,
            },
            token: api.getPrefs({sync: true,key: 'userToken'}),
            user_id: api.getPrefs({sync: true,key: 'userID'}),
            bind_list: {
              user_id: api.getPrefs({sync: true,key: 'userID'}),
              group_id: '',
              params: {},
              type: "",
              limit: 10,
              page: 1,
              imei: "",
              dtu_imei: "",
            },
            bind_list_data: [],
            userType: Number(api.getPrefs({sync: true,key: 'userType'})),
          },
           mounted() {
          },
          filters: {
            storeNameFilter(row) {
              if (row.name === "") {
                return "暂未命名"
              }else {
                return row.name
              }
            },
            locationFiltter(str) {
              if (str === null || str === '') {
                return '未知'
              }else {
                return str
              }
            }
          },
          created() {
            that = this
            api.setRefreshHeaderInfo({
              bgColor: '#F4F6F9',
              textColor: 'rgba(55,57,78,1)',
              textDown: '下拉刷新设备列表...',
              textUp: '松开刷新...'
            }, function(ret, err) {
              that.initDeviceList(true)
            });
            api.addEventListener({
              name:'scrolltobottom',
              extra:{
                  threshold:0            //设置距离底部多少距离时触发,默认值为0,数字类型
              }
            }, function(ret, err){
              that.initDeviceList(false)
            });
            this.initDeviceList(true)
          },
          methods: {
            async initDeviceList(bol) {
              if (bol) {
                this.hasNext = true
                this.bind_list.page = 1
                this.bind_list_data = []
                this.updateGroupInfo()
              }else {
                if (this.hasNext) {
                  this.bind_list.page += 1
                }else {
                  api.toast({msg: '暂无更多数据!',duration: 2000,location: 'bottom'});
                  api.hideProgress();
                  return;
                }
              }
              api.showProgress({
                  style: 'default',
                  animationType: 'fade',
                  title: '加载中...',
                  text: '',
                  modal: false
              });
              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.group_id = this.groupInfo.id
              let bind_list_data_ = await get_enterprise_group_store(this.bind_list)
              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') {
                    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 = {}
                  // 05001没有storetype
                  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 (d.store.storeType.id != '05001') {
                      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_
                    //---
                  }
                  this.bind_list_data.push(normalInfos)
                }
              });
              this.hasNext = bind_list_data_.data.next
              console.log(JSON.stringify(bind_list_data_.data));
              api.hideProgress();
              api.refreshHeaderLoadDone();
            },
            async updateGroupInfo() {
              let dataRes = await get_enterprise_tree_single_node(this.queryParam, this.token)
              if (dataRes.code === 0) {
                let handleList = dataRes.data.list.rows
                if (handleList.length > 0) {
                  handleList.forEach(list => {
                    if (list.id === this.groupInfo.id) {
                      this.groupInfo = list
                    }
                  });
                }else {
                  api.toast({msg: '暂无更多数据!',duration: 2000,location: 'bottom'});
                  return;
                }
              }
            },
            openDeviceDetailAlert(row) {
              if (row.storeType === '05001') {
                api.openWin({
                  name: 'dtu_list_win',
                  url: './dtu_list_win.html',
                  bounces: false,
                  pageParam: {row : row}
                });
              }else {
                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>