list.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <div class="app-container">
  3. <el-form ref="searchArr" :inline="true" :model="search" class="demo-form-inline">
  4. <el-form-item label="用戶名">
  5. <el-input v-model="search.nickname" clearable />
  6. </el-form-item>
  7. <el-form-item label="日期">
  8. <el-date-picker
  9. v-model="search.pushTime"
  10. type="date"
  11. value-format="yyyy-MM-dd"
  12. placeholder="选择日期"
  13. />
  14. </el-form-item>
  15. <el-form-item label="推送类型">
  16. <el-select v-model="search.type" clearable>
  17. <el-option
  18. v-for="item in [{key: 'game', value: 1}, {key: 'scale', value: 2}]"
  19. :key="item.value"
  20. :label="item.key"
  21. :value="item.value"
  22. />
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item>
  26. <el-button type="primary" size="small" @click="nextPage()">搜素</el-button>
  27. </el-form-item>
  28. <el-form-item>
  29. <el-button type="primary" size="small" @click="download()">下載</el-button>
  30. </el-form-item>
  31. <el-form-item>
  32. <el-button type="primary" size="small" @click="deleteC()">删除</el-button>
  33. </el-form-item>
  34. <el-form-item>
  35. <el-button type="primary" size="small" @click="back()">返回</el-button>
  36. </el-form-item>
  37. </el-form>
  38. <el-table
  39. ref="gamelog"
  40. v-loading="listLoading"
  41. :data="list"
  42. element-loading-text="Loading"
  43. border
  44. fit
  45. highlight-current-row
  46. @sort-change="sortChange"
  47. >
  48. <el-table-column
  49. type="selection"
  50. align="center"
  51. width="40"
  52. />
  53. <el-table-column align="center" label="ID" width="55">
  54. <template slot-scope="scope">
  55. {{ scope.row.id }}
  56. </template>
  57. </el-table-column>
  58. <el-table-column sortable prop="nickname" align="center" label="用戶">
  59. <template slot-scope="scope">
  60. {{ scope.row.nickname }}
  61. </template>
  62. </el-table-column>
  63. <el-table-column sortable prop="pushTime" align="center" label="推送日期">
  64. <template slot-scope="scope">
  65. {{ scope.row.pushTime.split(' ')[0] }}
  66. </template>
  67. </el-table-column>
  68. <el-table-column align="center" label="推送時間">
  69. <template slot-scope="scope">
  70. {{ scope.row.pushTime.split(' ')[1] }}
  71. </template>
  72. </el-table-column>
  73. <el-table-column sortable prop="status" align="center" label="推送狀態">
  74. <template slot-scope="scope">
  75. {{ scope.row.status === 1 ? 'delay' : scope.row.status === 2 ? 'expired' : 'enter' }}
  76. </template>
  77. </el-table-column>
  78. <el-table-column sortable prop="type" align="center" label="推送類型">
  79. <template slot-scope="scope">
  80. {{ scope.row.type === 1 ? 'game' : 'scale' }}
  81. </template>
  82. </el-table-column>
  83. <el-table-column align="center" label="操作" width="260">
  84. <template slot-scope="{row}">
  85. <el-button v-if="checkPermission(['admin'])" size="mini" @click="openDel(row)">
  86. 删除
  87. </el-button>
  88. <!-- <el-button v-if="checkPermission(['admin'])" size="mini" @click="openDetail(row)">-->
  89. <!-- 查看詳情-->
  90. <!-- </el-button>-->
  91. </template>
  92. </el-table-column>
  93. </el-table>
  94. <pagination
  95. :total="page.total"
  96. :page.sync="page.pageNum"
  97. :limit.sync="page.size"
  98. @pagination="nextPage"
  99. />
  100. </div>
  101. </template>
  102. <script>
  103. import Pagination from '@/components/Pagination'
  104. import { Message } from 'element-ui'
  105. import checkPermission from '@/utils/permission'
  106. import PushApi from '@/api/push'
  107. export default {
  108. name: 'List',
  109. components: { Pagination },
  110. data() {
  111. return {
  112. list: [],
  113. search: {},
  114. order: {},
  115. detail: [],
  116. page: { total: 0, size: 0, pageNum: 0 },
  117. listLoading: false,
  118. gameVisible: false
  119. }
  120. },
  121. created() {
  122. this.nextPage()
  123. },
  124. mounted() {
  125. },
  126. methods: {
  127. checkPermission,
  128. openDel(r) {
  129. this.$confirm('此操作将永久id爲 ' + r.id + '的遊戲記錄, 是否继续?', '提示', {
  130. confirmButtonText: '確定',
  131. cancelButtonText: '取消',
  132. type: 'warning'
  133. }).then(() => {
  134. this.delGameLog(r)
  135. }).catch(() => {
  136. this.$message({
  137. type: 'info',
  138. message: '已取消删除'
  139. })
  140. })
  141. },
  142. delGameLog(r) {
  143. PushApi.del({ id: r.id }).then(response => {
  144. Message({
  145. message: '刪除成功',
  146. type: 'success',
  147. duration: 2 * 1000
  148. })
  149. if (response.code === 200) {
  150. this.nextPage()
  151. }
  152. })
  153. },
  154. openDetail(r) {
  155. PushApi.detail({ id: r.id }).then(response => {
  156. if (response.code === 200) {
  157. this.detail = response.data
  158. this.gameVisible = true
  159. }
  160. })
  161. },
  162. nextPage() {
  163. this.listLoading = true
  164. PushApi.getList({ page: this.page.pageNum, search: JSON.stringify(this.search), order: JSON.stringify(this.order) }).then(response => {
  165. this.list = response.data.list
  166. this.page.total = response.data.total
  167. setTimeout(() => {
  168. this.listLoading = false
  169. }, 1 * 1000)
  170. })
  171. },
  172. sortChange(column) {
  173. this.order[column.prop] = column.order
  174. this.nextPage()
  175. },
  176. download() {
  177. PushApi.download({ search: JSON.stringify(this.search), order: JSON.stringify(this.order) }).then(response => {
  178. const url = window.URL.createObjectURL(new Blob([response.data]))
  179. const link = document.createElement('a')
  180. link.style.display = 'none'
  181. link.href = url
  182. link.setAttribute('download', response.headers['filename'])
  183. document.body.appendChild(link)
  184. link.click()
  185. })
  186. },
  187. deleteC() {
  188. const ids = this.$refs.gamelog.selection.map(function(elem, index) {
  189. return elem.id
  190. }).join(',')
  191. PushApi.deleteIds({ ids: ids }).then(response => {
  192. this.nextPage()
  193. })
  194. },
  195. back() {
  196. this.search = {}
  197. this.order = {}
  198. this.nextPage()
  199. }
  200. }
  201. }
  202. </script>
  203. <style scoped>
  204. </style>