浏览代码

TODO fix router

ethan 6 年之前
父节点
当前提交
03d9344ae4

+ 14 - 1
src/router/index.js

@@ -79,7 +79,19 @@ export const constantRouterMap = [
79 79
                 meta: {
80 80
                   title: '歷史紀錄'
81 81
                   // role: ['dd']
82
-                }
82
+                },
83
+                children: [
84
+                  {
85
+                    path: '/room/index/gambleMember/index/gameHistory/detail/index',
86
+                    name: 'bucketHistory',
87
+                    component: _import('room/detail/index'),
88
+                    hidden: true,
89
+                    meta: {
90
+                      title: '詳細記錄'
91
+                      // role: ['dd']
92
+                    }
93
+                  }
94
+                ]
83 95
               },
84 96
               {
85 97
                 path: '/room/index/gambleMember/index/chipsHistory',
@@ -169,6 +181,7 @@ export const constantRouterMap = [
169 181
                   title: '歷史紀錄'
170 182
                   // role: ['dd']
171 183
                 }
184
+                
172 185
               }
173 186
             ]
174 187
           }

+ 1 - 0
src/views/gambleGameBucket/detail/index.vue

@@ -215,6 +215,7 @@ export default {
215 215
     }
216 216
   },
217 217
   created() {
218
+    console.log('eeee', this.data.secondLayer)
218 219
     fetchRoundRecord(this.data.secondLayer, this.listQuery).then(response => {
219 220
       this.roundTime = response.data.createdAt
220 221
       this.door = response.data.initialDoor

+ 509 - 0
src/views/room/detail/index.vue

@@ -0,0 +1,509 @@
1
+<template>
2
+<div v-show="visible.fourLayer" class="app-container calendar-list-container">
3
+  <div class="app-container">
4
+     <div class="block">
5
+      <el-row :gutter="20">
6
+        <el-col :span="6">
7
+          <span class="demonstration">關數</span>
8
+          <el-select @change='handleFilter' style="width: 120px" class="filter-item" v-model="listQuery.round" placeholder="關">
9
+          <el-option v-for="item in roundOptions" :key="item.label" :label="item.label" :value="item.key">
10
+          </el-option>
11
+        </el-select>
12
+        </el-col >
13
+        <el-col :offset="10" :span="8">
14
+            <span class="demonstration">時間 : {{moment(this.roundTime)}}</span>
15
+        </el-col>
16
+      </el-row>
17
+    </div>
18
+  </div>
19
+    <el-table header-row-class-name="init" :data="bookie" v-loading.body="listLoading" element-loading-text="Loading" border fit highlight-current-row
20
+      style="width: 100%">      
21
+      <el-table-column label="本期開獎" lable-className="title" align="center">   
22
+        <el-table-column label="莊家結果" align="center">            
23
+                  
24
+          <el-table-column label="莊家" prop="MemberRecord.GambleMember.name"></el-table-column>
25
+          <el-table-column label="點數">
26
+            <template slot-scope="scope">
27
+              <span>{{`${scope.row.DealingRecord.point1} | ${scope.row.DealingRecord.point2} / ${point(scope.row.DealingRecord)}`}}</span>
28
+            </template>
29
+          </el-table-column>
30
+          <el-table-column label="上莊分數">
31
+            <template slot-scope="scope">
32
+              <span>{{memberRecord[memberRecord.length-1][0].wager}}</span>
33
+            </template>
34
+          </el-table-column>  
35
+          <el-table-column prop="MemberRecord.FixedServiceFees" label="服務費"></el-table-column>
36
+          <el-table-column label="有效下注量">
37
+            <template slot-scope="scope">
38
+              <div>{{scope.row.effectiveWagger}}</div>
39
+            </template>
40
+          </el-table-column>
41
+          <el-table-column label="下注量抽水" >
42
+            <template slot-scope="scope">
43
+                <div>{{scope.row.MemberRecord.wagerServiceFees}}</div>
44
+            </template>
45
+          </el-table-column>      
46
+          <el-table-column label="莊輸贏">
47
+            <template slot-scope="scope">
48
+              <div :style="moneyColor(scope.row.MemberRecord.earned)">{{scope.row.MemberRecord.earned}}</div>
49
+            </template>
50
+          </el-table-column>     
51
+          <el-table-column label="莊贏抽水">
52
+              <template slot-scope="scope">
53
+                <div>{{scope.row.MemberRecord.serviceFees}}</div>
54
+            </template>
55
+          </el-table-column>
56
+          <el-table-column label="莊家結果">
57
+            <template slot-scope="scope">
58
+              <div :style="moneyColor(scope.row.bookieResult)">{{scope.row.bookieResult}}</div>
59
+            </template>
60
+          </el-table-column>    
61
+        </el-table-column>             
62
+      </el-table-column>                   
63
+    </el-table>
64
+    <el-table :header-cell-style="initDoor" :data="dealing" v-loading.body="listLoading" :summary-method="getSummaries" show-summary  element-loading-text="Loading" border fit highlight-current-row
65
+      style="width: 100%">
66
+      <el-table-column label="各門結果" align="center"> 
67
+        <el-table-column label="名稱">
68
+          <template slot-scope="scope">
69
+            <span>{{scope.$index === 0 ?"點數":"門主"}}</span>
70
+          </template>
71
+        </el-table-column>   
72
+        <el-table-column label="第一門">
73
+          <template slot-scope="scope">
74
+            <span>{{doorTableSwitch(scope.$index, 0)}}</span>
75
+          </template>
76
+        </el-table-column>
77
+        <el-table-column label="第二門">
78
+          <template slot-scope="scope">
79
+            <span>{{doorTableSwitch(scope.$index, 1)}}</span>
80
+          </template>
81
+        </el-table-column>
82
+        <el-table-column label="第三門">
83
+          <template slot-scope="scope">
84
+            <span>{{doorTableSwitch(scope.$index, 2)}}</span>
85
+          </template>
86
+        </el-table-column>
87
+        <el-table-column label="第四門">
88
+          <template slot-scope="scope">
89
+            <span>{{doorTableSwitch(scope.$index, 3)}}</span>
90
+          </template>
91
+        </el-table-column>
92
+        <el-table-column label="第五門">
93
+          <template slot-scope="scope">
94
+            <span>{{doorTableSwitch(scope.$index, 4)}}</span>
95
+          </template>
96
+        </el-table-column>
97
+        <el-table-column label="第六門">
98
+          <template slot-scope="scope">
99
+            <span>{{doorTableSwitch(scope.$index, 5)}}</span>
100
+          </template>
101
+        </el-table-column>
102
+      </el-table-column>      
103
+    </el-table>
104
+    <el-table :data="detail" :span-method="objectSpanMethod"  v-loading.body="listLoading" element-loading-text="Loading" border fit highlight-current-row
105
+      style="width: 100%">
106
+      <el-table-column label="此關結果" align="center">
107
+        <el-table-column prop="MemberRecord.GambleMember.name" label="玩家">
108
+        </el-table-column>
109
+        <!-- <el-table-column prop="MemberRecord.GambleMember.name" label="門主">
110
+        </el-table-column> -->
111
+        <el-table-column  label="押">
112
+          <template slot-scope="scope">
113
+            <span>{{`${scope.row.MemberRecord.door} / ${scope.row.MemberRecord.wager}`}}</span>
114
+          </template>
115
+        </el-table-column>
116
+        <el-table-column prop="DealingRecord.totalPoints" label="點數">
117
+          <template slot-scope="scope">
118
+            <span>{{`${scope.row.DealingRecord.point1} | ${scope.row.DealingRecord.point2} / ${point(scope.row.DealingRecord)}`}}</span>
119
+          </template>
120
+        </el-table-column>
121
+        <el-table-column label="輸贏">
122
+          <template slot-scope="scope">
123
+            <div :style="moneyColor(scope.row.MemberRecord.earned)">{{scope.row.MemberRecord.earned}}</div>
124
+          </template>
125
+        </el-table-column>
126
+        <el-table-column prop="MemberRecord.serviceFees" label="抽水">
127
+        </el-table-column>
128
+        <el-table-column label="輸贏合計">
129
+          <template slot-scope="scope">
130
+            <div :style="moneyColor(scope.row.totalChips)">{{scope.row.totalChips}}</div>
131
+          </template>
132
+        </el-table-column>
133
+        <el-table-column label="最終積分">
134
+          <template slot-scope="scope">
135
+            <div>{{scope.row.MemberRecord.currentChips}}</div>
136
+          </template>
137
+        </el-table-column>
138
+      </el-table-column>      
139
+    </el-table>
140
+
141
+    <el-table v-show="hasPunishment(punishmentRecord)" :data="punishmentRecord" v-loading.body="listLoading" element-loading-text="Loading" border fit highlight-current-row
142
+      style="width: 100%">
143
+      <el-table-column label="懲罰名單" align="center">
144
+        <el-table-column prop="GambleMember.name" label="玩家">
145
+        </el-table-column>
146
+        <el-table-column label="原因">
147
+          <template slot-scope="scope">
148
+            <div>{{reason(scope.row.rule)}}</div>
149
+          </template>
150
+        </el-table-column>
151
+        <el-table-column prop="chips" label="金額">
152
+        </el-table-column>
153
+      </el-table-column>      
154
+    </el-table>
155
+    <el-table :data="members" v-loading.body="listLoading" element-loading-text="Loading" border fit highlight-current-row
156
+      style="width: 100%">
157
+      <el-table-column label="當前玩家餘額" align="center">
158
+        <el-table-column prop="name_0" label="成員">
159
+        </el-table-column>
160
+        <el-table-column prop="chips_0" label="當前積分">
161
+        </el-table-column>
162
+        <el-table-column prop="name_1" label="成員">
163
+        </el-table-column>
164
+        <el-table-column prop="chips_1" label="當前積分">
165
+        </el-table-column>
166
+        <el-table-column prop="name_2" label="成員">
167
+        </el-table-column>
168
+        <el-table-column prop="chips_2" label="當前積分">
169
+        </el-table-column>
170
+        <el-table-column prop="name_3" label="成員">
171
+        </el-table-column>
172
+        <el-table-column prop="chips_3" label="當前積分">
173
+        </el-table-column>
174
+        </el-table-column>      
175
+    </el-table>
176
+</div>
177
+</template>
178
+
179
+<script>
180
+import { mapGetters, mapActions } from "vuex";
181
+import {
182
+  fetchDetails,
183
+  fetchRoundCount,
184
+  fetchDealingRecords,
185
+  fetchMemberRecords,
186
+  fetchRoundRecord,
187
+  fetchGameBid,
188
+  fetchWagerRecord,
189
+  fetchMemberInfo,
190
+  fetchPunishmentRecord
191
+} from "@/api/gambleGameBucket";
192
+import { fetchGambleMemberList } from "@/api/gambleMember";
193
+import { ponitTransform } from "@/utils/point";
194
+import _ from "lodash";
195
+import moment from "moment-timezone";
196
+
197
+export default {
198
+  data() {
199
+    return {
200
+      list: null,
201
+      listLoading: true,
202
+      listQuery: {
203
+        round: 1
204
+      },
205
+      detail: [],
206
+      group: [],
207
+      statement: "",
208
+      rowspan: 0,
209
+      colspan: 0,
210
+      func: "",
211
+      rowIndex: 0,
212
+      colIndex: 0,
213
+      roundOptions: [],
214
+      members: [],
215
+      dealing: [],
216
+      bookie: [],
217
+      memberRecord: [],
218
+      door: 0,
219
+      // bidChips: 0,
220
+      punishmentRecord: [],
221
+      memberRecordTemp: [],
222
+      wagerRecord: [],
223
+      roundTime: 0
224
+    };
225
+  },
226
+  created() {
227
+    fetchRoundRecord(this.data.fourLayer, this.listQuery).then(response => {
228
+      this.roundTime = response.data.createdAt;
229
+      this.door = response.data.initialDoor;
230
+    });
231
+    // fetchGameBid(this.data.secondLayer).then(response => {
232
+    //   this.bidChips = response.data
233
+    // })
234
+    fetchRoundCount(this.data.fourLayer).then(response => {
235
+      this.listQuery.round = response.data;
236
+      for (let i = 1; i <= response.data; i++) {
237
+        this.roundOptions.push({ label: `第 ${i} 關`, key: i });
238
+      }
239
+    });
240
+    this.SetVisible(4);
241
+    this.getList();
242
+  },
243
+  computed: {
244
+    ...mapGetters([
245
+      "visible",
246
+      "data"
247
+      // 'query'
248
+    ])
249
+  },
250
+  methods: {
251
+    ...mapActions([
252
+      "SetVisible",
253
+      "SetData"
254
+      // 'SetQuery'
255
+    ]),
256
+    getList() {
257
+      this.listLoading = true;
258
+      let detailTemp, dealingTemp, memberRecordTemp;
259
+      this.detail = [];
260
+      fetchWagerRecord(this.data.fourLayer, this.listQuery).then(response => {
261
+        this.wagerRecord = response.data;
262
+      });
263
+      fetchDealingRecords(this.data.fourLayer, this.listQuery).then(
264
+        response => {
265
+          dealingTemp = response.data.rows.filter(record => {
266
+            return record.door !== -1;
267
+          });
268
+
269
+          const deal = {};
270
+          const member = {};
271
+          dealingTemp.map((record, index) => {
272
+            deal[`door_${index % 6}`] = record.door;
273
+            deal[`point1_${index % 6}`] = record.point1;
274
+            deal[`point2_${index % 6}`] = record.point2;
275
+            deal[`totalPoints_${index % 6}`] = record.totalPoints;
276
+            record.GambleMember
277
+              ? (member[`member_${index % 6}`] = record.GambleMember.name)
278
+              : false;
279
+            if (index % 6 === 5) {
280
+              this.dealing.push(deal);
281
+              this.dealing.push(member);
282
+            }
283
+          });
284
+        }
285
+      );
286
+      fetchMemberRecords(this.data.fourLayer, this.listQuery).then(
287
+        response => {
288
+          this.memberRecordTemp = response.data.rows;
289
+          let memberRecordTemp = _.groupBy(response.data.rows, record => {
290
+            return record.door;
291
+          });
292
+          this.memberRecord = Object.values(memberRecordTemp);
293
+        }
294
+      );
295
+      fetchDetails(this.data.fourLayer, this.listQuery).then(response => {
296
+        detailTemp = response.data.rows.filter(record => {
297
+          return (
298
+            record.DealingRecord.door !== -1 &&
299
+            record.MemberRecord.door !== -1 &&
300
+            record.MemberRecord.door === record.DealingRecord.door
301
+          );
302
+        });
303
+
304
+        this.bookie = response.data.rows.filter(record => {
305
+          return (
306
+            record.DealingRecord.door === -1 &&
307
+            record.MemberRecord.door === -1 &&
308
+            record.MemberRecord.door === record.DealingRecord.door
309
+          );
310
+        });
311
+        // console.log('this', this.memberRecord)
312
+        // this.bidChips ? this.bookie[0].bidChips = this.bidChips : false
313
+        this.group = _.groupBy(detailTemp, record => {
314
+          return record.MemberRecord.GambleMember.name;
315
+        });
316
+        this.group = Object.values(this.group);
317
+        console.log("wwww", this.group);
318
+
319
+        this.group.map(member => {
320
+          // console.log('aaaaa', member)
321
+          let currentChips =
322
+            _.sumBy(member, record => {
323
+              return record.MemberRecord.chips;
324
+            }) + member[0].MemberRecord.currentChips;
325
+          for (const item of member) {
326
+            item.MemberRecord.currentChips = currentChips;
327
+          }
328
+        });
329
+        this.detail = this.group.reduce((arr, element) => {
330
+          return arr.concat(element);
331
+        }, []);
332
+        console.log("eee", this.detail);
333
+        this.bookie[0].effectiveWagger = _.sumBy(this.detail, item => {
334
+          return Math.abs(item.MemberRecord.earned);
335
+        });
336
+        console.log("ssss", this.detail);
337
+        this.bookie[0].bookieResult =
338
+          this.bookie[0].MemberRecord.earned -
339
+          this.bookie[0].MemberRecord.serviceFees;
340
+        // console.log('bookie', this.bookie[0].effectiveWagger)
341
+        this.group.map((item, itemIndex) => {
342
+          let totalChips = 0;
343
+          item.map((person, personIndex) => {
344
+            totalChips =
345
+              totalChips +
346
+              person.MemberRecord.earned -
347
+              person.MemberRecord.serviceFees;
348
+            item.length - 1 === personIndex
349
+              ? (this.detail[this._sum(itemIndex)].totalChips = totalChips)
350
+              : false;
351
+          });
352
+        });
353
+
354
+        for (let i = 0; i < this.group.length; i++) {
355
+          if (i === 0) {
356
+            this.statement = `if(this.rowIndex === ${i}){
357
+              this.rowspan = ${this.group[i].length},
358
+              this.colspan = 1
359
+            }`;
360
+          } else {
361
+            this.statement += `else if(this.rowIndex === ${this._sum(i)}){
362
+              this.rowspan = ${this.group[i].length},
363
+              this.colspan = 1 
364
+            }`;
365
+          }
366
+          if (i === this.group.length - 1) {
367
+            this.statement += `else {
368
+              this.rowspan = 0,
369
+              this.colspan = 0
370
+            }`;
371
+          }
372
+        }
373
+
374
+        this.func = eval(`(function() {${this.statement}})`);
375
+      });
376
+      fetchPunishmentRecord(this.data.fourLayer, this.listQuery).then(
377
+        response => {
378
+          this.punishmentRecord = response.data;
379
+        }
380
+      );
381
+      fetchMemberInfo(this.data.fourLayer, this.listQuery).then(response => {
382
+        let { data } = response;
383
+        let members = {};
384
+        this.members = [];
385
+        data.map((person, index) => {
386
+          if (index % 4 === 0) {
387
+            members.name_0 = person.GambleMember.name;
388
+            members.chips_0 = person.chips;
389
+            index === data.length - 1 ? this.members.push(members) : false;
390
+          } else if (index % 4 === 1) {
391
+            members.name_1 = person.GambleMember.name;
392
+            members.chips_1 = person.chips;
393
+            index === data.length - 1 ? this.members.push(members) : false;
394
+          } else if (index % 4 === 2) {
395
+            members.name_2 = person.GambleMember.name;
396
+            members.chips_2 = person.chips;
397
+            index === data.length - 1 ? this.members.push(members) : false;
398
+          } else if (index % 4 === 3) {
399
+            members.name_3 = person.GambleMember.name;
400
+            members.chips_3 = person.chips;
401
+            this.members.push(members);
402
+            members = {};
403
+          }
404
+        });
405
+      });
406
+
407
+      this.listLoading = false;
408
+    },
409
+    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
410
+      if (
411
+        columnIndex === 0 ||
412
+        columnIndex === 5 ||
413
+        columnIndex === 6 ||
414
+        columnIndex === 7 ||
415
+        columnIndex === 8
416
+      ) {
417
+        this.rowIndex = rowIndex;
418
+        this.columnIndex = columnIndex;
419
+        const that = this;
420
+
421
+        this.func();
422
+        return {
423
+          rowspan: this.rowspan,
424
+          colspan: this.colspan
425
+        };
426
+      }
427
+    },
428
+    getSummaries() {
429
+      const sums = [];
430
+      this.wagerRecord.map((door, index) => {
431
+        if (index === 0) sums[index] = "總押注";
432
+        sums[index + 1] = door.chips;
433
+      });
434
+      return sums;
435
+    },
436
+    handleFilter() {
437
+      fetchRoundRecord(this.data.fourLayer, this.listQuery).then(response => {
438
+        this.roundTime = response.data.createdAt;
439
+        this.door = response.data.initialDoor;
440
+      });
441
+      // this.SetQuery({layer:2, query: {round: this.query.secondLayer.round}})
442
+      this.dealing = [];
443
+      this.getList();
444
+    },
445
+    moment(time) {
446
+      return moment(time)
447
+        .tz("Asia/Taipei")
448
+        .format("YYYY-MM-DD HH:mm:ss");
449
+    },
450
+    moneyColor(money) {
451
+      return money >= 0 ? { color: "#67C23A" } : { color: "#FA5555" };
452
+    },
453
+    // TODO refactor
454
+    doorTableSwitch(rowIndex, colIndex) {
455
+      if (rowIndex === 0) {
456
+        return `${this.dealing[0][`point1_${colIndex}`]} | ${
457
+          this.dealing[0][`point2_${colIndex}`]
458
+        } / ${this.point({
459
+          point1: this.dealing[0][`point1_${colIndex}`],
460
+          point2: this.dealing[0][`point2_${colIndex}`],
461
+          totalPoints: this.dealing[0][`totalPoints_${colIndex}`]
462
+        })}`;
463
+      }
464
+      if (rowIndex === 1) {
465
+        return this.dealing[1][`member_${colIndex}`]
466
+          ? `${this.dealing[1][`member_${colIndex}`]}`
467
+          : "從缺";
468
+      }
469
+    },
470
+    _sum(i) {
471
+      let count = 0;
472
+      for (let j = 0; j < i; j++) {
473
+        count += this.group[j].length;
474
+      }
475
+      return count;
476
+    },
477
+    point(dealingRecord) {
478
+      return ponitTransform(dealingRecord);
479
+    },
480
+    initDoor({ row, column, rowIndex, columnIndex }) {
481
+      return columnIndex === this.door ? { color: "#F56C6C" } : ``;
482
+    },
483
+    reason(reason) {
484
+      switch (reason) {
485
+        case "NO_DRAW_RIGHTS":
486
+          return "亂抽紅包";
487
+          break;
488
+        case "NO_RESPONSE":
489
+          return "門主未抽紅包";
490
+          break;
491
+        default:
492
+          return "請找客服";
493
+      }
494
+    },
495
+    hasPunishment(data) {
496
+      return data.length !== 0 ? true : false;
497
+    }
498
+  },
499
+  destroyed() {
500
+    this.SetVisible(3);
501
+  }
502
+};
503
+</script>
504
+<style>
505
+div {
506
+  font-weight: bold;
507
+  font-size: 25px;
508
+}
509
+</style>

+ 6 - 3
src/views/room/gameHistory/index.vue

@@ -87,6 +87,7 @@
87 87
         </div>
88 88
       </el-dialog>
89 89
     </div>
90
+    <router-view></router-view>
90 91
   </div>
91 92
 </template>
92 93
 
@@ -196,7 +197,6 @@ export default {
196 197
           })
197 198
         })
198 199
       })
199
-      console.log('wwwwwwww', this.list)
200 200
       this.list.sort(function compare(a, b) {
201 201
         const dateA = new Date(a.createdAt);
202 202
         const dateB = new Date(b.createdAt);
@@ -213,8 +213,11 @@ export default {
213 213
         this.listLoading = false
214 214
       })
215 215
     },
216
-    handleGameDetail() {
217
-      console.log('Game detail')
216
+    handleGameDetail(row) {
217
+      console.log('Game detail', row)
218
+      const temp = Object.assign({}, row) // copy obj
219
+      this.SetVisible(4)
220
+      this.SetData({layer:4, data: temp})
218 221
     },
219 222
     handleFilter() {
220 223
       this.listQuery.page = 1