ソースを参照

add total sum

ethan 6 年 前
コミット
e8786b15c3
共有1 個のファイルを変更した53 個の追加67 個の削除を含む
  1. 53 67
      src/views/agnetManagement/gambleMemberManagement/index.vue

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

@@ -53,38 +53,18 @@
53 53
             </template>
54 54
           </el-table-column>
55 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 57
         <el-table-column :label="`${this.data.secondLayer.GambleMember.name}的會員`" align="center">
58 58
           <el-table-column label="名稱" align="center">
59 59
             <template slot-scope="scope">
60 60
               <span>{{scope.row.name}}</span>
61 61
             </template>
62 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 68
           <el-table-column label="有效投注量" align="center">
89 69
             <template slot-scope="scope">
90 70
               <span>{{0}}</span>
@@ -100,44 +80,16 @@
100 80
               <span :style="moneyColor(scope.row.memberEarned)">{{scope.row.memberEarned}}</span>
101 81
             </template>
102 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 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 93
             </template>
142 94
           </el-table-column>
143 95
           <el-table-column align="center" label="操作" width="100">
@@ -224,11 +176,11 @@ export default {
224 176
       'SetVisible',
225 177
       'SetData',
226 178
     ]),
227
-    getList() {
179
+    async getList() {
228 180
       this.listLoading = true
229 181
       this.allCombine = []
230 182
       this.combine = []
231
-      fetchMemberList(this.data.secondLayer, this.listQuery).then(response => {
183
+      await fetchMemberList(this.data.secondLayer, this.listQuery).then(response => {
232 184
         response.data.rows.map(member => {
233 185
           let row = {
234 186
             id: member.id,
@@ -241,8 +193,11 @@ export default {
241 193
             bookieEarned: 0,
242 194
             memberEarned: 0,
243 195
             bookieWagerFee: 0,
196
+            bookieWagerFeeRatio: 0,
244 197
             bookieServiceFees: 0,
198
+            bookieServiceFeesRatio: 0,
245 199
             memberServiceFees: 0,
200
+            memberServiceFeesRatio: 0,
246 201
             totalServiceFees: 0,
247 202
             memberCheckOut: 0,
248 203
             feeRatio: new Decimal(this.data.secondLayer.feeRatio/100),
@@ -255,17 +210,21 @@ export default {
255 210
             });
256 211
             console.log('membeEarned', row.memberEarned)
257 212
             row.memberServiceFees = _.sumBy(bookie.false, 'serviceFees');
213
+            row.memberServiceFeesRatio = row.feeRatio.times(row.memberServiceFees).valueOf()
214
+            
258 215
           }
259 216
           if (bookie.true) {
260 217
             row.bookieWagerFee = _.sumBy(bookie.true, (item) => {
261 218
               return item.wagerServiceFees
262 219
             });
220
+            row.bookieWagerFeeRatio = row.feeRatio.times(row.bookieWagerFee).valueOf()
263 221
             console.log('eeee', bookie.true)
264 222
             row.bookieEarned = _.sumBy(bookie.true, item => {
265 223
               return Math.abs(item.earned)
266 224
             });
267 225
             console.log('bookieEarned' , row.bookieEarned)
268 226
             row.bookieServiceFees = _.sumBy(bookie.true, (item) => { return item.serviceFees});
227
+            row.bookieServiceFeesRatio = row.feeRatio.times(row.bookieServiceFees).valueOf()
269 228
           }
270 229
           row.totalServiceFees = Number(new Decimal(row.bookieServiceFees).plus(row.memberServiceFees).plus(row.bookieWagerFee).times(row.feeRatio).valueOf())
271 230
           let chipsLog = _.groupBy(member.GambleMemberChipsLogs, 'type')
@@ -281,7 +240,7 @@ export default {
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 244
           // TODO CHECK 是否需要
286 245
           if(chipsLog['1']) {
287 246
             row.totalReward = _.sumBy(chipsLog['1'], (item) => { 
@@ -359,7 +318,34 @@ export default {
359 318
     },
360 319
     all(scope) {
361 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 350
   destroyed() {
365 351
     this.SetVisible(1)