暂无描述

index.vue 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <div class="app-container">
  3. <div class="app-container">
  4. <div class="block">
  5. <span class="demonstration">時間篩選</span>
  6. <el-date-picker
  7. v-model="date"
  8. type="datetimerange"
  9. :picker-options="pickerOptions"
  10. range-separator="至"
  11. start-placeholder="開始日期"
  12. end-placeholder="结束日期"
  13. align="right">
  14. </el-date-picker>
  15. <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">搜尋</el-button>
  16. </div>
  17. </div>
  18. <el-table :data="list" v-loading.body="listLoading" element-loading-text="Loading" border fit highlight-current-row>
  19. <el-table-column :label="member.name" align="center">
  20. <el-table-column label="場次" align="center">
  21. <template slot-scope="scope">
  22. {{scope.row.game}}
  23. </template>
  24. </el-table-column>
  25. <el-table-column label="總押注" align="center">
  26. <template slot-scope="scope">
  27. <span>{{scope.row.wager}}</span>
  28. </template>
  29. </el-table-column>
  30. <el-table-column label="總輸贏" align="center">
  31. <template slot-scope="scope">
  32. <span>{{scope.row.earned}}</span>
  33. </template>
  34. </el-table-column>
  35. <el-table-column label="時間" align="center">
  36. <template slot-scope="scope">
  37. <span>{{moment(scope.row['GambleGame-Bucket'].createdAt)}}</span>
  38. </template>
  39. </el-table-column>
  40. <el-table-column align="center" label="操作">
  41. <template slot-scope="scope">
  42. <el-button type="primary" size="mini" icon="el-icon-tickets" @click="handleDetail(scope.row)">詳細紀錄</el-button>
  43. </template>
  44. </el-table-column>
  45. </el-table-column>
  46. </el-table>
  47. <div v-show="!listLoading" class="pagination-container">
  48. <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="listQuery.page"
  49. :page-sizes="[10,20,30, 50]" :page-size="listQuery.limit" layout="total, sizes, prev, pager, next, jumper" :total="total">
  50. </el-pagination>
  51. </div>
  52. </div>
  53. </template>
  54. <script>
  55. import { mapActions } from 'vuex'
  56. import { fetchHistory } from '@/api/gambleMember'
  57. import waves from '@/directive/waves' // 水波纹指令
  58. import moment from 'moment-timezone'
  59. export default {
  60. directives: {
  61. waves
  62. },
  63. data() {
  64. return {
  65. list: null,
  66. total: null,
  67. listLoading: true,
  68. listQuery: {
  69. page: 1,
  70. limit: 20,
  71. startAt: null,
  72. endAt: null,
  73. },
  74. pickerOptions: {
  75. shortcuts: [{
  76. text: '最近一周',
  77. onClick(picker) {
  78. const end = new Date();
  79. const start = new Date();
  80. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  81. picker.$emit('pick', [start, end]);
  82. }
  83. }, {
  84. text: '最近一個月',
  85. onClick(picker) {
  86. const end = new Date();
  87. const start = new Date();
  88. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  89. picker.$emit('pick', [start, end]);
  90. }
  91. }, {
  92. text: '最近三個月',
  93. onClick(picker) {
  94. const end = new Date();
  95. const start = new Date();
  96. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  97. picker.$emit('pick', [start, end]);
  98. }
  99. }]
  100. },
  101. date: null
  102. }
  103. },
  104. created() {
  105. this.SetVisible(false)
  106. this.getList()
  107. },
  108. props: ['member'],
  109. methods: {
  110. ...mapActions([
  111. 'SetVisible'
  112. ]),
  113. getList() {
  114. this.listLoading = true
  115. fetchHistory(this.member, this.listQuery).then(response => {
  116. this.list = response.data
  117. this.total = response.data.length
  118. this.listLoading = false
  119. })
  120. },
  121. handleDetail() {
  122. },
  123. handleFilter() {
  124. this.listQuery.page = 1
  125. if(this.date) {
  126. this.listQuery.startAt = moment.utc(this.date[0]).format()
  127. this.listQuery.endAt = moment.utc(this.date[1]).format()
  128. }else {
  129. this.listQuery.startAt = null
  130. this.listQuery.endAt = null
  131. }
  132. this.getList()
  133. },
  134. handleSizeChange(val) {
  135. this.listQuery.limit = val
  136. this.getList()
  137. },
  138. handleCurrentChange(val) {
  139. this.listQuery.page = val
  140. this.getList()
  141. },
  142. moment(time) {
  143. return moment(time).tz("Asia/Taipei").format('YYYY-MM-DD HH:mm:ss')
  144. },
  145. },
  146. destroyed() {
  147. this.SetVisible(true)
  148. }
  149. }
  150. </script>