二开案例.过滤插件.列表过滤窗体上查询基础资料时设置过滤条件
【应用场景】列表过滤窗体上查询基础资料时设置过滤条件,简单的过滤条件可以通过BOSIDE完成设置(https://vip.kingdee.com/article/104902355959012352),更复杂的场景需使用插件的方式设置。
【案例演示】采购订单列表过滤界面,给供应商和采购部门分别设置过滤条件。
【实现步骤】
<1>编写列表过滤插件,代码如下。
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.ListFilter;
using Kingdee.BOS.Util;
using System.ComponentModel;
namespace Jac.XkDemo.BOS.Business.PlugIn
{
/// <summary>
/// 【过滤插件】列表过滤窗体上查询基础资料时设置过滤条件
/// </summary>
[Description("【过滤插件】列表过滤窗体上查询基础资料时设置过滤条件"), HotUpdate]
public class SetBaseDataFilterBeforeFilterGridF7SelectListFilterPlugIn : AbstractListFilterPlugIn
{
public override void BeforeFilterGridF7Select(BeforeFilterGridF7SelectEventArgs e)
{
base.BeforeFilterGridF7Select(e);
// 设置采购订单列表过滤窗体上的部分基础资料字段的过滤条件
if (this.View.ParentFormView != null && this.View.ParentFormView.BillBusinessInfo.GetForm().Id.EqualsIgnoreCase("PUR_PurchaseOrder"))
{
// 给供应商查询附加过滤条件
if (e.FieldKey.StartsWith("FSupplierId"))
{
e.ListFilterParameter.Filter = e.ListFilterParameter.Filter.JoinFilterString(" FNumber like '%SCM%'");
return;
}
// 给采购部门查询附加过滤条件
if (e.FieldKey.StartsWith("FPurchaseDeptId"))
{
e.ListFilterParameter.Filter = e.ListFilterParameter.Filter.JoinFilterString(" FName like N'%车间%'");
return;
}
}
}
}
}
<2>拷贝插件组件到应用站点的WebSite\Bin目录下,重启IIS。
<3>BOSIDE扩展列表过滤(带组织)[BOS_OrgIsolationFilter],注册表单插件,保存元数据,开发完毕。
现在可以登录业务站点,打开采购订单编辑界面,检验一下插件效果啦。
供应商查询效果:
供应商查询SQL:
SELECT TOP 5
t0.FNUMBER AS FNumber ,
t0_L.FNAME AS FName ,
t0.FSUPPLIERID AS FSupplierId
FROM T_BD_SUPPLIER t0
LEFT JOIN T_BD_SUPPLIER_L t0_L ON ( t0.FSUPPLIERID = t0_L.FSUPPLIERID
AND t0_L.FLOCALEID = 2052
)
WHERE t0.FSUPPLIERID = t0.FMASTERID
AND EXISTS ( SELECT 1
FROM ( SELECT t0.FMASTERID
FROM T_BD_SUPPLIER t0
LEFT JOIN T_BD_SUPPLIER_L t0_L ON ( t0.FSUPPLIERID = t0_L.FSUPPLIERID
AND t0_L.FLOCALEID = 2052
)
WHERE ( (t0.FNUMBER LIKE '%SCM%') )
AND t0.FUSEORGID IN ( 1, 100001,
100002, 100003,
100004, 100005,
100006, 100007,
135255, 135713,
135879, 136122,
136492, 144050,
151026, 151043,
174323, 304707 )
) t0sfq
WHERE t0.FMASTERID = t0sfq.FMASTERID )
ORDER BY t0.FNUMBER;
采购部门查询效果:
采购部门查询SQL:
SELECT TOP 5
t0.FNUMBER AS FNumber ,
t0_L.FNAME AS FName ,
t0.FDEPTID AS FDEPTID
FROM T_BD_DEPARTMENT t0
LEFT JOIN T_BD_DEPARTMENT_L t0_L ON ( t0.FDEPTID = t0_L.FDEPTID
AND t0_L.FLOCALEID = 2052
)
WHERE t0.FDEPTID = t0.FMASTERID
AND EXISTS ( SELECT 1
FROM ( SELECT t0.FMASTERID
FROM T_BD_DEPARTMENT t0
LEFT JOIN T_BD_DEPARTMENT_L t0_L ON ( t0.FDEPTID = t0_L.FDEPTID
AND t0_L.FLOCALEID = 2052
)
WHERE ( (t0_L.FNAME LIKE N'%车间%') )
AND t0.FUSEORGID IN ( 1, 100001,
100002, 100003,
100004, 100005,
100006, 100007,
135255, 135713,
135879, 136122,
136492, 144050,
151026, 151043,
174323, 304707 )
) t0sfq
WHERE t0.FMASTERID = t0sfq.FMASTERID )
ORDER BY t0.FNUMBER;
----------------------------------------------------------------------------------------------
【金蝶云星空BOS二次开发案例演示】https://vip.kingdee.com/article/94751030918525696
二开案例.过滤插件.列表过滤窗体上查询基础资料时设置过滤条件
本文2024-09-23 04:21:15发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-164760.html