<!--
  @description:集采供应商分析
  @Modifier: zhangyawen
  @routerPath: /statisticalManagement/collectiveSupplierAnalysis-list
  @date: 2021-4-20-15:07
-->
<template>
  <div>
    <table-crud
      ref="tableCrud"
      :menu="true"
      :tabs="tabsList"
      :search-form="searchForm"
      search-label-width="90px"
      :page-flag="searchForm.queryStatus==='00'||searchForm.queryStatus==='01'"
      @on-load="loadData"
    >
      <template v-slot:header>
        <span>采购方式报表</span>
      </template>
      <template v-slot:search>
        <el-form-item label="统计时间" prop="deliveryDate">
          <el-date-picker
            v-model="searchForm.deliveryDate"
            type="daterange"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            @change="(val) => {handleCreateTime(val, 'deliveryStartTime', 'deliveryEndTime');}"
          />
        </el-form-item>
      </template>
      <template v-slot:menuLeft>
        <div class="mb10">
          <el-button type="primary" @click="onExportFile">
            导出
          </el-button>
        </div>
      </template>
      <template v-slot:GXTable>
        <!-- 合格供应商认证情况 -->
        <qualifiedSupplierCertificationTableComp
          v-if="searchForm.queryStatus === '00'"
          :loading="loading"
          :table-data="tableData"
        />
        <!-- 采购方式统计与分析 -->
        <procuremenStatisticsAndAnalysisTableComp
          v-if="searchForm.queryStatus === '01'"
          :loading="loading"
          :table-data="tableData"
        />
        <!-- 关键供应商交易分析 -->
        <keySupplierTransactionsTableComp
          v-if="searchForm.queryStatus === '02'"
          :loading="loading"
          :table-data="tableData"
        />
        <!-- 主要供应商分析 -->
        <materialAndMainListTableComp
          v-if="searchForm.queryStatus === '03'"
          :loading="loading"
          :table-data="tableData"
        />
      </template>
    </table-crud>
  </div>
</template>

<script>
/* api*/
// import {
//   getPurchasePlanDetailQryList, // 查询列表数据
//   downProcurementPlanQryList, // 导出
// } from "@/api/procurement/purchasplan";
import { filterDictText } from '@/assets/js/utils' // 常用方法
/* 导出公用方法*/
// import { download } from "@/assets/js/utils"; // 常用方法
// 表格组件
import qualifiedSupplierCertificationTableComp from './qualifiedSupplierCertificationTableComp.vue'
import procuremenStatisticsAndAnalysisTableComp from './procuremenStatisticsAndAnalysisTableComp.vue'
import keySupplierTransactionsTableComp from './keySupplierTransactionsTableComp.vue'
import materialAndMainListTableComp from './materialAndMainListTableComp.vue'
export default {
  name: 'CollectiveSupplierAnalysisList',
  components: { qualifiedSupplierCertificationTableComp, procuremenStatisticsAndAnalysisTableComp, keySupplierTransactionsTableComp, materialAndMainListTableComp },

  data() {
    return {
      loading: true,
      tableData: [{ index: 1, tenderName: '100' }], // 表格数据
      searchForm: {
        purchaseName: '', // 物资名称
        purchaseCode: '', // 物资编码
        purchaseNo: '', // 行项目编号
        tenderNo: '',
        queryStatus: '00'
      },

      tabsList: [
        // 查询tabs数据
        {
          name: '合格供应商认证情况',
          index: '00'
        },
        {
          name: '采购方式统计与分析',
          index: '01'
        },
        {
          name: '关键供应商交易分析',
          index: '02'
        },
        {
          name: '主要供应商分析',
          index: '03'
        }
      ]
    }
  },
  methods: {
    filterDictText, // 字典检索
    // 数据请求
    loadData(params, callback, tabData) {
      // this.loading = true
      if (tabData) {
        params.queryStatus = tabData.index
        this.searchForm.queryStatus = tabData.index
      }
      // getPurchasePlanDetailQryList(params).then(response => {
      //   this.searchForm.column = ''
      //   this.searchForm.orderSort = ''
      //   this.loading = false
      //   this.tableData = Object.freeze(response.data.records)
      //   callback(response.data.total)
      // }).catch(() => {
      //   this.searchForm.column = ''
      //   this.searchForm.orderSort = ''
      this.loading = false
      // })
    },
    // 导出
    onExportFile() {
      // const params = {
      //   queryStatus: this.searchForm.queryStatus,
      //   ...this.searchForm
      // }
      // const that = this
      // const index = this.tabsList.findIndex((item) => this.searchForm.queryStatus === item.typecode)
      // if (this.tableData.length <= 0) {
      //   this.$message.warning('没有可导出的数据')
      //   return false
      // } else {
      //   downProcurementPlanQryList(filterObj(params)).then((res) => {
      //     download(res, `${that.tabsList[index].name}.xls`)
      //   })
      // }
    }
  }
}
</script>

<style>
</style>
