<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"
        :flag="true"
        :form-data="formData"
        :query-params="queryParams"
        :total="tableDataTotal"
        :amountTotal="amountTotal"
        @handle-search="handleSearch"
      />
      <skeleton style="margin-left:16px;" v-if="isSkeleton"></skeleton>
      <tables
        v-else
        :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)"/>
            <div class="a-link" @click="linkTo(scope.row.bid)" v-if="scope.row.bid&&scope.row.dealTitle" v-html="scope.row.dealTitle" style="cursor: pointer"></div>
            <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"
import skeleton from '@/views/project/projectList/component/skeleton'
export default {
  props: [
    'data',
    'title'
  ],
  components: {
    HeadDetailForm,skeleton
  },
  mixins: [mixin],
  data() {
    return {
      isSkeleton:true,
      drawer: false,
      queryParams: {
        tendereeId: this.data.tendereeId,
        agencyId: this.data.agencyId,
        pageNum: 1,
        pageSize: 20
      },
      formData: [
        { type: 3, fieldName: 'keys', value: '', placeholder: '输入合作项目/工程名称查询', options: [], width: 260},
      ],
      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: {
    linkTo(id){
      this.drawer = false
      this.$router.push(`/radar/Notice/details/${id}`)
    },
    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.isSkeleton = false;
      this.tableDataTotal = res.total
      this.amountTotal = res.totalAmount
    },
    handlePic(url){
      if(url){
        window.open(url, "_blank")
      }
    },
    cancel() {
      this.$emit('cancel')
    }
  }
}
</script>

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