Browse Source

add total sum

ethan 6 years ago
parent
commit
e8786b15c3
1 changed files with 53 additions and 67 deletions
  1. 53 67
      src/views/agnetManagement/gambleMemberManagement/index.vue

+ 53 - 67
src/views/agnetManagement/gambleMemberManagement/index.vue

53
             </template>
53
             </template>
54
           </el-table-column>
54
           </el-table-column>
55
       </el-table>
55
       </el-table>
56
-      <el-table :data="combine" v-loading.body="listLoading" element-loading-text="Loading" border fit highlight-current-row>
56
+      <el-table show-summary :summary-method="getSummaries" :data="combine" v-loading.body="listLoading" element-loading-text="Loading" border fit highlight-current-row>
57
         <el-table-column :label="`${this.data.secondLayer.GambleMember.name}的會員`" align="center">
57
         <el-table-column :label="`${this.data.secondLayer.GambleMember.name}的會員`" align="center">
58
           <el-table-column label="名稱" align="center">
58
           <el-table-column label="名稱" align="center">
59
             <template slot-scope="scope">
59
             <template slot-scope="scope">
60
               <span>{{scope.row.name}}</span>
60
               <span>{{scope.row.name}}</span>
61
             </template>
61
             </template>
62
           </el-table-column>
62
           </el-table-column>
63
-          <el-table-column label="會員當前分數" align="center">
64
-            <template slot-scope="scope">
65
-              <span>{{scope.row.chips}}</span>
66
-            </template>
67
-          </el-table-column>
68
-          <el-table-column label="總上分額" align="center">
69
-            <template slot-scope="scope">
70
-              <span>{{scope.row.totalUp}}</span>
71
-            </template>
72
-          </el-table-column>
73
-          <el-table-column label="總下分額" align="center">
74
-            <template slot-scope="scope">
75
-              <span>{{scope.row.totalDown}}</span>
76
-            </template>
77
-          </el-table-column>
78
-          <el-table-column label="總獎勵" align="center">
79
-            <template slot-scope="scope">
80
-              <span>{{scope.row.totalReward}}</span>
81
-            </template>
82
-          </el-table-column>
83
-          <el-table-column label="總懲罰" align="center">
84
-            <template slot-scope="scope">
85
-              <span>{{scope.row.totalPunishment}}</span>
86
-            </template>
87
-          </el-table-column>
63
+          <el-table-column label="會員當前分數" prop="chips" align="center"></el-table-column>
64
+          <el-table-column label="總上分額" prop="totalUp" align="center"></el-table-column>
65
+          <el-table-column label="總下分額" prop="totalDown" align="center"></el-table-column>
66
+          <el-table-column label="總獎勵" prop="totalReward" align="center"></el-table-column>
67
+          <el-table-column label="總懲罰" prop="totalPunishment" align="center"></el-table-column>
88
           <el-table-column label="有效投注量" align="center">
68
           <el-table-column label="有效投注量" align="center">
89
             <template slot-scope="scope">
69
             <template slot-scope="scope">
90
               <span>{{0}}</span>
70
               <span>{{0}}</span>
100
               <span :style="moneyColor(scope.row.memberEarned)">{{scope.row.memberEarned}}</span>
80
               <span :style="moneyColor(scope.row.memberEarned)">{{scope.row.memberEarned}}</span>
101
             </template>
81
             </template>
102
           </el-table-column> -->
82
           </el-table-column> -->
103
-          <el-table-column label="莊家總投注量抽水" align="center">
104
-            <template slot-scope="scope">
105
-              <span>{{scope.row.bookieWagerFee}}</span>
106
-            </template>
107
-          </el-table-column>
108
-          <el-table-column label="莊家總投注量退水" align="center">
109
-            <template slot-scope="scope">
110
-              <span>{{scope.row.feeRatio.times(scope.row.bookieWagerFee).valueOf()}}</span>
111
-            </template>
112
-          </el-table-column>
113
-          <el-table-column label="莊家總抽水" align="center">
114
-            <template slot-scope="scope">
115
-              <span>{{scope.row.bookieServiceFees}}</span>
116
-            </template>
117
-          </el-table-column>
118
-          <el-table-column label="莊家退水" align="center">
119
-            <template slot-scope="scope">
120
-              <span>{{scope.row.feeRatio.times(scope.row.bookieServiceFees).valueOf()}}</span>
121
-            </template>
122
-          </el-table-column>
123
-          <el-table-column label="閒家總抽水" align="center">
124
-            <template slot-scope="scope">
125
-              <span>{{scope.row.memberServiceFees}}</span>
126
-            </template>
127
-          </el-table-column>
128
-          <el-table-column label="閒家退水" align="center">
129
-            <template slot-scope="scope">
130
-              <span>{{scope.row.feeRatio.times(scope.row.memberServiceFees).valueOf()}}</span>
131
-            </template>
132
-          </el-table-column>
133
-          <el-table-column label="總退水" align="center">
134
-            <template slot-scope="scope">
135
-              <span>{{scope.row.totalServiceFees}}</span>
136
-            </template>
137
-          </el-table-column>
138
-          <el-table-column label="會員結帳" align="center">
83
+          <el-table-column label="莊家總投注量抽水" prop="bookieWagerFee" align="center"></el-table-column>
84
+          <el-table-column label="莊家總投注量退水" prop="bookieWagerFeeRatio" align="center"></el-table-column>
85
+          <el-table-column label="莊家總抽水" prop="bookieServiceFees" align="center"></el-table-column>
86
+          <el-table-column label="莊家退水" prop="bookieServiceFeesRatio" align="center"></el-table-column>
87
+          <el-table-column label="閒家總抽水" prop="memberServiceFees" align="center"></el-table-column>
88
+          <el-table-column label="閒家退水" prop="memberServiceFeesRatio" align="center"></el-table-column>
89
+          <el-table-column label="總退水" prop="totalServiceFees" align="center"></el-table-column>
90
+          <el-table-column label="會員結帳" prop="memberCheckOut" align="center">
139
             <template slot-scope="scope">
91
             <template slot-scope="scope">
140
-              <span :style="moneyColor((scope.row.memberCheckOut)*(-1))">{{(scope.row.memberCheckOut)*(-1)}}</span>
92
+              <span :style="moneyColor((scope.row.memberCheckOut))">{{(scope.row.memberCheckOut)}}</span>
141
             </template>
93
             </template>
142
           </el-table-column>
94
           </el-table-column>
143
           <el-table-column align="center" label="操作" width="100">
95
           <el-table-column align="center" label="操作" width="100">
224
       'SetVisible',
176
       'SetVisible',
225
       'SetData',
177
       'SetData',
226
     ]),
178
     ]),
227
-    getList() {
179
+    async getList() {
228
       this.listLoading = true
180
       this.listLoading = true
229
       this.allCombine = []
181
       this.allCombine = []
230
       this.combine = []
182
       this.combine = []
231
-      fetchMemberList(this.data.secondLayer, this.listQuery).then(response => {
183
+      await fetchMemberList(this.data.secondLayer, this.listQuery).then(response => {
232
         response.data.rows.map(member => {
184
         response.data.rows.map(member => {
233
           let row = {
185
           let row = {
234
             id: member.id,
186
             id: member.id,
241
             bookieEarned: 0,
193
             bookieEarned: 0,
242
             memberEarned: 0,
194
             memberEarned: 0,
243
             bookieWagerFee: 0,
195
             bookieWagerFee: 0,
196
+            bookieWagerFeeRatio: 0,
244
             bookieServiceFees: 0,
197
             bookieServiceFees: 0,
198
+            bookieServiceFeesRatio: 0,
245
             memberServiceFees: 0,
199
             memberServiceFees: 0,
200
+            memberServiceFeesRatio: 0,
246
             totalServiceFees: 0,
201
             totalServiceFees: 0,
247
             memberCheckOut: 0,
202
             memberCheckOut: 0,
248
             feeRatio: new Decimal(this.data.secondLayer.feeRatio/100),
203
             feeRatio: new Decimal(this.data.secondLayer.feeRatio/100),
255
             });
210
             });
256
             console.log('membeEarned', row.memberEarned)
211
             console.log('membeEarned', row.memberEarned)
257
             row.memberServiceFees = _.sumBy(bookie.false, 'serviceFees');
212
             row.memberServiceFees = _.sumBy(bookie.false, 'serviceFees');
213
+            row.memberServiceFeesRatio = row.feeRatio.times(row.memberServiceFees).valueOf()
214
+            
258
           }
215
           }
259
           if (bookie.true) {
216
           if (bookie.true) {
260
             row.bookieWagerFee = _.sumBy(bookie.true, (item) => {
217
             row.bookieWagerFee = _.sumBy(bookie.true, (item) => {
261
               return item.wagerServiceFees
218
               return item.wagerServiceFees
262
             });
219
             });
220
+            row.bookieWagerFeeRatio = row.feeRatio.times(row.bookieWagerFee).valueOf()
263
             console.log('eeee', bookie.true)
221
             console.log('eeee', bookie.true)
264
             row.bookieEarned = _.sumBy(bookie.true, item => {
222
             row.bookieEarned = _.sumBy(bookie.true, item => {
265
               return Math.abs(item.earned)
223
               return Math.abs(item.earned)
266
             });
224
             });
267
             console.log('bookieEarned' , row.bookieEarned)
225
             console.log('bookieEarned' , row.bookieEarned)
268
             row.bookieServiceFees = _.sumBy(bookie.true, (item) => { return item.serviceFees});
226
             row.bookieServiceFees = _.sumBy(bookie.true, (item) => { return item.serviceFees});
227
+            row.bookieServiceFeesRatio = row.feeRatio.times(row.bookieServiceFees).valueOf()
269
           }
228
           }
270
           row.totalServiceFees = Number(new Decimal(row.bookieServiceFees).plus(row.memberServiceFees).plus(row.bookieWagerFee).times(row.feeRatio).valueOf())
229
           row.totalServiceFees = Number(new Decimal(row.bookieServiceFees).plus(row.memberServiceFees).plus(row.bookieWagerFee).times(row.feeRatio).valueOf())
271
           let chipsLog = _.groupBy(member.GambleMemberChipsLogs, 'type')
230
           let chipsLog = _.groupBy(member.GambleMemberChipsLogs, 'type')
281
             })
240
             })
282
 
241
 
283
           }
242
           }
284
-          row.memberCheckOut = row.totalUp + row.totalDown - row.chips
243
+          row.memberCheckOut = (row.totalUp + row.totalDown - row.chips)*(-1)
285
           // TODO CHECK 是否需要
244
           // TODO CHECK 是否需要
286
           if(chipsLog['1']) {
245
           if(chipsLog['1']) {
287
             row.totalReward = _.sumBy(chipsLog['1'], (item) => { 
246
             row.totalReward = _.sumBy(chipsLog['1'], (item) => { 
359
     },
318
     },
360
     all(scope) {
319
     all(scope) {
361
       return (scope.row.allUp+scope.row.allDown-scope.row.allChips-scope.row.allServiceFees)*(-1)
320
       return (scope.row.allUp+scope.row.allDown-scope.row.allChips-scope.row.allServiceFees)*(-1)
362
-    }
321
+    },
322
+    getSummaries(param) {
323
+        const { columns, data } = param;
324
+        const sums = [];
325
+        console.log('cl', columns)
326
+        columns.forEach((column, index) => {
327
+          if (index === 0) {
328
+            sums[index] = '合計';
329
+            return;
330
+          }
331
+          const values = data.map(item => Number(item[column.property]));
332
+          if (!values.every(value => isNaN(value))) {
333
+            sums[index] = values.reduce((prev, curr) => {
334
+              const value = Number(curr);
335
+              if (!isNaN(value)) {
336
+                return prev + curr;
337
+              } else {
338
+                return prev;
339
+              }
340
+            }, 0);
341
+            sums[index];
342
+          } else {
343
+            sums[index] = 'N/A';
344
+          }
345
+        });
346
+
347
+        return sums;
348
+      }
363
   },
349
   },
364
   destroyed() {
350
   destroyed() {
365
     this.SetVisible(1)
351
     this.SetVisible(1)