<template>
  <div class="app-container">
    <el-card shadow="never">
      <div slot="header" class="header-row">
        <span>租户费用明细（我的）</span>
        <el-button size="mini" type="primary" plain @click="loadMyDetails">刷新</el-button>
      </div>
      <el-table :data="detailList" v-loading="loading" border>
        <el-table-column label="事件ID" prop="eventId" min-width="180" />
        <el-table-column label="事件类型" prop="eventType" width="120" />
        <el-table-column label="子类型" prop="subType" width="120" />
        <el-table-column label="计费用量" prop="usageValue" width="120" />
        <el-table-column label="金额" prop="amount" width="120" />
        <el-table-column label="发生时间" prop="occurredAt" min-width="180" />
      </el-table>
    </el-card>
  </div>
</template>

<script>
import { listBillingDetailsMy } from '@/api/saas/billing'

export default {
  name: 'SaasBillingTenant',
  data() {
    return {
      loading: false,
      detailList: []
    }
  },
  created() {
    this.loadMyDetails()
  },
  methods: {
    loadMyDetails() {
      this.loading = true
      listBillingDetailsMy().then(res => {
        this.detailList = res.rows || []
      }).finally(() => {
        this.loading = false
      })
    }
  }
}
</script>

<style scoped>
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
</style>

