如何调用客户端自定义指令
金蝶云社区-洛尘
洛尘
10人赞赏了该文章 1,158次浏览 未经作者许可,禁止转载编辑于2021年12月09日 14:56:40

如何调用客户端自定义指令

客户端自定义指令是指通过this.getView().executeClientCommand(String command. Object... args)方法调用的指令,该指令是由前端定义的,现已经定义的指令有

指令名说明是否有回调
setCaption设置浏览器页签显示名字(移动端为设置页面标题)
callYZJApi调用云之家API根据云之家API决定
loadThirdPartyJS加载第三方JS文件
showCalculatorPC端打开计算器功能
panelScrollBottomFlex面板滚动到底部
panelScrollTopFlex面板滚动到顶部
closeTab关闭非showform方式打开的页签

如该指令有结果回调的话,则插件需要在customEvent中获取,如:

public void customEvent(CustomEventArgs e) {    String eventName = e.getEventName();    String value = e.getEventArgs();    String key = e.getKey();    if(eventName.equals("xxxx")){        // do something
    }
}
  • setCaption
    设置浏览器页签显示名字

    String title = "金蝶云苍穹";this.getView().executeClientCommand('setCaption', title)
  • callYZJApi
    调用云之家API,具体云之家API请参考,如需要调用拍照功能如下:

    HashMap map = new HashMap();
    map.put("method", "selectPic"); //selectPic 为云之家方法名HashMap args = new HashMap();
    args.put("type", "camera");
    map.put("args", args);  //args 调用该云之家方法需要传递的参数this.getView().executeClientCommand("callYZJApi", map);

如调用该云之家API是有结果返回的,则需要在插件中的customEvent方法中获取

  • loadThirdPartyJS
    加载指定url的js文件

    String jspath = 'http://xxx/xxx.js';this.getView().executeClientCommand("loadThirdPartyJS", jspath);
  • showCalculator
    打开计算器功能,

//不带参数方式打开计算器功能 this.getView().executeClientCommand("showCalculator"); 

//带参数方式打开计算器功能String key = '' //控件key,可为空int value = 100 // 计算器初始值this.getView().executeClientCommand("showCalculator",key,value);

计算器功能同时支持快捷键ctrl+F11的方式打开

  • panelScrollBottom
    当flex面板出现滚动条的时候,该指令可使面板滚动到底部

 //1、给指定面板设置支持滚动属性
 HashMap map = new HashMap();
 map1.put("scrollBottom", true); this.getView().updateControlMetadata("flexpanelap", map); //2、发送滚动到底部的指令
 this.getView().executeClientCommand("panelScrollBottom", "flexpanelap");
  • panelScrollTop
    当flex面板出现滚动条的时候,该指令可使面板滚动到顶部

 //1、给指定面板设置支持滚动属性
 HashMap map = new HashMap();
 map1.put("scrollTop", true); this.getView().updateControlMetadata("flexpanelap", map); //2、发送滚动到底部的指令
 this.getView().executeClientCommand("panelScrollTop", "flexpanelap");
  • closeTab
    关闭非showform方式打开的页签项,即在设计器上配置好的页签项

    String tabpageid = "tabpage";this.getView().executeClientCommand("closeTab", tabpageid);


本文转载自:金蝶云苍穹开发者门户

作者:金蝶云苍穹开发者门户

原文链接:https://dev.kingdee.com/index/docsNew/6af21b3a-0873-4657-b691-9d95322d24cc

赞 10