index.vue 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <div class="body" style="font-size:14px">
  3. <el-card class="box-card" shadow="never">
  4. 游戏名称:
  5. <el-input v-model="gameTitle" style="width: 200px; margin-right: 20px" />
  6. 用户昵称:
  7. <el-input v-model="nickName" style="width: 200px; margin-right: 20px" />
  8. 手机号:
  9. <el-input v-model="phone" style="width: 200px; margin-right: 20px" />
  10. 创建时间:
  11. <el-date-picker
  12. v-model="daterange"
  13. type="daterange"
  14. range-separator="至"
  15. start-placeholder="开始日期"
  16. end-placeholder="结束日期"
  17. value-format="yyyy-MM-dd"
  18. style="margin-right: 20px"
  19. @change="dateChange"
  20. />
  21. <div style="float:right">
  22. <el-button type="primary" @click="onSearch">查询</el-button>
  23. <el-button @click="onReset">重置</el-button>
  24. </div>
  25. </el-card>
  26. <el-table stripe :data="tableData" border style="width: 100%">
  27. <el-table-column prop="gameTitle" label="游戏名称" />
  28. <el-table-column prop="resultMode" label="游戏类型">
  29. <template slot-scope="scope">
  30. {{
  31. scope.row.resultMode=='examination'?'测试':'匹配'
  32. }}
  33. </template>
  34. </el-table-column>
  35. <el-table-column prop="nickName" label="用户昵称" />
  36. <el-table-column prop="avatar" label="用户头像">
  37. <template slot-scope="scope">
  38. <el-image :src="scope.row.avatar" style="width: 100px; height: 100px" />
  39. </template>
  40. </el-table-column>
  41. <el-table-column prop="phone" label="手机号" />
  42. <el-table-column prop="score" label="答题分数" />
  43. <el-table-column prop="characterName" label="实例结果" />
  44. <el-table-column prop="createDate" label="参与时间">
  45. <template slot-scope="scope">
  46. {{
  47. scope.row.createDate.substr(0, 10)
  48. }}
  49. </template>
  50. </el-table-column>
  51. </el-table>
  52. <el-pagination
  53. v-show="gameTotal!==0"
  54. style="float:right; margin:20px 0"
  55. :total="gameTotal"
  56. :current-page="currentPage"
  57. :page-sizes="[4, 10, 20, 50]"
  58. :page-size="pageSize"
  59. layout="total, prev, pager, next, sizes"
  60. @size-change="handleSizeChange"
  61. @current-change="handleCurrentChange"
  62. />
  63. </div>
  64. </template>
  65. <script>
  66. import { getGamePersonList } from '@/api/gamePerson'
  67. export default {
  68. data() {
  69. return {
  70. characterId: undefined,
  71. gameTitle: undefined,
  72. nickName: undefined,
  73. phone: undefined,
  74. daterange: undefined,
  75. tableData: [],
  76. endDate: undefined,
  77. startDate: undefined,
  78. //
  79. pageSize: 10,
  80. currentPage: 1,
  81. gameTotal: 0 // 条目总数
  82. }
  83. },
  84. mounted() {
  85. this.onSearch()
  86. },
  87. methods: {
  88. // 改变每页显示条数
  89. handleSizeChange(val) {
  90. this.pageSize = val
  91. this.changePagination()
  92. },
  93. // 改变页码
  94. handleCurrentChange(val) {
  95. this.currentPage = val
  96. this.changePagination()
  97. },
  98. // 改变分页组件重新查询数据
  99. changePagination() {
  100. getGamePersonList({
  101. gameTitle: this.gameTitle,
  102. nickName: this.nickName,
  103. phone: this.phone,
  104. startDate: this.startDate,
  105. endDate: this.endDate,
  106. pageNum: this.currentPage,
  107. pageSize: this.pageSize
  108. }).then((res) => {
  109. this.tableData = res.data.records
  110. })
  111. },
  112. onSearch() {
  113. getGamePersonList({
  114. gameTitle: this.gameTitle,
  115. nickName: this.nickName,
  116. phone: this.phone,
  117. startDate: this.startDate,
  118. endDate: this.endDate,
  119. pageSize: this.pageSize
  120. }).then((res) => {
  121. this.tableData = res.data.records
  122. this.gameTotal = res.data.total
  123. this.pageSize = res.data.size
  124. })
  125. },
  126. onReset() {
  127. this.gameTitle = undefined
  128. this.nickName = undefined
  129. this.phone = undefined
  130. this.daterange = undefined
  131. this.startDate = undefined
  132. this.endDate = undefined
  133. this.currentPage = 1
  134. this.pageSize = 10
  135. this.onSearch()
  136. },
  137. dateChange(val) {
  138. this.startDate = this.daterange[0]
  139. this.endDate = this.daterange[1]
  140. }
  141. }
  142. }
  143. </script>
  144. <style>
  145. </style>