Unknown 7 gadi atpakaļ
vecāks
revīzija
f21c0f9bd1

+ 2 - 1
src/store/getters.js

@@ -5,6 +5,7 @@ const getters = {
5 5
   username: state => state.user.username,
6 6
   roles: state => state.user.roles,
7 7
   visible: state => state.breadcrumb.visible,
8
-  data: state => state.breadcrumb.data
8
+  data: state => state.breadcrumb.data,
9
+  query: state => state.breadcrumb.query
9 10
 }
10 11
 export default getters

+ 58 - 8
src/store/modules/breadcrumb.js

@@ -9,10 +9,32 @@ const breadcrumb = {
9 9
       fourLayer: false
10 10
     },
11 11
     data: {
12
-      firstLayer: JSON.parse(localStorage.getItem('firstLayer')),
13
-      secondLayer: JSON.parse(localStorage.getItem('secondLayer')),
14
-      thirdLayer: JSON.parse(localStorage.getItem('thirdLayer')),
15
-      fourLayer: JSON.parse(localStorage.getItem('fourLayer'))
12
+      firstLayer: JSON.parse(localStorage.getItem('data_1st')),
13
+      secondLayer: JSON.parse(localStorage.getItem('data_2nd')),
14
+      thirdLayer: JSON.parse(localStorage.getItem('data_3rd')),
15
+      fourLayer: JSON.parse(localStorage.getItem('data_4th'))
16
+    },
17
+    query: {
18
+      firstLayer: {
19
+        limit: 20,
20
+        page: 1,
21
+        ...JSON.parse(localStorage.getItem('query_1st'))
22
+      },
23
+      secondLayer: {
24
+        limit: 20,
25
+        page: 1,
26
+        ...JSON.parse(localStorage.getItem('query_2nd'))
27
+      },
28
+      thirdLayer: {
29
+        limit: 20,
30
+        page: 1,
31
+        ...JSON.parse(localStorage.getItem('query_3rd'))
32
+      },
33
+      fourLayer: {
34
+        limit: 20,
35
+        page: 1,
36
+        ...JSON.parse(localStorage.getItem('query_4th'))
37
+      }
16 38
     }
17 39
   },
18 40
   mutations: {
@@ -55,26 +77,54 @@ const breadcrumb = {
55 77
     SET_DATA: (state, option) => {
56 78
       switch (option.layer) {
57 79
         case 1:
58
-          localStorage.setItem('firstLayer', JSON.stringify(option.data))
80
+          localStorage.setItem('data_1st', JSON.stringify(option.data))
81
+          state.data.firstLayer = option.data
59 82
           break
60 83
         case 2:
61
-          localStorage.setItem('secondLayer', JSON.stringify(option.data))
84
+          localStorage.setItem('data_2nd', JSON.stringify(option.data))
85
+          state.data.secondLayer = option.data
62 86
           break
63 87
         case 3:
64
-          localStorage.setItem('thirdLayer', JSON.stringify(option.data))
88
+          localStorage.setItem('data_3rd', JSON.stringify(option.data))
89
+          state.data.thirdLayer = option.data
65 90
           break
66 91
         case 4:
67
-          localStorage.setItem('fourLayer', JSON.stringify(option.data))
92
+          localStorage.setItem('data_4th', JSON.stringify(option.data))
93
+          state.data.fourLayer = option.data
94
+          break
95
+      }
96
+    },
97
+    SET_QUERY: (state, option) => {
98
+      switch (option.layer) {
99
+        case 1:
100
+          localStorage.setItem('query_1st', JSON.stringify(option.query))
101
+          state.query.firstLayer = { limit: 20, page: 1, ...option.query }
102
+          break
103
+        case 2:
104
+          localStorage.setItem('query_2nd', JSON.stringify(option.query))
105
+          state.query.secondLayer = { limit: 20, page: 1, ...option.query }
106
+          break
107
+        case 3:
108
+          localStorage.setItem('query_3rd', JSON.stringify(option.query))
109
+          state.query.thirdLayer = { limit: 20, page: 1, ...option.query }
110
+          break
111
+        case 4:
112
+          localStorage.setItem('query_4th', JSON.stringify(option.query))
113
+          state.query.fourLayer = { limit: 20, page: 1, ...option.query }
68 114
           break
69 115
       }
70 116
     }
71 117
   },
118
+
72 119
   actions: {
73 120
     SetVisible({ commit }, layer) {
74 121
       commit('SET_VISIBLE', layer)
75 122
     },
76 123
     SetData({ commit }, option) {
77 124
       commit('SET_DATA', option)
125
+    },
126
+    SetQuery({ commit }, option) {
127
+      commit('SET_QUERY', option)
78 128
     }
79 129
   }
80 130
 }

+ 43 - 32
src/views/room/gameHistory/index.vue

@@ -5,7 +5,7 @@
5 5
           <div class="block">
6 6
               <!-- <span class="demonstration">時間篩選</span> -->
7 7
               <el-date-picker
8
-              v-model="date"
8
+              v-model="query.thirdLayer.date"
9 9
               type="datetimerange"
10 10
               :picker-options="pickerOptions"
11 11
               range-separator="至"
@@ -17,7 +17,7 @@
17 17
           </div>
18 18
       </div>
19 19
       <el-table :data="list" v-loading.body="listLoading" element-loading-text="Loading" border fit highlight-current-row>
20
-        <el-table-column :label="member.name" align="center">
20
+        <el-table-column :label="data.thirdLayer.name" align="center">
21 21
           <el-table-column label="時間" align="center">
22 22
             <template slot-scope="scope">
23 23
               <span>{{moment(scope.row.createdAt)}}</span>
@@ -53,8 +53,8 @@
53 53
       </el-table>
54 54
 
55 55
       <div v-show="!listLoading" class="pagination-container">
56
-        <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="listQuery.page"
57
-          :page-sizes="[10,20,30, 50]" :page-size="listQuery.limit" layout="total, sizes, prev, pager, next, jumper" :total="total">
56
+        <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="query.thirdLayer.page"
57
+          :page-sizes="[10,20,30, 50]" :page-size="query.thirdLayer.limit" layout="total, sizes, prev, pager, next, jumper" :total="total">
58 58
         </el-pagination>
59 59
       </div>
60 60
 
@@ -116,30 +116,24 @@ export default {
116 116
       dialogList: null,
117 117
       total: null,
118 118
       listLoading: true,
119
-      listQuery: {
120
-        page: 1,
121
-        limit: 20,
122
-        startAt: null,
123
-        endAt: null
124
-      },
125 119
       pickerOptions: {
126 120
         shortcuts: [{
127 121
           text: '本週',
128 122
           onClick(picker) {
129
-            const end = moment().day(7).hour(11).minute(59).second(59)
130
-            const start = moment().subtract(1, 'weeks').day(7).hour(16).minute(0).second(0)
131
-            picker.$emit('pick', [start, end])
123
+            const endAt = moment().day(7).hour(11).minute(59).second(59)
124
+            const startAt = moment().subtract(1, 'weeks').day(7).hour(16).minute(0).second(0)
125
+            picker.$emit('pick', [startAt, endAt])
132 126
           }
133 127
         }, {
134 128
           text: '上週',
135 129
           onClick(picker) {
136
-            const end = moment().subtract(1, 'weeks').day(7).hour(11).minute(59).second(59)
137
-            const start = moment().subtract(2, 'weeks').day(7).hour(16).minute(0).second(0)
138
-            picker.$emit('pick', [start, end])
130
+            const endAt = moment().subtract(1, 'weeks').day(7).hour(11).minute(59).second(59)
131
+            const startAt = moment().subtract(2, 'weeks').day(7).hour(16).minute(0).second(0)
132
+            picker.$emit('pick', [startAt, endAt])
139 133
           }
140 134
         }]
141 135
       },
142
-      date: null,
136
+      // date: null,
143 137
       dialogFormVisible: false
144 138
 
145 139
     }
@@ -150,17 +144,21 @@ export default {
150 144
   },
151 145
   computed: {
152 146
     ...mapGetters([
153
-      'visible'
147
+      'visible',
148
+      'data',
149
+      'query'
154 150
     ])
155 151
   },
156
-  props: ['member'],
157 152
   methods: {
158 153
     ...mapActions([
159
-      'SetVisible'
154
+      'SetVisible',
155
+      'SetData',
156
+      'SetQuery'
160 157
     ]),
161 158
     getList() {
162 159
       this.listLoading = true
163
-      fetchGameHistory(this.member, this.listQuery).then(response => {
160
+      this.list = []
161
+      fetchGameHistory(this.data.thirdLayer, this.query.thirdLayer).then(response => {
164 162
         this.chipLogList = response.data
165 163
         this.chipLogList.map((item) => {
166 164
           this.list.push({
@@ -173,7 +171,7 @@ export default {
173 171
         })
174 172
         this.listLoading = false
175 173
       })
176
-      fetchChipsHistory(this.member, this.listQuery).then(response => {
174
+      fetchChipsHistory(this.data.thirdLayer, this.query.thirdLayer).then(response => {
177 175
         this.gameRecordList = response.data
178 176
         this.gameRecordList.map((item) => {
179 177
           if(item.type === config.const.GambleMemberChipsLog.type.deposit) item.type =  '上 / 下 分';
@@ -193,7 +191,7 @@ export default {
193 191
           const dateB = new Date(b.createdAt);
194 192
           return  dateB - dateA;
195 193
         });
196
-
194
+        this.total = this.list.length
197 195
         this.listLoading = false
198 196
       })
199 197
       
@@ -201,7 +199,7 @@ export default {
201 199
     handlePersonDetail(row) {
202 200
       this.listLoading = true
203 201
       this.dialogFormVisible = true
204
-      fetchPersonGameDetail(this.member.id, row.id).then(response => {
202
+      fetchPersonGameDetail(this.data.thirdLayer.id, row.id).then(response => {
205 203
         this.dialogList = response.data.rows
206 204
         this.listLoading = false
207 205
       })
@@ -210,22 +208,27 @@ export default {
210 208
       console.log('Game detail')
211 209
     },
212 210
     handleFilter() {
213
-      this.listQuery.page = 1
214
-      if (this.date) {
215
-        this.listQuery.startAt = moment.utc(this.date[0]).format()
216
-        this.listQuery.endAt = moment.utc(this.date[1]).format()
211
+      if (this.query.thirdLayer.date) {
212
+        this.SetQuery({layer:3, query: {page: 1,startAt: moment.utc(this.query.thirdLayer.date[0]).format(), endAt: moment.utc(this.query.thirdLayer.date[1]).format()}})      
217 213
       } else {
218
-        this.listQuery.startAt = null
219
-        this.listQuery.endAt = null
214
+         this.SetQuery({layer:3, query: {page: 1,startAt: null, endAt: null}})  
220 215
       }
221 216
       this.getList()
222 217
     },
223 218
     handleSizeChange(val) {
224
-      this.listQuery.limit = val
219
+      if (this.query.thirdLayer.date) {
220
+        this.SetQuery({layer:3, query: {limit: val, startAt: moment.utc(this.query.thirdLayer.date[0]).format(), endAt: moment.utc(this.query.thirdLayer.date[1]).format()}})      
221
+      } else {
222
+         this.SetQuery({layer:3, query: {limit: val,startAt: null, endAt: null}})  
223
+      }
225 224
       this.getList()
226 225
     },
227 226
     handleCurrentChange(val) {
228
-      this.listQuery.page = val
227
+      if (this.query.thirdLayer.date) {
228
+        this.SetQuery({layer:3, query: {page: val, startAt: moment.utc(this.query.thirdLayer.date[0]).format(), endAt: moment.utc(this.query.thirdLayer.date[1]).format()}})      
229
+      } else {
230
+         this.SetQuery({layer:3, query: {page: val,startAt: null, endAt: null}})  
231
+      }
229 232
       this.getList()
230 233
     },
231 234
     moment(time) {
@@ -256,6 +259,14 @@ export default {
256 259
   },
257 260
   destroyed() {
258 261
     this.SetVisible(2)
262
+  },
263
+  // TODO time 持九化
264
+  watch: {
265
+    'query.thirdLayer.date': function(val) {
266
+      if(this.query.thirdLayer.date) if((val[0] = this.query.thirdLayer.date[0]) && (val[1] = this.query.thirdLayer.date[1])) return
267
+      this.SetQuery({layer:3, query: {date: val}})
268
+      console.log('test', val);
269
+    }
259 270
   }
260 271
 }
261 272
 </script>

+ 15 - 16
src/views/room/index.vue

@@ -3,7 +3,7 @@
3 3
 <div class="app-container calendar-list-container">
4 4
   <div  v-show="visible.firstLayer">
5 5
     <div class="app-container">
6
-      <el-input @keyup.enter.native="handleFilter" style="width: 200px;" class="filter-item" placeholder="房間名" v-model="listQuery.name">
6
+      <el-input @keyup.enter.native="handleFilter" style="width: 200px;" class="filter-item" placeholder="房間名" v-model="query.firstLayer.name">
7 7
       </el-input>
8 8
       <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">搜尋</el-button>
9 9
       <el-button class="filter-item" @click="handleCreate" type="primary" icon="el-icon-edit">創建</el-button>
@@ -38,8 +38,8 @@
38 38
     </el-table>
39 39
 
40 40
     <div v-show="!listLoading" class="pagination-container">
41
-      <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="listQuery.page"
42
-        :page-sizes="[10,20,30, 50]" :page-size="listQuery.limit" layout="total, sizes, prev, pager, next, jumper" :total="total">
41
+      <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="query.firstLayer.page"
42
+        :page-sizes="[10,20,30, 50]" :page-size="query.firstLayer.limit" layout="total, sizes, prev, pager, next, jumper" :total="total">
43 43
       </el-pagination>
44 44
     </div>
45 45
 
@@ -56,7 +56,7 @@
56 56
     </el-dialog>
57 57
 
58 58
   </div>
59
-    <router-view :room="room"></router-view>
59
+    <router-view></router-view>
60 60
   </div>
61 61
 </template>
62 62
 
@@ -77,14 +77,9 @@ export default {
77 77
       list: null,
78 78
       total: null,
79 79
       listLoading: true,
80
-      listQuery: {
81
-        page: 1,
82
-        limit: 20,
83
-      },
84 80
       temp: {
85 81
         name: '',
86 82
       },
87
-      room: {},
88 83
       rules: {
89 84
         name: [{ type: 'string', required: true, message: '必填', trigger: 'change' }]
90 85
       },
@@ -97,16 +92,20 @@ export default {
97 92
   },
98 93
   computed: {
99 94
     ...mapGetters([
100
-      'visible'
95
+      'visible',
96
+      'query',
97
+      'data'
101 98
     ])
102 99
   },
103 100
   methods: {
104 101
     ...mapActions([
105
-      'SetVisible'
102
+      'SetVisible',
103
+      'SetData',
104
+      'SetQuery'
106 105
     ]),
107 106
     getList() {
108 107
       this.listLoading = true
109
-      fetchWechatRooms(this.listQuery).then(response => {
108
+      fetchWechatRooms(this.query.firstLayer).then(response => {
110 109
         this.list = response.data
111 110
         this.total = response.data.length
112 111
         this.listLoading = false
@@ -115,7 +114,7 @@ export default {
115 114
     handlePage(row) {
116 115
       const temp = Object.assign({}, row) // copy obj
117 116
       this.SetVisible(2)
118
-      this.room = temp
117
+      this.SetData({layer:2, data: temp})
119 118
     },
120 119
     handleCreate() {
121 120
       //TODO 了解wechat 的 room 關聯
@@ -149,15 +148,15 @@ export default {
149 148
       })
150 149
     },
151 150
     handleFilter() {
152
-      this.listQuery.page = 1
151
+      this.SetQuery({layer:1, query: {page: 1, name: this.query.firstLayer.name}})
153 152
       this.getList()
154 153
     },
155 154
     handleSizeChange(val) {
156
-      this.listQuery.limit = val
155
+      this.SetQuery({layer:1, query: {limit: val, name: this.query.firstLayer.name}})      
157 156
       this.getList()
158 157
     },
159 158
     handleCurrentChange(val) {
160
-      this.listQuery.page = val
159
+      this.SetQuery({layer:1, query: {page: val, name: this.query.firstLayer.name}})      
161 160
       this.getList()
162 161
     },
163 162
     handleDialogClose() {

+ 28 - 28
src/views/room/wechatMember/index.vue

@@ -2,7 +2,7 @@
2 2
   <div class="app-container calendar-list-container">
3 3
     <div  v-show="visible.secondLayer">
4 4
       <div class="app-container">
5
-        <el-input @keyup.enter.native="handleFilter" style="width: 200px;" class="filter-item" placeholder="名稱" v-model="listQuery.name">
5
+        <el-input @keyup.enter.native="handleFilter" style="width: 200px;" class="filter-item" placeholder="名稱" v-model="query.secondLayer.name">
6 6
         </el-input>
7 7
         <!-- <el-select clearable @change='handleFilter' style="width: 120px" class="filter-item" v-model="listQuery.chipsSort" placeholder="點數">
8 8
           <el-option v-for="item in chipsSortOptions" :key="item.label" :label="item.label" :value="item.key">
@@ -34,8 +34,8 @@
34 34
         </el-table-column>
35 35
         <el-table-column label="代理商" align="center">
36 36
           <template slot-scope="scope">
37
-            <el-button v-show="noAgent(scope.row.WeChatUser.GambleMember)" type="primary" size="mini" icon="el-icon-edit" @click="handleAgentUpdate(scope.row)">代理商設定</el-button>
38
-            <span v-show="haveAgent(scope.row.WeChatUser.GambleMember)">{{scope.row.WeChatUser.GambleMember.name}}</span>
37
+            <el-button v-if="noAgent(scope.row.WeChatUser.GambleMember)" type="primary" size="mini" icon="el-icon-edit" @click="handleAgentUpdate(scope.row)">代理商設定</el-button>
38
+            <span v-if="haveAgent(scope.row.WeChatUser.GambleMember)">{{scope.row.WeChatUser.GambleMember.GambleAgent.name}}</span>
39 39
           </template>
40 40
         </el-table-column>
41 41
         <el-table-column align="center" label="操作" width="350">
@@ -52,8 +52,8 @@
52 52
       </el-table>
53 53
 
54 54
       <div v-show="!listLoading" class="pagination-container">
55
-        <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="listQuery.page"
56
-          :page-sizes="[10,20,30, 50]" :page-size="listQuery.limit" layout="total, sizes, prev, pager, next, jumper" :total="total">
55
+        <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="query.secondLayer.page"
56
+          :page-sizes="[10,20,30, 50]" :page-size="query.secondLayer.limit" layout="total, sizes, prev, pager, next, jumper" :total="total">
57 57
         </el-pagination>
58 58
       </div>
59 59
 
@@ -120,7 +120,7 @@
120 120
       </el-dialog>
121 121
 
122 122
     </div>
123
-    <router-view :member="member"></router-view>
123
+    <router-view></router-view>
124 124
   </div>
125 125
 </template>
126 126
 
@@ -145,13 +145,13 @@ export default {
145 145
       list: null,
146 146
       total: null,
147 147
       listLoading: true,
148
-      listQuery: {
149
-        page: 1,
150
-        limit: 20,
151
-        name: '',
152
-        chipsSort: '',
153
-        updatedSort: ''
154
-      },
148
+      // listQuery: {
149
+      //   page: 1,
150
+      //   limit: 20,
151
+      //   name: '',
152
+      //   chipsSort: '',
153
+      //   updatedSort: ''
154
+      // },
155 155
       temp: {
156 156
         id: '',
157 157
         WeChatUser: {
@@ -168,14 +168,11 @@ export default {
168 168
         deposit: '上下分',
169 169
         reward: '獎懲'
170 170
       },
171
-      member: {},
172 171
       chipsSortOptions: [{ label: '多 -> 少', key: 'DESC' }, { label: '少 -> 多', key: 'ASC' }],
173 172
       updatedSortOptions: [{ label: '新 -> 舊', key: 'DESC' }, { label: '舊 -> 新', key: 'ASC' }],
174 173
       rules: {
175 174
         rewardChips: [{ pattern: /^-?\d+$/, required: true, message: '請輸入整數', trigger: 'change' }],        
176 175
         depositChips: [{ pattern: /^-?\d+$/, required: true, message: '請輸入整數', trigger: 'change' }],                
177
-        // chips: [{ pattern: /^(0|[1-9][0-9]*)$/, required: true, message: '請輸入整數', trigger: 'change' }],
178
-        // name: [{ type: 'string', required: true, message: '必填', trigger: 'change' }]
179 176
       },
180 177
       activeName: 'deposit',
181 178
       dialogUpdateFormVisible: false,
@@ -183,7 +180,6 @@ export default {
183 180
       agentLIstOptions: [],
184 181
     }
185 182
   },
186
-  props: ['room'],
187 183
   created() {
188 184
     this.SetVisible(2)
189 185
     this.getList()
@@ -193,16 +189,20 @@ export default {
193 189
   },
194 190
   computed: {
195 191
     ...mapGetters([
196
-      'visible'
192
+      'visible',
193
+      'data',
194
+      'query'
197 195
     ])
198 196
   },
199 197
   methods: {
200 198
     ...mapActions([
201
-      'SetVisible'
199
+      'SetVisible',
200
+      'SetData',
201
+      'SetQuery'
202 202
     ]),
203 203
     getList() {
204 204
       this.listLoading = true
205
-      fetchWeChatMemberList(this.room, this.listQuery).then(response => {
205
+      fetchWeChatMemberList(this.data.secondLayer, this.query.secondLayer).then(response => {
206 206
         this.list = response.data.rows
207 207
         this.total = response.data.count
208 208
         this.listLoading = false
@@ -256,23 +256,24 @@ export default {
256 256
     handlePage(row) {
257 257
       const temp = Object.assign({}, row) // copy obj
258 258
       this.SetVisible(3)
259
-      this.member = temp.WeChatUser.GambleMember
259
+      this.SetData({layer:3, data: temp.WeChatUser.GambleMember})
260 260
     },
261 261
     handleLog(row) {
262
-      const temp = Object.assign({}, row) // copy obj
263 262
       this.SetVisible(3)
264
-      this.member = temp.WeChatUser.GambleMember
263
+      this.SetData({layer:3, data: temp.WeChatUser.GambleMember})
265 264
     },
266 265
     handleFilter() {
267
-      this.listQuery.page = 1
266
+      this.SetQuery({layer:2, query: {page: 1, name: this.query.secondLayer.name}})
268 267
       this.getList()
269 268
     },
270 269
     handleSizeChange(val) {
271
-      this.listQuery.limit = val
270
+      // this.listQuery.limit = val
271
+      this.SetQuery({layer:2, query: {limit: val, name: this.query.secondLayer.name}})   
272 272
       this.getList()
273 273
     },
274 274
     handleCurrentChange(val) {
275
-      this.listQuery.page = val
275
+      // this.listQuery.page = val
276
+      this.SetQuery({layer:2, query: {page: val, name: this.query.secondLayer.name}})    
276 277
       this.getList()
277 278
     },
278 279
     handleClick(tab, event) {
@@ -354,8 +355,7 @@ export default {
354 355
         cancelButtonText: '取消',
355 356
         type: 'warning'
356 357
       }).then(() => {
357
-        resetWechatRoomMembersChips(this.room).then(response => {
358
-          console.log('11111')
358
+        resetWechatRoomMembersChips(this.data.secondLayer).then(response => {
359 359
           this.$message({
360 360
             type: 'success',
361 361
             message: '歸零成功!'