电脑桌面
添加蚂蚁七词文库到电脑桌面
安装后可以在桌面快捷访问

移动单据下推暂存,跳转

来源:金蝶云社区作者:金蝶2024-09-163

移动单据下推暂存,跳转

移动单据下推移动单据,暂存生成的下游单据,然后自动跳转打开生成的下游单据并进行编辑。

在原链接--移动单据自动下推上修改https://wenku.my7c.com/link/s/lK50I

                   //暂存下推数据
                    var draftResult = BusinessDataServiceHelper.Draft(this.View.Context, targetBillMeta.BusinessInfo, targetBillObjs, saveOption, "draft");
                    //打开暂存的单据
                    MobileShowParameter paramBill = new MobileShowParameter();
                    paramBill.FormId = "VBGU_YHMMDH_BOS";// 移动单据标识
                    paramBill.PKey = Convert.ToString(targetBillObjs[0]["id"]) ;
                    paramBill.Status = OperationStatus.EDIT;//新增为 OperationStatus.ADDNEW
                    this.View.ShowForm(paramBill);
完整代码如下:
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.DataEntity;
using Kingdee.BOS.Mobile.PlugIn;
using Kingdee.BOS.Mobile.PlugIn.Args;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Dynamic;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Core.Report.PlugIn.Args;
using Kingdee.BOS.Core.Metadata.EntityElement;
using Kingdee.BOS.ServiceHelper;
using Kingdee.BOS.Core.Metadata.ConvertElement.ServiceArgs;
using Kingdee.BOS.Core.List;
using Kingdee.BOS.Core.DynamicForm.Operation;
using Kingdee.BOS;
using Kingdee.BOS.Orm;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Util;
using Kingdee.BOS.Core.Interaction;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Mobile;

namespace XT01
{
    /// <summary>
     /// 移动表单继承:AbstractMobilePlugin, 移动单据继承:AbstractMobileBillPlugin
     /// 演示单据下推: 苗木申请单——》苗木到货单
     /// </summary>
     [System.ComponentModel.Description("移动单据--下推")]


    public class MobileBillPlugIn_XiaTui : AbstractMobileBillPlugin
    {
        public override void ButtonClick(ButtonClickEventArgs e)
        {
            if (e.Key == "XT")
            {
                try
                {
                    //本次演示的是苗木申请单订单=》苗木到货单
                    //单据内码
                    var pkVale = this.View.BillModel.GetPKValue().ToString();
                    //上游PC单据 苗木申请单FormId=单据的唯一标识
                    var sourceFormId = "VBGU_YHMMSQD";
                    //下游PC单据 苗木到货单FormId
                    var targetFormId = "VBGU_YHMMDHD";
                    if (string.IsNullOrWhiteSpace(pkVale))
                    {
                        this.View.ShowErrMessage("当前单据内码为空,无法下推!");
                        return;
                    }

                    //获取单据转换规则
                    var rules = ConvertServiceHelper.GetConvertRules(this.View.Context, sourceFormId, targetFormId);
                    if (rules == null || rules.Count == 0)
                    {
                        this.View.ShowErrMessage("未找到启用的转换规则,无法下推!");
                        return;
                    }
                    var rule = rules.FirstOrDefault(t => t.IsDefault);
                    rule = rule == null ? rules[0] : rule;

                    //构建待下推的源单数据行(这里我们只演示整单下推)
                    ListSelectedRow row = new ListSelectedRow(pkVale, string.Empty, 0, sourceFormId);
                    //如果下推的是指定单据体行,请参照下句代码,在ListSelectedRow中,指定EntryId以及EntryEntityKey
                    //ListSelectedRow row = new ListSelectedRow(pkVale, EntryId, 0, sourceFormId) { EntryEntityKey = "FEntity" };
                    ListSelectedRow[] selectedRows = new ListSelectedRow[] { row };

                    //调用下推服务,生成下游单据数据包
                    ConvertOperationResult operationResult = null;
                    Dictionary<string, object> custParams = new Dictionary<string, object>();
                    PushArgs pushArgs = new PushArgs(rule, selectedRows)
                    {
                        //设定目标单据单据类型。如无单据类型,可以空字符
                        TargetBillTypeId = "64c7652dbcfcd7",
                        //设定目标单据主业务组织。如无主业务组织,可以为0,建议在转换规则中,配置好主业务组织字段的映射关系:运行时,由系统根据映射关系,自动从上游单据取主业务组织,避免由插件指定
                        TargetOrgId = 0,
                        //可以传递额外附加的参数给单据转换插件,如无此需求,可以忽略
                        CustomParams = custParams,
                    };
                    //执行下推操作,并获取下推结果
                    operationResult = ConvertServiceHelper.Push(this.View.Context, pushArgs, OperateOption.Create());


                    //开始处理下推结果:
                    //获取下推生成的下游单据数据包
                    Kingdee.BOS.Orm.DataEntity.DynamicObject[] targetBillObjs = (from p in operationResult.TargetDataEntities select p.DataEntity).ToArray();
                    if (targetBillObjs.Length == 0)
                    {
                        throw new KDBusinessException("", string.Format("由{0}自动下推{1},没有成功生成数据包,自动下推失败!", sourceFormId, targetFormId));
                    }
                    // 读取目标单据元数据
     

移动单据下推暂存,跳转

移动单据下推移动单据,暂存生成的下游单据,然后自动跳转打开生成的下游单据并进行编辑。在原链接--移动单据自动下推上修改https://wenku....
点击下载文档文档为doc格式

声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。如若本站内容侵犯了原著者的合法权益,可联系本站删除。

已经是第一篇
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息
QQ群
  • 答案:my7c点击这里加入QQ群
支持邮箱
微信
  • 微信