<template>
  <div class="table-box">
    <div class="title">门票检票数据</div>
    <el-table
      border
      stripe
      v-loading="loading"
      :data="CheckStatistics"
      :row-class-name="totalRowClassName">
      <el-table-column
        prop="otaSourceName"
        label="订单渠道">
      </el-table-column>
      <el-table-column
        prop="checkCount"
        label="张数">
      </el-table-column>
      <el-table-column
        prop="checkNum"
        label="人数">
      </el-table-column>
      <el-table-column
        prop="checkPrice"
        label="金额">
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import moment from 'moment'
import { totalRowClassName } from '@/utils'
import { apiCheckList } from '@/api/order.js'

const fmt = 'YYYY-MM-DD HH:mm:ss'

export default {
  props: {
    dataDate: {
      type: String,
      default: 'today'
    }
  },
  data () {
    return {
      totalRowClassName,
      loading: false,
      CheckStatistics: [], // 按售票渠道今日门票检票数据
      startDate: moment().startOf('day').format(fmt),
      endDate: moment().endOf('day').format(fmt)
    }
  },
  created () {
    this.getCheckStatisticsByOtaName()
  },
  methods: {
    getData () {
      switch (this.dataDate) {
        case 'yesterday':
          this.startDate = moment().subtract(1, 'days').startOf('day').format(fmt)
          this.endDate = moment().subtract(1, 'days').endOf('day').format(fmt)
          break
        case 'week':
          this.startDate = moment().subtract(7, 'days').startOf('day').format(fmt)
          this.endDate = moment().endOf('day').format(fmt)
          break
        case 'month':
          this.startDate = moment().subtract(30, 'days').startOf('day').format(fmt)
          this.endDate = moment().endOf('day').format(fmt)
          break
        default:
          this.startDate = moment().startOf('day').format(fmt)
          this.endDate = moment().endOf('day').format(fmt)
          break
      }

      this.getCheckStatisticsByOtaName()
    },
    getCheckStatisticsByOtaName () {
      this.loading = true
      apiCheckList({
        startDate: this.startDate,
        endDate: this.endDate,
        ticketTypeIdList: [], // 票种ID
        otaSourceNameList: [],
        pageNum: 1,
        pageSize: -1
      }).then(res => {
        this.CheckStatistics = res.data
        console.log('this.CheckStatistics', this.CheckStatistics)
        this.loading = false
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.table-box {
  .title {
    color: $blue;
    font-size: 16px;
    height: 40px;
    line-height: 40px;
    border-bottom: 1px solid #eee;
  }
}
</style>
