1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { Util, HttpResponse } from '../utils';
import { ControlServiceBase } from './control-service-base';
/**
* 数据视图部件服务基类
*
* @export
* @class DataViewServiceBase
* @extends {ControlServiceBase}
*/
export class DataViewServiceBase extends ControlServiceBase {
/**
* 查询数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isLoading]
* @returns {Promise<HttpResponse>}
* @memberof DataViewServiceBase
*/
public async search(action: string, context: any = {}, data: any = {}, isLoading?: boolean): Promise<HttpResponse> {
await this.onBeforeAction(action, context, data, isLoading);
data = this.handleRequestData(action, context, data);
let response: HttpResponse;
if (Util.isFunction(this.service[action])) {
response = await this.service[action](context, data);
} else {
response = await this.service.FetchDefault(context, data);
}
if (!response.isError()) {
response = this.handleResponse(action, response);
}
await this.onAfterAction(action, context, response);
return response;
}
}