index.vue 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <div class="body" style="font-size:14px">
  3. <el-card class="box-card">
  4. 游戏名称:<el-input
  5. v-model="title"
  6. size="mini"
  7. style="width: 200px; margin-right: 20px"
  8. />
  9. 创建时间:
  10. <el-date-picker
  11. v-model="daterange"
  12. size="mini"
  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. <el-button type="primary" size="mini" @click="onSearch">查询</el-button>
  22. <el-button size="mini" @click="onReset">重置</el-button>
  23. <el-button type="primary" size="mini" @click="handleAdd">添加游戏</el-button>
  24. </el-card>
  25. <el-table stripe :data="tableData" border style="width: 100%">
  26. <el-table-column prop="title" label="游戏名称" />
  27. <el-table-column prop="gameImage" label="游戏图标">
  28. <template slot-scope="scope">
  29. <el-image :src="scope.row.gameImage" style="width: 100px; height: 100px" />
  30. </template>
  31. </el-table-column>
  32. <el-table-column prop="createDate" label="创建时间">
  33. <template slot-scope="scope">{{
  34. scope.row.createDate.substr(0, 10)
  35. }}</template>
  36. </el-table-column>
  37. <el-table-column fixed="right" label="操作">
  38. <template slot-scope="scope">
  39. <el-button type="text" @click="handleEdit(scope.row)">编辑</el-button>
  40. <el-popconfirm
  41. icon="el-icon-info"
  42. icon-color="red"
  43. title="确定删除这个游戏吗?"
  44. @onConfirm="handleDelete(scope.row)"
  45. >
  46. <el-button slot="reference" type="text">删除</el-button>
  47. </el-popconfirm>
  48. </template>
  49. </el-table-column>
  50. </el-table>
  51. <el-pagination
  52. style="float:right; margin:20px 0"
  53. :total="gameTotal"
  54. :current-page="currentPage"
  55. :page-sizes="[10, 50, 100]"
  56. :page-size="pageSize"
  57. layout="total, sizes, prev, pager, next, jumper"
  58. @current-change="handleCurrentChange"
  59. />
  60. </div>
  61. </template>
  62. <script>
  63. import { getGameList, deleteGame } from '@/api/game'
  64. export default {
  65. data() {
  66. return {
  67. characterId: undefined,
  68. title: undefined,
  69. daterange: undefined,
  70. tableData: [],
  71. endDate: undefined,
  72. startDate: undefined,
  73. //
  74. pageSize: 10,
  75. currentPage: 1,
  76. gameTotal: 0// 条目总数
  77. }
  78. },
  79. mounted() {
  80. this.onSearch()
  81. },
  82. methods: {
  83. handleCurrentChange(val) {
  84. this.currentPage = val
  85. this.onSearch()
  86. },
  87. //
  88. handleAdd() {
  89. this.$router.push({ name: 'gameEdit' })
  90. },
  91. handleEdit(row) {
  92. this.$router.push({
  93. name: 'gameEdit',
  94. query: { id: row.gameId }
  95. })
  96. },
  97. handleDelete(row) {
  98. deleteGame(row.gameId).then(() => {
  99. this.onSearch()
  100. })
  101. },
  102. onSearch() {
  103. getGameList({
  104. title: this.title,
  105. startDate: this.startDate,
  106. endDate: this.endDate,
  107. pageNum: this.currentPage
  108. }).then((res) => {
  109. this.tableData = res.data.records
  110. this.gameTotal = res.data.total
  111. this.pageSize = res.data.size
  112. this.currentPage = res.data.current
  113. })
  114. },
  115. onReset() {
  116. this.title = undefined
  117. this.daterange = undefined
  118. this.startDate = undefined
  119. this.endDate = undefined
  120. this.onSearch()
  121. },
  122. dateChange(val) {
  123. this.startDate = this.daterange[0]
  124. this.endDate = this.daterange[1]
  125. }
  126. }
  127. }
  128. </script>
  129. <style>
  130. </style>