<template>
<skeleton style="margin-left:16px;" v-if="isSkeleton"></skeleton>
  <div class="app-container detail-container" v-else>
    <head-form
      title=""
      :form-data="formData"
      :query-params="queryParams"
      :total="tableDataTotal"
    />
    <el-tabs v-model="activeName" @tab-click="handleClick" class="detail-tab">
      <el-tab-pane label="股东信息" name="first"></el-tab-pane>
      <el-tab-pane label="历史股东" :disabled="disabled" name="second"></el-tab-pane>
    </el-tabs>

    <tables
      :tableLoading="tableLoading"
      :tableData="tableData"
      :forData="forData"
      :tableDataTotal="tableDataTotal"
      :queryParams="queryParams"
      @handle-current-change="handleCurrentChange"
    >
      <template slot="stockName" slot-scope="scope">
        <router-link :to="scope.row.uipId?`/enterprise/${encodeStr(scope.row.stockId)}`:`/company/${encodeStr(scope.row.stockId)}`" tag="a" class="a-link" v-if="scope.row.stockId&&scope.row.stockName " v-html="scope.row.stockName"></router-link>
        <div v-else v-html="scope.row.stockName  || '--'"></div>
        <div class="tags" v-if="scope.row.businessStatus">
          <span class="tag" :class="labelArr.includes(scope.row.businessStatus)?'style2':'style1'" v-if="scope.row.businessStatus">{{scope.row.businessStatus}}</span>
          <span class="tag style1" v-if="scope.row.biddingCount">招标{{scope.row.biddingCount}}</span>
          <span class="tag style1" v-if="scope.row.landInfoCount">土地{{scope.row.landInfoCount}}</span>
          <span class="tag style1" v-if="scope.row.proposedProjectCount">拟建{{scope.row.proposedProjectCount}}</span>
        </div>
      </template>
      <template slot="stockPercent" slot-scope="scope">
        <span>{{scope.row.stockPercent?parseFloat(Number(scope.row.stockPercent*100).toFixed(4))+'%':'--'}}</span>
      </template>
      <template slot="shouldCapiConv" slot-scope="scope">
        <span>{{scope.row.shouldCapiConv === '0.00万元人民币'? '--':scope.row.shouldCapiConv}}</span>
      </template>
    </tables>
  </div>
</template>

<script>
import mixin from '../mixins/mixin'
import {bestStockPage} from '@/api/detail/party-a/overview'
export default {
  name: 'Holderinfo',
  props: ['companyId'],
  mixins: [mixin],
  data() {
    return {
      activeName: 'first',
      queryParams: {
        cid: this.companyId,
        isHistory: 0,
        pageNum: 1,
        pageSize: 20
      },
      forData: [
        {label: '发起人/股东', prop: 'stockName', minWidth: '230', slot: true},
        {label: '持股比例', prop: 'stockPercent', slot: true},
        {label: '认缴出资', prop: 'shouldCapiConv', slot: true},
        {label: '实缴出资额', prop: 'realCapi'},
        {label: '认缴出资日期', prop: 'conDate'},
        {label: '参股日期', prop: 'realCapiDate', width: '150'}
      ],
      formData: [],
      //列表
      tableLoading:false,
      tableData:[],
      tableDataTotal:0,
      disabled:false,
      labelArr:['失信联合惩戒企业','严重行政处罚','司法纠纷','注销', '注销企业'],
    }
  },
  created() {
    this.handleQuery();
    this.handleQuery1();
  },
  methods: {
    handleClick(){
      this.handleQuery()
    },
    async handleQuery(params) {
      this.isSkeleton = true;
      this.tableLoading = true
      let param = params?params:this.queryParams
      param.isHistory = this.activeName == 'first' ? 0 : 1
      let res = await bestStockPage(param)
      this.tableLoading = false
      if(res.code==200){
        this.isSkeleton = false;
        this.tableData = res.rows
      }
      this.tableDataTotal = res.total
    },
    async handleQuery1(params) {
      let param = params?params:this.queryParams
      param.isHistory = 1
      let res = await bestStockPage(param)
      this.tableLoading = false
      if(res.code==200){
        if(res.total<1){
          this.disabled = true
        }
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.detail-container{
  margin: 0;
  padding: 16px;
  background: #FFFFFF;
  border-radius: 4px;
  .detail-tab{
    margin: -34px 0 0 -16px;
    ::v-deep .el-tabs__nav-wrap::after{
      display: none;
    }
    ::v-deep .el-tabs__item{
      font-size: 16px;
      height: 30px;
      line-height: 30px;
      padding: 0 16px;
      &.is-active{
        font-weight: bold;
      }
    }
  }
  .tags{
    .tag{
      display: inline-block;
      border-radius: 2px;
      padding: 1px 7px;
      margin: 4px 8px 0 0;
      &.style1{
        background: #E4F3FD;
        color: #41A1FD;
      }
      &.style2{
        background: #FFF1F1;
        color: #FF3C3C;
      }
    }
  }
}
</style>
