|
@@ -0,0 +1,349 @@
|
|
1
|
+<template>
|
|
2
|
+ <div class="app-container calendar-list-container">
|
|
3
|
+ <div v-show="visible.secondLayer">
|
|
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
|
+ </div>
|
|
17
|
+ <el-table :data="list" v-loading.body="listLoading" element-loading-text="Loading" border fit highlight-current-row
|
|
18
|
+ style="width: 100%">
|
|
19
|
+ <el-table-column align="center" label='ID' >
|
|
20
|
+ <template slot-scope="scope">
|
|
21
|
+ {{scope.row.id}}
|
|
22
|
+ </template>
|
|
23
|
+ </el-table-column>
|
|
24
|
+ <el-table-column label="名稱" align="center">
|
|
25
|
+ <template slot-scope="scope">
|
|
26
|
+ {{scope.row.name}}
|
|
27
|
+ </template>
|
|
28
|
+ </el-table-column>
|
|
29
|
+ <el-table-column label="點數" align="center">
|
|
30
|
+ <template slot-scope="scope">
|
|
31
|
+ <span>{{scope.row.chips}}</span>
|
|
32
|
+ </template>
|
|
33
|
+ </el-table-column>
|
|
34
|
+ <el-table-column label="代理商" align="center">
|
|
35
|
+ <template slot-scope="scope">
|
|
36
|
+ {{!scope.row.GambleAgent ? 'N/A': scope.row.GambleAgent.name}}
|
|
37
|
+ </template>
|
|
38
|
+ </el-table-column>
|
|
39
|
+ <el-table-column align="center" label="操作" width="450">
|
|
40
|
+ <template slot-scope="scope">
|
|
41
|
+ <el-button type="primary" size="mini" icon="el-icon-edit" @click="handleChipsMangement(scope.row)">分數管理</el-button>
|
|
42
|
+ <router-link to="/room/index/gambleMember/index/chipsHistory">
|
|
43
|
+ <el-button type="primary" size="mini" icon="el-icon-tickets" @click="handleLog(scope.row)">分數紀錄</el-button>
|
|
44
|
+ </router-link>
|
|
45
|
+ <el-button type="primary" size="mini" icon="el-icon-edit" @click="handleAgentUpdate(scope.row)">代理商設定</el-button>
|
|
46
|
+ <router-link to="/room/index/gambleMember/index/gameHistory">
|
|
47
|
+ <el-button type="primary" size="mini" icon="el-icon-tickets" @click="handlePage(scope.row)">歷史查詢</el-button>
|
|
48
|
+ </router-link>
|
|
49
|
+ </template>
|
|
50
|
+ </el-table-column>
|
|
51
|
+ </el-table>
|
|
52
|
+
|
|
53
|
+ <div v-show="!listLoading" class="pagination-container">
|
|
54
|
+ <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="listQuery.page"
|
|
55
|
+ :page-sizes="[10,20,30, 50]" :page-size="listQuery.limit" layout="total, sizes, prev, pager, next, jumper" :total="total">
|
|
56
|
+ </el-pagination>
|
|
57
|
+ </div>
|
|
58
|
+
|
|
59
|
+ <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" :before-close="handleDialogClose" center>
|
|
60
|
+ <el-tabs v-model="activeName" @tab-click="handleClick" type="card">
|
|
61
|
+ <el-tab-pane label="上下分" name="deposit">
|
|
62
|
+ <el-form :rules="rules" ref="depositForm" :model="temp" label-position="left" label-width="100px" style='width: 400px; margin-left:50px;'>
|
|
63
|
+ <el-form-item label="ID" prop="id">
|
|
64
|
+ <el-input v-model="temp.id" :disabled="true"></el-input>
|
|
65
|
+ </el-form-item>
|
|
66
|
+ <el-form-item label="名稱" prop="name">
|
|
67
|
+ <el-input v-if="dialogStatus=='deposit'" v-model="temp.name" :disabled="true"></el-input>
|
|
68
|
+ </el-form-item>
|
|
69
|
+ <el-form-item label="點數" prop="chips">
|
|
70
|
+ <el-input v-model="temp.chips" :disabled="true"></el-input>
|
|
71
|
+ </el-form-item>
|
|
72
|
+ <el-form-item v-if="dialogStatus=='deposit'" label="上下分" prop="depositChips">
|
|
73
|
+ <el-input placeholder="請輸入上下分" v-model="temp.depositChips"></el-input>
|
|
74
|
+ </el-form-item>
|
|
75
|
+ </el-form>
|
|
76
|
+ </el-tab-pane>
|
|
77
|
+ <el-tab-pane label="獎懲" name="reward">
|
|
78
|
+ <el-form :rules="rules" ref="rewardForm" :model="temp" label-position="left" label-width="100px" style='width: 400px; margin-left:50px;'>
|
|
79
|
+ <el-form-item label="ID" prop="id">
|
|
80
|
+ <el-input v-model="temp.id" :disabled="true"></el-input>
|
|
81
|
+ </el-form-item>
|
|
82
|
+ <el-form-item label="名稱" prop="name">
|
|
83
|
+ <el-input v-model="temp.name" :disabled="true"></el-input>
|
|
84
|
+ </el-form-item>
|
|
85
|
+ <el-form-item label="點數" prop="chips">
|
|
86
|
+ <el-input v-model="temp.chips" :disabled="true"></el-input>
|
|
87
|
+ </el-form-item>
|
|
88
|
+ <el-form-item v-if="dialogStatus=='reward'" label="獎懲" prop="rewardChips">
|
|
89
|
+ <el-input placeholder="請輸入獎懲點數" v-model="temp.rewardChips"></el-input>
|
|
90
|
+ </el-form-item>
|
|
91
|
+ </el-form>
|
|
92
|
+ </el-tab-pane>
|
|
93
|
+ </el-tabs>
|
|
94
|
+
|
|
95
|
+ <div slot="footer" class="dialog-footer">
|
|
96
|
+ <el-button @click="handleDialogClose">取 消</el-button>
|
|
97
|
+ <el-button v-if="dialogStatus=='reward'" type="primary" @click="rewardChips">確 定</el-button>
|
|
98
|
+ <el-button v-if="dialogStatus=='deposit'" type="primary" @click="depositChips">確 定</el-button>
|
|
99
|
+ </div>
|
|
100
|
+ </el-dialog>
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+ <el-dialog title="所屬代理商" :visible.sync="dialogUpdateFormVisible" :before-close="handleDialogClose" center>
|
|
104
|
+ <el-form :rules="rules" :model="temp" ref="updateForm" label-position="left" label-width="100px" style='width: 400px; margin-left:50px;'>
|
|
105
|
+ <el-form-item label="使用者" prop="id">
|
|
106
|
+ <el-input v-model="temp.name" :disabled="true"></el-input>
|
|
107
|
+ </el-form-item>
|
|
108
|
+ <el-form-item label="代理商" prop="name">
|
|
109
|
+ <multiselect v-model="updateFormData" :options="agentLIstOptions" @search-change="getRemoteAgentList" placeholder="代理商搜尋" selectLabel="選擇"
|
|
110
|
+ deselectLabel="删除" track-by="key" :internalSearch="false" label="key">
|
|
111
|
+ <span slot='noResult'>無結果</span>
|
|
112
|
+ </multiselect>
|
|
113
|
+ </el-form-item>
|
|
114
|
+ </el-form>
|
|
115
|
+ <div slot="footer" class="dialog-footer">
|
|
116
|
+ <el-button @click="handleDialogClose">取 消</el-button>
|
|
117
|
+ <el-button type="primary" @click="updateData">確 定</el-button>
|
|
118
|
+ </div>
|
|
119
|
+ </el-dialog>
|
|
120
|
+
|
|
121
|
+ </div>
|
|
122
|
+ <router-view :member="member"></router-view>
|
|
123
|
+ </div>
|
|
124
|
+</template>
|
|
125
|
+
|
|
126
|
+<script>
|
|
127
|
+
|
|
128
|
+import { mapGetters, mapActions } from 'vuex'
|
|
129
|
+// TODO 需更改抓取此房間人員
|
|
130
|
+import { fetchList, chipsDeposit, chipsReward, createGambleMember, fetchAgentList, updateBelongAgent } from '@/api/gambleMember'
|
|
131
|
+import waves from '@/directive/waves' // 水波纹指令
|
|
132
|
+import Multiselect from 'vue-multiselect'// 使用的一个多选框组件,element-ui的select不能满足所有需求
|
|
133
|
+import 'vue-multiselect/dist/vue-multiselect.min.css'// 多选框组件css
|
|
134
|
+
|
|
135
|
+export default {
|
|
136
|
+ name: 'gambleMemberTable',
|
|
137
|
+ components: { Multiselect },
|
|
138
|
+ directives: {
|
|
139
|
+ waves
|
|
140
|
+ },
|
|
141
|
+ data() {
|
|
142
|
+ return {
|
|
143
|
+ list: null,
|
|
144
|
+ total: null,
|
|
145
|
+ listLoading: true,
|
|
146
|
+ listQuery: {
|
|
147
|
+ page: 1,
|
|
148
|
+ limit: 20,
|
|
149
|
+ chipsSort: '',
|
|
150
|
+ updatedSort: ''
|
|
151
|
+ },
|
|
152
|
+ temp: {
|
|
153
|
+ id: '',
|
|
154
|
+ name: '',
|
|
155
|
+ chips: '',
|
|
156
|
+ depositChips: '',
|
|
157
|
+ rewardChips: '',
|
|
158
|
+ },
|
|
159
|
+ dialogFormVisible: false,
|
|
160
|
+ dialogStatus: '',
|
|
161
|
+ textMap: {
|
|
162
|
+ deposit: '上下分',
|
|
163
|
+ reward: '獎懲'
|
|
164
|
+ },
|
|
165
|
+ member: {},
|
|
166
|
+ chipsSortOptions: [{ label: '多 -> 少', key: 'DESC' }, { label: '少 -> 多', key: 'ASC' }],
|
|
167
|
+ updatedSortOptions: [{ label: '新 -> 舊', key: 'DESC' }, { label: '舊 -> 新', key: 'ASC' }],
|
|
168
|
+ rules: {
|
|
169
|
+ rewardChips: [{ pattern: /^-?\d+$/, required: true, message: '請輸入整數', trigger: 'change' }],
|
|
170
|
+ depositChips: [{ pattern: /^-?\d+$/, required: true, message: '請輸入整數', trigger: 'change' }],
|
|
171
|
+ // chips: [{ pattern: /^(0|[1-9][0-9]*)$/, required: true, message: '請輸入整數', trigger: 'change' }],
|
|
172
|
+ // name: [{ type: 'string', required: true, message: '必填', trigger: 'change' }]
|
|
173
|
+ },
|
|
174
|
+ activeName: 'deposit',
|
|
175
|
+ dialogUpdateFormVisible: false,
|
|
176
|
+ updateFormData: {},
|
|
177
|
+ agentLIstOptions: [],
|
|
178
|
+ }
|
|
179
|
+ },
|
|
180
|
+ created() {
|
|
181
|
+ this.SetVisible(2)
|
|
182
|
+ this.getList()
|
|
183
|
+ },
|
|
184
|
+ destroyed() {
|
|
185
|
+ this.SetVisible(1)
|
|
186
|
+ },
|
|
187
|
+ computed: {
|
|
188
|
+ ...mapGetters([
|
|
189
|
+ 'visible'
|
|
190
|
+ ])
|
|
191
|
+ },
|
|
192
|
+ methods: {
|
|
193
|
+ ...mapActions([
|
|
194
|
+ 'SetVisible'
|
|
195
|
+ ]),
|
|
196
|
+ getList() {
|
|
197
|
+ this.listLoading = true
|
|
198
|
+ fetchList(this.listQuery).then(response => {
|
|
199
|
+ console.log('list',response.data.rows)
|
|
200
|
+ this.list = response.data.rows
|
|
201
|
+ this.total = response.data.count
|
|
202
|
+ this.listLoading = false
|
|
203
|
+ })
|
|
204
|
+ },
|
|
205
|
+ handleChipsMangement(row) {
|
|
206
|
+ this.temp = Object.assign({}, row) // copy obj
|
|
207
|
+ this.dialogStatus = 'deposit'
|
|
208
|
+ this.dialogFormVisible = true
|
|
209
|
+ this.$nextTick(() => {
|
|
210
|
+ this.$refs['depositForm'].clearValidate()
|
|
211
|
+ this.$refs['rewardForm'].clearValidate()
|
|
212
|
+ })
|
|
213
|
+ },
|
|
214
|
+ depositChips() {
|
|
215
|
+ this.$refs['depositForm'].validate((valid) => {
|
|
216
|
+ if (valid) {
|
|
217
|
+ const tempData = Object.assign({}, this.temp)
|
|
218
|
+ chipsDeposit(tempData).then(() => {
|
|
219
|
+ for (const v of this.list) {
|
|
220
|
+ if (v.id === this.temp.id) {
|
|
221
|
+ const index = this.list.indexOf(v)
|
|
222
|
+ this.list.splice(index, 1, this.temp)
|
|
223
|
+ break
|
|
224
|
+ }
|
|
225
|
+ }
|
|
226
|
+ this.dialogFormVisible = false
|
|
227
|
+ this.$notify({
|
|
228
|
+ title: '成功',
|
|
229
|
+ message: '操作成功',
|
|
230
|
+ type: 'success',
|
|
231
|
+ duration: 2000
|
|
232
|
+ })
|
|
233
|
+ this.getList()
|
|
234
|
+ })
|
|
235
|
+ }
|
|
236
|
+ })
|
|
237
|
+ },
|
|
238
|
+ resetTemp() {
|
|
239
|
+ this.temp = {
|
|
240
|
+ id: undefined,
|
|
241
|
+ name: '',
|
|
242
|
+ chips: '',
|
|
243
|
+ depositChips: ''
|
|
244
|
+ }
|
|
245
|
+ },
|
|
246
|
+ handlePage(row) {
|
|
247
|
+ const temp = Object.assign({}, row) // copy obj
|
|
248
|
+ this.SetVisible(3)
|
|
249
|
+ this.member = temp
|
|
250
|
+ },
|
|
251
|
+ handleLog(row) {
|
|
252
|
+ const temp = Object.assign({}, row) // copy obj
|
|
253
|
+ this.SetVisible(3)
|
|
254
|
+ this.member = temp
|
|
255
|
+ },
|
|
256
|
+ handleFilter() {
|
|
257
|
+ this.listQuery.page = 1
|
|
258
|
+ this.getList()
|
|
259
|
+ },
|
|
260
|
+ handleSizeChange(val) {
|
|
261
|
+ this.listQuery.limit = val
|
|
262
|
+ this.getList()
|
|
263
|
+ },
|
|
264
|
+ handleCurrentChange(val) {
|
|
265
|
+ this.listQuery.page = val
|
|
266
|
+ this.getList()
|
|
267
|
+ },
|
|
268
|
+ handleClick(tab, event) {
|
|
269
|
+ this.dialogStatus = tab.name;
|
|
270
|
+ },
|
|
271
|
+ handleDialogClose() {
|
|
272
|
+ this.activeName = 'deposit';
|
|
273
|
+ this.dialogFormVisible = false;
|
|
274
|
+ this.dialogUpdateFormVisible = false;
|
|
275
|
+ },
|
|
276
|
+ rewardChips() {
|
|
277
|
+ this.$refs['rewardForm'].validate((valid) => {
|
|
278
|
+ if (valid) {
|
|
279
|
+ const tempData = Object.assign({}, this.temp)
|
|
280
|
+ chipsReward(tempData).then(() => {
|
|
281
|
+ for (const v of this.list) {
|
|
282
|
+ if (v.id === this.temp.id) {
|
|
283
|
+ const index = this.list.indexOf(v)
|
|
284
|
+ this.list.splice(index, 1, this.temp)
|
|
285
|
+ break
|
|
286
|
+ }
|
|
287
|
+ }
|
|
288
|
+ this.dialogFormVisible = false
|
|
289
|
+ this.$notify({
|
|
290
|
+ title: '成功',
|
|
291
|
+ message: '操作成功',
|
|
292
|
+ type: 'success',
|
|
293
|
+ duration: 2000
|
|
294
|
+ })
|
|
295
|
+ this.getList()
|
|
296
|
+ })
|
|
297
|
+ }
|
|
298
|
+ })
|
|
299
|
+ },
|
|
300
|
+ handleAgentUpdate(row) {
|
|
301
|
+ this.temp = Object.assign({}, row) // copy obj
|
|
302
|
+ this.dialogUpdateFormVisible = true;
|
|
303
|
+ this.$nextTick(() => {
|
|
304
|
+ this.$refs['updateForm'].clearValidate()
|
|
305
|
+ })
|
|
306
|
+ },
|
|
307
|
+ updateData() {
|
|
308
|
+ this.$refs['updateForm'].validate((valid) => {
|
|
309
|
+ if (valid) {
|
|
310
|
+ const tempMember = Object.assign({}, this.temp)
|
|
311
|
+ const tempAgent = Object.assign({}, this.updateFormData.value)
|
|
312
|
+ console.log('aaaaa',tempAgent)
|
|
313
|
+ updateBelongAgent(tempMember, tempAgent).then(() => {
|
|
314
|
+ for (const v of this.list) {
|
|
315
|
+ if (v.id === this.temp.id) {
|
|
316
|
+ const index = this.list.indexOf(v)
|
|
317
|
+ this.list.splice(index, 1, this.temp)
|
|
318
|
+ break
|
|
319
|
+ }
|
|
320
|
+ }
|
|
321
|
+ this.dialogUpdateFormVisible = false
|
|
322
|
+ this.$notify({
|
|
323
|
+ title: '成功',
|
|
324
|
+ message: '操作成功',
|
|
325
|
+ type: 'success',
|
|
326
|
+ duration: 2000
|
|
327
|
+ })
|
|
328
|
+ this.getList()
|
|
329
|
+ })
|
|
330
|
+ }
|
|
331
|
+ })
|
|
332
|
+ },
|
|
333
|
+ getRemoteAgentList(query) {
|
|
334
|
+ fetchAgentList(query).then(response => {
|
|
335
|
+ if (!response.data.rows) return
|
|
336
|
+ this.agentLIstOptions = response.data.rows.map(v => ({
|
|
337
|
+ key: v.GambleMember.name,
|
|
338
|
+ value: v.GambleMember
|
|
339
|
+ }))
|
|
340
|
+ })
|
|
341
|
+ }
|
|
342
|
+ },
|
|
343
|
+ // watch: {
|
|
344
|
+ // activeName: (val) => {
|
|
345
|
+ // console.log('test', val);
|
|
346
|
+ // }
|
|
347
|
+ // }
|
|
348
|
+}
|
|
349
|
+</script>
|