check_pro.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <div id="withdraw">
  3. <div class="table">
  4. <el-table
  5. v-if="tableData.length"
  6. height="100%"
  7. border
  8. style="width: 100%"
  9. :data="tableData"
  10. :row-class-name="tableRowClassName"
  11. >
  12. <el-table-column
  13. v-for="(prop, index) of tableProps"
  14. :key="index"
  15. :prop="prop"
  16. :label="tableHeaders[index]"
  17. >
  18. <template slot-scope="scope">
  19. <el-button
  20. type="text"
  21. v-if="prop === 'uid'"
  22. @click="clickUID(scope.row[prop])"
  23. >{{scope.row[prop]}}</el-button>
  24. <span v-else-if="prop === 'statusShow' && scope.row['status'] !== '1'">
  25. {{scope.row[prop]}}
  26. <el-button type="text" @click="clickRetry(scope.row['id'])">重试</el-button>
  27. </span>
  28. <el-button type="text" v-else-if="prop === 'ctrl'" @click="clickCtrl(scope.row, index)">操作</el-button>
  29. <span v-else>{{scope.row[prop]}}</span>
  30. </template>
  31. </el-table-column>
  32. </el-table>
  33. </div>
  34. <el-pagination
  35. @current-change="getTableData"
  36. :current-page.sync="currentPage"
  37. :page-size="20"
  38. layout="total, prev, pager, next"
  39. :total="totalCount"
  40. ></el-pagination>
  41. </div>
  42. </template>
  43. <script>
  44. const tableHeaders = [
  45. "名称",
  46. "状态",
  47. "排序",
  48. "价格",
  49. "配图",
  50. "简介",
  51. "说明",
  52. "操作",
  53. ]
  54. const tableProps = [
  55. "uid",
  56. "real_name",
  57. "amount",
  58. "true_amount",
  59. "after_amount",
  60. "account",
  61. "created_atShow",
  62. "ctrl",
  63. ]
  64. export default {
  65. data() {
  66. return {
  67. // 数据总条目
  68. totalCount: 0,
  69. currentPage: 1,
  70. // 列表头显示内容
  71. tableHeaders,
  72. // 列表头字段
  73. tableProps,
  74. // 列表数据
  75. tableData: []
  76. }
  77. },
  78. mounted() {
  79. this.getTableData()
  80. },
  81. methods: {
  82. clickCtrl(item, index) {
  83. console.log(JSON.stringify(item))
  84. },
  85. // 点击重试
  86. async clickRetry(id) {
  87. const res = await this.$post("/api/admin/payment/redoDraw", { id })
  88. console.log(res)
  89. },
  90. // 点击用户的 uid
  91. clickUID(uid) {
  92. console.log("click uid: " + uid)
  93. },
  94. // 根据状态显示图表样式
  95. tableRowClassName({ row, rowIndex }) {
  96. // console.log({row, rowIndex})
  97. let className = ""
  98. if(row.status === "1") className = "success-row"
  99. return className
  100. },
  101. // 格式化列表数据
  102. formatTableData(data) {
  103. return data.map(i => ({
  104. ...i,
  105. statusShow: i.status === "1" ? "到账" : "失败",
  106. created_atShow: new Date(Number(i.created_at) * 1000).toLocaleString(),
  107. taken_atShow: new Date(Number(i.taken_at) * 1000).toLocaleString(),
  108. ctrl: 1
  109. }))
  110. },
  111. // 获取列表数据
  112. async getTableData(page = 1) {
  113. this.tableData = []
  114. const res = await this.$post("/api/admin/payment/listDraw", { page })
  115. // console.log(res)
  116. const data = res.data
  117. this.tableData = this.formatTableData(res.data.list)
  118. // console.log(this.tableData)
  119. this.totalCount = Number(data.total)
  120. this.totalPage = data.totalPage
  121. }
  122. }
  123. };
  124. </script>
  125. <style scoped>
  126. .table {
  127. height: calc(100% - 40px);
  128. }
  129. </style>