<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      label-width="68px"
    >
      <el-form-item label="会员名" prop="customerName">
        <el-input
          v-model="queryParams.customerName"
          placeholder="请输入客户名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="油品" prop="cardOilsType">
        <el-select
          v-model="queryParams.cardOilsType"
          placeholder="请选择油品"
          clearable
          size="small"
        >
          <el-option label="汽油卡" value="1"></el-option>
          <el-option label="柴油卡" value="2"></el-option>
          <el-option label="非油品卡" value="3"></el-option>
          <el-option label="LNG卡" value="4"></el-option>
          <el-option label="CNG卡" value="5"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="类型" prop="usageType">
        <el-select
          v-model="queryParams.usageType"
          placeholder="请选择消费充值类型"
          clearable
          size="small"
        >
          <el-option label="充值" value="+" />
          <el-option label="消费" value="-" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button
          type="cyan"
          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 :data="recordList">
      <af-table-column label="id" align="center" prop="id" v-if="false" />
      <af-table-column label="油站名" align="center" prop="stationName" />
      <af-table-column label="充值/消费单号" align="center" prop="orderNo" />
      <!-- <af-table-column label="会员号ID" align="center" prop="customerNo" /> -->
      <af-table-column label="客户名" align="center" prop="customerName" />
      <af-table-column
        label="消费充值类型"
        align="center"
        prop="usageType"
        :formatter="usageTypeFotmat"
      />
      <af-table-column
        label="电子会员卡充值消费类型：1.微信；2.POS机"
        align="center"
        prop="payType"
        v-if="false"
      />
      <af-table-column
        label="油类"
        align="center"
        prop="cardOilsType"
        :formatter="cardOilsTypeFotmat"
      />
      <af-table-column label="充值，消费金额" align="center" prop="amt" />
      <af-table-column label="赠送金额" align="center" prop="presentAmt" />
      <af-table-column label="余额" align="center" prop="balance" />
      <af-table-column
        label="油站ID"
        align="center"
        prop="stationId"
        v-if="false"
      />
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listRecord } from "@/api/customer/record";

export default {
  name: "Dzk_Bill",
  data() {
    return {
      // 总条数
      total: 0,
      // 客户电子会员卡充值消费记录表格数据
      recordList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderNo: null,
        customerNo: null,
        customerName: null,
        usageType: null,
        payType: null,
        cardOilsType: null,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    usageTypeFotmat(row, column) {
      if (row.usageType === "+") {
        return "充值";
      } else if (row.usageType === "-") {
        return "消费";
      }
    },
    cardOilsTypeFotmat(row, column) {
      if (row.cardOilsType === "1") {
        return "汽油";
      } else if (row.cardOilsType === "2") {
        return "柴油";
      } else if (row.cardOilsType === "3") {
        return "非油品";
      } else if (row.cardOilsType === "4") {
        return "LNG";
      } else if (row.cardOilsType === "5") {
        return "CNG";
      }
    },
    /** 查询客户电子会员卡充值消费记录列表 */
    getList() {
      listRecord(this.queryParams).then((response) => {
        this.recordList = response.rows;
        this.total = response.total;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  },
};
</script>
