1
- import { randomString } from './utils'
1
+ import { randomString , getQueryInfo } from './utils'
2
+ import _get from 'lodash/get'
2
3
3
4
export default {
4
5
props : {
@@ -50,7 +51,9 @@ export default {
50
51
}
51
52
} ,
52
53
data : ( ) => ( {
53
- isFindPending : false
54
+ isFindPending : false ,
55
+ queryId : null ,
56
+ pageId : null
54
57
} ) ,
55
58
computed : {
56
59
items ( ) {
@@ -62,9 +65,17 @@ export default {
62
65
pagination ( ) {
63
66
return this . $store . state [ this . service ] . pagination [ this . qid ]
64
67
} ,
68
+ queryInfo ( ) {
69
+ if ( this . pagination == null || this . queryId == null ) return { }
70
+ return _get ( this . pagination , `[${ this . queryId } ]` ) || { }
71
+ } ,
72
+ pageInfo ( ) {
73
+ if ( this . pagination == null || this . queryId == null || this . pageId == null ) return { }
74
+ return _get ( this . pagination , `[${ this . queryId } ][${ this . pageId } ]` || { }
75
+ } ,
65
76
scope ( ) {
66
- const { items, isFindPending, pagination } = this
67
- const defaultScope = { isFindPending, pagination, items }
77
+ const { items, isFindPending, pagination, queryInfo , pageInfo } = this
78
+ const defaultScope = { isFindPending, pagination, items, queryInfo , pageInfo }
68
79
69
80
return this . editScope ( defaultScope ) || defaultScope
70
81
}
@@ -85,8 +96,11 @@ export default {
85
96
86
97
return this . $store
87
98
. dispatch ( `${ this . service } /find` , params )
88
- . then ( ( ) => {
99
+ . then ( ( response ) => {
89
100
this . isFindPending = false
101
+ { queryId , pageId } = getQueryInfo ( params , response )
102
+ this . queryId = queryId
103
+ this . pageId = pageId
90
104
} )
91
105
}
92
106
}
0 commit comments