<template>
  <div class="app-container detail-container">
    <head-form
      title="分支机构"
      :form-data="formData"
      :query-params="queryParams"
      :total="tableDataTotal"
      :isExcel="true"
      @handle-search="handleSearch"
    />

    <tables
      :indexFixed="true"
      :tableLoading="tableLoading"
      :tableData="tableData"
      :forData="forData"
      :tableDataTotal="tableDataTotal"
      :queryParams="queryParams"
      @handle-current-change="handleCurrentChange"
    >
      <template slot="name" slot-scope="scope">
        <router-link :to="scope.row.uipId?`/enterprise/${encodeStr(scope.row.id)}`:`/company/${encodeStr(scope.row.id)}`" tag="a" class="a-link" v-if="scope.row.id&&scope.row.name " v-html="scope.row.name"></router-link>
        <div v-else v-html="scope.row.name  || '--'"></div>
        <div class="tags" v-if="scope.row.status || scope.row.biddingAnnouncement">
          <span class="tag style1" v-if="scope.row.status">{{scope.row.status}}</span>
          <span class="tag style1" v-if="scope.row.biddingCount">招标数{{scope.row.biddingCount}}</span>
        </div>
      </template>
    </tables>
  </div>
</template>

<script>
import mixin from '../mixins/mixin'
import {affiliates} from '@/api/detail/party-a/overview'
export default {
  name: 'Branch',
  props: ['companyId'],
  mixins: [mixin],
  data() {
    return {
      queryParams: {
        cid: this.companyId,
        pageNum: 1,
        pageSize: 20
      },
      forData: [
        {label: '被投资企业名称', prop: 'name', slot: true},
        {label: '负责人', prop: 'operName'},
        {label: '成立日期', prop: 'startDate'}
      ],
      formData: [
        { type: 1, fieldName: 'hasBid', value: '', placeholder: '招标公告', options: [
            {name:'不限',value:'noLimit'},
            {name:'有招标公告',value:1},
            {name:'无招标公告',value:0}
          ]
        }
      ],
      //列表
      tableLoading:false,
      tableData:[],
      tableDataTotal:0,
    }
  },
  created() {
    this.handleQuery()
  },
  methods: {
    async handleQuery(params) {
      this.tableLoading = true
      let param = params?params:this.queryParams
      if(param.hasBid=='noLimit'){
        delete param.hasBid
      }
      let res = await affiliates(param)
      this.tableLoading = false
      if(res.code==200){
        this.tableData = res.rows
      }
      this.tableDataTotal = res.total
    }
  }
}
</script>

<style lang="scss" scoped>
  .detail-container{
    margin: 0;
    padding: 16px;
    background: #FFFFFF;
    border-radius: 4px;
    .tags{
      .tag{
        display: inline-block;
        border-radius: 2px;
        padding: 1px 7px;
        margin: 4px 8px 0 0;
        &.style1{
          background: #E4F3FD;
          color: #41A1FD;
        }
      }
    }
  }
</style>
