【二开案例】单据体单元格字段超链接点击打开单据查看
注:以发货通知单中的源单单号为例,在发货通知单查看中点击源单单号直接查看上游销售订单,不需要通过上查去查看上游销售订单
1. 修改扩展的发货通知单中的源单单号字段的可见性为查看可见,列表显示控件为链接,勾选单据应用列表显示控制:
![image.webp](/download/0100d8b0ca44b08542acbb0b9d30652cc75a.webp)
设置好后记得保存修改使其生效;
2. 将实现的插件挂载到表单插件中
![image.webp](/download/0100c14eb9f8a3e94ce6b4002ccb47a2c735.webp)
具体的插件打包和挂载方式请参考文章:[二开案例.开发环境.从零开发第一个插件](https://wenku.my7c.com/article/83500607104976896?productLineId=1&isKnowledge=2)
若使用Python插件,则直接在表单插件中注册并加插件打发复制进去即可:
![image.webp](/download/0100351fd67f642a4373a5a6bf2b53fc1854.webp)
Python插件在确定是可能会提示错误信息,可忽略不管,这是因为库的引用问题导致的,只要确保需要使用的库在代码中有import即可
3. C#代码示例:
```C#
using System;
using System.Collections.Generic;
using Kingdee.BOS.Core.Bill;
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.ServiceHelper;
using Kingdee.BOS.Util;
using Kingdee.BOS.Orm.DataEntity;
using System.ComponentModel;
namespace Alpicool.BOS.Business.Bill.PlugIn
{
[Description("单据体单元格字段超链接点击事件"), HotUpdate]
public class GridCellHyperlinkBillPlugIn:AbstractBillPlugIn
{
public override void EntryButtonCellClick(EntryButtonCellClickEventArgs e)
{
base.EntryButtonCellClick(e);
if (!e.FieldKey.EqualsIgnoreCase("FSrcBillNo"))
{
return;
}
if (e.Row < 0)
{
return;
}
String formId = "SAL_SaleOrder"; // 关联单据的FormId,可使用源单类型
FormMetadata requisitionMetaData = (FormMetadata)MetaDataServiceHelper.Load(this.Context, formId);
object billNo = this.Model.GetValue(e.FieldKey, e.Row);
object billSrcTye = this.Model.GetValue("FSrcType", e.Row);
if (!billSrcTye.ToString().EqualsIgnoreCase(formId)) // 源单类型不等于关联单据的FormId, 不打开单据
{
return;
}
DynamicObject[] objects = BusinessDataServiceHelper.Load(this.Context, requisitionMetaData.BusinessInfo, new List<SelectorItemInfo>(new[] { new SelectorItemInfo("FID") }), OQLFilter.CreateHeadEntityFilter("FBillNo='" + billNo + "'"));
if (objects == null || objects.Length == 0)
{
return;
}
String pkId = objects[0]["id"].ToString();
BillShowParameter showParameter = new BillShowParameter
{
FormId = formId,
PKey = pkId,
Status = OperationStatus.VIEW
};
this.View.ShowForm(showParameter);
}
}
}
```
4. Python代码示例:
```Python
import clr
clr.AddReference('mscorlib')
clr.AddReference('System')
clr.AddReference('System.Data')
clr.AddReference('Kingdee.BOS')
clr.AddReference('Kingdee.BOS.Core')
clr.AddReference("Kingdee.BOS.App")
clr.AddReference("Newtonsoft.Json")
from System import *
from Kingdee.BOS import *
from Kingdee.BOS.Core.Bill import *
from Kingdee.BOS.Core.Bill.PlugIn import *
from Kingdee.BOS.Core.DynamicForm.PlugIn.Args import *
from Kingdee.BOS.Core.Metadata import *
from Kingdee.BOS.ServiceHelper import *
from Kingdee.BOS.JSON import *
from Kingdee.BOS.Util import *
from Kingdee.BOS.App.Data import *
from Newtonsoft.Json import *
from System.Collections.Generic import *
def EntryButtonCellClick(e):
if e.Row < 0:
return
if not e.FieldKey.Equals("FSrcBillNo", StringComparison.OrdinalIgnoreCase) and not e.FieldKey.Equals("FOrderNo", StringComparison.OrdinalIgnoreCase):
return
formId = "SAL_SaleOrder" # FormId可以使用srcType
requisitionMetadata = MetaDataServiceHelper.Load(this.Context, formId)
billNo = this.Model.GetValue(e.FieldKey, e.Row)
srcType = this.Model.GetValue("FSrcType", e.Row)
if srcType != formId: # 判断源单类型是否为销售订单,如果不是,则直接返回,不弹窗提示
return
itemList = List[SelectorItemInfo]()
itemList.Add(SelectorItemInfo("FID"))
objs = BusinessDataServiceHelper.Load(this.Context, requisitionMetadata.BusinessInfo, itemList, OQLFilter.CreateHeadEntityFilter("FBillNo='" + billNo + "'"))
if objs is None or objs.Length == 0:
return
pkId = str(objs[0]["Id"])
showParameter = BillShowParameter()
showParameter.FormId = formId
showParameter.PKey = pkId
showParameter.Status = OperationStatus.VIEW
this.View.ShowForm(showParameter)
```
很好的文章啊。
【二开案例】单据体单元格字段超链接点击打开单据查看
注:以发货通知单中的源单单号为例,在发货通知单查看中点击源单单号直接查看上游销售订单,不需要通过上查去查看上游销售订单1. 修改扩展...
点击下载文档
本文2024-09-16 18:31:05发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-22659.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章