提交 cbc336af 编写于 作者: Mosher's avatar Mosher

add:新增部件逻辑

上级 d0e8e267
<#macro initControlEvents ctrl view>
/**
* 处理部件事件
*
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public handleCtrlEvents(eventName: string, args: any = {}): Promise<boolean> {
const data = args && args.data ? args.data : this.getData() || {};
const event = args && args.event ? args.event : {};
const result = await this.executeCtrlLogic(eventName, data, event);
if (result && result.hasOwnProperty('srfret') && (result.srfret === 'false' || result.srfret === false)) {
return false;
}
this.$emit(eventName, data, event);
return true;
}
/**
* 执行部件逻辑(由部件触发)
*
* @param {string} eventName 部件事件名称
* @param {any[]} data 数据
* @param {*} event 源事件对象
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public async executeCtrlLogic(eventName: string, data: any[], event?: any): Promise<boolean> {
<#if ctrl.getPSControlLogics?? && ctrl.getPSControlLogics()??>
<#list ctrl.getPSControlLogics() as logic>
<#if logic.getLogicType() != 'APPVIEWLOGIC' && logic.getTriggerType() == 'CTRLEVENT'>
if ('${logic.getEventNames()?lower_case}'.indexOf(eventName) !== -1) {
return await this.execute_${logic.name}_ctrl_logic(data, event);
}
</#if>
</#list>
</#if>
return true;
}
<#if ctrl.getPSControlLogics?? && ctrl.getPSControlLogics()??>
<#list ctrl.getPSControlLogics() as logic>
<#if logic.getLogicType() != 'APPVIEWLOGIC' && logic.getTriggerType() == 'CTRLEVENT'>
/**
* 部件逻辑 -- ${logic.name}
*
* @param {string} eventName 部件事件名称
* @param {any[]} data 数据
* @param {*} event 源事件对象
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public async execute_${logic.name}_ctrl_logic(data: any[], event?: any): Promise<boolean> {
<#if logic.getLogicType() == 'DEUILOGIC'>
<#if logic.getPSAppDEUILogic?? && logic.getPSAppDEUILogic()??>
try {
const uiService = await window.uiServiceRegister.getService('${logic.getPSAppDEUILogic().getPSAppDataEntity().getCodeName()?lower_case}');
if (uiService) {
const result = await uiService.executeUILogic(
'${logic.getPSAppDEUILogic().codeName}',
data,
Util.deepCopy(this.context),
Util.deepCopy(this.viewparams),
event,
this,
this.viewCtx && this.viewCtx.view ? this.viewCtx.view : {},
this.context.srfparentdename ? this.context.srfparentdename : ''
);
if (result && result.hasOwnProperty('srfret') && (result.srfret === 'false' || result.srfret === false)) {
return false;
}
}
} catch (error: any) {
}
</#if>
</#if>
return true;
}
</#if>
</#list>
</#if>
</#macro>
......@@ -242,6 +242,12 @@ ${P.getLogicCode(uiAction, "LOGIC.vue").code}
})
}
}
<#ibizinclude>
./@MACRO/control-logic.txt
</#ibizinclude>
<#-- START: 部件事件 -->
<@initControlEvents ctrl view/>
<#-- END: 部件事件 -->
<#if ctrl.render?? && ctrl.render.code2??>
${ctrl.render.code2}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册