<template>
  <div class="tableBox">
    <div class="title">门票检票数据</div>
    <el-table
      border
      stripe
      v-loading="loading"
      :data="CheckStatistics">
      <el-table-column
        prop="otaSourceName"
        label="订单渠道">
      </el-table-column>
      <el-table-column
        prop="ticketTypeName"
        label="票种">
      </el-table-column>
      <el-table-column
        prop="unitPrice"
        label="单价">
      </el-table-column>
      <el-table-column
        prop="checkCount"
        label="检票数量">
      </el-table-column>
      <el-table-column
        prop="checkPrice"
        label="检票金额">
      </el-table-column>
      <el-table-column
        prop="checkMarketPrice"
        label="检票市场金额">
      </el-table-column>
      <el-table-column
        prop="checkSettlementPrice"
        label="检票结算金额">
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import moment from 'moment'
import { getCheckAndPrintStatistics } from '@/api/queryReport'

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

export default {
  props: {
    dataDate: {
      type: String,
      default: 'today'
    }
  },
  data () {
    return {
      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
      getCheckAndPrintStatistics({
        checkTimeBegin: this.startDate,
        checkTimeEnd: 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>
.tableBox {
  .title {
    font-size: 16px;
    font-weight: bold;
    padding: 10px 0;
  }
}
</style>
