<!--
 * @Descripttion:
 * @version:
 * @Author: kangkang
 * @Date: 2020-10-22 14:18:12
 * @LastEditors: kangkang
 * @LastEditTime: 2020-10-28 15:32:57
-->
<template>
<div style="height:95%">
  <el-date-picker
      v-model="timeSearh"
      type="daterange"
      align="right"
      unlink-panels
      size=small
      range-separator="至"
      start-placeholder="开始日期"
      end-placeholder="结束日期"
      :picker-options="pickerOptions">
    </el-date-picker>
    <el-button size=small @click="search()" type="primary">查询</el-button>
  <el-table  :show-overflow-tooltip="true" :data="tableData" height="calc(100% - 150px)" style="width: 100%">
    <el-table-column prop="day_time" label="日期" width="100px"> </el-table-column>
    <el-table-column prop="user_balance" label="24点余额"> </el-table-column>
    <el-table-column prop="ali_invest" label="支付宝充"> </el-table-column>
    <el-table-column prop="wechat_invest" label="微信充"> </el-table-column>
    <el-table-column prop="taobao_invest" label="淘宝充"  width="70px"> </el-table-column>
    <el-table-column prop="manager_invest" label="管理员充"  width="70px"> </el-table-column>
    <el-table-column prop="refund_amount" label="退款金额"> </el-table-column>
    <el-table-column prop="cash_out_refund" label="提现被拒退款" width="70px"> </el-table-column>
    <el-table-column prop="manager_deduct" label="管理员扣除" width="70px"> </el-table-column>
    <el-table-column prop="cash_out" label="提现扣除"> </el-table-column>
    <el-table-column prop="taobao_refund" label="淘宝扣除"> </el-table-column>
    <el-table-column prop="balance_pay" label="余额付"> </el-table-column>
    <el-table-column prop="ali_pay" label="支付宝付"> </el-table-column>
    <el-table-column prop="wechat_pay" label="微信付"> </el-table-column>
    <el-table-column prop="new_amount" label="新开金额"> </el-table-column>
    <el-table-column prop="renew_amount" label="续费金额"> </el-table-column>
    <el-table-column prop="balance_diff" label="余额差值"> </el-table-column>
    <el-table-column prop="in_out_diff" label="支付差值"> </el-table-column>
    <el-table-column prop="sell_monet" label="当日销售额"> </el-table-column>
    <el-table-column prop="income" label="当日总进账"> </el-table-column>
    <el-table-column prop="expend" label="当日总支出"> </el-table-column>
  </el-table>
  <el-pagination
    background
    v-if="count !== 0"
    :current-page="pageNum"
    style="top:91%"
    layout="prev, pager, next"
    :page-size = "50"
    @prev-click="prev_page"
    @next-click="next_page"
    @current-change="handleCurrentChange"
    :total="count">
  </el-pagination>
</div>
</template>

<script>
export default {
  data () {
    return {
      tableData: [],
      count: 0,
      pageNum: 1,
      pickerOptions: {
        shortcuts: [{
          text: '最近一周',
          onClick (picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
            picker.$emit('pick', [start, end])
          }
        }, {
          text: '最近一个月',
          onClick (picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
            picker.$emit('pick', [start, end])
          }
        }, {
          text: '最近三个月',
          onClick (picker) {
            const end = new Date()
            const start = new Date()
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
            picker.$emit('pick', [start, end])
          }
        }]
      },
      timeSearh: ''
    }
  },

  created () {
    this.$store.commit('setCurrentNav', '订单管理>>收支核对')
    this.getData()
  },
  methods: {
    getData () {
      this.$api.get(this.$api.phpURL + 'order/IncomeCheck/getList').then(res => {
        this.tableData = res.data
        this.count = parseInt(res.count)
      })
    },
    prev_page () {
      this.$api.get(this.$api.phpURL + 'order/IncomeCheck/getList', {page: this.pageNum}).then(res => {
        this.tableData = res.data
      })
    },
    next_page () {
      this.$api.get(this.$api.phpURL + 'order/IncomeCheck/getList', {page: this.pageNum}).then(res => {
        this.tableData = res.data
      })
    },
    handleCurrentChange: function (currentPage) {
      this.pageNum = currentPage
      this.$api.get(this.$api.phpURL + 'order/IncomeCheck/getList', {page: this.pageNum}).then(res => {
        this.tableData = res.data
      })
    },
    search () {
      this.$api.post(this.$api.phpURL + 'order/IncomeCheck/search', {time: this.timeSearh}).then(res => {
        this.tableData = res.data
        this.count = 0
      })
    }
  }
}
</script>

<style>

  .el-table .success-row {
    background: #d7f8c5;
  }

  .el-table .error-row {
    background: #f1c6c6;
  }
</style>
