<template>
  <div class="detail-container">
    <head-form
      title="标讯Pro"
      :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="projectName" slot-scope="scope">
        <router-link :to="`/radar/bxprozbgg/details/${scope.row.id}`" tag="a" class="a-link" v-if="scope.row.id&&scope.row.projectName " v-html="scope.row.projectName"></router-link>
        <div v-else v-html="scope.row.projectName  || '--'"></div>
      </template>
      <template slot="tenderee" slot-scope="scope">
        <router-link :to="`/enterprise/${encodeStr(scope.row.tendereeId)}`" tag="a" class="a-link" v-if="scope.row.tendereeId&&scope.row.tenderee " v-html="scope.row.tenderee"></router-link>
        <div v-else v-html="scope.row.tenderee  || '--'"></div>
      </template>
      <template slot="agency" slot-scope="scope">
        <router-link :to="`/enterprise/${encodeStr(scope.row.agencyId)}`" tag="a" class="a-link" v-if="scope.row.agencyId&&scope.row.agency " v-html="scope.row.agency"></router-link>
        <div v-else v-html="scope.row.agency  || '--'"></div>
      </template>
      <template slot="province" slot-scope="scope">
        {{scope.row.province}}{{`${scope.row.city?'-'+scope.row.city:''}`}}{{`${scope.row.area?'-'+scope.row.area:''}`}}
      </template>
    </tables>

  </div>
</template>

<script>
import mixin from '../mixins/mixin'
import { bidNoticeProProjectType, bidNoticeProProjectPurposes, bidNoticeProAssessmentWay, bidNoticeProPage } from '@/api/detail/party-a/opport'
export default {
  name: 'Tencent',
  props: ['companyId'],
  mixins: [mixin],
  components: {
  },
  data() {
    return {
      queryParams: {
        cid: this.companyId,
        pageNum: 1,
        pageSize: 20
      },
      forData: [
        {label: '项目名称', prop: 'projectName', minWidth: '320', slot: true},
        {label: '金额（万元）', prop: '', children: [
          { label: '建安费暂估', prop: 'projectSafeAmount', width: '88px'},
          { label: '勘察费暂估', prop: 'projectSurveyAmount', width: '88px'},
          { label: '保证金', prop: 'projectEnsureAmount', width: '88px'}
        ]},
        {label: '招标人及联系方式', prop: '', children: [
          { label: '招标人', prop: 'tenderee', width: '88px', slot: true},
          { label: '联系人', prop: 'tendereeTel', width: '88px'}
        ]},
        {label: '代理机构及联系方式', prop: '', children: [
          { label: '代理机构', prop: 'agency', width: '88px', slot: true},
          { label: '联系人', prop: 'agencyTel', width: '88px'}
        ]},
        {label: '项目分类', prop: 'projectType', width: '130'},
        {label: '工程类别', prop: 'projectPurposes', width: '130'},
        {label: '分部分项', prop: 'projectSub', width: '130'},
        {label: '项目级别', prop: 'projectLevel', width: '130'},
        {label: '评标办法', prop: 'bidAssessmentWay', width: '130'},
        {label: '项目属地', prop: 'province', width: '130', slot: true},
        {label: '发布日期', prop: 'pubdate', width: '130'}
      ],
      formData: [
        { type: 1, fieldName: 'projectType', value: '', placeholder: '项目类别', options: []},
        { type: 1, fieldName: 'projectPurposes', value: '', placeholder: '工程类别', options: []},
        { type: 1, fieldName: 'bidAssessmentWay', value: '', placeholder: '评标办法', options: []},
        { type: 3, fieldName: 'keys', value: '', placeholder: '输入关键词查询', options: []}
      ],
      //列表
      tableLoading:false,
      tableData:[],
      tableDataTotal:0
    }
  },
  computed: {
  },
  created() {
    this.handleOption()
    this.handleQuery()
  },
  methods: {
    async handleOption(){
      let [projectType, projectPurposes, proAssessmentWay] = await Promise.all([
        bidNoticeProProjectType({cid: this.companyId}),
        bidNoticeProProjectPurposes({cid: this.companyId}),
        bidNoticeProAssessmentWay({cid: this.companyId})
      ])
      if(projectType.code==200){
        let type = projectType.data.map(item => {
          let it = {name:item.projectType+'('+item.count+')',value:item.projectType}
          return it
        })
        this.setFormData('projectType', type)
      }
      if(projectPurposes.code==200){
        let purposes = projectPurposes.data.map(item => {
          let it = {name:item.projectPurposes+'('+item.count+')',value:item.projectPurposes}
          return it
        })
        this.setFormData('projectPurposes', purposes)
      }
      if(proAssessmentWay.code==200){
        let way = proAssessmentWay.data.map(item => {
          let it = {name:item.bidAssessmentWay+'('+item.count+')',value:item.bidAssessmentWay}
          return it
        })
        this.setFormData('bidAssessmentWay', way)
      }
    },
    async handleQuery(params) {
      this.tableLoading = true
      let param = params?params:this.queryParams
      let res = await bidNoticeProPage(param)
      this.tableLoading = false
      if(res.code==200){
        this.tableData = res.rows
      }
      this.tableDataTotal = res.total
    }
  }
}
</script>
<style lang="scss" scoped>
.detail-container{
  background: #ffffff;
  border-radius: 4px;
  padding: 16px;
}
</style>
