group_device_info_frm.html 11.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=12>
                <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;">{{ api.pageParam.row | 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=2 :offset=1 style="margin-top: 10px;" >
                    <img src="../../image/icon_badgeDot_green.png" style="height: 6px;" />
                  </el-col>
                  <el-col :span=8><span class="group-normal-span">在线: {{ groupInfo.on_line }}</span></el-col>
                  <el-col :span=2>&nbsp;</el-col>
                  <el-col :span=2 :offset=1 style="margin-top: 10px;">
                    <img src="../../image/icon_badgeDot_red.png" style="height: 6px;" />
                  </el-col>
                  <el-col :span=8><span class="group-normal-span">离线: {{ groupInfo.off_line }}</span></el-col>
                </el-row>
              </el-col>
              <el-col :span=12 style="text-align: right;" >
                <span class="group-device-info-add-device-btn" tapmode @click="addDevice">添加设备</span>
              </el-col>
            </el-row>
            <div class="group-device-info-line"></div>
            <!-- handle.. -->
          </div>
        </div>


        <div class="device-list-outside">
          <div v-if="deviceList.length > 0" class="device-list-area">
            <div class="device-info-card" v-for="(bind_list_d, bind_list_i) in deviceList">
              <div class="device-info-card-inside" @click="openDeviceAlert(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" v-if="bind_list_d.storename === null || bind_list_d.storename === ''">&nbsp;{{ bind_list_d.imei }}</span>
                          <span class="store-name" v-else>&nbsp;{{ bind_list_d.storename }}</span>
                        </el-col>
                        <el-col :span=4>
                          <div class="device-status-online" v-if="bind_list_d.status === '1'">
                            <span>在线</span>
                          </div>
                          <div class="device-status-offline" v-if="bind_list_d.status === '0'">
                            <span>离线</span>
                          </div>
                        </el-col>
                      </el-row>
                      <el-row>
                        <el-col :span=24 style="margin-top: 0.2rem;">
                          <span class="device-code">设备编号{{ bind_list_d.imei }}</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-for="(bind_list_params_d, bind_list_params_i) in bind_list_d.Param">
                      <div  v-if="bind_list_params_d.title === '开关' && bind_list_params_d.value != ''" >
                        <el-col :span=10 class="prop-interval">
                          <span class="prop-name">开关</span>
                          <span class="prop-value gate-value" v-if="bind_list_params_d.value === 't'">合闸</span>
                          <span class="prop-value gate-value" style="color: #70C248;" v-if="bind_list_params_d.value === 'f'">分闸</span>
                        </el-col>
                        <el-col :span=2 class="prop-interval">
                          &nbsp;
                        </el-col>
                      </div>
                      <el-col v-if="bind_list_params_d.title.length <= 4 && bind_list_params_d.title != '开关'" :span=10 class="prop-interval">
                        <span class="prop-name">{{ bind_list_params_d.title }}</span>
                        <span class="prop-value">{{ bind_list_params_d.value }}{{ bind_list_params_d.unit }}</span>
                      </el-col>

                      <el-col v-if="bind_list_params_d.title.length > 4  && bind_list_params_d.title != '开关'" :span=20 class="prop-interval">
                        <span class="prop-name">{{ bind_list_params_d.title }}</span>
                        <span class="prop-value">{{ bind_list_params_d.value }}{{ bind_list_params_d.unit }}</span>
                      </el-col>
                      <el-col v-if="bind_list_params_d.title != '开关'" :span=2 class="prop-interval">
                        &nbsp;
                      </el-col>
                    </div>
                  </el-row>
              </div>
            </div>
          </div>
          <div v-if="deviceList.length === 0" class="group-panel group-manage-btn" tapmode @click="addDevice()">添加设备</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.row,
            deviceList: [],
          },
           mounted() {
            //window.chooseProduct = this.chooseProduct;
          },
          filters: {
            storeNameFilter(row) {
              if (row.group_name === "") {
                return "暂未命名"
              }else {
                return row.group_name
              }
            }
          },
          created() {
            that = this
            api.setRefreshHeaderInfo({
              bgColor: '#F4F6F9',
              textColor: 'rgba(55,57,78,1)',
              textDown: '下拉刷新设备列表...',
              textUp: '松开刷新...'
            }, function(ret, err) {
              that.initDeviceList()
            });
            api.addEventListener({
              name: 'addDeviceToGroupFinish'
            }, function(ret, err){
              api.closeWin({
                name: 'addDeviceToGroup'
              });
              that.addDevice()
              that.initDeviceList()
            });
            api.addEventListener({
              name: 'delDeviceToGroupFinish'
            }, function(ret, err){
              that.initDeviceList()
            });

            this.initDeviceList()
            // setTimeout(() => {
            //   this.addDevice()
            // }, 2000);
          },
          methods: {
            async initDeviceList() {
              let deviceListRes =await get_devices_by_group_id(this.groupInfo.id)
              console.log(JSON.stringify(deviceListRes));
              if (deviceListRes && deviceListRes.data.TotalCount > 0) {
                let normalInfos = deviceListRes.data.List
                // normalInfos.forEach(d => {
                //   let pic_url_ =  $api.getStorage(d.pic_url)
                //   if (!pic_url_) {
                //     api.imageCache({
                //         url: d.pic_url
                //     }, function(ret, err) {
                //         var url = ret.url;
                //         $api.setStorage(d.pic_url, url);
                //         d.pic_url = url
                //     });
                //   }else {
                //     d.pic_url = pic_url_
                //   }
                // });
                // console.log(JSON.stringify(normalInfos));
                this.deviceList = normalInfos
              }else {
                this.deviceList = []
              }
              api.refreshHeaderLoadDone();
            },
            addDevice() {
              api.openWin({
                name: 'addDeviceToGroup',
                url: './add_device_to_group.html',
                bounces: false,
                pageParam: {deviceList : this.deviceList,
                  groupInfo: this.groupInfo}
              });
            },
            openDeviceAlert(row) {
              row.storeType = row.type
              let paramArr = row.Param
              let arr_ = []
              paramArr.forEach(d => {
                arr_.push({name: d.title, type: d.col_name, value: d.value+d.unit })
              });
              row.indexParams = arr_
              // delete row.Param
              // delete row.type
              // console.log(JSON.stringify(row));
              this.openDeviceDetailAlert(row)
            },
            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(){
                console.log('----');
                api.closeFrame({
                 name: 'detailAlertFrm',
                });
                $("#app").unbind();
              })
            }
          }
        })
      };
  </script>
</html>