<!--
  @description: 报表统计-专家统计-专家出席率查看详情
  @Modifier: 杨胜国
  @routerPath:
  @date: 2021-03-15
-->
<template>
  <el-dialog
    v-dialogDrag
    :modal="false"
    :visible.sync="dialog"
    :close-on-click-modal="false"
    title="查看明细"
    width="1000px"
  >
    <section class="clearfix">
      <el-form ref="searchForm" :model="searchForm" inline>
        <el-form-item prop="tenderNo" label="项目编号">
          <el-input v-model="searchForm.tenderNo" />
        </el-form-item>
        <el-form-item class="fr">
          <el-button type="primary" round @click="search">
            查询
          </el-button>
          <el-button type="primary" round @click="resetForm('searchForm')">
            重置
          </el-button>
          <el-button type="primary" round @click="exportChange()">
            导出
          </el-button>
        </el-form-item>
      </el-form>
    </section>
    <tableChart
      :height="height"
      class="echart-dom"
      :option="option"
    />
    <pagination :pagination-data="paginationData" @change="loadData" />
  </el-dialog>
</template>

<script>
/* api */
import { listExpertAttendanceProjectPages, exportExpertAttendanceProjectPages } from '@api/statisticalAnalysis/reportChart.js' // listTenderByexpertIdPages
/* 公用方法*/
import { download, filterObj, restoreInitialValue, filterDictText } from '@/assets/js/utils'// 过滤空的key ,
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页
import { reportChartGroupMixin } from './../../mixins/reportChartGroup.js'
/* 組件 */
import tableChart from './../../components/tableChart'// table列表渲染组件
import pagination from '@comp/common/pagination/pagination'// 分页

export default {
  name: 'ExpertBePresentRateDetailDialog',
  components: {
    tableChart, // table列表渲染组件
    pagination // 分页
  },
  mixins: [ListMixin],
  data() {
    return {
      height: '450px', // 高度
      dialog: false, // 弹窗状态
      // 查询条件
      expertId: '', // 供应商id
      expertName: '', // 供应商名称
      searchForm: {
        tenderNo: '', // 项目编号
        expertId: '' // 供应商id
      },
      /* 字典信息-start */
      ...reportChartGroupMixin,
      /* 字典信息-end */
      option: {
        // 非TOP排序
        showIndexTOP: false,
        // 标题
        thead: [
          { lable: '项目编号', prop: 'tenderNo', align: 'center' },
          { lable: '采购项目名称', prop: 'tenderName', align: 'left' },
          { lable: '采购单位', prop: 'buyersName', align: 'left' },
          { lable: '采购方式', prop: 'tenderMethod', align: 'center' }
          // { lable: '开标时间', prop: 'openTime' }
        ],
        // 渲染数据
        data: []
      }
    }
  },
  methods: {
    /**
     * 打开弹窗
     *  @param {row} Object 专家信息
    */
    open(row) {
      this.dialog = true
      this.expertId = row.expertId
      this.expertName = row.expertName
      this.loadData()
    },
    // 获取数据
    loadData() {
      this.option.data = []
      const data = this.getParams()
      listExpertAttendanceProjectPages(data).then(res => {
        this.paginationData.total = res.data.total
        res.data.records.forEach(item => {
          this.option.data.push({
            ...item,
            tenderMethod: filterDictText(this.bidAndprocForMethod, item.tenderMethod)
          })
        })
      })
    },
    // 查询条件
    getParams() {
      const param = Object.assign({}, this.searchForm)
      param.expertId = this.expertId
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      return filterObj(param)// 过滤空的key
    },
    // 搜索
    search() {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      this.loadData()
    },
    // 重置
    resetForm(formName) {
      restoreInitialValue(this.searchForm)
      this.search()
    },
    // 导出
    exportChange() {
      const data = this.getParams()
      exportExpertAttendanceProjectPages(data).then(res => {
        download(res, this.expertName + '专家出席投标项目信息详情表.xls')
      })
    }
  }
}
</script>

<style scoped lang="less">
</style>
