|
@@ -2,12 +2,12 @@ import BaseCurd from './BaseCurd'
|
|
|
import MapBuilder from './MapBuilder'
|
|
|
import bindPrototype from './bindPrototype'
|
|
|
|
|
|
-export default (target, hasPagination = true) => ({
|
|
|
+export default (Target, hasPagination = true) => ({
|
|
|
name: 'BaseCurdList',
|
|
|
- extends: BaseCurd(target),
|
|
|
+ extends: BaseCurd(Target),
|
|
|
data: () => ({
|
|
|
optionGroup: Object.freeze({}),
|
|
|
- query: target.$$getQuery(),
|
|
|
+ query: Target.$$getQuery(),
|
|
|
pagination: {
|
|
|
pageNo: 0,
|
|
|
pageSize: 20
|
|
@@ -30,14 +30,14 @@ export default (target, hasPagination = true) => ({
|
|
|
let query = Object.assign({}, this.query)
|
|
|
if (hasPagination) {
|
|
|
Object.assign(query, this.pagination)
|
|
|
- this.$$request(target.$$api.getPagination, this.query, this.pagination)
|
|
|
+ this.$$request(Target.$$api.getPagination, this.query, this.pagination)
|
|
|
.then(data => {
|
|
|
const { count, list } = data
|
|
|
const { pagination } = this
|
|
|
const { pageSize } = pagination
|
|
|
if (list.length > 0 || pagination.pageNo === 1) {
|
|
|
this.total = count
|
|
|
- this.list = Object.freeze(bindPrototype(data.list, target))
|
|
|
+ this.list = Object.freeze(bindPrototype(data.list, Target))
|
|
|
this.afterLoadList()
|
|
|
return
|
|
|
}
|
|
@@ -46,9 +46,9 @@ export default (target, hasPagination = true) => ({
|
|
|
this.loadList()
|
|
|
}).catch(console.error).finally(() => {})
|
|
|
} else {
|
|
|
- this.$$request(target.$$api.getList, this.query).then(list => {
|
|
|
+ this.$$request(Target.$$api.getList, this.query).then(list => {
|
|
|
this.total = list.length
|
|
|
- this.list = Object.freeze(bindPrototype(Object.freeze(list), target))
|
|
|
+ this.list = Object.freeze(bindPrototype(list, Target))
|
|
|
this.afterLoadList()
|
|
|
}).catch(console.error).finally(() => {})
|
|
|
}
|
|
@@ -87,7 +87,7 @@ export default (target, hasPagination = true) => ({
|
|
|
})
|
|
|
},
|
|
|
deleteData (data) {
|
|
|
- this.$$request(target.$$api.delete, data)
|
|
|
+ this.$$request(Target.$$api.delete, data, Target)
|
|
|
.then(this.deleteSuccess)
|
|
|
.catch(this.deleteFailed)
|
|
|
.finally(() => {})
|
|
@@ -104,6 +104,9 @@ export default (target, hasPagination = true) => ({
|
|
|
this.deleteData(data)
|
|
|
}).catch(() => {})
|
|
|
},
|
|
|
+ onSaved () {
|
|
|
+ this.loadList()
|
|
|
+ },
|
|
|
getEditor () {
|
|
|
return this.$refs[this.editorName]
|
|
|
},
|
|
@@ -128,7 +131,7 @@ export default (target, hasPagination = true) => ({
|
|
|
async getOptionGroup () {
|
|
|
const optionGroup = {}
|
|
|
|
|
|
- const { $$optionTargetConfigGroup } = target
|
|
|
+ const { $$optionTargetConfigGroup } = Target
|
|
|
if (Array.isArray($$optionTargetConfigGroup)) {
|
|
|
const $$optionTargetConfigGroupLen = $$optionTargetConfigGroup.length
|
|
|
for (let i = 0; i < $$optionTargetConfigGroupLen; i++) {
|
|
@@ -143,9 +146,9 @@ export default (target, hasPagination = true) => ({
|
|
|
return Object.freeze(optionGroup)
|
|
|
},
|
|
|
setOptionGroup () {
|
|
|
- this.getOptionGroup(target).then(optionGroup => {
|
|
|
+ this.getOptionGroup(Target).then(optionGroup => {
|
|
|
this.optionGroup = optionGroup
|
|
|
- target.$$optionData = optionGroup
|
|
|
+ Target.$$optionData = optionGroup
|
|
|
this.loadList()
|
|
|
})
|
|
|
}
|