<template>
  <div>
    <h4 class="table_title">
      主要供应商分析
    </h4>
    <el-table ref="smallTable" v-loading="loading" :data="tableData">
      <el-table-column type="index" label="序号" width="60px" align="center" />
      <el-table-column
        header-align="center"
        prop="areaIndustryCompany"
        label="专业类别"
        width="170"
      />
      <el-table-column
        header-align="center"
        prop="buyersName"
        label="订单净总额（万元）"
        width="170"
        align="right"
      />
      <el-table-column
        header-align="center"
        prop="tenderNo"
        label="中选供应商总数"
        width="170"
        align="right"
      />
      <el-table-column
        header-align="center"
        prop="tenderName"
        label="其中，排名前三的供应商"
        min-width="170"
      />
      <el-table-column
        header-align="center"
        prop="tenderName"
        label="主要物资"
        min-width="170"
      />
      <el-table-column
        header-align="center"
        prop="packName"
        label="采购方式"
        min-width="170"
      />
      <el-table-column
        header-align="center"
        prop="packName"
        label="集采订单净总额（万元）"
        min-width="170"
        align="right"
      />
      <el-table-column
        header-align="center"
        prop="packName"
        label="企业性质"
        min-width="170"
      />
    </el-table>
    <h4 class="table_title">
      主要供应商交易分析
    </h4>
    <el-table ref="smallTable" v-loading="loading" :data="tableData">
      <el-table-column label="企业性质" header-align="center">
        <el-table-column
          header-align="center"
          prop="tenderName"
          label="贸易企业家数"
          min-width="170"
          align="right"
        />
        <el-table-column
          header-align="center"
          prop="packName"
          label="制造企业家数"
          min-width="170"
          align="right"
        />
      </el-table-column>
      <el-table-column label="采购方式" header-align="center">
        <el-table-column
          header-align="center"
          prop="tenderName"
          label="制造企业家数"
          min-width="170"
          align="right"
        />
        <el-table-column
          header-align="center"
          prop="packName"
          label="询价家数"
          min-width="170"
          align="right"
        />
        <el-table-column
          header-align="center"
          prop="tenderName"
          label="招标家数"
          min-width="170"
          align="right"
        />
        <el-table-column
          header-align="center"
          prop="packName"
          label="竞争性谈判家数"
          min-width="170"
          align="right"
        />
        <el-table-column
          header-align="center"
          prop="packName"
          label="单一来源家数"
          min-width="170"
          align="right"
        />
        <el-table-column
          header-align="center"
          prop="packName"
          label="框架协议家数"
          min-width="170"
          align="right"
        />
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
/* 公共方法*/
import { filterDictText, numFilter, moneyFormat } from '@/assets/js/utils' // 字典方法
export default {
  name: 'MaterialAndMainListTableComp',
  props: {
    tableData: {
      type: Array,
      default: () => []
    },
    loading: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      /* --------------字典----------------*/
      tender_methodList: [], // 采购方式
      collectionTypeList: [], // 是否集采
      purchaseUnitList: [], // 计量单位
      taxRateList: [], // 税率
      dictionaryType: ['tender_method', 'collectionType', 'purchaseUnit', 'taxRate'] // 字典请求参数
    }
  },
  created() {
    this.getGroupType() // 字典请求初始化
  },
  methods: {
    filterDictText, // 字典
    numFilter, // 金额
    moneyFormat, // 金额千分位
    // 字典请求
    getGroupType() {
      this.$store.dispatch('getGroupType', this.dictionaryType).then((data) => {
        // 遍历key存储相应的数据
        for (const key in data.bidTypeData) {
          /* 是否有数据*/
          if (data.bidTypeData[key]) {
            this[key] = data.bidTypeData[key]
          }
        }
      })
    }
  }
}
</script>

<style>
.table_title{
  text-align: center;
  margin: 0px 0 10px 0;
}
</style>
