231801_test_to_master #1519
|
@ -126,20 +126,20 @@ export default class CrudModel extends ModelProxy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loadMore(append) {
|
loadMore(overwrite) {
|
||||||
if (!this.moreRows)
|
if (!this.moreRows)
|
||||||
return this.$q.resolve();
|
return this.$q.resolve();
|
||||||
|
|
||||||
const filter = Object.assign({}, this.currentFilter);
|
const filter = Object.assign({}, this.currentFilter);
|
||||||
if (append)
|
if (overwrite)
|
||||||
filter.skip = this.orgData ? this.orgData.length : 0;
|
filter.skip = this.orgData ? this.orgData.length : 0;
|
||||||
|
|
||||||
if (!append) {
|
if (!overwrite) {
|
||||||
this.page += 1;
|
this.page += 1;
|
||||||
filter.limit = this.page * this.limit;
|
filter.limit = this.page * this.limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.sendRequest(filter, append);
|
return this.sendRequest(filter, overwrite, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
|
@ -231,12 +231,12 @@ export default class CrudModel extends ModelProxy {
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
sendRequest(filter, append) {
|
sendRequest(filter, overwrite, loadMore) {
|
||||||
this.cancelRequest();
|
this.cancelRequest();
|
||||||
this.canceler = this.$q.defer();
|
this.canceler = this.$q.defer();
|
||||||
this.isPaging = append;
|
this.isPaging = overwrite;
|
||||||
|
|
||||||
if (!append)
|
if (!loadMore)
|
||||||
this.status = 'loading';
|
this.status = 'loading';
|
||||||
|
|
||||||
let params = Object.assign(
|
let params = Object.assign(
|
||||||
|
@ -249,16 +249,16 @@ export default class CrudModel extends ModelProxy {
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.$http.get(this._url, options).then(
|
return this.$http.get(this._url, options).then(
|
||||||
json => this.onRemoteDone(json, filter, append),
|
json => this.onRemoteDone(json, filter, overwrite),
|
||||||
json => this.onRemoteError(json, append)
|
json => this.onRemoteError(json, overwrite)
|
||||||
).finally(() => {
|
).finally(() => {
|
||||||
this.isPaging = false;
|
this.isPaging = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onRemoteDone(json, filter, append) {
|
onRemoteDone(json, filter, overwrite) {
|
||||||
let data = json.data;
|
let data = json.data;
|
||||||
if (append)
|
if (overwrite)
|
||||||
this.orgData = this.orgData.concat(data);
|
this.orgData = this.orgData.concat(data);
|
||||||
else {
|
else {
|
||||||
this.orgData = data;
|
this.orgData = data;
|
||||||
|
@ -269,8 +269,8 @@ export default class CrudModel extends ModelProxy {
|
||||||
this.onRequestEnd();
|
this.onRequestEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
onRemoteError(err, append) {
|
onRemoteError(err, overwrite) {
|
||||||
if (!append) {
|
if (!overwrite) {
|
||||||
this.clear();
|
this.clear();
|
||||||
this.status = 'error';
|
this.status = 'error';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue