|
@@ -0,0 +1,150 @@
|
|
1
|
+<template>
|
|
2
|
+ <div class="body" style="font-size:14px">
|
|
3
|
+ <el-card class="box-card" shadow="never">
|
|
4
|
+ 游戏名称:
|
|
5
|
+ <el-input v-model="title" style="width: 200px; margin-right: 20px" />
|
|
6
|
+ 用户昵称:
|
|
7
|
+ <el-input v-model="nickName" style="width: 200px; margin-right: 20px" />
|
|
8
|
+ 创建时间:
|
|
9
|
+ <el-date-picker
|
|
10
|
+ v-model="daterange"
|
|
11
|
+ type="daterange"
|
|
12
|
+ range-separator="至"
|
|
13
|
+ start-placeholder="开始日期"
|
|
14
|
+ end-placeholder="结束日期"
|
|
15
|
+ value-format="yyyy-MM-dd"
|
|
16
|
+ style="margin-right: 20px"
|
|
17
|
+ @change="dateChange"
|
|
18
|
+ />
|
|
19
|
+ <div style="float:right">
|
|
20
|
+ <el-button type="primary" @click="onSearch">查询</el-button>
|
|
21
|
+ <el-button @click="onReset">重置</el-button>
|
|
22
|
+ <el-button type="primary" icon="el-icon-plus" @click="handleAdd">添加游戏</el-button>
|
|
23
|
+ </div>
|
|
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="title" label="游戏类型" />
|
|
28
|
+ <!-- <el-table-column prop="nickName" label="用户昵称" /> -->
|
|
29
|
+ <el-table-column prop="score" label="答题分数" />
|
|
30
|
+ <el-table-column prop="resultId" label="实例结果" />
|
|
31
|
+ <el-table-column prop="createDate" label="测试时间">
|
|
32
|
+ <template slot-scope="scope">
|
|
33
|
+ {{
|
|
34
|
+ scope.row.createDate.substr(0, 10)
|
|
35
|
+ }}
|
|
36
|
+ </template>
|
|
37
|
+ </el-table-column>
|
|
38
|
+ <el-table-column fixed="right" label="操作">
|
|
39
|
+ <template slot-scope="scope">
|
|
40
|
+ <el-link :underline="false" style="margin-right:1em" type="primary">
|
|
41
|
+ <router-link
|
|
42
|
+ :to="{name: 'gameEdit', query: { id: scope.row.gameId }}"
|
|
43
|
+ >编辑</router-link>
|
|
44
|
+ </el-link>
|
|
45
|
+ <el-popconfirm
|
|
46
|
+ icon="el-icon-info"
|
|
47
|
+ icon-color="red"
|
|
48
|
+ title="确定删除这个游戏吗?"
|
|
49
|
+ @onConfirm="handleDelete(scope.row)"
|
|
50
|
+ >
|
|
51
|
+ <el-button slot="reference" type="text" style="color:red">删除</el-button>
|
|
52
|
+ </el-popconfirm>
|
|
53
|
+ </template>
|
|
54
|
+ </el-table-column>
|
|
55
|
+ </el-table>
|
|
56
|
+ <el-pagination
|
|
57
|
+ v-show="gameTotal!==0"
|
|
58
|
+ style="float:right; margin:20px 0"
|
|
59
|
+ :total="gameTotal"
|
|
60
|
+ :current-page="currentPage"
|
|
61
|
+ :page-sizes="[4, 10, 20, 50]"
|
|
62
|
+ :page-size="pageSize"
|
|
63
|
+ layout="total, prev, pager, next, sizes"
|
|
64
|
+ @size-change="handleSizeChange"
|
|
65
|
+ @current-change="handleCurrentChange"
|
|
66
|
+ />
|
|
67
|
+ </div>
|
|
68
|
+</template>
|
|
69
|
+<script>
|
|
70
|
+import { getGameList, deleteGame } from '@/api/game'
|
|
71
|
+
|
|
72
|
+export default {
|
|
73
|
+ data() {
|
|
74
|
+ return {
|
|
75
|
+ characterId: undefined,
|
|
76
|
+ title: undefined,
|
|
77
|
+ daterange: undefined,
|
|
78
|
+ tableData: [],
|
|
79
|
+ endDate: undefined,
|
|
80
|
+ startDate: undefined,
|
|
81
|
+ //
|
|
82
|
+ pageSize: 10,
|
|
83
|
+ currentPage: 1,
|
|
84
|
+ gameTotal: 0 // 条目总数
|
|
85
|
+ }
|
|
86
|
+ },
|
|
87
|
+ mounted() {
|
|
88
|
+ this.onSearch()
|
|
89
|
+ },
|
|
90
|
+ methods: {
|
|
91
|
+ // 改变每页显示条数
|
|
92
|
+ handleSizeChange(val) {
|
|
93
|
+ this.pageSize = val
|
|
94
|
+ this.changePagination()
|
|
95
|
+ },
|
|
96
|
+ // 改变页码
|
|
97
|
+ handleCurrentChange(val) {
|
|
98
|
+ this.currentPage = val
|
|
99
|
+ this.changePagination()
|
|
100
|
+ },
|
|
101
|
+ // 改变分页组件重新查询数据
|
|
102
|
+ changePagination() {
|
|
103
|
+ getGameList({
|
|
104
|
+ title: this.title,
|
|
105
|
+ startDate: this.startDate,
|
|
106
|
+ endDate: this.endDate,
|
|
107
|
+ pageNum: this.currentPage,
|
|
108
|
+ pageSize: this.pageSize
|
|
109
|
+ }).then((res) => {
|
|
110
|
+ this.tableData = res.data.records
|
|
111
|
+ })
|
|
112
|
+ },
|
|
113
|
+ handleAdd() {
|
|
114
|
+ this.$router.push({ name: 'gameEdit' })
|
|
115
|
+ },
|
|
116
|
+ handleDelete(row) {
|
|
117
|
+ deleteGame(row.gameId).then(() => {
|
|
118
|
+ this.onSearch()
|
|
119
|
+ })
|
|
120
|
+ },
|
|
121
|
+ onSearch() {
|
|
122
|
+ getGameList({
|
|
123
|
+ title: this.title,
|
|
124
|
+ startDate: this.startDate,
|
|
125
|
+ endDate: this.endDate,
|
|
126
|
+ pageSize: this.pageSize
|
|
127
|
+ }).then((res) => {
|
|
128
|
+ this.tableData = res.data.records
|
|
129
|
+ this.gameTotal = res.data.total
|
|
130
|
+ this.pageSize = res.data.size
|
|
131
|
+ })
|
|
132
|
+ },
|
|
133
|
+ onReset() {
|
|
134
|
+ this.title = undefined
|
|
135
|
+ this.daterange = undefined
|
|
136
|
+ this.startDate = undefined
|
|
137
|
+ this.endDate = undefined
|
|
138
|
+ this.currentPage = 1
|
|
139
|
+ this.pageSize = 10
|
|
140
|
+ this.onSearch()
|
|
141
|
+ },
|
|
142
|
+ dateChange(val) {
|
|
143
|
+ this.startDate = this.daterange[0]
|
|
144
|
+ this.endDate = this.daterange[1]
|
|
145
|
+ }
|
|
146
|
+ }
|
|
147
|
+}
|
|
148
|
+</script>
|
|
149
|
+<style>
|
|
150
|
+</style>
|