Browse Source

SET_PERSISTENCE_DATE

Unknown 7 years ago
parent
commit
f01e1c58a8
3 changed files with 27 additions and 17 deletions
  1. 2 1
      src/store/getters.js
  2. 9 1
      src/store/modules/breadcrumb.js
  3. 16 15
      src/views/room/gameHistory/index.vue

+ 2 - 1
src/store/getters.js

6
   roles: state => state.user.roles,
6
   roles: state => state.user.roles,
7
   visible: state => state.breadcrumb.visible,
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
+  query: state => state.breadcrumb.query,
10
+  p_date: state => state.breadcrumb.p_date
10
 }
11
 }
11
 export default getters
12
 export default getters

+ 9 - 1
src/store/modules/breadcrumb.js

35
         page: 1,
35
         page: 1,
36
         ...JSON.parse(localStorage.getItem('query_4th'))
36
         ...JSON.parse(localStorage.getItem('query_4th'))
37
       }
37
       }
38
-    }
38
+    },
39
+    p_date: [...JSON.parse(localStorage.getItem('date'))]
39
   },
40
   },
40
   mutations: {
41
   mutations: {
41
     SET_VISIBLE: (state, layer) => {
42
     SET_VISIBLE: (state, layer) => {
113
           state.query.fourLayer = { limit: 20, page: 1, ...option.query }
114
           state.query.fourLayer = { limit: 20, page: 1, ...option.query }
114
           break
115
           break
115
       }
116
       }
117
+    },
118
+    SET_PERSISTENCE_DATE: (state, date) => {
119
+      localStorage.setItem('date', JSON.stringify(date))
120
+      state.p_date = date
116
     }
121
     }
117
   },
122
   },
118
 
123
 
125
     },
130
     },
126
     SetQuery({ commit }, option) {
131
     SetQuery({ commit }, option) {
127
       commit('SET_QUERY', option)
132
       commit('SET_QUERY', option)
133
+    },
134
+    SetDate({ commit }, date) {
135
+      commit('SET_PERSISTENCE_DATE', date)
128
     }
136
     }
129
   }
137
   }
130
 }
138
 }

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

5
           <div class="block">
5
           <div class="block">
6
               <!-- <span class="demonstration">時間篩選</span> -->
6
               <!-- <span class="demonstration">時間篩選</span> -->
7
               <el-date-picker
7
               <el-date-picker
8
-              v-model="query.thirdLayer.date"
8
+              v-model="date"
9
               type="datetimerange"
9
               type="datetimerange"
10
               :picker-options="pickerOptions"
10
               :picker-options="pickerOptions"
11
               range-separator="至"
11
               range-separator="至"
133
           }
133
           }
134
         }]
134
         }]
135
       },
135
       },
136
-      // date: null,
136
+      date: [],
137
       dialogFormVisible: false
137
       dialogFormVisible: false
138
 
138
 
139
     }
139
     }
140
   },
140
   },
141
   created() {
141
   created() {
142
+    this.date = this.p_date
142
     this.SetVisible(3)
143
     this.SetVisible(3)
143
     this.getList()
144
     this.getList()
144
   },
145
   },
146
     ...mapGetters([
147
     ...mapGetters([
147
       'visible',
148
       'visible',
148
       'data',
149
       'data',
149
-      'query'
150
+      'query',
151
+      'p_date'
150
     ])
152
     ])
151
   },
153
   },
152
   methods: {
154
   methods: {
153
     ...mapActions([
155
     ...mapActions([
154
       'SetVisible',
156
       'SetVisible',
155
       'SetData',
157
       'SetData',
156
-      'SetQuery'
158
+      'SetQuery',
159
+      'SetDate'
157
     ]),
160
     ]),
158
     getList() {
161
     getList() {
159
       this.listLoading = true
162
       this.listLoading = true
208
       console.log('Game detail')
211
       console.log('Game detail')
209
     },
212
     },
210
     handleFilter() {
213
     handleFilter() {
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()}})      
214
+      if (this.p_date) {
215
+        this.SetQuery({layer:3, query: {page: 1,startAt: moment.utc(this.p_date[0]).format(), endAt: moment.utc(this.p_date[1]).format()}})      
213
       } else {
216
       } else {
214
          this.SetQuery({layer:3, query: {page: 1,startAt: null, endAt: null}})  
217
          this.SetQuery({layer:3, query: {page: 1,startAt: null, endAt: null}})  
215
       }
218
       }
216
       this.getList()
219
       this.getList()
217
     },
220
     },
218
     handleSizeChange(val) {
221
     handleSizeChange(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()}})      
222
+      if (this.p_date) {
223
+        this.SetQuery({layer:3, query: {limit: val, startAt: moment.utc(this.p_date[0]).format(), endAt: moment.utc(this.p_date[1]).format()}})      
221
       } else {
224
       } else {
222
          this.SetQuery({layer:3, query: {limit: val,startAt: null, endAt: null}})  
225
          this.SetQuery({layer:3, query: {limit: val,startAt: null, endAt: null}})  
223
       }
226
       }
224
       this.getList()
227
       this.getList()
225
     },
228
     },
226
     handleCurrentChange(val) {
229
     handleCurrentChange(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()}})      
230
+      if (this.p_date) {
231
+        this.SetQuery({layer:3, query: {page: val, startAt: moment.utc(this.p_date[0]).format(), endAt: moment.utc(this.p_date[1]).format()}})      
229
       } else {
232
       } else {
230
          this.SetQuery({layer:3, query: {page: val,startAt: null, endAt: null}})  
233
          this.SetQuery({layer:3, query: {page: val,startAt: null, endAt: null}})  
231
       }
234
       }
260
   destroyed() {
263
   destroyed() {
261
     this.SetVisible(2)
264
     this.SetVisible(2)
262
   },
265
   },
263
-  // TODO time 持九
266
+  // time 持久
264
   watch: {
267
   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);
268
+    'date': function(val) {
269
+     this.SetDate(val)
269
     }
270
     }
270
   }
271
   }
271
 }
272
 }