check_pro.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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="10"
  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. this.$router.push({
  85. path: 'check_edit',
  86. query: {
  87. id: item.id
  88. }
  89. })
  90. },
  91. // 点击重试
  92. async clickRetry(id) {
  93. const res = await this.$post("/api/admin/payment/redoDraw", { id })
  94. console.log(res)
  95. },
  96. // 点击用户的 uid
  97. clickUID(uid) {
  98. console.log("click uid: " + uid)
  99. },
  100. // 根据状态显示图表样式
  101. tableRowClassName({ row, rowIndex }) {
  102. // console.log({row, rowIndex})
  103. let className = ""
  104. if(row.status === "1") className = "success-row"
  105. return className
  106. },
  107. // 格式化列表数据
  108. formatTableData(data) {
  109. return data.map(i => ({
  110. ...i,
  111. statusShow: i.status === "1" ? "到账" : "失败",
  112. created_atShow: new Date(Number(i.created_at) * 1000).toLocaleString(),
  113. taken_atShow: new Date(Number(i.taken_at) * 1000).toLocaleString(),
  114. ctrl: 1
  115. }))
  116. },
  117. // 获取列表数据
  118. async getTableData(page = 1) {
  119. this.tableData = []
  120. const res = await this.$post("/api/admin/payment/listDraw", { page })
  121. // console.log(res)
  122. const data = res.data
  123. this.tableData = this.formatTableData(res.data.list)
  124. // console.log(this.tableData)
  125. this.totalCount = Number(data.total)
  126. this.totalPage = data.totalPage
  127. }
  128. }
  129. };
  130. </script>
  131. <style scoped>
  132. .table {
  133. height: calc(100% - 40px);
  134. }
  135. </style>