|
@@ -1,5 +1,6 @@
|
|
|
import BaseCurd from './BaseCurd'
|
|
|
import MapBuilder from './MapBuilder'
|
|
|
+import bindPrototype from './bindPrototype'
|
|
|
|
|
|
export default (target, hasPagination = true) => ({
|
|
|
name: 'BaseCurdList',
|
|
@@ -19,15 +20,15 @@ export default (target, hasPagination = true) => ({
|
|
|
let query = Object.assign({}, this.query)
|
|
|
if (hasPagination) {
|
|
|
Object.assign(query, this.pagination)
|
|
|
- this.$$request(target.$$api.getPagination, Object.assign({}, this.query, this.pagination))
|
|
|
+ this.$$request(target.$$api.getPagination, this.query, this.pagination)
|
|
|
.then(data => {
|
|
|
- this.total = data.total
|
|
|
- this.list = Object.freeze(data.record)
|
|
|
+ this.total = data.count
|
|
|
+ this.data = Object.freeze(bindPrototype(data.list, target))
|
|
|
}).catch(console.error).finally(() => {})
|
|
|
} else {
|
|
|
this.$$request(target.$$api.getList, this.query).then(list => {
|
|
|
this.total = list.length
|
|
|
- this.list = Object.freeze(list)
|
|
|
+ this.data = Object.freeze(bindPrototype(Object.freeze(list), target))
|
|
|
}).catch(console.error).finally(() => {})
|
|
|
}
|
|
|
},
|
|
@@ -76,6 +77,7 @@ export default (target, hasPagination = true) => ({
|
|
|
setOptionGroup () {
|
|
|
this.getOptionGroup(target).then(optionGroup => {
|
|
|
this.optionGroup = optionGroup
|
|
|
+ target.$$optionData = optionGroup
|
|
|
this.loadList()
|
|
|
})
|
|
|
}
|