先执行表单再执行操作

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-16浏览:1

先执行表单再执行操作

最近有遇到一个需求:客户在单据表单/列表打开一个动态表单,做用户二次登录效验,效验完成后去执行某些操作,由于操作服务插件不能打开动态表单,所以分为表单插件和操作服务插件分开进行,由于打开动态表单是异步得,所以会出现在你打开动态表单得时候,你的操作服务插件已经在执行或者已经执行完了,就与客户需求冲突,从而给出以下

解决方法:在表单插件调的之前你要先设置e.Cancel=true以取消本次操作,然后再验证二次密码OK后,再次触发同样操作,注意第二次触发操作时要加标记,以便表单插件的BeforeDoOpe...事件放过

示例:

/// <summary>
/// 主菜单单击事件
/// </summary>
 public override void BarItemClick(BarItemClickEventArgs e)
        {
            base.BarItemClick(e);
            if (e.BarItemKey.Equals("按钮标识"))
            {
                e.Cancel = true;//先取消当前操作,执行表单/列表逻辑
                int Get = Submit(this.Model.GetValue("FBILLNO").ToString());
                int Voucher = FindVoucherForPayBill(this.Model.GetValue("FBILLNO").ToString());//查询单据是否生成凭证
                if (GetSubmitCBS > 0)
                {
                    if (Voucher > 0)
                    {
                        DynamicFormShowParameter formpa = new DynamicFormShowParameter();
                        formpa.FormId = "动态表单标识";
                        this.View.ShowForm(formpa, delegate (FormResult result)
                        {
                            //定义接收值,转换成(DynamicObjectCollection)类型
                            string returnData = result.ReturnData.ToString();

                            //如果不为空,执行
                            if (returnData != null)
                            {
                                string[] sgin = returnData.Split(';');
                                string zh = sgin[0];
                                string mm = ConfidentialDataSecurityUtil.CipherText(sgin[1]);//调用系统密码加密

                                LoginInfo info = new LoginInfo();
                                info.Username = zh;
                                info.Password = mm;
                                LoginResult results = LoginServiceHelper.CheckLoginInfo(this.Context, info);//二次效验
                                if (string.IsNullOrEmpty(results.Message))
                                {
                                    this.View.ShowMessage("是否确操作", MessageBoxOptions.YesNo, ret =>
                                    {
                                        if (ret == MessageBoxResult.No)
                                        {
                                            e.Cancel = true; return;//取消当前操作
                                        }
                                        else
                                        {
                                            this.View.InvokeFormOperation("操作标识");//调用操作
                                            this.View.ShowMessage("成功");
                                            return;
                                        }
                                    });
                                }
                                else
                                {
                                    this.View.ShowMessage(results.Message.ToString());
                                }
                            }
                        });
                    }
                    else
                    {
                        throw new Exception("当前单据不满足条件,不允许操作");
                    }
                }
                else
                {
                    throw new Exception("当前单据不满足条件,不允许操作");
                }

            }
     }

然后再去BeforeDoOperation内标记一下这个操作

        /// <summary>
        /// 单据持有事件发生前需要完成的功能
        /// </summary>
        /// <param name="e"></param>
        public override void BeforeDoOperation(BeforeDoOperationEventArgs e)
        {
            base.BeforeDoOperation(e);
            if (e.Operation.FormOperation.Id == "Submit")
            {
                e.Cancel = false;
            }
        }

分享不易,若有帮助,帮忙一键三联噢


妙啊!~

先执行表单再执行操作

最近有遇到一个需求:客户在单据表单/列表打开一个动态表单,做用户二次登录效验,效验完成后去执行某些操作,由于操作服务插件不能打开动...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息