表单插件如何传参到操作插件原创
金蝶云社区-开发者赋能部_吴富彪
开发者赋能部_吴富彪
7人赞赏了该文章 2,430次浏览 未经作者许可,禁止转载编辑于2022年12月01日 10:05:30

需求:

      众所周知,操作插件中是取不到view对象的,如果我们想要在操作插件中获取view对象里面的参数,通过以下方式是获取不到的:

FormShowParameter formShowParameter = this.getView().getFormShowParameter();

Map<String, Object> customParams = formShowParameter.getCustomParams();


实现:

1、在表单插件的beforeDoOperation事件中获取操作参数对象OperateOption,并设置参数

    @Override
    public void beforeDoOperation(BeforeDoOperationEventArgs args) {
        super.beforeDoOperation(args);
        FormOperate source = (FormOperate) args.getSource();
        String operateKey = source.getOperateKey();
        if("donothing".equals(operateKey)){
            OperateOption option = source.getOption();
//            FormShowParameter formShowParameter = this.getView().getFormShowParameter();
//            Map<String, Object> customParams = formShowParameter.getCustomParams();
            option.setVariableValue("test","111");
            source.setOption(option);
        }
    }

2、在操作插件中获取参数,操作插件的基类AbstractOperationServicePlugIn中是存在OperateOption变量的

image.png

所以可以在操作插件中通过this.operateOption获取到操作参数

image.png


效果:

image.png

赞 7