<!--
  @description:成单时间统计表
  @Modifier: zhangyawen
  @routerPath: /statisticalManagement/completeBillTimeStatistics-list
  @date: 2021-5-21-13:58
-->
<template>
  <table-crud
    :menu="true"
    :search-form="searchForm"
    search-label-width="100px"
    :page-flag="false"
    @on-load="loadData"
  >
    <template v-slot:header>
      成单时间统计表
    </template>
    <template v-slot:search>
      <el-form-item label="统计月份" prop="statisticsYearMonth">
        <el-date-picker
          v-model="searchForm.statisticsYearMonth"
          type="month"
          placeholder="选择月"
          @change="(val) => {handleCreateTime(val, 'statisticsYearMonth');}"
        />
      </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
          header-align="center"
          prop="tenderMethod"
          label="采购方式"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="curMonthValue"
          label="当月（天）"
          width="170"
          align="right"
        >
          <template slot-scope="scope">
            <!--style="color:#31A7DA;"-->
            <span>{{ scope.row.curMonthValue }}</span>
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          prop="tongMonthRate"
          label="月度同比"
          width="170"
          align="right"
        />
        <el-table-column
          header-align="center"
          prop="huanMonthRate"
          label="月度环比"
          min-width="170"
          align="right"
        />
        <el-table-column
          header-align="center"
          prop="curYearValue"
          label="年度"
          width="170"
          align="right"
        />
        <el-table-column
          header-align="center"
          prop="yearTongRate"
          label="年度同比"
          min-width="170"
          align="right"
        />
        <el-table-column
          header-align="center"
          prop="一月"
          label="一月"
          min-width="170"
          align="right"
        />
        <el-table-column
          header-align="center"
          prop="二月"
          label="二月"
          min-width="170"
          align="right"
        />
        <el-table-column
          header-align="center"
          prop="三月"
          label="三月"
          min-width="170"
          align="right"
        />
        <el-table-column
          header-align="center"
          prop="四月"
          label="四月"
          min-width="170"
          align="right"
        />
        <el-table-column
          header-align="center"
          prop="五月"
          label="五月"
          min-width="170"
          align="right"
        />
        <el-table-column
          header-align="center"
          prop="六月"
          label="六月"
          min-width="170"
          align="right"
        />
        <el-table-column
          header-align="center"
          prop="七月"
          label="七月"
          min-width="170"
          align="right"
        />
        <el-table-column
          header-align="center"
          prop="八月"
          label="八月"
          min-width="170"
          align="right"
        />
        <el-table-column
          header-align="center"
          prop="九月"
          label="九月"
          min-width="170"
          align="right"
        />
        <el-table-column
          header-align="center"
          prop="十月"
          label="十月"
          min-width="170"
          align="right"
        />
        <el-table-column
          header-align="center"
          prop="十一月"
          label="十一月"
          min-width="170"
          align="right"
        />
        <el-table-column
          header-align="center"
          prop="十二月"
          label="十二月"
          min-width="170"
          align="right"
        />
      </el-table>
    </template>
  </table-crud>
</template>
<script>
/* api */
import { getProcurementProjectOverTimeStatistics, downProcurementProjectOverTimeStatistics } from '@/api/procurement/statisticalManagement'

// /* 公用方法*/
import { download } from '@/assets/js/utils'// 常用方法
export default {
  name: 'CompleteBillTimeStatisticsList',
  data() {
    return {
      loading: true,
      // 搜索
      searchForm: {
        statisticsYearMonth: ''// 统计月份
      },
      tableData: [],
      searchParams: {} // 参数
    }
  },
  created() {
  },
  methods: {
    // 导出
    exportAll() {
      downProcurementProjectOverTimeStatistics(this.searchParams).then(res => {
        download(res, '成单时间统计表.xls')
      })
    },
    // 获取数据
    loadData(params, callback) {
      this.searchParams = params
      delete this.searchParams.pageNo
      delete this.searchParams.pageSize
      getProcurementProjectOverTimeStatistics(this.searchParams).then(response => {
        this.loading = false
        this.tableData = response.data
      }).catch(() => {
        this.loading = false
      })
    },
    // 处理搜索时间格式
    handleCreateTime(val, start) {
      if (val) {
        this.searchForm[start] = this.$Moment(val).format(this.momentDate)
      }
    }
  }
}
</script>

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