my_enterprise_win.html 14.7 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>我的单位_win</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;
          height: 100%;
          width: 100%;
        }
        .el-collapse-item__wrap{
          height: auto;
        }
        /* .collapse-top{
          margin-right: 15px;
        } */
        .panel-bg {
          margin-right: 0px;
          margin-left: 0px;
          margin-top: 0px;
          border-radius:0px;
        }
        .el-collapse-item__content{
          padding-bottom:5px;
        }
        .collapse-item-top {
          margin-top: 10px;
        }

        .group-panel {
          margin-top: 0.1rem;
          margin-left: 15px;
          margin-right: 15px;
          margin-bottom: 0.1rem;  
          height: auto;
        }
        
      </style>
      <style scoped>
          .el-collapse-item__arrow.is-active {
              transform: rotate(90deg);
              font-size: 20px;
          }
          .el-collapse-item__arrow, .el-tabs__nav {
              transform: rotate(0deg);
              border: none;
              box-shadow:0px 0px 0px 0px #FFFFFF;
          }
          /* .el-collapse-item__arrow1, .el-tabs__nav1 {
              transform: rotate(0deg);
              font-size: 0px;
          } */
      </style>
  </head>
  <body>
    <div id="root">
      <template>
        <!-- <children-item v-for="item in groupList" :key="item.id" :todo="item"></children-item> -->
        <div v-if="groupList.length >= 0">
          <div v-for="(info1,i1) in groupList"><!-- 第一层列表 -->
            <el-collapse > 
              <el-collapse-item v-if="info1.hasChildren" class="store01001-operate-info-panel collapse-item-top el-collapse-item__arrow1"><!-- 有子节点的第一层下拉列表 -->
                <template slot="title">
                  <span class="group-list-panel-title" style="padding-left: .9375rem;">{{ info1.name | projectNameFilter }}</span>
                </template>
                <!-- start 上一层的item中写入这一层的list -->
                <div class="store01001-operate-info-pan  el panel-bg" v-for="(info2, i2) in info1.children"> <!-- 第二层列表 -->
                  <el-collapse v-model="info2.id" @change="changeCollapse">
                    <el-collapse-item v-if="info2.hasChildren" > <!-- 有子节点的第二层下拉列表 -->
                      <template slot="title">
                        <div style="margin-left: .9375rem;">
                          <img v-if="info2.openList" src="../../image/icon-arrow-view.png" style="height: 14px;float: left;margin-top: 17px;" /><!-- ../../image/icon-arrow-view.png -->
                          <img v-if="!info2.openList" src="../../image/icon-arrow-hidden.png" style="height: 14px;float: left;margin-top: 17px;" /><!-- ../../image/icon-arrow-view.png -->
                          <span class="group-list-panel-title" >&nbsp;{{ info2.name }}</span>

                          <!-- <el-row>
                            <el-col :span=3>
                            </el-col>
                            <el-col :span=21>
                            </el-col>
                          </el-row> -->
                        </div>
                      </template>
                      <div class="store01001-operate-info-panel panel-bg" v-for="(info3, i3) in info2.children"> <!-- 第三层列表 -->
                        <el-collapse>
                          <el-collapse-item v-if="info3.hasChildren"> <!-- 有子节点的第三层下拉列表 -->
                            <template slot="title">
                              <span class="group-list-panel-title" style="padding-left: .9375rem;">{{ info3.name }}</span>
                            </template>
                          </el-collapse-item>
                          <div  class="group-panel" v-else>
                            <div class="group-list-panel" tapmode @click="chooseToHandle(info3)">
                              <div class="group-list-inside-panel">
                                <el-row>
                                  <el-col :span=12>
                                    <span class="group-list-panel-title">{{ info3.name }}</span>
                                  </el-col>
                                  <el-col :span=11>
                                    <div class="group-list-panel-subtitle">{{ info3.count }}个设备</div>
                                  </el-col>
                                  <el-col :span=1>
                                    <i class="aui-iconfont aui-icon-right"></i>
                                  </el-col>
                                </el-row>
                                <div class="group-list-line"></div>
                                <el-row style="padding-bottom: 10px;">
                                  <el-col :span=1>
                                    <img src="../../image/icon_badgeDot_green.png" style="height: 6px;" />
                                  </el-col>
                                  <el-col :span=6><span class="group-normal-span">在线: {{ info3.online_count }}</span></el-col>
                                  <el-col :span=2>&nbsp;</el-col>
                                  <el-col :span=1>
                                    <img src="../../image/icon_badgeDot_red.png" style="height: 6px;" />
                                  </el-col>
                                  <el-col :span=6><span class="group-normal-span">离线: {{ info3.count - info3.online_count }}</span></el-col>
                                </el-row>
                              </div>
                            </div>
                          </div>
                        </el-collapse>
                      </div>
                    </el-collapse-item>
                    <div  class="group-panel" v-else>
                      <div class="group-list-panel" tapmode @click="chooseToHandle(info2)">
                        <div class="group-list-inside-panel">
                          <el-row>
                            <el-col :span=12>
                              <span class="group-list-panel-title">{{ info2.name }}</span>
                            </el-col>
                            <el-col :span=11>
                              <div class="group-list-panel-subtitle">{{ info2.count }}个设备</div>
                            </el-col>
                            <el-col :span=1>
                              <i class="aui-iconfont aui-icon-right"></i>
                            </el-col>
                          </el-row>
                          <div class="group-list-line"></div>
                          <el-row style="padding-bottom: 10px;">
                            <el-col :span=1>
                              <img src="../../image/icon_badgeDot_green.png" style="height: 6px;" />
                            </el-col>
                            <el-col :span=6><span class="group-normal-span">在线: {{ info2.online_count }}</span></el-col>
                            <el-col :span=2>&nbsp;</el-col>
                            <el-col :span=1>
                              <img src="../../image/icon_badgeDot_red.png" style="height: 6px;" />
                            </el-col>
                            <el-col :span=6><span class="group-normal-span">离线: {{ info2.count - info2.online_count }}</span></el-col>
                          </el-row>
                        </div>
                      </div>
                    </div>
                  </el-collapse>
                </div>
                <!-- end -->
              </el-collapse-item>
              <div  class="group-panel" v-else>
                <div class="group-list-panel" tapmode @click="chooseToHandle(info1)">
                  <div class="group-list-inside-panel">
                    <el-row>
                      <el-col :span=12>
                        <span class="group-list-panel-title">{{ info1.name }}</span>
                      </el-col>
                      <el-col :span=11>
                        <div class="group-list-panel-subtitle">{{ info1.count }}个设备</div>
                      </el-col>
                      <el-col :span=1>
                        <i class="aui-iconfont aui-icon-right"></i>
                      </el-col>
                    </el-row>
                    <div class="group-list-line"></div>
                    <el-row style="padding-bottom: 10px;">
                      <el-col :span=1>
                        <img src="../../image/icon_badgeDot_green.png" style="height: 6px;" />
                      </el-col>
                      <el-col :span=6><span class="group-normal-span">在线: {{ info1.online_count }}</span></el-col>
                      <el-col :span=2>&nbsp;</el-col>
                      <el-col :span=1>
                        <img src="../../image/icon_badgeDot_red.png" style="height: 6px;" />
                      </el-col>
                      <el-col :span=6><span class="group-normal-span">离线: {{ info1.count - info1.online_count }}</span></el-col>
                    </el-row>
                  </div>
                </div>
              </div>
              <div style="height: 10px;"></div>
            </el-collapse>
          </div>
        </div>
        <div v-if="groupList.length === 0">
          <div class="no-list-data" style="top: 2rem;bottom: 13rem;">
            <img src="../../image/img-unit-null.png" />
          </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(){
      $(function() {
        FastClick.attach(document.body);
      }); 
      vm = new Vue({
        el: '#root',
        data: {
          userId: api.getPrefs({sync: true,key: 'userID'}),
          token: api.getPrefs({sync: true,key: 'userToken'}),
          userType: Number(api.getPrefs({sync: true,key: 'userType'})),
          groupList: [],
          queryParam: {
            limit: 10,
            page: 1,
            userId: api.getPrefs({sync: true,key: 'userID'}),
            parentId: 9999,
          },
          hasNext: true,
        },
        created() {
          that = this
          api.setRefreshHeaderInfo({
            bgColor: '#F4F6F9',
            textColor: 'rgba(55,57,78,1)',
            textDown: '下拉刷新单位项目列表...',
            textUp: '松开刷新...'
          }, function(ret, err) {
            that.initenterPriseGroups(true)//false:上拉加载 true:重新加载
          });
          api.addEventListener({
            name:'scrolltobottom',
            extra:{
                threshold:0            //设置距离底部多少距离时触发,默认值为0,数字类型
            }
          }, function(ret, err){
            that.initenterPriseGroups(false)
          });
          
          this.initenterPriseGroups(true)
        },
        filters: {
          projectNameFilter(v) {
            if (v.length > 10) {
              return v.substring(0,15) + '...'
            }
          }
        },

        methods: {
          async initenterPriseGroups(reflush) {
            if (reflush) {//重新加载 清除查询条件
              this.queryParam.page = 1
              this.groupList = []
              this.hasNext = true
            }else {//下拉加载 page+1
              if (this.hasNext) {
                this.queryParam.page += 1
              }else {
                api.toast({msg: '暂无更多数据!',duration: 2000,location: 'bottom'});
                return;
              }
            }
            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(list1 => {
                  if (list1.hasChildren) {
                    list1.children.forEach(list2 => {
                      if (list2.hasChildren) {
                        list2.openList = false
                      }
                    });
                  }
                  this.groupList.push(list1)
                });
              }
              this.hasNext = dataRes.data.next
            }
            api.refreshHeaderLoadDone();
          },
          changeCollapse(val) {
            this.groupList.forEach(list1 => {
              if (list1.hasChildren) {
                list1.children.forEach(list2 => {
                  if (typeof list2.id === 'object') {
                    if ( list2.hasChildren && list2.id[0] === val[0]) {
                      if (val.length === 1) { //折叠闭合,不进行操作
                        list2.id = val[0]
                        list2.openList = false
                      }else {
                        list2.openList = true
                      }
                    }
                  }
                });
              }
            });
          },
          chooseToHandle(info) {
            if (info.count > 0) {
              api.openWin({
                name: 'enterprise_detail_win',
                url: './enterprise_detail_win.html',
                bounces: false,
                animation: {
                      type:"movein",                //动画类型(详见动画类型常量)
                      subType:"from_right",       //动画子类型(详见动画子类型常量)
                      duration:300                //动画过渡时间,默认300毫秒
                },
                pageParam: {groupInfo : info}
              });
            }else {
              api.toast({msg: '暂无更多数据!',duration: 2000,location: 'bottom'});
            }
          }
        }
      })
    };
  </script>
</html>