index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <el-main>
  3. <el-card shadow="never">
  4. <template #header>
  5. <span>佣金明细</span>
  6. </template>
  7. <el-table v-loading="loading" :data="list">
  8. <el-table-column prop="id" label="ID" width="80" />
  9. <el-table-column label="用户" min-width="100" show-overflow-tooltip>
  10. <template #default="{ row }">
  11. {{ row.uid || row.user_id || "-" }}
  12. </template>
  13. </el-table-column>
  14. <el-table-column label="标题/关联" min-width="160" show-overflow-tooltip>
  15. <template #default="{ row }">
  16. {{ row.title || row.mark || row.link_id || "-" }}
  17. </template>
  18. </el-table-column>
  19. <el-table-column label="金额" width="120">
  20. <template #default="{ row }">
  21. {{ row.number ?? row.price ?? row.brokerage ?? row.amount ?? "-" }}
  22. </template>
  23. </el-table-column>
  24. <el-table-column label="时间" min-width="160" show-overflow-tooltip>
  25. <template #default="{ row }">
  26. {{ formatTime(row.add_time || row.create_time || row.created_at) }}
  27. </template>
  28. </el-table-column>
  29. </el-table>
  30. <div class="pager">
  31. <el-pagination
  32. background
  33. layout="total, prev, pager, next, sizes"
  34. :total="total"
  35. :current-page="query.page"
  36. :page-size="query.limit"
  37. :page-sizes="[5, 10, 20, 50]"
  38. @current-change="handlePageChange"
  39. @size-change="handleSizeChange"
  40. />
  41. </div>
  42. </el-card>
  43. </el-main>
  44. </template>
  45. <script>
  46. export default {
  47. name: "BrokerageList",
  48. data() {
  49. return {
  50. loading: false,
  51. list: [],
  52. total: 0,
  53. query: { page: 1, limit: 10 }
  54. };
  55. },
  56. created() {
  57. this.getList();
  58. },
  59. methods: {
  60. formatTime(val) {
  61. if (val == null || val === "") return "-";
  62. const n = Number(val);
  63. if (!Number.isNaN(n) && String(val).length <= 12) {
  64. const ms = n < 1e12 ? n * 1000 : n;
  65. const d = new Date(ms);
  66. if (!Number.isNaN(d.getTime())) return d.toLocaleString();
  67. }
  68. return String(val);
  69. },
  70. async getList() {
  71. this.loading = true;
  72. try {
  73. const res = await this.$API.finance.brokerage.list.get(this.query);
  74. if (res.code !== 1) {
  75. this.$message.error(res.msg || "获取佣金明细失败");
  76. return;
  77. }
  78. const data = res.data || {};
  79. this.list = data.data || data.list || [];
  80. this.total = Number(data.count || data.total || this.list.length || 0);
  81. } finally {
  82. this.loading = false;
  83. }
  84. },
  85. handlePageChange(page) {
  86. this.query.page = page;
  87. this.getList();
  88. },
  89. handleSizeChange(limit) {
  90. this.query.limit = limit;
  91. this.query.page = 1;
  92. this.getList();
  93. }
  94. }
  95. };
  96. </script>
  97. <style scoped>
  98. .pager {
  99. margin-top: 16px;
  100. display: flex;
  101. justify-content: flex-end;
  102. }
  103. </style>