<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="商户号/AppId" prop="payId" label-width="100px">
        <el-input
            v-model="queryParams.payId"
            placeholder="请输入商户号/AppId"
            clearable
            @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="时间" prop="date">
        <el-date-picker clearable
                        v-model="queryParams.date"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="平台" prop="payType">
        <el-select v-model="queryParams.payType" clearable size="small">
          <el-option
              v-for="dict in payConfigTypeList"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
              @keyup.enter.native="handleQuery"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="payTotalList" @selection-change="handleSelectionChange">
<!--      <el-table-column type="selection" width="55" align="center"/>-->
      <el-table-column label="支付平台" align="center" prop="payType">
        <template v-slot="scope">
          <cai-dict-tag :options="payConfigTypeList" :value="scope.row.payType"/>
        </template>
      </el-table-column>
      <el-table-column label="名称" align="center" prop="name"/>
      <el-table-column label="商户号/AppId" align="center" prop="payId"/>
      <el-table-column label="时间" align="center" prop="date" width="180"/>
      <el-table-column label="金额" align="center" prop="money"/>
    </el-table>

    <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
    />
  </div>
</template>

<script>
import {listPayTotal} from "@/api/cai/payTotal";
import {payConfigTypeList} from "@/constant/statusMap";

export default {
  name: "PayTotal",
  data() {
    return {
      payConfigTypeList,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 支付统计表格数据
      payTotalList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        payId: undefined,
        payType: undefined,
        date: undefined,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询支付统计列表 */
    getList() {
      this.loading = true;
      listPayTotal(this.queryParams).then(response => {
        this.payTotalList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
  }
};
</script>
