index.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <div id="withdraw">
  3. <el-select @change="changeSelect" v-model="selectValue" placeholder="请选择">
  4. <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option>
  5. </el-select>
  6. <div class="table">
  7. <el-table
  8. v-if="tableData.length"
  9. border
  10. style="width: 100%"
  11. :data="tableData"
  12. :row-class-name="tableRowClassName"
  13. >
  14. <el-table-column
  15. v-for="(prop, index) of tableProps"
  16. :key="index"
  17. :prop="prop"
  18. :label="tableHeaders[index]"
  19. >
  20. <template slot-scope="scope">
  21. <el-button
  22. type="text"
  23. v-if="prop === 'uid'"
  24. @click="clickUID(scope.row[prop])"
  25. >{{scope.row[prop]}}</el-button>
  26. <span v-else-if="prop === 'statusShow' && scope.row['status'] !== '1'">
  27. {{scope.row[prop]}}
  28. <el-button type="text" @click="clickRetry(scope.row['id'])">重试</el-button>
  29. </span>
  30. <span v-else>{{scope.row[prop]}}</span>
  31. </template>
  32. </el-table-column>
  33. </el-table>
  34. </div>
  35. <el-pagination
  36. @current-change="getTableData"
  37. :current-page.sync="currentPage"
  38. :page-size="10"
  39. layout="total, prev, pager, next"
  40. :total="totalCount"
  41. ></el-pagination>
  42. </div>
  43. </template>
  44. <script>
  45. const tableHeaders = [
  46. "用户ID",
  47. "真实姓名",
  48. "提现金额",
  49. "到账金额",
  50. "账户余额",
  51. "到账账户",
  52. "提现时间",
  53. "到账时间",
  54. "订单号",
  55. "支付方式",
  56. "状态"
  57. ];
  58. const tableProps = [
  59. "uid",
  60. "real_name",
  61. "amount",
  62. "true_amount",
  63. "after_amount",
  64. "account",
  65. "created_atShow",
  66. "taken_atShow",
  67. "order_no",
  68. "channel",
  69. "statusShow"
  70. ];
  71. export default {
  72. data() {
  73. return {
  74. options: [
  75. {
  76. value: -1,
  77. label: "全部"
  78. },
  79. {
  80. value: 0,
  81. label: "提交"
  82. },
  83. {
  84. value: 1,
  85. label: "成功"
  86. },
  87. {
  88. value: 2,
  89. label: "失败"
  90. },
  91. {
  92. value: 3,
  93. label: "进行中"
  94. }
  95. ],
  96. selectValue: -1,
  97. // 数据总条目
  98. totalCount: 0,
  99. currentPage: 1,
  100. // 列表头显示内容
  101. tableHeaders,
  102. // 列表头字段
  103. tableProps,
  104. // 列表数据
  105. tableData: []
  106. };
  107. },
  108. mounted() {
  109. this.getTableData();
  110. },
  111. methods: {
  112. changeSelect(status) {
  113. this.getTableData();
  114. },
  115. // 点击重试
  116. async clickRetry(id) {
  117. const res = await this.$post("/api/admin/payment/redoDraw", { id });
  118. },
  119. // 点击用户的 uid
  120. clickUID(uid) {
  121. // console.log("click uid: " + uid)
  122. },
  123. // 根据状态显示图表样式
  124. tableRowClassName({ row, rowIndex }) {
  125. let className = "";
  126. if (row.status === "1") className = "success-row";
  127. return className;
  128. },
  129. // 格式化列表数据
  130. formatTableData(data) {
  131. return data.map(i => ({
  132. ...i,
  133. statusShow: i.status === "1" ? "到账" : "失败",
  134. created_atShow: new Date(Number(i.created_at) * 1000).toLocaleString(),
  135. taken_atShow: new Date(Number(i.taken_at) * 1000).toLocaleString()
  136. }));
  137. },
  138. // 获取列表数据
  139. async getTableData(page = this.currentPage) {
  140. this.tableData = [];
  141. const res = await this.$post("/api/admin/payment/listDraw", {
  142. page,
  143. status: this.selectValue
  144. });
  145. const data = res.data;
  146. this.tableData = this.formatTableData(res.data.list);
  147. this.totalCount = Number(data.total);
  148. this.totalPage = data.totalPage;
  149. }
  150. }
  151. };
  152. </script>
  153. <style scoped>
  154. .table {
  155. height: calc(100% - 80px);
  156. }
  157. </style>