<!--
  @description: 报表统计-采购单位计划完成率TOP
  @Modifier：肖文龙/杨胜国
  @routerPath:
  @date：  2021/01/29
-->
<template>
  <dl
    class="reportChart_crud"
  >
    <dt>
      本年采购单位计划完成情况
    </dt>
    <dd>
      <tableChart
        :height="height"
        class="echart-dom"
        :option="option"
      />
    </dd>
    <!-- 报表统计-采购单位计划完成率TOP-更多弹框 -->
    <buyerAndPlanCompletionRateList ref="moreSupplyList" />
  </dl>
</template>

<script>
/* api */
import { getPurchaserPlanCompletionRateList } from '@api/statisticalAnalysis/reportChart.js'
/* 組件 */
import tableChart from './../../components/tableChart'// table列表渲染组件
import buyerAndPlanCompletionRateList from './buyerAndPlanCompletionRateList-dialog' // 采购单位计划完成率TOP-更多弹框
export default {
  name: 'BuyerAndPlanCompletionRateTOP',
  components: {
    tableChart, // table列表渲染组件
    buyerAndPlanCompletionRateList // 采购单位计划完成率TOP-更多弹框
  },
  props: {
    height: {
      type: String,
      default: '100%'
    }
  },
  data() {
    return {
      // 查询条件
      searchData: {
      },
      option: {
        // 底部-操作类
        footer: [
          {
            text: '更多',
            click: this.more
          }
        ],
        // 标题
        thead: [
          { lable: '采购单位名称', prop: 'purchaserName', align: 'left' },
          { lable: '计划数（个）', prop: 'planNumbers', align: 'center' },
          { lable: '完成数（个）', prop: 'planCompleteNumbers', align: 'center' },
          { lable: '完成率（%）', prop: 'planCompleteRate', align: 'center' }
        ],
        // 渲染数据
        data: []
      }
    }
  },
  methods: {
    /**
     * 获取数据
     *  @param {searchData} Object 查询条件
    */
    initChart(searchData) {
      this.option.data = []
      const data = {
        ...searchData
      }
      getPurchaserPlanCompletionRateList(data).then(res => {
        this.option.data.push(...res.data.records)
      })
    },
    // 更多
    more() {
      this.$refs.moreSupplyList.open(this.searchData)
    }
  }
}
</script>
<style lang="less" scoped>
</style>
