<template>
  <div class="form-wrap">
    <div class="page-title">搜索条件</div>
    <el-form
      ref="form"
      :model="form"
      :inline="true"
      label-width="150px">
      <el-form-item
        label="购票起始时间"
        prop="startDate">
        <el-date-picker
          v-model="form.startDate"
          type="datetime"
          placeholder="选择日期时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item
        label="购票截止时间"
        prop="endDate">
        <el-date-picker
          v-model="form.endDate"
          type="datetime"
          placeholder="选择日期时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item
        label="检票起始时间"
        prop="keyWords1">
        <el-date-picker
          v-model="form.keyWords1"
          type="datetime"
          placeholder="选择日期时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item
        label="检票截止时间"
        prop="keyWords2">
        <el-date-picker
          v-model="form.keyWords2"
          type="datetime"
          placeholder="选择日期时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item
        label="分销商名称"
        prop="keyWords3">
        <el-input v-model="form.keyWords3"></el-input>
      </el-form-item>
      <el-form-item
        label="票种"
        prop="keyWords4">
        <el-select
          v-model="form.keyWords4"
          placeholder="请选择">
          <el-option
            label="全部"
            value="">
          </el-option>
          <el-option
            v-for="item in ticketTypeList"
            :key="item.id"
            :label="item.name"
            :value="item.ticketTypeId">
          </el-option>
        </el-select>
      </el-form-item>
    </el-form>
    <div class="btn-wrap">
      <el-button
        type="primary"
        @click="getData">搜索</el-button>
    </div>
    <div
      class="page-title"
      style="margin-top:30px">
      查询信息
    </div>
    <el-table :data="tableData">
      <el-table-column
        prop="otaSourceName"
        label="分销商">
      </el-table-column>
      <el-table-column
        prop="ticketTypeName"
        label="商品名">
      </el-table-column>
      <el-table-column
        prop="price"
        label="单价">
      </el-table-column>
      <el-table-column
        prop="saleNum"
        label="门票总数">
      </el-table-column>
      <el-table-column
        prop="salePrice"
        label="门票总额">
      </el-table-column>
      <el-table-column
        prop="wait_count"
        label="待检数量">
      </el-table-column>
      <el-table-column
        prop="wait_price"
        label="待检金额">
      </el-table-column>
      <el-table-column
        prop="cancelNum"
        label="退票数量">
      </el-table-column>
      <el-table-column
        prop="cancelPrice"
        label="退票金额">
      </el-table-column>
      <el-table-column
        prop="check_count"
        label="已检数量">
      </el-table-column>
      <el-table-column
        prop="check_price"
        label="已检金额">
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
// import { getSaleStatistics } from '@/api/statistics'
import { getTicketTypeList } from '@/api/ticketType'
import { getSaleStatistics } from '@/api/queryReport'
import moment from 'moment'
export default {
  data () {
    return {
      ticketTypeList: [],
      form: {
        startDate: new Date(moment().subtract(1, 'months').format('YYYY-MM-DD') + ' 00:00:00'),
        endDate: new Date(moment().format('YYYY-MM-DD') + ' 23:59:59'),
        keyWords1: '', // 检票起始时间
        keyWords2: '', // 检票截止时间
        keyWords3: '', // 分销商名称
        keyWords4: '' // 票种名称
      },
      tableData: []
    }
  },
  created () {
    this.getTicketTypeList().then(() => {
      this.getData()
    })
  },
  methods: {
    // 获取票种列表
    getTicketTypeList () {
      return getTicketTypeList({
        pageNum: 1,
        pageSize: 999
      }).then(res => {
        this.ticketTypeList = res.list
      })
    },
    getData () {
      getSaleStatistics(this.form).then(res => {
        this.tableData = res.data
      })
    }
  }
}
</script>

<style scoped>

</style>
