Ver Código Fonte

refactor sum

EthnaYeh 7 anos atrás
pai
commit
c169b7232f
1 arquivos alterados com 11 adições e 16 exclusões
  1. 11 16
      src/views/gambleGameBucket/detail/index.vue

+ 11 - 16
src/views/gambleGameBucket/detail/index.vue

@@ -52,7 +52,6 @@
52 52
         </el-table-column>
53 53
         <el-table-column label="上莊分數" prop="bidChips"></el-table-column>      
54 54
         <el-table-column label="莊輸贏" prop="MemberRecord.earned"></el-table-column>      
55
-        <el-table-column label="總押注" prop="totalWager"></el-table-column>      
56 55
         <el-table-column label="抽水" prop="MemberRecord.serviceFees"></el-table-column>     
57 56
       </el-table-column>                   
58 57
     </el-table>
@@ -191,6 +190,7 @@ export default {
191 190
         })
192 191
         // TODO refactor
193 192
         let deal = {}
193
+
194 194
         dealingTemp.map((record, index) => {
195 195
           if (index % 6 === 0) {
196 196
             deal.door_0 = record.door
@@ -248,24 +248,12 @@ export default {
248 248
         this.detail = this.group.reduce((arr, element) => {
249 249
           return arr.concat(element)
250 250
         }, [])
251
-        this.bookie[0].totalWager = 0
252
-        this.detail.map((item) => {
253
-          this.bookie[0].totalWager += item.MemberRecord.wager
254
-        })
255
-        // TODO 抽出去
256
-        const sum = (i) => {
257
-          let count = 0
258
-          for (let j = 0; j < i; j++) {
259
-            count += this.group[j].length
260
-          }
261
-          return count
262
-        }
263 251
 
264 252
         this.group.map((item, itemIndex) => {
265 253
           let totalChips = 0
266 254
           item.map((person, personIndex) => {
267 255
             totalChips += person.MemberRecord.earned
268
-            item.length - 1 === personIndex ? this.detail[sum(itemIndex)].totalChips = totalChips : false
256
+            item.length - 1 === personIndex ? this.detail[this._sum(itemIndex)].totalChips = totalChips : false
269 257
           })
270 258
         })
271 259
 
@@ -278,7 +266,7 @@ export default {
278 266
             }`
279 267
           } else if (i === this.group.length - 1) {
280 268
             this.statement +=
281
-            `else if(this.rowIndex === ${sum(i)}){
269
+            `else if(this.rowIndex === ${this._sum(i)}){
282 270
               this.rowspan = ${this.group[i].length},
283 271
               this.colspan = 1
284 272
             }else {
@@ -287,7 +275,7 @@ export default {
287 275
             }`
288 276
           } else {
289 277
             this.statement +=
290
-            `else if(this.rowIndex === ${sum(i)}){
278
+            `else if(this.rowIndex === ${this._sum(i)}){
291 279
               this.rowspan = ${this.group[i].length},
292 280
               this.colspan = 1 
293 281
             }`
@@ -315,6 +303,13 @@ export default {
315 303
     handleFilter() {
316 304
       this.dealing = []
317 305
       this.getList()
306
+    },
307
+    _sum(i) {
308
+      let count = 0
309
+      for (let j = 0; j < i; j++) {
310
+          count += this.group[j].length
311
+      }
312
+      return count
318 313
     }
319 314
   },
320 315
   destroyed() {