<template>
  <div class="client-details">
    <el-drawer
      :visible.sync="drawer"
      size="60%"
      custom-class="client-drawer"
      :with-header="false"
      @closed="cancel">
      <head-detail-form
        :title="title"
        :form-data="formData"
        :query-params="queryParams"
        :total="tableDataTotal"
        :amountTotal="amountTotal"
        @handle-search="handleSearch"
      />
      <tables
        :indexFixed="true"
        :tableLoading="tableLoading"
        :tableData="tableData"
        :forData="forData"
        :tableDataTotal="tableDataTotal"
        :queryParams="queryParams"
        @handle-current-change="handleCurrentChange"
        style="margin: 12px;"
      >
        <template slot="dealTitle" slot-scope="scope">
          <div class="flex-box">
            <img class="tip-img" src="@/assets/images/detail/ico_pdf.png" v-if="scope.row.fileUrlL" @click="handlePic(scope.row.fileUrlL)"/>
            <router-link to="" tag="a" class="a-link" v-if="scope.row.bid&&scope.row.dealTitle" v-html="scope.row.dealTitle"></router-link>
            <span v-else v-html="scope.row.dealTitle || '--'"></span>
          </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>
    </el-drawer>
  </div>
</template>

<script>
import mixin from '../../mixins/mixin'
import {bidCooperatePage} from '@/api/detail/party-a/dealings'
import HeadDetailForm from "../../component/HeadDetailForm"

export default {
  props: {
    'data': {
      type: Object,
      default: () => {
        return {}
      }
    },
    'title': {
      type: String,
      default: () => {
        return ''
      }
    }
  },
  components: {
    HeadDetailForm
  },
  mixins: [mixin],
  data() {
    return {
      drawer: false,
      queryParams: {
        tendereeId: this.data.tendereeId,
        agencyId: this.data.agencyId,
        pageNum: 1,
        pageSize: 20
      },
      formData: [
        { type: 3, fieldName: 'keys', value: '', placeholder: '输入合作项目/工程名称查询', options: []},
      ],
      forData: [
        {label: '合作项目/工程名称', prop: 'dealTitle', width: '720', slot: true},
        {label: '项目/工程金额（万元）', prop: 'projectAmount', width: '160'},
        {label: '合作时间', prop: 'issueTime', width: '100'},
        {label: '项目地区', prop: 'province', width: '160', slot: true},
        {label: '项目类型', prop: 'projectCategory', width: '130'}
      ],
      //列表
      tableLoading:false,
      tableData:[],
      tableDataTotal:0,
      amountTotal: 0
    }
  },
  created() {
    this.drawer = true
    this.handleQuery()
  },
  methods: {
    async handleQuery(params) {
      this.tableLoading = true
      let param = params?params:this.queryParams
      let res = await bidCooperatePage(param)
      this.tableLoading = false
      if(res.code==200){
        this.tableData = res.rows
      }
      this.tableDataTotal = res.total
      this.amountTotal = res.totalAmount
    },
    handlePic(url){
      window.open(url, "_blank")
    },
    cancel() {
      this.$emit('cancel')
    }
  }
}
</script>

<style lang="scss" scoped>
  .client-details {
    ::v-deep .client-drawer{
      background: #FFFFFF;
    }
  }
</style>
