场景描述:选择销售订单号,过滤出销售订单所对应的物料编码
案例所用代码
继承:AbstractCommonFilterPlugIn
重写BeforeF7Select方法
代码参考:
using Kingdee.BOS.App.Data;
using Kingdee.BOS.Core.CommonFilter.PlugIn;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.List;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HL.K3Cloud.PUS.ProductionWarehousingReport.Plugin
{
[Description("二开--BOM完整性检查过滤")]
[Kingdee.BOS.Util.HotUpdate]
public class BOMSearchFilter: AbstractCommonFilterPlugIn
{
public override void BeforeF7Select(BeforeF7SelectEventArgs e)
{
base.BeforeF7Select(e);
switch (e.FieldKey)
{
case "FOrderNumber": //字段的标识
ListSelBillShowParameter para = new ListSelBillShowParameter();
para.FormId = "SAL_SaleOrder";
para.ParentPageId = this.View.PageId;
para.ListFilterParameter.Filter = "FDOCUMENTSTATUS= '"+"C"+"'";//过滤条件
this.View.ShowForm(para, new Action
{
if (result != null && result.ReturnData != null && (result.ReturnData as ListSelectedRowCollection).Count > 0)
{
ListSelectedRowCollection rows = (ListSelectedRowCollection)result.ReturnData;
string BillNo = "";
foreach (ListSelectedRow row in rows)
{
BillNo = BillNo + row.BillNo + ";";
}
BillNo = BillNo.Remove(BillNo.Length - 1, 1);
this.View.Model.SetValue("FOrderNumber", BillNo);
}
}));
break;
case "FMaterialID":// 表示物料编码所对应的标识
{
string FOrderNumber = (string)this.Model.GetValue("FOrderNumber");// 获销售订单号
if (!ObjectUtils.IsNullOrEmptyOrWhiteSpace(FOrderNumber)) //如果销售订单号不为空
{
FOrderNumber = splitString(FOrderNumber);
string sql = "select distinct " +
" SALOrderEntry.FMATERIALID," +
" SALOrder.FBILLNO OrderNum," +
" SALOrder.FSALEORGID USEORGID," +
" BOM.FNUMBER FNUMBER, BOM.FDOCUMENTSTATUS " +
" from T_SAL_ORDER SALOrder " +
" left join T_SAL_ORDERENTRY SALOrderEntry " +
" on SALOrder.FID = SALOrderEntry.FID " +
" left join T_ENG_BOM BOM " +
" on(BOM.FUSEORGID = SALOrder.FSALEORGID and BOM.FMATERIALID = SALOrderEntry.FMATERIALID)" +
" where SALOrder.FDOCUMENTSTATUS = 'C' and SALOrder.FBILLNO in(" + FOrderNumber + ")";
var count = DBUtils.ExecuteDynamicObject(this.Context, sql.ToString());
List
foreach (DynamicObject obj in count)
{
if (!"".Equals(obj["FMATERIALID"]))
{
long FMATERIALID = Convert.ToInt32(obj["FMATERIALID"]);
orgList.Add(FMATERIALID);
}
}
string productLineFilter = string.Format(" FMaterialID in ({0}) ", string.Join(",", orgList.ToArray()));// 过滤字符串
e.ListFilterParameter.Filter = productLineFilter;
}
}
break;
}
}
//分割字符串
private string splitString(string fOrderNumber)
{
string splitAfter = "";
string[] arr = fOrderNumber.Split(';');
foreach (string str in arr)
{
splitAfter = splitAfter + "'" + str + "'" + ",";
}
splitAfter = splitAfter.Remove(splitAfter.Length - 1, 1);
return splitAfter;
}
}
}
------------------------------------------------------------------------支持多选----------[list=1]
[*]public override void ButtonClick(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.ButtonClickEventArgs e)
[*] {
[*] base.ButtonClick(e);
[*] if (e.Key.Equals("Fbtn"))
[*] {
[*] ListShowParameter listPara = new ListShowParameter();
[*] listPara.FormId = "BD_Metarial";
[*] listPara.IsLookUp = true; //查找型列表
[*] listPara.MultiSelect = true; //支持多选
[*] this.View.ShowForm(listPara, new Action
[*] {
[*] //回调函数里面处理数据回填等逻辑
[*] if (result.ReturnData == null)
[*] {
[*] return;
[*] }
[*] })
[*] );
[*] }
[*] }
[/list]
第三步:挂载表单插件
推荐阅读