<template>
  <el-card header="最近售票记录">
    <div
      slot="header"
      class="card-title">
      <span>最近售票记录</span>

      <div>
        <!-- <el-link @click="getOrderList()">
          刷新数据
        </el-link> -->
        <el-link @click="$router.push('/queryReport/salesQuery')">
          查看更多
        </el-link>
      </div>
    </div>
    <!-- <el-table
      stripe
      border
      v-loading="loading"
      :data="tableData">
      <el-table-column
        min-width="190"
        prop="orderNo"
        label="订单号"
        fixed="left"
      >
        <template slot-scope="scope">
          {{ scope.row.orderNo }}
          <svg-icon
            v-if="scope.row.customerType"
            icon-class="you"
            style="color:red; font-size:22px" />
        </template>
      </el-table-column>
      <el-table-column
        prop="payChannel"
        label="支付方式">
      </el-table-column>
      <el-table-column
        prop="checkNum"
        label="检票人数">
      </el-table-column>
      <el-table-column
        label="门票数量">
        <template slot-scope="scope">
          {{ scope.row.tickets.length }}
        </template>
      </el-table-column>
      <el-table-column
        prop="price"
        label="总价">
      </el-table-column>
      <el-table-column
        width="80"
        label="状态"
        fixed="right"
      >
        <template slot-scope="scope">
          <el-tag :type="scope.row.status | orderStatusColor">
            {{ scope.row.status | orderStatus }}
          </el-tag>
        </template>
      </el-table-column>
    </el-table> -->
  </el-card>
</template>

<script>
import moment from 'moment'
import { apiOrderList } from '@/api/order'

export default {
  created () {
    // this.getOrderList()
  },
  data () {
    return {
      loading: false,
      tableData: [],
      form: {
        startDate: new Date(moment().startOf('day').valueOf()),
        endDate: new Date(moment().endOf('day').valueOf()),
        keyWords1: '', // 订单号
        keyWords2: '', // 游客姓名
        keyWords3: '', // 游客手机
        keyWords4: '', // 游客身份证
        keyWords5: '', // 状态
        keyWords6: '', // 1散客 2团体
        keyWords7: '', // 票号
        keyWords8: null, // 销售渠道需要传null，显示全部
        keyWords9: this.$store.getters.name, // 售票员
        keyWords10: '',
        keyWords11: '',
        keyWords12: '',
        pageNum: 1,
        pageSize: 3
      }
    }
  },
  methods: {
    getOrderList () {
      this.loading = true
      apiOrderList(this.form).then(res => {
        res.list.forEach(item => {
          item.checkNum = item.tickets.reduce((init, val) => {
            return init + val.checkNum
          }, 0)
        })
        this.tableData = res.list
      }).finally(() => {
        this.loading = false
      })
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
