<!--
  @description: 报表统计-供应商统计-中标次数TOP-更多弹框
  @Modifier: 杨胜国
  @routerPath:
  @date: 2021-03-10
-->
<template>
  <el-dialog
    v-dialogDrag
    :modal="false"
    :visible.sync="dialog"
    :close-on-click-modal="false"
    title="更多信息"
    width="840px"
  >
    <el-form ref="searchForm" :model="searchForm" inline>
      <el-form-item label="供应商名称">
        <el-input v-model="searchForm.supplierName" />
      </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>
    <tableChart
      :height="height"
      class="echart-dom"
      :option="option"
    />
    <pagination :pagination-data="paginationData" @change="loadData" />
    <!-- 报表统计-供应商统计-供应商投标项目详情 -->
    <supplierTenderDetail ref="tenderDetail" v-bind="$attrs" />
  </el-dialog>
</template>

<script>
/* eslint-disable */
/* api */
import { getProcurementSupplierMoreStatistics,downProcurementSupplierMoreStatistics } from '@/api/procurement/statisticalManagement'
/* 公用方法*/
import { filterObj, restoreInitialValue,download } from '@/assets/js/utils'// 过滤空的key
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页
/* 組件 */
import tableChart from './../../statisticalChartCommon/tableChart'// table列表渲染组件
import supplierTenderDetail from './../supplierWinBIdMoney/supplierTenderDetail-dialog.vue' // 报表统计-供应商统计-供应商投标项目详情
import pagination from '@comp/common/pagination/pagination'// 分页

export default {
  name: 'SupplierWinBIdNumberListDialog',
  components: {
    tableChart, // table列表渲染组件
    supplierTenderDetail, // 报表统计-供应商统计-供应商投标项目详情
    pagination // 分页
  },
  mixins: [ListMixin],
  data() {
    return {
      height: '450px', // 高度
      dialog: false, // 弹窗状态
      // 查询条件
      searchForm: {
        supplierName: '' // 供应商名称
      },
      option: {
        // 非TOP排序
        showIndexTOP: false,
        // 标题
        thead: [
          { lable: '供应商名称', prop: 'supplierName', align: 'left' },
          { lable: '中选次数（次）', prop: 'queryNum', align: 'center' },
          { lable: '详情',
            // 操作类
            handle: [
              {
                text: '查看',
                click: this.detail
              }
            ] }
        ],
        // 渲染数据
        data: []
      }
    }
  },
  methods: {
    /**
     * 打开弹窗
     *  @param {row} Object 供应商信息
     *  @param {searchChartData} Object 全局的查询条件
    */
    // open(searchChartData) {
    //   this.dialog = true
    //   this.searchChartData = searchChartData
    //   this.loadData()
    // },
    open() {
      this.dialog = true
      restoreInitialValue(this.searchForm)
      this.searchChartData = this.$attrs.searchdata
      this.loadData()
    },
    // 获取数据
    loadData() {
      this.option.data = []
      const data = this.getParams()
      getProcurementSupplierMoreStatistics(data).then(res => {
        this.paginationData.total = res.data.total
        this.option.data.push(...res.data.records)
      })
    },
    // 查询条件
    getParams() {
      const param = {
        ...this.searchChartData,
        ...this.searchForm,
        supplierQueryType: '02'
      }
      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()
      downProcurementSupplierMoreStatistics(data).then(res => {
        download(res, '中选次数TOP信息表.xls')
      })
    },
    // 查看
    detail(row) {
      this.$refs.tenderDetail.open(row.row,'02')
    }
  }
}
</script>

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