<template>
  <div class="detail-container">
    <head-form
      title="招标计划"
      :form-data="formData"
      :query-params="queryParams"
      :isExcel="true"
      @handle-search="handleSearch"
      :total="tableDataTotal"
    />

    <tables
      :indexFixed="true"
      :defaultSort="defaultSort"
      :tableLoading="tableLoading"
      :tableData="tableData"
      :forData="forData"
      :tableDataTotal="tableDataTotal"
      :queryParams="queryParams"
      @handle-current-change="handleCurrentChange"
      @sort-change="sortChange"
    >
      <template slot="projectName" slot-scope="scope">
        <router-link :to="`/radar/Bidding/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="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 {bidPlanPage,bidPlanProjectType} from '@/api/detail/party-a/opport'
export default {
  name: 'Biddingplan',
  props: ['companyId'],
  mixins: [mixin],
  components: {
  },
  data() {
    return {
      queryParams: {
        cid: this.companyId,
        sort: 3,
        pageNum: 1,
        pageSize: 20
      },
      defaultSort: {prop: 'issueTime', order: 'descending'},
      forData: [
        {label: '项目名称', prop: 'projectName', minWidth: '400', slot: true},
        {label: '发布日期', prop: 'issueTime', sortable: 'custom', descending: '3', ascending: '4', width: '120'},
        {label: '合同预估金额（万元）', prop: 'planTenderAmount', sortable: 'custom', descending: '1', ascending: '2', width: '170'},
        {label: '资金来源', prop: 'projecetCapitalSource', minWidth: '100'},
        {label: '项目地区', prop: 'province', minWidth: '110', slot: true},
        {label: '项目类型', prop: 'buildingProjectType', minWidth: '100'},
        {label: '标的物类型', prop: 'objectType', minWidth: '100'},
        {label: '预计招标日期', prop: 'planTenderDateStart', sortable: 'custom', descending: '15', ascending: '16', minWidth: '110'}
      ],
      formData: [
        { type: 4, fieldName: 'buildingProjectType', value: '', placeholder: '项目类型', options: []},
        { type: 3, fieldName: 'keys', value: '', placeholder: '输入项目名称关键词查询', options: [], width: 220}
      ],
      //列表
      tableLoading:false,
      tableData:[],
      tableDataTotal:0
    }
  },
  computed: {
  },
  created() {
    this.handleQuery()
    this.handleOption()
  },
  methods: {
    async handleOption(){
      let res = await bidPlanProjectType({cid: this.companyId})
      if(res.code==200){
        let buildingProjectType = res.data.map(item => {
          let it = {name:item.buildingProjectType+'('+item.count+')',value:item.buildingProjectType}
          return it
        })
        this.setFormData('buildingProjectType', buildingProjectType)
      }
    },
    async handleQuery(params) {
      this.tableLoading = true
      let param = params?params:this.queryParams
      let res = await bidPlanPage(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>
