Skip to content

Commit

Permalink
fix: correct redundant initial request(set init tag)
Browse files Browse the repository at this point in the history
  • Loading branch information
lbwa committed Oct 8, 2018
1 parent 31c0d9d commit ef0c4da
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/store/modules/analysis/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default {
fetchAnalysis ({ commit }) {
fetchAllAnalysis().then(res => {
const data = res.data
commit(types.SET_INIT)
commit(types.SET_SALES, data.sales)
commit(types.SET_VISITORS, data.visitors)
commit(types.SET_PAYMENTS, data.payments)
Expand Down
3 changes: 3 additions & 0 deletions src/store/modules/analysis/mutations/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import types from './types'

export default {
[types.SET_INIT] (state) {
state.init = true
},
[types.SET_SALES] (state, sales) {
state.sales = sales
},
Expand Down
15 changes: 8 additions & 7 deletions src/store/modules/analysis/mutations/types.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
export default {
'SET_SALES': 'SET_SALES',
'SET_VISITORS': 'SET_VISITORS',
'SET_PAYMENTS': 'SET_PAYMENTS',
'SET_OPERATIONS': 'SET_OPERATIONS',
'SET_RANK_LIST': 'SET_RANK_LIST',
'SET_SEARCH_DATA': 'SET_SEARCH_DATA',
'SET_SALES_TYPE': 'SET_SALES_TYPE'
SET_SALES: 'SET_SALES',
SET_VISITORS: 'SET_VISITORS',
SET_PAYMENTS: 'SET_PAYMENTS',
SET_OPERATIONS: 'SET_OPERATIONS',
SET_RANK_LIST: 'SET_RANK_LIST',
SET_SEARCH_DATA: 'SET_SEARCH_DATA',
SET_SALES_TYPE: 'SET_SALES_TYPE',
SET_INIT: 'SET_INIT'
}
1 change: 1 addition & 0 deletions src/store/modules/analysis/state.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// store.state basic schema

export default {
init: false,
sales: {
trend: [
{
Expand Down
3 changes: 2 additions & 1 deletion src/view/Dashboard/Analysis.vue
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ export default {
return this.formatData(this.sales.totalDetails, ['month', 'total'])
},
...mapState('analysis', [
'init',
'sales',
'visitors',
'payments',
Expand All @@ -171,7 +172,7 @@ export default {
},
created () {
this.fetchAnalysis()
!this.init && this.fetchAnalysis()
},
methods: {
Expand Down

0 comments on commit ef0c4da

Please sign in to comment.