Skip to content

Commit c17d174

Browse files
authored
Update FeathersVuexFind.ts
add queryInfo & pageInfo to scope.
1 parent 240af6d commit c17d174

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/FeathersVuexFind.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { randomString } from './utils'
1+
import { randomString, getQueryInfo } from './utils'
2+
import _get from 'lodash/get'
23

34
export default {
45
props: {
@@ -50,7 +51,9 @@ export default {
5051
}
5152
},
5253
data: () => ({
53-
isFindPending: false
54+
isFindPending: false,
55+
queryId: null,
56+
pageId: null
5457
}),
5558
computed: {
5659
items() {
@@ -62,9 +65,17 @@ export default {
6265
pagination() {
6366
return this.$store.state[this.service].pagination[this.qid]
6467
},
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+
},
6576
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 }
6879

6980
return this.editScope(defaultScope) || defaultScope
7081
}
@@ -85,8 +96,11 @@ export default {
8596

8697
return this.$store
8798
.dispatch(`${this.service}/find`, params)
88-
.then(() => {
99+
.then((response) => {
89100
this.isFindPending = false
101+
{ queryId, pageId } = getQueryInfo(params, response)
102+
this.queryId = queryId
103+
this.pageId = pageId
90104
})
91105
}
92106
}

0 commit comments

Comments
 (0)