|
@@ -0,0 +1,236 @@
|
|
1
|
+<template>
|
|
2
|
+<div class="app-container calendar-list-container">
|
|
3
|
+ <div v-show="visible">
|
|
4
|
+ <div class="app-container">
|
|
5
|
+ <el-input @keyup.enter.native="handleFilter" style="width: 200px;" class="filter-item" placeholder="名稱" v-model="listQuery.name">
|
|
6
|
+ </el-input>
|
|
7
|
+ <el-select clearable @change='handleFilter' style="width: 120px" class="filter-item" v-model="listQuery.chipsSort" placeholder="點數">
|
|
8
|
+ <el-option v-for="item in chipsSortOptions" :key="item.label" :label="item.label" :value="item.key">
|
|
9
|
+ </el-option>
|
|
10
|
+ </el-select>
|
|
11
|
+ <el-select clearable @change='handleFilter' style="width: 120px" class="filter-item" v-model="listQuery.updatedSort" placeholder="更新時間">
|
|
12
|
+ <el-option v-for="item in updatedSortOptions" :key="item.label" :label="item.label" :value="item.key">
|
|
13
|
+ </el-option>
|
|
14
|
+ </el-select>
|
|
15
|
+ <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">搜尋</el-button>
|
|
16
|
+ <el-button class="filter-item" @click="handleCreate" type="primary" icon="el-icon-edit">創建</el-button>
|
|
17
|
+ </div>
|
|
18
|
+ <el-table :data="list" v-loading.body="listLoading" element-loading-text="Loading" border fit highlight-current-row
|
|
19
|
+ style="width: 100%">
|
|
20
|
+ <el-table-column align="center" label='ID' >
|
|
21
|
+ <template slot-scope="scope">
|
|
22
|
+ {{scope.row.id}}
|
|
23
|
+ </template>
|
|
24
|
+ </el-table-column>
|
|
25
|
+ <el-table-column label="名稱" align="center">
|
|
26
|
+ <template slot-scope="scope">
|
|
27
|
+ {{scope.row.name}}
|
|
28
|
+ </template>
|
|
29
|
+ </el-table-column>
|
|
30
|
+ <el-table-column label="點數" align="center">
|
|
31
|
+ <template slot-scope="scope">
|
|
32
|
+ <span>{{scope.row.chips}}</span>
|
|
33
|
+ </template>
|
|
34
|
+ </el-table-column>
|
|
35
|
+ <el-table-column align="center" label="操作" width="350">
|
|
36
|
+ <template slot-scope="scope">
|
|
37
|
+ <el-button type="primary" size="mini" icon="el-icon-edit" @click="handleDeposit(scope.row)">上下分</el-button>
|
|
38
|
+ <router-link to="/gambleMember/index/chipsHistory">
|
|
39
|
+ <el-button type="primary" size="mini" icon="el-icon-tickets" @click="handleLog(scope.row)">上下分紀錄</el-button>
|
|
40
|
+ </router-link>
|
|
41
|
+ <router-link to="/gambleMember/index/gameHistory">
|
|
42
|
+ <el-button type="primary" size="mini" icon="el-icon-tickets" @click="handlePage(scope.row)">歷史查詢</el-button>
|
|
43
|
+ </router-link>
|
|
44
|
+ </template>
|
|
45
|
+ </el-table-column>
|
|
46
|
+ </el-table>
|
|
47
|
+
|
|
48
|
+ <div v-show="!listLoading" class="pagination-container">
|
|
49
|
+ <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="listQuery.page"
|
|
50
|
+ :page-sizes="[10,20,30, 50]" :page-size="listQuery.limit" layout="total, sizes, prev, pager, next, jumper" :total="total">
|
|
51
|
+ </el-pagination>
|
|
52
|
+ </div>
|
|
53
|
+
|
|
54
|
+ <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
|
|
55
|
+ <el-form :rules="rules" ref="dataForm" :model="temp" label-position="left" label-width="100px" style='width: 400px; margin-left:50px;'>
|
|
56
|
+ <el-form-item v-if="dialogStatus=='deposit'" label="ID" prop="id">
|
|
57
|
+ <el-input v-model="temp.id" :disabled="true"></el-input>
|
|
58
|
+ </el-form-item>
|
|
59
|
+ <el-form-item label="名稱" prop="name">
|
|
60
|
+ <el-input v-if="dialogStatus=='deposit'" v-model="temp.name" :disabled="true"></el-input>
|
|
61
|
+ <el-input v-if="dialogStatus=='create'" v-model="temp.name"></el-input>
|
|
62
|
+ </el-form-item>
|
|
63
|
+ <el-form-item label="點數" prop="chips">
|
|
64
|
+ <el-input v-if="dialogStatus=='deposit'" v-model="temp.chips" :disabled="true"></el-input>
|
|
65
|
+ <el-input v-if="dialogStatus=='create'" v-model="temp.chips"></el-input>
|
|
66
|
+ </el-form-item>
|
|
67
|
+ <el-form-item v-if="dialogStatus=='deposit'" label="上下分" prop="depositChips">
|
|
68
|
+ <el-input placeholder="請輸入上下分" v-model="temp.depositChips">
|
|
69
|
+ </el-input>
|
|
70
|
+ </el-form-item>
|
|
71
|
+ </el-form>
|
|
72
|
+ <div slot="footer" class="dialog-footer">
|
|
73
|
+ <el-button @click="dialogFormVisible = false">取 消</el-button>
|
|
74
|
+ <el-button v-if="dialogStatus=='create'" type="primary" @click="createData">確 定</el-button>
|
|
75
|
+ <el-button v-if="dialogStatus=='deposit'" type="primary" @click="depositChips">確 定</el-button>
|
|
76
|
+ </div>
|
|
77
|
+ </el-dialog>
|
|
78
|
+ </div>
|
|
79
|
+ <router-view :member="member"></router-view>
|
|
80
|
+ </div>
|
|
81
|
+</template>
|
|
82
|
+
|
|
83
|
+<script>
|
|
84
|
+
|
|
85
|
+import { mapGetters, mapActions } from 'vuex'
|
|
86
|
+import { fetchList, updateChips, createGambleMember } from '@/api/gambleMember'
|
|
87
|
+import waves from '@/directive/waves' // 水波纹指令
|
|
88
|
+
|
|
89
|
+export default {
|
|
90
|
+ name: 'gambleMemberTable',
|
|
91
|
+ directives: {
|
|
92
|
+ waves
|
|
93
|
+ },
|
|
94
|
+ data() {
|
|
95
|
+ return {
|
|
96
|
+ list: null,
|
|
97
|
+ total: null,
|
|
98
|
+ listLoading: true,
|
|
99
|
+ listQuery: {
|
|
100
|
+ page: 1,
|
|
101
|
+ limit: 20,
|
|
102
|
+ chipsSort: '',
|
|
103
|
+ updatedSort: ''
|
|
104
|
+ },
|
|
105
|
+ temp: {
|
|
106
|
+ id: '',
|
|
107
|
+ name: '',
|
|
108
|
+ chips: '',
|
|
109
|
+ depositChips: ''
|
|
110
|
+ },
|
|
111
|
+ dialogFormVisible: false,
|
|
112
|
+ dialogStatus: '',
|
|
113
|
+ textMap: {
|
|
114
|
+ deposit: '儲值',
|
|
115
|
+ create: '新增'
|
|
116
|
+ },
|
|
117
|
+ member: {},
|
|
118
|
+ chipsSortOptions: [{ label: '多 -> 少', key: 'DESC' }, { label: '少 -> 多', key: 'ASC' }],
|
|
119
|
+ updatedSortOptions: [{ label: '新 -> 舊', key: 'DESC' }, { label: '舊 -> 新', key: 'ASC' }],
|
|
120
|
+ rules: {
|
|
121
|
+ depositChips: [{ pattern: /^-?\d+$/, required: true, message: '請輸入整數', trigger: 'change' }],
|
|
122
|
+ chips: [{ pattern: /^(0|[1-9][0-9]*)$/, required: true, message: '請輸入整數', trigger: 'change' }],
|
|
123
|
+ name: [{ type: 'string', required: true, message: '必填', trigger: 'change' }]
|
|
124
|
+ }
|
|
125
|
+ }
|
|
126
|
+ },
|
|
127
|
+ created() {
|
|
128
|
+ this.SetVisible(true)
|
|
129
|
+ this.getList()
|
|
130
|
+ },
|
|
131
|
+ computed: {
|
|
132
|
+ ...mapGetters([
|
|
133
|
+ 'visible'
|
|
134
|
+ ])
|
|
135
|
+ },
|
|
136
|
+ methods: {
|
|
137
|
+ ...mapActions([
|
|
138
|
+ 'SetVisible'
|
|
139
|
+ ]),
|
|
140
|
+ getList() {
|
|
141
|
+ this.listLoading = true
|
|
142
|
+ fetchList(this.listQuery).then(response => {
|
|
143
|
+ this.list = response.data.rows
|
|
144
|
+ this.total = response.data.count
|
|
145
|
+ this.listLoading = false
|
|
146
|
+ })
|
|
147
|
+ },
|
|
148
|
+ handleDeposit(row) {
|
|
149
|
+ this.temp = Object.assign({}, row) // copy obj
|
|
150
|
+ this.dialogStatus = 'deposit'
|
|
151
|
+ this.dialogFormVisible = true
|
|
152
|
+ this.$nextTick(() => {
|
|
153
|
+ this.$refs['dataForm'].clearValidate()
|
|
154
|
+ })
|
|
155
|
+ },
|
|
156
|
+ depositChips() {
|
|
157
|
+ this.$refs['dataForm'].validate((valid) => {
|
|
158
|
+ if (valid) {
|
|
159
|
+ const tempData = Object.assign({}, this.temp)
|
|
160
|
+ updateChips(tempData).then(() => {
|
|
161
|
+ for (const v of this.list) {
|
|
162
|
+ if (v.id === this.temp.id) {
|
|
163
|
+ const index = this.list.indexOf(v)
|
|
164
|
+ this.list.splice(index, 1, this.temp)
|
|
165
|
+ break
|
|
166
|
+ }
|
|
167
|
+ }
|
|
168
|
+ this.dialogFormVisible = false
|
|
169
|
+ this.$notify({
|
|
170
|
+ title: '成功',
|
|
171
|
+ message: '操作成功',
|
|
172
|
+ type: 'success',
|
|
173
|
+ duration: 2000
|
|
174
|
+ })
|
|
175
|
+ this.getList()
|
|
176
|
+ })
|
|
177
|
+ }
|
|
178
|
+ })
|
|
179
|
+ },
|
|
180
|
+ resetTemp() {
|
|
181
|
+ this.temp = {
|
|
182
|
+ id: undefined,
|
|
183
|
+ name: '',
|
|
184
|
+ chips: '',
|
|
185
|
+ depositChips: ''
|
|
186
|
+ }
|
|
187
|
+ },
|
|
188
|
+ handleCreate() {
|
|
189
|
+ this.resetTemp()
|
|
190
|
+ this.dialogStatus = 'create'
|
|
191
|
+ this.dialogFormVisible = true
|
|
192
|
+ this.$nextTick(() => {
|
|
193
|
+ this.$refs['dataForm'].clearValidate()
|
|
194
|
+ })
|
|
195
|
+ },
|
|
196
|
+ createData() {
|
|
197
|
+ this.$refs['dataForm'].validate((valid) => {
|
|
198
|
+ if (valid) {
|
|
199
|
+ createGambleMember(this.temp).then((response) => {
|
|
200
|
+ this.list.unshift(response.data)
|
|
201
|
+ this.dialogFormVisible = false
|
|
202
|
+ this.$notify({
|
|
203
|
+ title: '成功',
|
|
204
|
+ message: '創建成功',
|
|
205
|
+ type: 'success',
|
|
206
|
+ duration: 2000
|
|
207
|
+ })
|
|
208
|
+ })
|
|
209
|
+ }
|
|
210
|
+ })
|
|
211
|
+ },
|
|
212
|
+ handlePage(row) {
|
|
213
|
+ const temp = Object.assign({}, row) // copy obj
|
|
214
|
+ this.SetVisible(false)
|
|
215
|
+ this.member = temp
|
|
216
|
+ },
|
|
217
|
+ handleLog(row) {
|
|
218
|
+ const temp = Object.assign({}, row) // copy obj
|
|
219
|
+ this.SetVisible(false)
|
|
220
|
+ this.member = temp
|
|
221
|
+ },
|
|
222
|
+ handleFilter() {
|
|
223
|
+ this.listQuery.page = 1
|
|
224
|
+ this.getList()
|
|
225
|
+ },
|
|
226
|
+ handleSizeChange(val) {
|
|
227
|
+ this.listQuery.limit = val
|
|
228
|
+ this.getList()
|
|
229
|
+ },
|
|
230
|
+ handleCurrentChange(val) {
|
|
231
|
+ this.listQuery.page = val
|
|
232
|
+ this.getList()
|
|
233
|
+ }
|
|
234
|
+ }
|
|
235
|
+}
|
|
236
|
+</script>
|