提交 3213cdbd 编写于 作者: WodahsOrez's avatar WodahsOrez

update:表单部件服务

上级 c85b0f53
import { ControlServiceBase, ControlVOBase, hasFunction } from '@ibiz-core'; import { ControlServiceBase, ControlVOBase, hasFunction } from '@ibiz-core';
import { createUUID } from 'qx-util';
/**
* 表单部件服务
*
* @export
* @class EditFormService
* @template T 部件数据对象类型
*/
export class EditFormService<T extends ControlVOBase> extends ControlServiceBase<T> { export class EditFormService<T extends ControlVOBase> extends ControlServiceBase<T> {
/** /**
* 加载草稿数据 * 加载草稿数据
* *
...@@ -12,14 +17,15 @@ export class EditFormService<T extends ControlVOBase> extends ControlServiceBase ...@@ -12,14 +17,15 @@ export class EditFormService<T extends ControlVOBase> extends ControlServiceBase
* @return {*} * @return {*}
*/ */
public async loadDraft(context: any, data: any, opts: { action: string; isLoading?: boolean }): Promise<any> { public async loadDraft(context: any, data: any, opts: { action: string; isLoading?: boolean }): Promise<any> {
const { context: Context, data: Data } = this.handleRequestData(context, data, opts); let _entityService: any = this.entityService;
// todo主键 const { context: Context, data: Data } = this.handleRequestData(context, data, opts);
const action = hasFunction(this.entityService, opts.action) ? opts.action : 'GetDraft'; // todo主键
const response = await this.entityService[action](Context, Data, opts.isLoading); const action = hasFunction(_entityService, opts.action) ? opts.action : 'GetDraft';
// this.setRemoteCopyData(response); const response = await _entityService[action](Context, Data, opts.isLoading);
response.data = this.newControlVO(response.data); // this.setRemoteCopyData(response);
response.data.srfuf = "0"; response.data = this.newControlVO(response.data);
return this.handleResponse(response, opts); response.data.srfuf = '0';
return this.handleResponse(response, opts);
} }
/** /**
...@@ -31,12 +37,13 @@ export class EditFormService<T extends ControlVOBase> extends ControlServiceBase ...@@ -31,12 +37,13 @@ export class EditFormService<T extends ControlVOBase> extends ControlServiceBase
* @return {*} * @return {*}
*/ */
public async get(context: any, data: any, opts: { action: string; isLoading?: boolean }): Promise<any> { public async get(context: any, data: any, opts: { action: string; isLoading?: boolean }): Promise<any> {
const { context: Context, data: Data } = this.handleRequestData(context, data, opts); let _entityService: any = this.entityService;
const action = hasFunction(this.entityService, opts.action) ? opts.action : 'GET'; const { context: Context, data: Data } = this.handleRequestData(context, data, opts);
const response = await this.entityService[action](Context, Data, opts.isLoading); const action = hasFunction(_entityService, opts.action) ? opts.action : 'GET';
// this.setRemoteCopyData(response); const response = await _entityService[action](Context, Data, opts.isLoading);
response.data = this.newControlVO(response.data); // this.setRemoteCopyData(response);
return this.handleResponse(response, opts); response.data = this.newControlVO(response.data);
return this.handleResponse(response, opts);
} }
/** /**
...@@ -48,11 +55,12 @@ export class EditFormService<T extends ControlVOBase> extends ControlServiceBase ...@@ -48,11 +55,12 @@ export class EditFormService<T extends ControlVOBase> extends ControlServiceBase
* @return {*} * @return {*}
*/ */
public async create(context: any, data: any, opts: { action: string; isLoading?: boolean }): Promise<any> { public async create(context: any, data: any, opts: { action: string; isLoading?: boolean }): Promise<any> {
const { context: Context, data: Data } = this.handleRequestData(context, data, opts); let _entityService: any = this.entityService;
const action = hasFunction(this.entityService, opts.action) ? opts.action : 'Create'; const { context: Context, data: Data } = this.handleRequestData(context, data, opts);
const response = await this.entityService[action](Context, Data, opts.isLoading); const action = hasFunction(_entityService, opts.action) ? opts.action : 'Create';
response.data = this.newControlVO(response.data); const response = await _entityService[action](Context, Data, opts.isLoading);
return this.handleResponse(response, opts); response.data = this.newControlVO(response.data);
return this.handleResponse(response, opts);
} }
/** /**
...@@ -64,11 +72,12 @@ export class EditFormService<T extends ControlVOBase> extends ControlServiceBase ...@@ -64,11 +72,12 @@ export class EditFormService<T extends ControlVOBase> extends ControlServiceBase
* @return {*} * @return {*}
*/ */
public async remove(context: any, data: any, opts: { action: string; isLoading?: boolean }): Promise<any> { public async remove(context: any, data: any, opts: { action: string; isLoading?: boolean }): Promise<any> {
const { context: Context, data: Data } = this.handleRequestData(context, data, opts); let _entityService: any = this.entityService;
const action = hasFunction(this.entityService, opts.action) ? opts.action : 'Remove'; const { context: Context, data: Data } = this.handleRequestData(context, data, opts);
const response = await this.entityService[action](Context, Data, opts.isLoading); const action = hasFunction(_entityService, opts.action) ? opts.action : 'Remove';
response.data = this.newControlVO(response.data); const response = await _entityService[action](Context, Data, opts.isLoading);
return this.handleResponse(response, opts); response.data = this.newControlVO(response.data);
return this.handleResponse(response, opts);
} }
/** /**
...@@ -80,11 +89,11 @@ export class EditFormService<T extends ControlVOBase> extends ControlServiceBase ...@@ -80,11 +89,11 @@ export class EditFormService<T extends ControlVOBase> extends ControlServiceBase
* @return {*} * @return {*}
*/ */
public async update(context: any, data: any, opts: { action: string; isLoading?: boolean }): Promise<any> { public async update(context: any, data: any, opts: { action: string; isLoading?: boolean }): Promise<any> {
const { context: Context, data: Data } = this.handleRequestData(context, data, opts); let _entityService: any = this.entityService;
const action = hasFunction(this.entityService, opts.action) ? opts.action : 'Update'; const { context: Context, data: Data } = this.handleRequestData(context, data, opts);
const response = await this.entityService[action](Context, Data, opts.isLoading); const action = hasFunction(_entityService, opts.action) ? opts.action : 'Update';
response.data = this.newControlVO(response.data); const response = await _entityService[action](Context, Data, opts.isLoading);
return this.handleResponse(response, opts); response.data = this.newControlVO(response.data);
} return this.handleResponse(response, opts);
} }
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册