123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- <template>
- <div class="body" style="font-size:14px">
- <el-card class="box-card">
- 游戏名称:<el-input
- v-model="title"
- size="mini"
- style="width: 200px; margin-right: 20px"
- />
- 创建时间:
- <el-date-picker
- v-model="daterange"
- size="mini"
- type="daterange"
- range-separator="至"
- start-placeholder="开始日期"
- end-placeholder="结束日期"
- value-format="yyyy-MM-dd"
- style="margin-right: 20px"
- @change="dateChange"
- />
- <el-button type="primary" size="mini" @click="onSearch">查询</el-button>
- <el-button size="mini" @click="onReset">重置</el-button>
- <el-button type="primary" size="mini" @click="handleAdd">添加游戏</el-button>
- </el-card>
- <el-table stripe :data="tableData" border style="width: 100%">
- <el-table-column prop="title" label="游戏名称" />
- <el-table-column prop="gameImage" label="游戏图标">
- <template slot-scope="scope">
- <el-image :src="scope.row.gameImage" style="width: 100px; height: 100px" />
- </template>
- </el-table-column>
- <el-table-column prop="createDate" label="创建时间">
- <template slot-scope="scope">{{
- scope.row.createDate.substr(0, 10)
- }}</template>
- </el-table-column>
- <el-table-column fixed="right" label="操作">
- <template slot-scope="scope">
- <el-button type="text" @click="handleEdit(scope.row)">编辑</el-button>
- <el-popconfirm
- icon="el-icon-info"
- icon-color="red"
- title="确定删除这个游戏吗?"
- @onConfirm="handleDelete(scope.row)"
- >
- <el-button slot="reference" type="text">删除</el-button>
- </el-popconfirm>
- </template>
- </el-table-column>
- </el-table>
- <el-pagination
- style="float:right; margin:20px 0"
- :total="gameTotal"
- :current-page="currentPage"
- :page-sizes="[10, 50, 100]"
- :page-size="pageSize"
- layout="total, sizes, prev, pager, next, jumper"
- @current-change="handleCurrentChange"
- />
- </div>
- </template>
- <script>
- import { getGameList, deleteGame } from '@/api/game'
-
- export default {
- data() {
- return {
- characterId: undefined,
- title: undefined,
- daterange: undefined,
- tableData: [],
- endDate: undefined,
- startDate: undefined,
- //
- pageSize: 10,
- currentPage: 1,
- gameTotal: 0// 条目总数
- }
- },
- mounted() {
- this.onSearch()
- },
- methods: {
- handleCurrentChange(val) {
- this.currentPage = val
- this.onSearch()
- },
- //
- handleAdd() {
- this.$router.push({ name: 'gameEdit' })
- },
- handleEdit(row) {
- this.$router.push({
- name: 'gameEdit',
- query: { id: row.gameId }
- })
- },
- handleDelete(row) {
- deleteGame(row.gameId).then(() => {
- this.onSearch()
- })
- },
- onSearch() {
- getGameList({
- title: this.title,
- startDate: this.startDate,
- endDate: this.endDate,
- pageNum: this.currentPage
- }).then((res) => {
- this.tableData = res.data.records
- this.gameTotal = res.data.total
- this.pageSize = res.data.size
- this.currentPage = res.data.current
- })
- },
- onReset() {
- this.title = undefined
- this.daterange = undefined
- this.startDate = undefined
- this.endDate = undefined
- this.onSearch()
- },
- dateChange(val) {
- this.startDate = this.daterange[0]
- this.endDate = this.daterange[1]
- }
- }
- }
- </script>
- <style>
- </style>
|