<template>
  <div class="m-container">
    <h2>
      <div class="squrt"></div>充值列表
    </h2>
    <div class="m-core">
      <!-- 搜索类型 -->
      <el-form :inline="true"
               class="searchForm"
               v-model.trim="searchForm">
        <el-form-item>
          <el-select v-model.trim="searchForm.paymentType"
                     clearable
                     filterable
                     placeholder="交易类型">
            <el-option v-for="(item, index) in orderStatus"
                       :key="index"
                       :label="item.label"
                       :value="item.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-select v-model.trim="searchForm.paymentStatus"
                     clearable
                     filterable
                     placeholder="交易状态">
            <el-option v-for="(item, index) in dealStatus"
                       :key="index"
                       :label="item.label"
                       :value="item.value"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button @click="search"
                     type="danger">搜索</el-button>
          <el-button @click="onReSet"
                     type="primary">重置</el-button>
        </el-form-item>
      </el-form>
      <!-- 列表 -->
      <div class="tableWrap">
        <el-table :data='tableList'
                  :header-cell-style="{background:'#EDEEF0',color:'#444'}">
          <el-table-column align='center'
                           prop="transNo"
                           label="交易流水号">
          </el-table-column>
          <el-table-column align='center'
                           prop="payTime"
                           label="订单日期">
          </el-table-column>
          <el-table-column align='center'
                           prop="actualAmount"
                           label="实付金额">
          </el-table-column>
          <el-table-column align='center'
                           prop="user.username"
                           label="学员姓名">
          </el-table-column>
          <el-table-column align='center'
                           prop="paymentChannel"
                           label="交易方式">
          </el-table-column>
          <el-table-column align='center'
                           label="收款账户">
            <template slot-scope="scope">
              {{ scope.row.paymentChannelType | paymentChannelType }}
            </template>
          </el-table-column>
          <el-table-column align='center'
                           label="交易状态">
            <template slot-scope="scope">
              {{ scope.row.status | dealStatus }}
            </template>
          </el-table-column>
        </el-table>
        <pagination :total="pageInfo.total"
                    :page.sync="pageInfo.page"
                    :limit.sync="pageInfo.limit"
                    :page-sizes="pageInfo.page_size"
                    @pagination="getList" />
      </div>
    </div>
  </div>
</template>
<script>
import pagination from '@/components/Pagination/index'
import { studentRechargeList } from '@/api/orderManager'
import store from '@/store'
import { orderStatus, dealStatus } from '@/utils/searchArray'
export default {
  components: { pagination },
  name: 'incomebuy',
  data () {
    return {
      orderStatus: orderStatus,
      dealStatus: dealStatus,
      orderDate: null,
      searchForm: {
        orderStartDate: null,
        orderEndDate: null,
        paymentStatus: null,
        paymentType: null,
      },
      tableList: [],
      pageInfo: {
        // 分页规则
        limit: 10, // 限制显示条数
        page: 1, // 当前页
        total: 0, // 总条数
        page_size: [10, 20, 40, 50] // 选择限制显示条数
      },
    }
  },
  mounted () {
    this.getList()
  },
  methods: {
    search () {
      this.pageInfo.page = 1;
      this.getList();
    },
    getList () {
      let params = this.searchForm
      params.rows = this.pageInfo.limit
      params.page = this.pageInfo.page
      studentRechargeList(params).then(res => {
        let result = res.data
        if (res.code == 200) {
          this.tableList = result.rows
          this.pageInfo.total = result.total
        }
      })
    },
    searchOrderDate (value) {
      if (value) {
        this.searchForm.orderStartDate = value[0]
        this.searchForm.orderEndDate = value[1]
      } else {
        this.searchForm.orderStartDate = null
        this.searchForm.orderEndDate = null
      }
    },
    onReSet () { // 重置搜索
      this.orderDate = null
      this.searchForm = {
        orderStartDate: null,
        orderEndDate: null,
        paymentStatus: null,
        paymentType: null,
      }
    },
  }
}
</script>
<style lang="scss">
</style>