<template>
  <div class="client-details">
    <el-drawer
      :visible.sync="drawer"
      size="40%"
      custom-class="client-drawer"
      :with-header="false"
      @closed="cancel">
      <skeleton style="margin-left:16px;" v-if="isSkeleton"></skeleton>
      <div class="head" v-if="!isSkeleton">
        <img class="tip-img" src="@/assets/images/icon.png" />
        <span>{{title}}</span>
      </div>
      <tables
        v-if="!isSkeleton"
        :tableLoading="tableLoading"
        :tableData="tableData"
        :forData="forData"
        :tableDataTotal="tableDataTotal"
        :queryParams="queryParams"
        @handle-current-change="handleCurrentChange"
        style="margin: 12px;"
      >
        <template slot="companyName" slot-scope="scope">
          <div @click="cancel">
            <router-link :to="scope.row.uipId?`/enterprise/${encodeStr(scope.row.companyId)}`:`/company/${encodeStr(scope.row.companyId)}`" tag="a" class="a-link" v-if="scope.row.companyId&&scope.row.companyName" v-html="scope.row.companyName"></router-link>
          </div>
          <!--<div v-else v-html="scope.row.companyName || '&#45;&#45;'"></div>-->
        </template>
      </tables>
    </el-drawer>
  </div>
</template>

<script>
  import mixin from '../../party-a/mixins/mixin'
  import {memberCertificateList} from '@/api/detail/groupAccount/groupAccount'

export default {
  props: [
    'data',
    'title'
  ],
  components: { },
  mixins: [mixin],
  data() {
    return {
      drawer: false,
      isSkeleton:true,
      queryParams: {
        id: this.data.id,
        pageNum: 1,
        pageSize: 10
      },
      formData: [
        { type: 3, fieldName: 'keys', value: '', placeholder: '输入项目/工程名称查询', options: []},
      ],
      forData: [
        {label: '拥有该资质成员', prop: 'companyName', slot: true},
        {label: '成员共有资质（个）', prop: 'certificateCount'},
      ],
      //列表
      tableLoading:false,
      tableData:[],
      tableDataTotal:0,
      amountTotal: 0
    }
  },
  created() {
    this.drawer = true;
    this.handleQuery()
  },
  methods: {
    async handleQuery(params) {
      this.isSkeleton = true
      let param = params?params:this.queryParams
      let res = await memberCertificateList(param)
      this.isSkeleton = false
      if(res.code==200){
        this.tableData = res.rows
      }
      this.tableDataTotal = res.total
      // this.amountTotal = res.totalAmount
    },
    handlePic(url, isPic){
      isPic ? url = 'https://imgs.jiansheku.com/'+url : ''
      if(url){
        window.open(url, "_blank")
      }
    },
    linkTo(scope){
      this.drawer = false
      this.$router.push(`/biddetail/${scope.row.id}`)
    },
    cancel() {
      this.$emit('cancel')
    }
  }
}
</script>

<style lang="scss" scoped>
  .client-details {
    ::v-deep .client-drawer{
      background: #FFFFFF;
    }
    .head{
      height: 48px;
      line-height: 48px;
      border-bottom: 1px solid #E1E1E1;
    }
    .tip-img{
      width: 17px;
      height: 17px;
      margin: 0 8px -2px 12px;
    }
  }
</style>
