index.vue 3.7 KB

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