二开案例.python.python实现输入框f7事件(弹框列表双击返回)原创
94人赞赏了该文章
378次浏览
未经作者许可,禁止转载编辑于2024年04月19日 17:20:33
拉取一个文本字段
给文本字段勾选上显示编辑按钮
新建一个普通动态表单
新建好的如下图:单据体、单据体字段(记得对应的标识)
动态表单的ID
基本工作做完后上代码:
# 刚刚新建的动态表单-表单插件代码: #引入clr运行库 import clr # 添加对cloud插件开发的常用组件的引用 clr.AddReference('System') clr.AddReference('System.Core') clr.AddReference('System.Data') clr.AddReference("System.Web.Extensions") clr.AddReference('Kingdee.BOS') clr.AddReference('Kingdee.BOS.DataEntity') clr.AddReference('Kingdee.BOS.Core') clr.AddReference('Kingdee.BOS.App') clr.AddReference('Kingdee.BOS.App.Core') clr.AddReference('Kingdee.BOS.ServiceHelper') clr.AddReference('Kingdee.BOS.ServiceFacade.Common') clr.AddReference('Newtonsoft.Json') from System.Threading.Tasks import * from System.ComponentModel import * from Kingdee.BOS import * from Kingdee.BOS.Core import * from Kingdee.BOS.Core.DependencyRules import * from Kingdee.BOS.Core.Bill import * from Kingdee.BOS.Core.DynamicForm.PlugIn import * from Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel import * from Kingdee.BOS.Core.DynamicForm.PlugIn.Args import * from Kingdee.BOS.Core.Metadata.FormElement import * from System import * from System.Data import * from System.Threading import * from System.Text import * from System.Collections.Generic import * from System.Linq import * from System.IO import * from System.Net import * from System.Security.Cryptography import * from System.Web.Script.Serialization import * from Kingdee.BOS.App.Data import * from Kingdee.BOS.ServiceHelper import * from Kingdee.BOS.Core.DynamicForm import * from Kingdee.BOS.Core.Metadata.EntityElement import * from Kingdee.BOS.Core.Metadata.FieldElement import * from Kingdee.BOS.Orm.DataEntity import * from Kingdee.BOS.ServiceFacade import * from Newtonsoft.Json import * from Newtonsoft.Json.Linq import * j = JsonSerializerProxy(Encoding.UTF8, False) # 动态表单加载绑定事件 def OnLoad(e): entity = this.View.BillBusinessInfo.GetEntity("F_PYIV_Entity") rows = this.Model.GetEntityDataObject(entity) # 可以来源于sql,或者第三方webapi接口(sql自己实现) strSql = ''' select * from xxx '''.format(this.Context.UserId) lists = DBServiceHelper.ExecuteDynamicObject(this.Context, strSql) #拿到的sql绑定到动态表单拉去的单据体中。 for index, l in enumerate(lists): row = DynamicObject(entity.DynamicObjectType) # 设置序号,复制使用即可 entity.SeqDynamicProperty.SetValue(row, 1 + index) #row["动态表单中拉取的字段的标识,自己填写"] = I["sql 查询出来的字段名字,自己填写"] #row["F_PYIV_Text1"] = l["FDESCRIPTION"] #row["F_PYIV_Text2"] = l["FSCHEMEID"] #添加到单据体中 rows.Add(row) # 双击单据体内容,关闭动态表单,并把选择的值返回到对应父窗体的字段中 def EntityRowDoubleClick(e): # 单据体标识(用于判断是哪个单据体) if e.Key == "F_PYIV_ENTITY": # 组装需要返回到父窗体的数据 val = { "F_PYIV_Text2": this.View.Model.GetValue("F_PYIV_Text2", e.Row), "F_PYIV_Text1": this.View.Model.GetValue("F_PYIV_Text1", e.Row) } #把要返回的数据写入到父窗体 this.View.ReturnToParentWindow(val) # 关闭动态表单 this.View.Close()
# 刚刚拉去的文本字段-方案的BeforeF7Select事件。注册在对应表单的表单插件里面 # 引入clr运行库 import clr # 添加对cloud插件开发的常用组件的引用 clr.AddReference('System') clr.AddReference('System.Core') clr.AddReference('System.Data') clr.AddReference("System.Web.Extensions") clr.AddReference('Kingdee.BOS') clr.AddReference('Kingdee.BOS.DataEntity') clr.AddReference('Kingdee.BOS.Core') clr.AddReference('Kingdee.BOS.App') clr.AddReference('Kingdee.BOS.App.Core') clr.AddReference('Kingdee.BOS.ServiceHelper') clr.AddReference('Kingdee.BOS.ServiceFacade.Common') clr.AddReference('Newtonsoft.Json') from System.Threading.Tasks import * from System.ComponentModel import * from Kingdee.BOS import * from Kingdee.BOS.Core import * from Kingdee.BOS.Core.DependencyRules import * from Kingdee.BOS.Core.Bill import * from Kingdee.BOS.Core.DynamicForm.PlugIn import * from Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel import * from Kingdee.BOS.Core.DynamicForm.PlugIn.Args import * from Kingdee.BOS.Core.Metadata.FormElement import * from System import * from System.Data import * from System.Threading import * from System.Text import * from System.Collections.Generic import * from System.Linq import * from System.IO import * from System.Net import * from System.Security.Cryptography import * from System.Web.Script.Serialization import * from Kingdee.BOS.App.Data import * from Kingdee.BOS.ServiceHelper import * from Kingdee.BOS.Core.DynamicForm import * from Kingdee.BOS.Core.Metadata.EntityElement import * from Kingdee.BOS.Core.Metadata.FieldElement import * from Kingdee.BOS.Orm.DataEntity import * from Kingdee.BOS.ServiceFacade import * from Newtonsoft.Json import * from Newtonsoft.Json.Linq import * j = JsonSerializerProxy(Encoding.UTF8, False) def resultInfo(results): #处理动态表单所返回的值 data = results.ReturnData if data is not None: #赋值到父窗口对应的字段上面 this.View.Model.SetValue("F_PYIV_Text",data["F_PYIV_Text1"]) this.View.Model.SetValue("F_PYIV_Text1", data["F_PYIV_Text2"]) this.View.UpdateView("F_PYIV_Text",0) this.View.UpdateView("F_PYIV_Text1", 0) def BeforeF7Select(e): key = e.FieldKey.ToUpper() if key =="F_PYIV_TEXT": #打开过滤动态表单 dy = DynamicFormShowParameter() dy.Resizable = False dy.OpenStyle.ShowType = ShowType.Modal # 动态表单的唯一标识 dy.FormId = "k1a8aa854e3594cc884dcfe12bb72b0b0" # 打开动态表单,第二个参数是一个方法,用于处理动态表单关闭后返回的值 this.View.ShowForm(dy,resultInfo)
要多看代码,sql语句自己实现。其余地方改一下赋值取值的字段即可。
效果如下:
如有不懂请留言。制作不易,谢谢大家收藏点赞。
推荐阅读