<template>
  <div class="app-container group-container">
    <div class="header-container">
      <div class="flex-box part-header">
        <img class="header-logo" :src="details && details.logoUrl || require('@/assets/images/detail/company_logo.png')">
        {{details.companyName || '--'}}
      </div>
    </div>
    <div class="flex-box group-main" ref="contentData">
      <div class="group-left">
        <side-bar ref="sidebar" :statisticObj="statisticObj" @currentPath="showPartPage" :pathName="currentPath.pathName" :customerId="customerId"/>
      </div>
      <div class="group-right">
        <div class="data-list" v-if="currentPath.pathName=='members'">
          <div class="list">
            <div class="item" v-for="(item,index) in detailsList" :class="{'color': color === index}" @click="clickItem(item,index)">
              <img class="logo" :src="item.logoUrl || require('@/assets/images/detail/company_logo.png')" />
              <div style="float: left">
                <h3>{{item.companyName}}</h3>
                <p>集团成员：{{item.combineMemberNum}}</p>
                <p>集团本身：
                  <el-tooltip effect="dark" :content="item.combineMemberName" placement="bottom-start"><span>{{ item.combineMemberName }}</span></el-tooltip></p>
              </div>
            </div>
          </div>
        </div>
        <div id="groupBox" v-if="id">
          <Members v-if="currentPath.pathName=='members'" @handle-scroll="scrollToTop" :customerId="id" :isSkeleton="isSkeleton" :combineName="name"/>
          <Qualifications v-if="currentPath.pathName=='qualifications'" @handle-scroll="scrollToTop" :customer-id="id" :isSkeleton="isSkeleton" :combineName="name"/>
          <Landtransaction v-if="currentPath.pathName=='landtransaction'" @handle-scroll="scrollToTop" :customer-id="id" :isSkeleton="isSkeleton" :combineName="name"/>
          <Performance v-if="currentPath.pathName=='performance'" @handle-scroll="scrollToTop" :customer-id="id" :isSkeleton="isSkeleton"  :combineName="name"/>
          <Zhaobiao v-if="currentPath.pathName=='zhaobiao'" @handle-scroll="scrollToTop" :customer-id="id" :isSkeleton="isSkeleton"  :combineName="name"/>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import { idRemark } from '@/api/common'
  import SideBar from "./component/Sidebar"
  import Members from "./component/members"
  import Qualifications from "./component/qualifications"
  import Landtransaction from "./component/landtransaction"
  import Performance from "./component/performance"
  import Zhaobiao from "./component/zhaobiao"
  import { infoHeader } from '@/api/detail/party-a/index'
  import {combineMemberLogo,infoMemberCount} from '@/api/detail/groupAccount/groupAccount'
  export default {
    name: 'GroupAccount',
    components:{
      SideBar,Members,Qualifications,Landtransaction,Performance,Zhaobiao
    },
    data(){
      return{
        customerId: '',  //集团Id（测试默认'81de7ca2a967d91c2afad9cb5fc30e6d'）
        companyInfo: {},
        statisticObj: {},
        cooDetail: {},
        currentPath: {
          pathName: 'members'  //默认展示页
        },
        isCompany: false,
        isSkeleton: false,
        name:'',
        id:'',
        details:{},
        detailsList:[],
        color:0
      }
    },
    created() {
      if (this.$route.params.id) { // customerId
        this.customerId = this.$route.params.id
      }
      combineMemberLogo({combineId: this.customerId}).then(res=>{
        this.detailsList=res.data;
        this.details=res.data[0];
        this.name=this.$route.query.name ? this.$route.query.name : this.details.companyName
        this.id = this.$route.params.id
      })
      infoMemberCount({combineId: this.customerId}).then(res=>{
        if(res.code==200){
          this.statisticObj = res.data
        }
      })
      // if (this.$route.query.path) { // 获取跳转对应板块
      //   this.currentPath.pathName = this.$route.query.path
      // }

    },
    mounted(){},
    methods: {
      clickItem(item,index){
        this.color=index;
        this.combineId=item.combineId
        this.id=item.combineId
        this.name=item.combineName
      },
      showPartPage(e){
        this.currentPath = e;
        this.color=0;
        this.combineId=this.details.combineId
        this.id=this.details.combineId
        this.name=this.details.combineName
      },
      scrollToTop() {
        this.$nextTick(() => {
          this.$refs.contentData.scrollTop = 0
        })
      },
    }
  }
</script>

<style lang="scss" scoped>
  .group-container{
    padding: 0;
    margin-top: 0;
    margin-bottom: 0;
  }
  .group-main{
    margin-top: 12px;
    /*position: fixed;*/
    width: 100%;
    /*width: calc(100% - 192px);*/
    height: calc(100vh - 155px);
    overflow-y: auto;
    align-items: initial;
  }
  .group-left{
    margin-right: 16px;
    padding-bottom: 16px;
    position: fixed;
    background: #FFFFFF;
    width: 144px;
  }
  .group-right{
    min-width: 1088px;
    /*width: calc(100% - 162px);*/
    width: 100%;
    background: #FFFFFF;
    border-radius: 4px;
    margin-left: 160px;
    .data-list{
      margin: 16px;
      overflow-x: auto;
      white-space: nowrap;
      .item{
        width: 283px;
        height: 88px;
        border-radius: 4px;
        margin-right: 16px;
        display: inline-block;
        border: 1px solid #EFEFEF;
        padding: 12px;
        cursor: pointer;
        .logo{
          width: 64px;
          height: 64px;
          border-radius: 2px;
          float: left;
          margin-right: 12px;
        }
        h3{
          font-size: 16px;
          font-weight: normal;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          width: 178px;
          margin: 0;
        }
        p{
          font-size: 12px;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          width: 178px;
          margin-top: 6px;
          margin-bottom: 0;
        }
      }
      .color{
        background: #0081FF;
        color:#fff;
      }
    }

    ::v-deep .el-table__header-wrapper{
      position: sticky;
      top:0;
      z-index: 9;
    }
    #groupBox{
      height: 100%;
    }
  }
  .part-header{
    font-size: 16px;
    font-weight: bold;
    color: #232323;
    background: #FFFFFF;
    padding: 14px 16px;
    margin-top: 12px;
    border-radius: 4px;
    .header-logo{
      width: 28px;
      height: 28px;
      margin-right: 16px;
    }
  }
</style>
