<!--
  @description: 报表统计-平台运营情况
  @Modifier：肖文龙
  @routerPath:
  @date：  2021/01/27
-->
<template>
  <div>
    <div class="reportChart-content">
      <!-- 统计分析-平台运营情况-搜索条件 -->
      <runStatisticsSearch />
      <!-- 统计分析-总汇组件 -->
      <statisticsCrud :list="crudList" />
      <el-row :gutter="crudObj.gutter" class="el-row-x-1">
        <!-- 招采地图 -->
        <el-col :span="12">
          <bidAndProcMapCard reportchart="reportChart" :height="heightData.bidAndProcMapCard_h" />
        </el-col>
        <el-col :span="12">
          <el-row class="el-row-y-2">
            <!-- 开标项目 -->
            <el-col>
              <yearBidProjectChart reportchart="reportChart" :height="heightData.yearBidProjectChart_h" />
            </el-col>
            <el-col>
              <!-- 完成项目 -->
              <el-col>
                <yearCompleteProjectChart reportchart="reportChart" :height="heightData.yearCompleteProjectChart_h" />
              </el-col>
              <el-col />
            </el-col>
          </el-row>
        </el-col>
      </el-row>
      <el-row :gutter="crudObj.gutter" class="el-row-x-1">
        <!-- 完成项目数量 -->
        <el-col :span="12">
          <completeProjectNumberChart reportchart="reportChart" :height="heightData.completeProjectNumberChart_h" />
        </el-col>
        <!-- 完成项目金额 -->
        <el-col :span="12">
          <completeProjectMoneyChart reportchart="reportChart" :height="heightData.completeProjectMoneyChart_h" />
        </el-col>
      </el-row>
      <el-row :gutter="crudObj.gutter" class="el-row-x-1">
        <!-- 项目采购方式 -->
        <el-col :span="12">
          <projectProcMethodChart reportchart="reportChart" :height="heightData.projectProcMethodChart_h" />
        </el-col>
        <el-col :span="12">
          <projectProcMoneyChart reportchart="reportChart" :height="heightData.projectProcMoneyChart_h" />
        </el-col>
      </el-row>
    </div>
  </div>
</template>
<script>
/* api */
import { getProcurementProjectInfoNumber, getSupplierStatisticInfoNumber, getExpertNumberAndSupplierNumber } from '@api/statisticalAnalysis/reportChart.js'
/* 公共方法*/
import { addChineseUnit } from '@/assets/js/utils' // 为数字加上单位：万或亿
/* 组件 */
import runStatisticsSearch from './runStatisticsSearch.vue' // 统计分析-平台运营情况-搜索条件
import statisticsCrud from './../../components/statisticsCrud.vue' // 统计分析-总汇组件
import bidAndProcMapCard from './../bidAndProcMap/bidAndProcMapCard.vue' // 招采地图
import yearBidProjectChart from './../bidProject/yearBidProjectChart.vue' // 开标项目
import yearCompleteProjectChart from './../completeProject/yearCompleteProjectChart.vue' // 完成项目
import completeProjectNumberChart from './../completeProjectNumber/completeProjectNumberChart.vue' // 完成项目数量
import completeProjectMoneyChart from './../completeProjectMoney/completeProjectMoneyChart.vue' // 完成项目金额
import projectProcMethodChart from './../projectProcMethod/projectProcMethodChart.vue' // 项目采购方式
import projectProcMoneyChart from './../projectProcMoney/projectProcMoneyChart.vue' // 项目采购金额

export default {
  inject: ['crudObj'],
  components: {
    runStatisticsSearch, // 平台运营情况-搜索条件
    statisticsCrud, // 统计分析-总汇组件
    bidAndProcMapCard, // 招采地图
    yearBidProjectChart, // 开标项目
    yearCompleteProjectChart, // 完成项目
    completeProjectNumberChart, // 完成项目数量
    completeProjectMoneyChart, // 完成项目金额
    projectProcMethodChart, // 项目采购方式
    projectProcMoneyChart // 项目采购金额
  },
  data() {
    return {
      // echarts 高度换算
      heightData: {
        search_h: '2.6875rem', // 搜索条件的高度
        statisticsCrud_h: '4.75rem', // 总汇组件高度
        h_p: '1.875rem', // 间距
        bidAndProcMapCard_h: '', // 招采地图高度
        yearBidProjectChart_h: '', // 本年度开标项目
        yearCompleteProjectChart_h: '', // 本年度完成项目
        completeProjectNumberChart_h: '', // 完成项目数量
        completeProjectMoneyChart_h: '', // 完成项目金额
        projectProcMethodChart_h: '', // 项目采购方式
        projectProcMoneyChart_h: '' // 项目采购金额
      },
      // 统计汇总
      crudList: [],
      crudInfoData: {
        projectEndedNumber: '', // 已完成项目
        transactionMoney: '', // 成交金额
        projectTotalNumber: '', // 已发布项目
        projectInProgressNumber: '', // 进行中项目
        registeredSupplierNumber: '', // 注册供应商
        qualifiedSupplierNumber: '', // 合格供应商
        expertNumber: '', // 在库专家
        buyersNumber: '' // 招标人数量
      }
    }
  },
  created() {
    this.initHeightData()// 高度计算
  },
  methods: {
    // 高度计算
    initHeightData() {
      // 招采地图高度
      if (this.crudObj.height_default) {
        this.heightData.bidAndProcMapCard_h = this.crudObj.height_default
      } else {
        this.heightData.bidAndProcMapCard_h = 'calc( ' +
        this.crudObj.height_default + ' - ' +
        this.crudObj.header_H + ' - ' +
        this.heightData.search_h + ' - ' +
        this.heightData.h_p + ' - ' +
        this.heightData.statisticsCrud_h + ')'
      }

      // 本年度开标项目
      this.heightData.yearBidProjectChart_h = `calc((${this.heightData.bidAndProcMapCard_h} - .625rem) / 2)`
      // 本年度完成项目
      this.heightData.yearCompleteProjectChart_h = this.heightData.yearBidProjectChart_h
      // 完成项目数量
      this.heightData.completeProjectNumberChart_h = this.heightData.yearBidProjectChart_h
      // 完成项目金额
      this.heightData.completeProjectMoneyChart_h = this.heightData.yearBidProjectChart_h
      // 项目采购方式
      this.heightData.projectProcMethodChart_h = this.heightData.yearBidProjectChart_h
      // 项目采购金额
      this.heightData.projectProcMoneyChart_h = this.heightData.yearBidProjectChart_h
    },
    /**
     * 获取平台运营情况信息数据
     *  @param {searchData} Object 查询条件
    */
    async initChart(searchData) {
      const data = { ...searchData }

      // 采购项目
      await getProcurementProjectInfoNumber(data).then(res => {
        this.crudInfoData.projectTotalNumber = res.data.projectTotalNumber // 已发布项目
        this.crudInfoData.projectInProgressNumber = res.data.projectInProgressNumber // 进行中项目
        this.crudInfoData.projectEndedNumber = res.data.projectEndedNumber // 已完成项目
        this.crudInfoData.transactionMoney = res.data.transactionMoney // 成交金额
      })
      // 供应商统计
      await getSupplierStatisticInfoNumber(data).then(res => {
        this.crudInfoData.registeredSupplierNumber = res.data.registeredSupplierNumber // 注册供应商
        this.crudInfoData.qualifiedSupplierNumber = res.data.qualifiedSupplierNumber // 合格供应商
      })
      // 专家库统计
      await getExpertNumberAndSupplierNumber(data).then(res => {
        this.crudInfoData.expertNumber = res.data.expertNumber // 在库专家
        this.crudInfoData.buyersNumber = res.data.buyersNumber // 招标人数量
      })
      await this.crudData(this.crudInfoData)// 统计汇总
    },
    // 统计汇总
    crudData(data) {
      this.crudList = [
        {
          name: '招标人',
          value: addChineseUnit(data.buyersNumber),
          suffix: '个',
          width: '12%',
          code: '00'
        },
        {
          name: '已发布项目',
          value: addChineseUnit(data.projectTotalNumber),
          suffix: '个',
          width: '12%',
          code: '00'
        },
        {
          name: '进行中项目',
          value: addChineseUnit(data.projectInProgressNumber),
          suffix: '个',
          width: '12.5%',
          code: '00'
        },
        {
          name: '已完成项目',
          value: addChineseUnit(data.projectEndedNumber),
          suffix: '个',
          width: '12%',
          code: '00'
        },
        {
          name: '成交金额',
          value: addChineseUnit(data.transactionMoney),
          suffix: '元',
          width: '12%',
          code: '00'
        },
        {
          name: '注册供应商',
          value: addChineseUnit(data.registeredSupplierNumber),
          suffix: '个',
          width: '12%',
          code: '00'
        }, {
          name: '合格供应商',
          value: addChineseUnit(data.qualifiedSupplierNumber),
          suffix: '个',
          width: '12%',
          code: '00'
        },
        {
          name: '专家',
          value: addChineseUnit(data.expertNumber),
          suffix: '个',
          width: '12%',
          code: '00'
        }
        // {
        //   name: '采购未执行计划',
        //   value: addChineseUnit(data.planNotExecutedNumber),
        //   suffix: '元',
        //   width: '14%',
        //   code: '00'
        // },
        // {
        //   name: '采购已执行计划',
        //   value: addChineseUnit(data.planExecutedNumber),
        //   suffix: '元',
        //   width: '14%',
        //   code: '00'
        // },
        // {
        //   name: '采购计划执行率',
        //   value: data.purchaseExecutionRate,
        //   suffix: '%',
        //   width: '13%',
        //   code: '00'
        // },
        // {
        //   name: '进行中项目,
        //   value: addChineseUnit(data.projectInProgressNumber),
        //   suffix: '个',
        //   width: '18%',
        //   code: '00'
        // },
        // // {
        // //   name: '进行中项目概算',
        // //   value: addChineseUnit(data.projectInProgressEstimateAmount),
        // //   suffix: '元',
        // //   width: '11%',
        // //   code: '00'
        // // },
        // {
        //   name: '已完成项目',
        //   value: addChineseUnit(data.projectEndedNumber),
        //   suffix: '个',
        //   width: '14%',
        //   code: '00'
        // },
        // // {
        // //   name: '已完成项目概算',
        // //   value: addChineseUnit(data.projectEndedEstimateAmount),
        // //   suffix: '元',
        // //   width: '14%',
        // //   code: '00'
        // // },
        // {
        //   name: '成交金额',
        //   value: addChineseUnit(data.dealAmount),
        //   suffix: '元',
        //   width: '14%',
        //   code: '00'
        // },
        // {
        //   name: '节资率',
        //   value: data.savingRate,
        //   suffix: '%',
        //   width: '12%',
        //   code: '00'
        // }
      ]
    }
  }
}
</script>
<style lang="less" scoped>

</style>
