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

update:部件服务

上级 41b1c709
controlsAction:{ controlsAction:{
{{#page.ctrls as | ctrl |}}
{{#neq controlType "TOOLBAR"}}
{{codeName}}:{
loadAction: '{{ctrl.getPSControlAction.psAppDEMethod.codeName}}', loadAction: '{{ctrl.getPSControlAction.psAppDEMethod.codeName}}',
removeAction: '{{ctrl.removePSControlAction.psAppDEMethod.codeName}}', removeAction: '{{ctrl.removePSControlAction.psAppDEMethod.codeName}}',
updateAction: '{{ctrl.updatePSControlAction.psAppDEMethod.codeName}}', updateAction: '{{ctrl.updatePSControlAction.psAppDEMethod.codeName}}',
loadDraftAction: '{{ctrl.getDraftPSControlAction.psAppDEMethod.codeName}}', loadDraftAction: '{{ctrl.getDraftPSControlAction.psAppDEMethod.codeName}}',
createAction: '{{ctrl.getDraftPSControlAction.psAppDEMethod.codeName}}', createAction: '{{ctrl.getDraftPSControlAction.psAppDEMethod.codeName}}',
} },
\ No newline at end of file {{/neq}}
{{/page.ctrls}}
}
\ No newline at end of file
viewCodeName: '{{page.codeName}}', viewCodeName: '{{page.codeName}}',
viewName: '{{page.name}}', viewName: '{{page.name}}',
viewCaption: '{{page.caption}}', viewCaption: '{{page.caption}}',
height: '{{page.height}}', height: '{{page.height}}',
width: '{{page.width}}', width: '{{page.width}}',
viewMsgGroup: '{{page.psAppViewMsgGroup}}', viewMsgGroup: '{{page.psAppViewMsgGroup}}',
viewUIActions: '{{page.psAppViewUIActions}}', viewUIActions: '{{page.psAppViewUIActions}}',
viewSysCss: '{{page.psSysCss}}', viewSysCss: '{{page.psSysCss}}',
viewSysImage: '{{page.psSysImage}}', viewSysImage: '{{page.psSysImage}}',
subCaption: '{{page.subCaption}}', subCaption: '{{page.subCaption}}',
viewType: '{{page.viewType}}', viewType: '{{page.viewType}}',
viewStyle: '{{page.viewStyle}}', viewStyle: '{{page.viewStyle}}',
showCaptionBar: '{{page.viewStyle}}', showCaptionBar: '{{page.viewStyle}}',
viewToolbarModel: [ viewToolbarModel: [
{{#page.ctrls}} {{#page.ctrls}}
{{#eq controlType "TOOLBAR"}} {{#eq controlType "TOOLBAR"}}
{{#psDEToolbarItems}} {{#psDEToolbarItems}}
{ name:'{{name}}',caption:'{{caption}}',groupExtractMode:'{{groupExtractMode}}',itemType:'{{itemType}}',noPrivDisplayMode:'{{noPrivDisplayMode}}',showIcon:{{showIcon}},showCaption:{{showCaption}},tooltip:'{{tooltip}}' }, { name:'{{name}}',caption:'{{caption}}',groupExtractMode:'{{groupExtractMode}}',itemType:'{{itemType}}',noPrivDisplayMode:'{{noPrivDisplayMode}}',showIcon:{{showIcon}},showCaption:{{showCaption}},tooltip:'{{tooltip}}' },
{{/psDEToolbarItems}} {{/psDEToolbarItems}}
{{/eq}} {{/eq}}
{{/page.ctrls}} {{/page.ctrls}}
], ],
{{> @macro/front-end/view/common/controlAction.hbs}}
\ No newline at end of file
\ No newline at end of file
...@@ -74,6 +74,23 @@ export class ControlVOBase { ...@@ -74,6 +74,23 @@ export class ControlVOBase {
} }
} }
/**
* 克隆方法(创建一个新的ControlVO对象)
* 拥有ControlVO的功能,且与原对象的互不影响。
*
*/
public clone(){
}
/**
* 转换成普通js对象,拷贝所有的数据
*
*/
public toObject(){
return {};
}
/** /**
* 用后台数据重置数据对象 * 用后台数据重置数据对象
* @param data 后台数据 * @param data 后台数据
......
export class ControlServiceBase { import { ControlVOBase, EntityService } from "@ibiz-core";
export class ControlServiceBase<T extends ControlVOBase> {
/**
* 构造函数
* @param controlVOType
*/
constructor(private controlVOType: new (data: any)=> T,public entityService: EntityService){}
/**
* 新建部件界面数据对象
* @param $DO 后台数据对象
* @return {*}
*/
public newControlVO($DO: any){
return new this.controlVOType($DO);
}
/** /**
* 请求前处理函数 * 请求前处理函数
* *
......
import { ControlServiceBase, hasFunction } from '@ibiz-core'; import { ControlServiceBase, ControlVOBase, hasFunction } from '@ibiz-core';
import { createUUID } from 'qx-util'; import { createUUID } from 'qx-util';
import { {{pascalCase ctrl.psAppDataEntity.codeName}}Service } from '@service/entity/{{spinalCase ctrl.psAppDataEntity.codeName}}/{{spinalCase ctrl.psAppDataEntity.codeName}}-service';
import { ControlVO } from './{{spinalCase ctrl.codeName}}-form-config';
export class ControlService extends ControlServiceBase { export class EditFormService<T extends ControlVOBase> extends ControlServiceBase<T> {
/**
* 实体服务对象
*/
public entityService: {{pascalCase ctrl.psAppDataEntity.codeName}}Service = new {{pascalCase ctrl.psAppDataEntity.codeName}}Service();
/** /**
* 加载草稿数据 * 加载草稿数据
...@@ -24,7 +17,7 @@ export class ControlService extends ControlServiceBase { ...@@ -24,7 +17,7 @@ export class ControlService extends ControlServiceBase {
const action = hasFunction(this.entityService, opts.action) ? opts.action : 'GetDraft'; const action = hasFunction(this.entityService, opts.action) ? opts.action : 'GetDraft';
const response = await this.entityService[action](Context, Data, opts.isLoading); const response = await this.entityService[action](Context, Data, opts.isLoading);
// this.setRemoteCopyData(response); // this.setRemoteCopyData(response);
response.data = new ControlVO(response.data); response.data = this.newControlVO(response.data);
response.data.srfuf = "0"; response.data.srfuf = "0";
return this.handleResponse(response, opts); return this.handleResponse(response, opts);
} }
...@@ -42,7 +35,7 @@ export class ControlService extends ControlServiceBase { ...@@ -42,7 +35,7 @@ export class ControlService extends ControlServiceBase {
const action = hasFunction(this.entityService, opts.action) ? opts.action : 'GET'; const action = hasFunction(this.entityService, opts.action) ? opts.action : 'GET';
const response = await this.entityService[action](Context, Data, opts.isLoading); const response = await this.entityService[action](Context, Data, opts.isLoading);
// this.setRemoteCopyData(response); // this.setRemoteCopyData(response);
response.data = new ControlVO(response.data); response.data = this.newControlVO(response.data);
return this.handleResponse(response, opts); return this.handleResponse(response, opts);
} }
...@@ -58,7 +51,7 @@ export class ControlService extends ControlServiceBase { ...@@ -58,7 +51,7 @@ export class ControlService extends ControlServiceBase {
const { context: Context, data: Data } = this.handleRequestData(context, data, opts); const { context: Context, data: Data } = this.handleRequestData(context, data, opts);
const action = hasFunction(this.entityService, opts.action) ? opts.action : 'Create'; const action = hasFunction(this.entityService, opts.action) ? opts.action : 'Create';
const response = await this.entityService[action](Context, Data, opts.isLoading); const response = await this.entityService[action](Context, Data, opts.isLoading);
response.data = new ControlVO(response.data); response.data = this.newControlVO(response.data);
return this.handleResponse(response, opts); return this.handleResponse(response, opts);
} }
...@@ -74,7 +67,7 @@ export class ControlService extends ControlServiceBase { ...@@ -74,7 +67,7 @@ export class ControlService extends ControlServiceBase {
const { context: Context, data: Data } = this.handleRequestData(context, data, opts); const { context: Context, data: Data } = this.handleRequestData(context, data, opts);
const action = hasFunction(this.entityService, opts.action) ? opts.action : 'Remove'; const action = hasFunction(this.entityService, opts.action) ? opts.action : 'Remove';
const response = await this.entityService[action](Context, Data, opts.isLoading); const response = await this.entityService[action](Context, Data, opts.isLoading);
response.data = new ControlVO(response.data); response.data = this.newControlVO(response.data);
return this.handleResponse(response, opts); return this.handleResponse(response, opts);
} }
...@@ -90,7 +83,7 @@ export class ControlService extends ControlServiceBase { ...@@ -90,7 +83,7 @@ export class ControlService extends ControlServiceBase {
const { context: Context, data: Data } = this.handleRequestData(context, data, opts); const { context: Context, data: Data } = this.handleRequestData(context, data, opts);
const action = hasFunction(this.entityService, opts.action) ? opts.action : 'Update'; const action = hasFunction(this.entityService, opts.action) ? opts.action : 'Update';
const response = await this.entityService[action](Context, Data, opts.isLoading); const response = await this.entityService[action](Context, Data, opts.isLoading);
response.data = new ControlVO(response.data); response.data = this.newControlVO(response.data);
return this.handleResponse(response, opts); return this.handleResponse(response, opts);
} }
......
export * from './control-service-base' export * from './control-service-base'
\ No newline at end of file export * from './edit-form-service'
\ No newline at end of file
export const ViewConfig = { export const ViewConfig = {
viewCodeName: '{{page.codeName}}', {{> @macro/front-end/view/common/viewBaseConfig.hbs}}
viewName: '{{page.name}}',
viewCaption: '{{page.caption}}',
}; };
\ No newline at end of file
export const ViewConfig = { export const ViewConfig = {
{{> @macro/front-end/view/common/viewBaseConfig.hbs}} {{> @macro/front-end/view/common/viewBaseConfig.hbs}}
{{#each page.ctrls as | ctrl |}}
{{#if (eq ctrl.controlType "FORM")}}
{{> @macro/front-end/view/common/controlAction.hbs ctrl=ctrl}}
{{/if}}
{{/each}}
}; };
\ No newline at end of file
...@@ -2,9 +2,4 @@ export const ViewConfig = { ...@@ -2,9 +2,4 @@ export const ViewConfig = {
gridRowActiveMode: {{page.gridRowActiveMode}}, gridRowActiveMode: {{page.gridRowActiveMode}},
rowEditState: {{#if page.enableRowEdit}}{{page.rowEditDefault}}{{else}}false{{/if}}, rowEditState: {{#if page.enableRowEdit}}{{page.rowEditDefault}}{{else}}false{{/if}},
{{> @macro/front-end/view/common/viewBaseConfig.hbs}} {{> @macro/front-end/view/common/viewBaseConfig.hbs}}
{{#each page.ctrls as | ctrl |}}
{{#if (eq ctrl.controlType "GRID")}}
{{> @macro/front-end/view/common/controlAction.hbs ctrl=ctrl}}
{{/if}}
{{/each}}
}; };
\ No newline at end of file
export const ViewConfig = { export const ViewConfig = {
viewCodeName: '{{page.codeName}}', {{> @macro/front-end/view/common/viewBaseConfig.hbs}}
viewName: '{{page.name}}',
viewCaption: '{{page.caption}}',
{{#page.ctrls}}
{{#eq controlType "GRID"}}
{{lowerCase codeName}}:{
name:'{{name}}',
codeName:'{{codeName}}',
action:{
'createAction': 'Create'
}
},
{{/eq}}
{{/page.ctrls}}
}; };
\ No newline at end of file
export const ViewConfig = { export const ViewConfig = {
viewCodeName: '{{page.codeName}}', {{> @macro/front-end/view/common/viewBaseConfig.hbs}}
viewName: '{{page.name}}',
viewCaption: '{{page.caption}}',
{{#page.ctrls}}
{{#eq controlType "PICKUPVIEWPANEL"}}
{{lowerCase codeName}}:{
name:'{{name}}',
codeName:'{{codeName}}',
action:{
'createAction': 'Create'
}
},
{{/eq}}
{{/page.ctrls}}
}; };
\ No newline at end of file
{{>@macro/form-detail/include-form.hbs}} {{>@macro/form-detail/include-form.hbs}}
import { ControlVOBase, verifyRules } from '@ibiz-core'; import { ControlVOBase, verifyRules, EditFormService } from '@ibiz-core';
import { ControlService } from './{{spinalCase ctrl.codeName}}-form-service'; import { {{pascalCase ctrl.psAppDataEntity.codeName}}Service } from '@service/entity/{{spinalCase ctrl.psAppDataEntity.codeName}}/{{spinalCase ctrl.psAppDataEntity.codeName}}-service';
/**
* 部件展示数据对象
* @export
* @class ControlVO
*/
export class ControlVO extends ControlVOBase {
/**
* 用后台数据对象创建部件数据对象
* @param data 后台数据
*/
constructor(data: any){
super(data);
// 记录没有映射的属性
this.$ownKeys =
{{~#each ctrl.psDEFormItems as | formItem | ~}}
{{#if @first}}[{{/if~}}
'{{lowerCase formItem.id}}'{{#unless @last}},{{/unless}}
{{~#if @last}}];{{/if~}}
{{/each}}
}
// 表单里映射了属性的字段
{{#each ctrl.psDEFormItems as | formItem | }}
{{!-- TODO: 表单formItem的name拿不到 --}}
{{#neq formItem.psAppDEField null }}
get {{lowerCase formItem.id}}() {
return this.$DO.{{lowerCase formItem.psAppDEField.codeName}};
}
set {{lowerCase formItem.id}}(value: any) {
this.$DO.{{lowerCase formItem.psAppDEField.codeName}} = value;
}
{{/neq}}
{{/each}}
// 表单里没有映射实体属性的字段(srfuf除外)
{{#each ctrl.psDEFormItems as | formItem | }}
{{#if (and (eq formItem.psAppDEField null) (neq formItem.id "srfuf" )) }}
{{lowerCase formItem.id}}: any;
{{/if}}
{{/each}}
}
// 部件配置对象
export const CtrlConfig = { export const CtrlConfig = {
controlCodeName: '{{ctrl.codeName}}', controlCodeName: '{{ctrl.codeName}}',
controlName: '{{ctrl.name}}', controlName: '{{ctrl.name}}',
controlService: new ControlService(), controlService: new EditFormService<ControlVO>(ControlVO, new {{pascalCase ctrl.psAppDataEntity.codeName}}Service() ),
data: {}, data: new ControlVO({}),
itemsModel: [ itemsModel: [
{{#each ctrl.psDEFormPages as | FormPage | }} {{#each ctrl.psDEFormPages as | FormPage | }}
{{>(lookup 'FORMDETAILSMODEL') items=FormPage.psDEFormDetails}} {{>(lookup 'FORMDETAILSMODEL') items=FormPage.psDEFormDetails}}
...@@ -34,32 +79,4 @@ export const CtrlConfig = { ...@@ -34,32 +79,4 @@ export const CtrlConfig = {
{{/neq}} {{/neq}}
{{/each}} {{/each}}
}, },
}; };
\ No newline at end of file
/**
* 部件展示数据对象
* @export
* @class ControlVO
*/
export class ControlVO extends ControlVOBase {
// 表单里映射了属性的字段
{{#each ctrl.psDEFormItems as | formItem | }}
{{!-- TODO: 表单formItem的name拿不到 --}}
{{#neq formItem.psAppDEField null }}
get {{lowerCase formItem.id}}() {
return this.$DO.{{lowerCase formItem.psAppDEField.codeName}};
}
set {{lowerCase formItem.id}}(value: any) {
this.$DO.{{lowerCase formItem.psAppDEField.codeName}} = value;
}
{{/neq}}
{{/each}}
// 表单里没有映射实体属性的字段(srfuf除外)
{{#each ctrl.psDEFormItems as | formItem | }}
{{#if (and (eq formItem.psAppDEField null) (neq formItem.id "srfuf" )) }}
{{lowerCase formItem.id}}: any;
{{/if}}
{{/each}}
}
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册