跳转到内容

面板部件逻辑脚本

在面板部件逻辑中,可在脚本代码中根据部件数据实现复杂的业务逻辑。如加载数据前添加或删除请求参数,或者数据保存成功后通知另一视图刷新。部件逻辑支持绑定的事件请参考组件中对应部件的事件描述。

参数

名称类型描述
triggerControlNamestring触发部件名称,仅面板部件触发时存在
triggerEventNamestring事件名称,仅面板部件触发时存在
triggerEventIApiData触发部件参数,仅面板部件触发时存在
panelItemNamestring面板项名称,仅非面板部件触发时存在
panelItemEventNamestring面板项事件名称,仅非面板部件触发时存在
documentDocument当前文档对象
selector(className: string) => HTMLCollectionOf<Element>元素选择器
envIEnvironment当前环境对象
appSessionIApiData当前应用会话对象
topViewSessionIApiData当前顶级视图会话对象
viewSessionIApiData当前视图会话对象
contextIApiContext当前视图上下文
viewParamIApiParams当前视图参数
dataIApiData[]当前业务数据
appIApiAppHubController当前应用
topViewIApiViewController当前顶级视图
parentViewIApiViewController | undefined当前父视图
viewIApiViewController当前视图
parentIApiViewController | undefined当前父视图
util{ message: IApiMessageUtil, notification: IApiNotificationUtil,modal: IApiModalUtil,confirm: IApiConfirmUtil,openView: IApiOpenViewUtil}工具集
ctrlIApiControlController | undefined当前部件

调用示例

部件加载前(onBeforeLoad)添加请求参数

typescript
viewParam.queryconds=["n_title_like", "n_identifier_like", "n_description_like"];

部件初始化(onCreated)时默认不显示容器

typescript
view.layoutPanel.panelItems.send_comment_container.state.visible = false;

视图加载成功后(onLoadSuccess)判断面板项是否该隐藏

typescript
if (view.layoutPanel.panelItems.mdctrl.control.state.items.length == 0) {
  view.layoutPanel.panelItems.mdctrl.state.visible = false;
}

视图保存成功后发送实体更新消息

typescript
ibiz.mc.command.update.send({ srfdecodename: "library" });

部件加载成功后(onLoadSuccess)通知相同实体刷新

ibiz.mc.command.update.send({ srfdecodename: 'work_item'})

搜索表单加载草稿前(onBeforeLoadDraft)设置默认值

const currentDate = new Date();
const currentYear = currentDate.getFullYear();
const currentMonth = currentDate.getMonth();
const day = currentDate.getDate();
const n_tjsj_gt1 = `${currentYear}-${currentMonth}-${day}`;
const n_tjsj_lt1 = `${currentYear}-${currentMonth + 1}-${day}`;
const n_ywfl_eq = 'JXJS';
const n_sjfwlx_eq1 = 'YEAR';
Object.assign(viewParam, {
  n_ywfl_eq,
  n_tjsj_gt1,
  n_tjsj_lt1,
  n_sjfwlx_eq1,
})

监听视图下所有部件选中事件打开视图

if (triggerEventName && triggerEventName === 'onSelectionChange') {
    view.call('Edit', { 
        context: view.context,
        params: view.params,
        data: triggerEvent.data,
        view,
        ctrl: triggerEvent.ctrl,
    });
}
未来已来,立即拥抱应用融合的力量
Released under the MIT License.