金蝶云星空表单插件传递参数到服务插件

发布时间 2023-11-27 20:10:54作者: lanrenka

一、 业务需求
操作售后单行反关闭时将当前选中行的序号传递到服务端,然后在服务端接收序列号,根据序列号处理相关逻辑。

二、开发实现
2.1、传递参数
售后单表单插件的BeforeDoOperation事件

public override void BeforeDoOperation(BeforeDoOperationEventArgs e)
{
    base.BeforeDoOperation(e);
    switch (e.Operation.FormOperation.Operation.ToUpperInvariant())
    {
        case "ROWUNCLOSE": //行反关闭
            if (this.Model.DataChanged)
            {
                this.View.ShowErrMessage("当前界面未保存,请先操作保存。");
                e.Cancel = true;
                return;
            }
            //获取当前选中行
            int rowIndexV = this.View.Model.GetEntryCurrentRowIndex("FEntity"); //获取当前明细选中行
            Entity entityV = this.View.BusinessInfo.GetEntity("FEntity");
            DynamicObject itemV = View.Model.GetEntityDataObject(entityV, rowIndexV) as DynamicObject;
            //获取序列号
            int unCloseSeq = Convert.ToInt32(itemV["Seq"]);
            e.Option.SetVariableValue("unCloseSeq", unCloseSeq);//给行反关闭添加自定义参数 表单插件传递参数到服务插件
            break;
    }
}
View Code

 

 

2.2、接收参数
在行关闭的服务插件BeforeExecuteOperationTransaction事件

public override void BeforeExecuteOperationTransaction(BeforeExecuteOperationTransaction e)
{
    base.BeforeExecuteOperationTransaction(e);
    var aa=this.FormOperation.Operation;
           
    if (this.Option.ContainsVariable("unCloseSeq"))//判断表单是否传递关键字
    {
        unCloseSeq = this.Option.GetVariables()["unCloseSeq"].ToString();//取出关键字的值
    }
}
View Code