二开案例.列表插件.读写单据类型参数
【应用场景】使用列表插件读写单据类型参数。
【案例演示】采购订单,列表界面,在列表插件中读写单据类型参数。
【实现步骤】
<1>编写列表插件,实现读写单据类型参数的功能,代码如下。
using Kingdee.BOS;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.List.PlugIn;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.ServiceHelper;
using Kingdee.BOS.Util;
using System.ComponentModel;
namespace Jac.XkDemo.BOS.Business.PlugIn
{
/// <summary>
/// 【列表插件】读写单据类型参数
/// </summary>
[Description("【列表插件】读写单据类型参数"), HotUpdate]
public class ReadAndWriteBillTypeParameterListPlugIn : AbstractListPlugIn
{
/// <summary>
/// 采购订单的【标准采购订单】的单据类型内码
/// SQL:SELECT * FROM T_BAS_BILLTYPE WHERE FNUMBER='CGDD01_SYS'
/// </summary>
private string billTypeId = "83d822ca3e374b4ab01e5dd46a0062bd";
/// <summary>
/// 列表主菜单点击事件
/// </summary>
/// <param name="e"></param>
public override void BarItemClick(BarItemClickEventArgs e)
{
base.BarItemClick(e);
if (e.BarItemKey.EqualsIgnoreCase("tbReadBillTypeParameter"))
{
var auxMustInput = ReadBillTypeParameter(this.Context, this.View.BillBusinessInfo, billTypeId, "IsLink");
this.View.ShowMessage("单据类型参数【关联生成】:" + auxMustInput);
return;
}
if (e.BarItemKey.EqualsIgnoreCase("tbWriteBillTypeParameter"))
{
var isOk = WriteBillTypeParameter(this.Context, this.View.BillBusinessInfo, billTypeId, "IsLink", true);
this.View.ShowMessage(isOk ? "单据类型参数保存成功" : "单据类型参数保存失败");
return;
}
}
/// <summary>
/// 读取单据类型参数
/// </summary>
/// <param name="ctx">上下文</param>
/// <param name="businessInfo">业务对象</param>
/// <param name="billTypeId">单据类型内码</param>
/// <param name="parameterName">单据类型参数的实体属性名</param>
/// <returns></returns>
public static object ReadBillTypeParameter(Context ctx, BusinessInfo businessInfo, string billTypeId, string parameterName)
{
// 获取单据类型参数的业务对象标识
var billTypeParaFormId = businessInfo.GetForm().BillTypePara;
if (billTypeParaFormId == null || billTypeParaFormId.Trim().Length == 0)
{
billTypeParaFormId = "BOS_BILLTYPEPARAMODEL";
}
var parameterFormMetadata = FormMetaDataCache.GetCachedFormMetaData(ctx, billTypeParaFormId);
// 读取单据类型参数包
var parameterData = BusinessDataServiceHelper.LoadBillTypePara(ctx, parameterFormMetadata.BusinessInfo, billTypeId);
// 从单据类型参数包中获取某一个参数
if (parameterData != null && parameterData.DynamicObjectType.Properties.ContainsKey(parameterName))
{
return parameterData[parameterName];
}
return null;
}
/// <summary>
/// 保存单据类型参数
/// </summary>
/// <param name="ctx">上下文</param>
/// <param name="businessInfo">业务对象</param>
/// <param name="billTypeId">单据类型内码</param>
/// <param name="parameterName">单据类型参数的实体属性名</param>
/// <param name="parameterValue">单据类型参数值</param>
/// <returns></returns>
public static bool WriteBillTypeParameter(Context ctx, BusinessInfo businessInfo, string billTypeId, string parameterName, object parameterValue)
{
// 获取单据类型参数的业务对象标识
var billTypeParaFormId = businessInfo.GetForm().BillTypePara;
if (billTypeParaFormId == null || billTypeParaFormId.Trim().Length == 0)
{
billTypeParaFormId = "BOS_BILLTYPEPARAMODEL";
}
var parameterFormMetadata = FormMetaDataCache.GetCachedFormMetaData(ctx, billTypeParaFormId);
// 读取单据类型参数包
var parameterData = BusinessDataServiceHelper.LoadBillTypePara(ctx, parameterFormMetadata.BusinessInfo, billTypeId);
// 从单据类型参数包中获取某一个参数
if (parameterData != null && parameterData.DynamicObjectType.Properties.Contains(parameterName))
{
parameterData[parameterName] = parameterValue;
return BusinessDataServiceHelper.SaveBillTypePara(ctx, parameterFormMetadata.BusinessInfo, billTypeId, parameterData);
}
return false;
}
}
}
/*
-- 查询单据类型参数
SELECT a.FBILLTYPEID AS 单据类型内码,a.FNUMBER AS 单据类型编码,b.FNAME AS 单据类型名称,FPARASETTINGXML AS 单据类型参数,a.*
FROM T_BAS_BILLTYPE a LEFT JOIN T_BAS_BILLTYPE_L b ON a.FBILLTYPEID=b.FBILLTYPEID
*/
<2>拷贝插件组件到应用站点的WebSite\Bin目录下,重启IIS。
<3>BOSIDE扩展采购订单,列表菜单添加两个菜单,注册列表插件,保存元数据,开发完毕。
现在可以登录业务站点,打开采购订单列表,检验一下插件效果啦。
插件读取单据类型参数:
插件修改单据类型参数:
查看单据类型参数:
【知识点】
<1>获取单据类型参数的业务对象标识。
<2>单据类型参数存储在哪个表?
SELECT a.FBILLTYPEID AS 单据类型内码,a.FNUMBER AS 单据类型编码,b.FNAME AS 单据类型名称,FPARASETTINGXML AS 单据类型参数,a.*
FROM T_BAS_BILLTYPE a LEFT JOIN T_BAS_BILLTYPE_L b ON a.FBILLTYPEID=b.FBILLTYPEID
--------------------------------------------------------------------------------------------
【金蝶云星空BOS二次开发案例演示】https://vip.kingdee.com/article/94751030918525696
二开案例.列表插件.读写单据类型参数
本文2024-09-23 04:21:22发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-164773.html