<!--
  @description: 供应商订单明细统计表
  @Modifier: haoFx
  @routerPath: /statisticalManagement/supplierOrderDetailReport-list
  @date: 2021-05-24-17:18
-->
<template>
  <table-crud
    :menu="true"
    :search-form="searchForm"
    search-label-width="100px"
    @on-load="loadData"
  >
    <template v-slot:header>
      供应商订单明细统计表
    </template>
    <template v-slot:search="search">
      <el-form-item label="订单生成时间" prop="submitDate">
        <el-date-picker
          v-model="searchForm.submitDate"
          type="daterange"
          start-placeholder="开始时间"
          end-placeholder="结束时间"
          @change="(val) => {handleCreateTime(val, 'supplierSubmitTimeStart', 'supplierSubmitTimeEnd');}"
        />
      </el-form-item>
    </template>
    <template slot="menuLeft">
      <div class="mb10">
        <el-button type="primary" @click="exportAll">
          导出
        </el-button>
      </div>
    </template>
    <template v-slot:GXTable>
      <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=""
          label="订单生成时间"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop=""
          label="订单号"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="businessType"
          label="业务类型"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop=""
          label="是否框架协议"
          min-width="170"
          align="center"
        />
        <el-table-column
          header-align="center"
          prop=""
          label="采购方式"
          min-width="170"
        />
        <el-table-column
          header-align="center"
          prop=""
          label="物资编号"
          min-width="170"
          align="center"
        />
        <el-table-column
          header-align="center"
          prop=""
          label="供应商专业分类"
          min-width="150"
          align="center"
        />
        <el-table-column
          header-align="center"
          prop=""
          label="物料分类"
          min-width="150"
          align="center"
        />
        <el-table-column
          header-align="center"
          prop=""
          label="长文本"
          min-width="150"
          align="center"
        />
        <el-table-column
          header-align="center"
          prop=""
          label="库存地点"
          min-width="150"
          align="center"
        />
        <el-table-column
          header-align="center"
          prop=""
          label="采购组织"
          min-width="150"
          align="center"
        />
        <el-table-column
          header-align="center"
          prop=""
          label="单价（不含税）"
          min-width="150"
          align="center"
        />
        <el-table-column
          header-align="center"
          prop=""
          label="采购订单数量"
          min-width="150"
          align="center"
        />
        <el-table-column
          header-align="center"
          prop=""
          label="总金额"
          min-width="150"
          align="center"
        />
        <el-table-column
          header-align="center"
          prop=""
          label="供应商sap编号"
          min-width="150"
          align="center"
        />
        <el-table-column
          header-align="center"
          prop=""
          label="供应商名称"
          min-width="150"
          align="center"
        />
        <el-table-column
          header-align="center"
          prop=""
          label="采购计划编号"
          min-width="150"
          align="center"
        />
        <el-table-column
          header-align="center"
          prop=""
          label="供应商类别"
          min-width="150"
          align="center"
        />
      </el-table>
    </template>
  </table-crud>
</template>
<script>
/* 接口*/
import { getProcurementSupplierAuditStatistics, downProcurementSupplierAuditStatistics } from '@api/procurement/statisticalManagement'
import { statisticalMixins } from '../../mixins/statisticalMixins'// 字典信息
import { download } from '@/assets/js/utils'// 常用方法
export default {
  name: 'PurchaseOrderList',
  mixins: [statisticalMixins],
  data() {
    return {
      loading: true,
      // 搜索
      searchForm: {
        supplierName: '', // 供应商名称
        supplierType: '', // 供应商类型
        businessType: '', // 业务类型
        supplierManager: '', // 供应商管理员
        submitDate: [], // 供应商提交时间
        supplierSubmitTimeStart: '', // 供应商提交时间-开始
        supplierSubmitTimeEnd: '', // 供应商提交时间-结束
        passDate: [], // 审批完成时间
        supplierPassTimeStart: '', // 审批完成时间-开始
        supplierPassTimeEnd: '', // 审批完成时间-结束
        managerPassDate: [], // 供应商管理员通过时间
        supplierManagerPassTimeStart: '', // 供应商管理员通过时间-开始
        supplierManagerPassTimeEnd: '' // 供应商管理员通过时间-结束
      },
      tableData: [],
      queryObj: {}
    }
  },
  created() {
  },
  methods: {
    // 导出
    exportAll() {
      if (this.tableData.length <= 0) {
        this.$message.warning('没有可导出的数据')
        return false
      } else {
        downProcurementSupplierAuditStatistics(this.queryObj).then((res) => {
          download(res, '供应商审批报表.xls')
        })
      }
    },
    // 获取数据
    loadData(params, callback) {
      delete params.submitDate
      delete params.passDate
      delete params.managerPassDate
      this.queryObj = params
      getProcurementSupplierAuditStatistics(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        callback(response.data.total)
      }).catch(() => {
        this.loading = false
      })
    },
    // 处理搜索时间格式
    handleCreateTime(val, start, end) {
      if (val) {
        this.searchForm[start] = this.$Moment(val[0]).format(this.momentDate) // 开始时间
        this.searchForm[end] = this.$Moment(val[1]).format(this.momentDate) // 结束时间
      }
    }
  }
}
</script>

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

