<template>
  <div style="padding: 20px;">
    <h1 style="text-align: center; margin-bottom: 30px;">充值明细</h1>
    <el-divider></el-divider>
    <el-form  ref="queryForm" :inline="true" :model="queryParams" size="small">
      <el-form-item label="创建时间">
        <el-date-picker
          v-model="dateRange"
          end-placeholder="结束日期"
          range-separator="-"
          start-placeholder="开始日期"
          style="width: 240px"
          type="daterange"
          value-format="yyyy-MM-dd"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button icon="el-icon-search" size="mini" type="primary" @click="handleQuery">搜索</el-button>
      </el-form-item>
    </el-form>
    <el-row>
      <el-button
        v-hasPermi="['system:pay:export']"
        icon="el-icon-download"
        plain
        size="mini"
        type="warning"
        @click="handleExport"
      >导出
      </el-button>
    </el-row>

    <el-table
      :data="listDate"
      style="width: 100%; border-collapse: collapse;">
      <el-table-column
        label="序号"
        width="300"
        style="border: 1px solid #ccc; padding: 10px; text-align: center;">
        <template slot-scope="scope">
          {{ scope.row.id }}
        </template>
      </el-table-column>
      <el-table-column
        label="充值编号"
        width="300"
        style="border: 1px solid #ccc; padding: 10px; text-align: center;">
        <template slot-scope="scope">
          {{ scope.row.outTradeNo }}
        </template>
      </el-table-column>
      <el-table-column
        label="充值金额"
        width="300"
        style="border: 1px solid #ccc; padding: 10px; text-align: center;">
        <template slot-scope="scope">
          {{ scope.row.totalAmount }}
        </template>
      </el-table-column>
      <el-table-column
        label="充值类型"
        width="300"
        style="border: 1px solid #ccc; padding: 10px; text-align: center;">
        <template slot-scope="scope">
          {{ scope.row.productCode }}
        </template>
      </el-table-column>
      <el-table-column
        label="充值时间"
        width="300"
        style="border: 1px solid #ca8a8a; padding: 10px; text-align: center;">
        <template slot-scope="scope">
          {{ scope.row.createTime }}
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total > 0"
      :limit.sync="queryParams.pageSize"
      :page.sync="queryParams.pageNum"
      :total="total"
      @pagination="getList"
    />
  </div>
</template>


<script>
import { userPayinfo } from "@/api/system/user";
import PanelGroup from "@/views/dashboard/PanelGroup.vue";
export default {
  components: {PanelGroup},
  data() {
    return {
      dateRange: [],
      listDate: [],
      total: 0,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      }
    }
  },
  created() {
    this.getList();
  },
  methods: {
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/user/export', {
        ...this.queryParams
      }, `pay_${new Date().getTime()}.xlsx`)
    },
    getList() {
      userPayinfo(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
          this.listDate = response.data.rows;
          this.total = response.data.total;
        }
      );
    }
  }
}
</script>
