Python表单插件-点击菜单弹出动态表单传递参数到子页面原创
金蝶云社区-CQ周玉立
CQ周玉立
29人赞赏了该文章 5754次浏览 未经作者许可,禁止转载编辑于2022年03月15日 10:54:17

对于我们日常开发的功能中,会经常遇到需要做界面交互,需要弹出界面来做数据处理,同时需要传递参数到子页面。

这里分享一下Python表单插件-点击菜单弹出动态表单传递参数到子页面的示例代码。

可以根据实际需求,将弹出界面的方法放到其他触发事件里面!不说太多,下面看代码。

那么动态表单子页面如何处理呢?传送门:Python动态表单插件-子页面关闭返回数据到父页面


#引入clr运行库

# -*- coding: utf-8 -*-
import clr

#添加对cloud插件开发的常用组件的引用
clr.AddReference('System')
clr.AddReference('System.Data')
clr.AddReference('Kingdee.BOS')
clr.AddReference('Kingdee.BOS.Core')
clr.AddReference('Kingdee.BOS.App')
clr.AddReference('Kingdee.BOS.ServiceHelper')
#clr.AddReference('Kingdee.BOS.KDSReportEntity')
#clr.AddReference('Kingdee.BOS.App.KDSService')
clr.AddReference('Newtonsoft.Json')
#导入cloud基础库中的常用实体对象(分命名空间导入,不会递归导入)
from Kingdee.BOS import *
from Kingdee.BOS.Core import *
from Kingdee.BOS.Core.Bill import *
from Kingdee.BOS.Core.DynamicForm.PlugIn import *
from Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel import *
from System import *
from System.Data import *
from Kingdee.BOS.App.Data import *
from System.Collections.Generic import List
from Kingdee.BOS.ServiceHelper import *
from Kingdee.BOS.JSON import *
from Newtonsoft.Json.Linq import *

global orgId,year,month,orgName;
#子页面关闭回调处理方法
def ChildFromClosed(obj):
    #this.View.ShowMessage("欢迎回来");
    if (obj.ReturnData == None):
        return;
    global orgId,year,month,orgName;
    dictionary=obj.ReturnData;#读取子页面返回的数据,这里返回的也是字典形式
    orgId=dictionary["orgId"];#从字典中取出具体字段
    year=str(dictionary["year"]);
    month=str(dictionary["month"]);
    orgName=dictionary["orgName"];
    #this.View.ShowMessage(str(dictionary["year"]));

#弹出动态表单子页面的方法
def ShowFilterForm():
    global orgId,year,month;
    dic={};#以字典的形式构建传递多个参数
    dic["orgId"]=orgId;
    dic["year"]=year;
    dic["month"]=month;
    dynamicFormShowParameter = DynamicFormShowParameter();
    guid = str(Guid.NewGuid());
    dynamicFormShowParameter.PageId=guid;
    dynamicFormShowParameter.FormId="ora_MDLRZBGL";#动态表单子页面FormID
    dynamicFormShowParameter.CustomComplexParams.Add("DIC", dic);#将构建好的参数传入子页面,参数标识是"DIC"
    this.View.ShowForm(dynamicFormShowParameter, Action[FormResult](ChildFromClosed));#弹出动态表单

def OnInitialize(e):
    global orgId,year,month;
    orgId=this.Context.CurrentOrganizationInfo.ID;
    year=str(DateTime.Now.Year);
    month=str(DateTime.Now.Month);
def BarItemClick(e):
    key=e.BarItemKey;
    if(str(key)=="filterBtn"):
        ShowFilterForm();#弹出子页面


#========代码结束==================================================

网页复制代码会有格式问题,如需复制代码,请下载附件!

发布于 金蝶云星空BOS开发交流圈 社群

赞 29