<template>
  <div class="app-container rela-container">
    <div class="common-title">关系企业</div>
    <el-tabs v-model="activeName" @tab-click="handleQuery" class="tabpane selfTab">
      <el-tab-pane label="股东" name="first"></el-tab-pane>
      <el-tab-pane label="对外投资" name="second"></el-tab-pane>
    </el-tabs>
    <div class="table-item">
      <div class="rela-person" v-if="activeName=='first'">实际控制人：<router-link to="" tag="a" class="a-link">{{financial&&financial.actualController || '--'}}</router-link></div>
      <el-table :data="holderData" border style="width: 100%" v-if="activeName=='first'">
        <el-table-column label="序号" width="55" align="left" fixed>
          <template slot-scope="scope">{{ holderParams.pageNum * holderParams.pageSize - holderParams.pageSize + scope.$index + 1 }}</template>
        </el-table-column>
        <el-table-column prop="stockName" min-width="140" label="股东名称"></el-table-column>
        <el-table-column prop="xxx" label="持股数量（亿）"></el-table-column>
        <el-table-column prop="xxx" label="持股比例"></el-table-column>
        <el-table-column prop="xxx" label="法定代表人"></el-table-column>
        <el-table-column prop="xxx" label="成立日期"></el-table-column>
      </el-table>
      <el-table :data="shipData" border style="width: 100%" v-else>
        <el-table-column label="序号" width="55" align="left" fixed>
          <template slot-scope="scope">{{ shipParams.pageNum * shipParams.pageSize - shipParams.pageSize + scope.$index + 1 }}</template>
        </el-table-column>
        <el-table-column prop="investName" min-width="140" label="被投资企业名称">
          <template slot-scope="scope">
            <router-link to="" tag="a" class="a-link" v-if="scope.row.id&&scope.row.investName" v-html="scope.row.investName"></router-link>
            <div v-else v-html="scope.row.investName  || '--'"></div>
            <div class="tags" v-if="scope.row.businessStatus || scope.row.biddingAnnouncement">
              <span class="tag style1" v-if="scope.row.businessStatus">{{scope.row.businessStatus}}</span>
              <span class="tag style1" v-if="scope.row.biddingAnnouncement">招标数{{scope.row.biddingAnnouncement}}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="investOperName" label="法定代表人"></el-table-column>
        <el-table-column prop="investRegistCapi" label="注册资本（万元）"></el-table-column>
        <el-table-column prop="investStartDate" label="成立日期"></el-table-column>
        <el-table-column prop="stockPercentage" label="股权占比">
          <template slot-scope="scope">
            <span>{{scope.row.stockPercentage?parseFloat(Number(scope.row.stockPercentage*100).toFixed(4))+'%':'--'}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="shouldCapi" label="认缴出资额（万元）"></el-table-column>
      </el-table>
      <div class="rela-more" v-if="activeName=='second'&& shipTotal>shipParams.pageSize"><router-link to="" tag="a" class="a-link">查看更多数据 ></router-link></div>
    </div>
  </div>
</template>

<script>
import {bestStockPage, investment} from '@/api/detail/party-a/overview'
export default {
  name: 'Relationship',
  props: ['companyId', 'financial'],
  data() {
    return {
      activeName:'first',
      //表格数据
      holderData:[],
      holderParams: {
        cid: this.companyId,
        isHistory: 0,
        pageNum: 1,
        pageSize: 20
      },
      shipData:[],
      shipParams: {
        cid: this.companyId,
        pageNum: 1,
        pageSize: 10
      },
      shipTotal: 0
    }
  },
  created() {
    this.handleQuery()
  },
  mounted() {
  },
  methods: {
    async handleQuery(){
      let res = this.activeName=='first'?await bestStockPage(this.holderParams):await investment(this.shipParams)
      if(res.code==200){
        this.activeName=='first'?this.holderData = res.rows:this.shipData = res.rows
      }
      this.activeName=='second'?this.shipTotal = res.total:''
    }
  }
}
</script>

<style lang="scss" scoped>
  .rela-container{
    margin: 0;
    padding: 24px 16px;
    background: #FFFFFF;
    border-radius: 4px;
    .selfTab{
      margin: 24px 0 0 -12px;
      ::v-deep .el-tabs__nav-wrap::after{
        display: none;
      }
      ::v-deep .el-tabs__item{
        height: 30px;
        line-height: 30px;
        padding: 0 12px;
      }
    }
    .table-item{
      margin-top: 16px;
      .tags{
        .tag{
          display: inline-block;
          border-radius: 2px;
          padding: 1px 7px;
          margin: 4px 8px 0 0;
          &.style1{
            background: #E4F3FD;
            color: #41A1FD;
          }
        }
      }
      ::v-deep .el-table--border .el-table__cell{
        border-bottom: 0;
      }
    }
    .rela-person{
      width: 100%;
      height: 24px;
      line-height: 24px;
      font-size: 12px;
      color: #3D3D3D;
      padding: 0 8px;
      background: #FDF8E9;
    }
    .rela-more{
      padding-top: 16px;
      text-align: center;
    }
  }
</style>
