|
@@ -70,8 +70,8 @@ export default {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- needPagination () {
|
|
|
|
|
- return !this.schema.singlePage
|
|
|
|
|
|
|
+ isManualPagination () {
|
|
|
|
|
+ return this.schema.singlePage
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
watch: {
|
|
watch: {
|
|
@@ -111,9 +111,9 @@ export default {
|
|
|
return {
|
|
return {
|
|
|
loading: false,
|
|
loading: false,
|
|
|
error: false,
|
|
error: false,
|
|
|
- params: { ...(this.needPagination ? { pageSize: this.pageSize, pageNum: 1 } : null), ...condition },
|
|
|
|
|
- list: [],
|
|
|
|
|
- totalCount: 0
|
|
|
|
|
|
|
+ params: { pageSize: this.pageSize, pageNum: 1, ...condition },
|
|
|
|
|
+ totalCount: 0,
|
|
|
|
|
+ list: []
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
filterInvokes (data) {
|
|
filterInvokes (data) {
|
|
@@ -128,23 +128,24 @@ export default {
|
|
|
({ data, totalCount }) => {
|
|
({ data, totalCount }) => {
|
|
|
options.loading = false
|
|
options.loading = false
|
|
|
options.error = false
|
|
options.error = false
|
|
|
- data = transform ? data.map(transform) : data
|
|
|
|
|
- if (this.needPagination) {
|
|
|
|
|
- if (data.length === 0) {
|
|
|
|
|
- const { pageNum, pageSize } = options.params
|
|
|
|
|
- if (pageNum > 1) {
|
|
|
|
|
- return this.pageTo(totalCount ? Math.ceil(totalCount / pageSize) : 1)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ options.totalCount = totalCount || data.length
|
|
|
|
|
+ if (this.isManualPagination) {
|
|
|
|
|
+ const { pageNum, pageSize } = options.params
|
|
|
|
|
+ data = data.slice((pageNum - 1) * pageSize, pageNum * pageSize)
|
|
|
|
|
+ }
|
|
|
|
|
+ if (data.length === 0) {
|
|
|
|
|
+ const { pageNum, pageSize } = options.params
|
|
|
|
|
+ if (pageNum > 1) {
|
|
|
|
|
+ return this.pageTo(totalCount ? Math.ceil(totalCount / pageSize) : 1)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- options.list = data
|
|
|
|
|
- options.totalCount = totalCount || data.length
|
|
|
|
|
|
|
+ options.list = transform ? data.map(transform) : data
|
|
|
},
|
|
},
|
|
|
() => {
|
|
() => {
|
|
|
options.loading = false
|
|
options.loading = false
|
|
|
options.error = true
|
|
options.error = true
|
|
|
- options.list = []
|
|
|
|
|
options.totalCount = 0
|
|
options.totalCount = 0
|
|
|
|
|
+ options.list = []
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
@@ -177,10 +178,7 @@ export default {
|
|
|
return this.options.params
|
|
return this.options.params
|
|
|
},
|
|
},
|
|
|
mergeCondition (condition) {
|
|
mergeCondition (condition) {
|
|
|
- const params = { ...this.options.params, ...condition }
|
|
|
|
|
- if (this.needPagination) {
|
|
|
|
|
- params.pageNum = 1
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ const params = { ...this.options.params, pageNum: 1, ...condition }
|
|
|
if (this.options.loading) {
|
|
if (this.options.loading) {
|
|
|
this.options = this.createOptions(params)
|
|
this.options = this.createOptions(params)
|
|
|
} else {
|
|
} else {
|
|
@@ -214,17 +212,15 @@ export default {
|
|
|
this.onChange()
|
|
this.onChange()
|
|
|
},
|
|
},
|
|
|
pageTo (pageNum) {
|
|
pageTo (pageNum) {
|
|
|
- if (this.needPagination && pageNum >= 1) {
|
|
|
|
|
|
|
+ if (pageNum >= 1) {
|
|
|
return this.mergeCondition({ pageNum })
|
|
return this.mergeCondition({ pageNum })
|
|
|
}
|
|
}
|
|
|
- this.mergeCondition()
|
|
|
|
|
|
|
+ this.mergeCondition({ pageNum: this.options.params.pageNum })
|
|
|
},
|
|
},
|
|
|
decrease (count) {
|
|
decrease (count) {
|
|
|
- if (this.needPagination) {
|
|
|
|
|
- const options = this.options
|
|
|
|
|
- if (options.list.length <= count) {
|
|
|
|
|
- return this.pageTo(options.params.pageNum - 1)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ const options = this.options
|
|
|
|
|
+ if (options.list.length <= count) {
|
|
|
|
|
+ return this.pageTo(options.params.pageNum - 1)
|
|
|
}
|
|
}
|
|
|
this.pageTo()
|
|
this.pageTo()
|
|
|
}
|
|
}
|