<template>
  <div>
    <el-table v-loading="loading" :data="billList">
      <el-table-column align="center" type="index" label="#"></el-table-column>
      <el-table-column align="center" label="时间" prop="createTime"></el-table-column>
      <el-table-column align="center" label="类型">
        <template slot-scope="d">
          <dict-tag :options="dict.type.sm_transaction_bill_type" :value="d.row.type"></dict-tag>
        </template>
      </el-table-column>
      <el-table-column align="center" label="用户" prop="userName"></el-table-column>
      <el-table-column align="center"  label="金额" prop="arrivalAmount">
        <template slot-scope="d">{{d.row.arrivalAmount | money}} 元</template>
      </el-table-column>
    </el-table>

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

<script>
import {listBill} from "@/api/system/recharge";

export default {
  name: 'userAccount',
  dicts: ['sm_transaction_bill_type'],
  props: {
    // 到账用户id
    landlordId: {
      type: String,
      default: null,
    }
  },
  data() {
    return {
      billList: [],
      loading: false,
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        userId: null,
      },
      total: 0,
    }
  },
  watch: {
    landlordId(nv, ov) {
      this.getBillList(nv);
    }
  },
  created() {
    this.getBillList(this.landlordId);
  },
  methods: {
    // 获取用户设备列表
    getBillList(landlordId) {
      this.loading = true;
      this.queryParams.mchId = landlordId | this.landlordId;
      listBill(this.queryParams).then(response => {
        this.billList = response.rows;
        this.total = response.total;
      }).finally(() => {
        this.loading = false;
      })
    },
  }
}
</script>
