新增:

1.客户价格管理
2.销售订单表单插件取值
This commit is contained in:
liangjunyu
2025-11-18 14:50:08 +08:00
parent 61b915d793
commit 4dd2091dee
74 changed files with 694 additions and 2 deletions

View File

@@ -0,0 +1,104 @@
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.Metadata;
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 Gatedge.K3.Pilot.PlugIn.BOSPlugIn.BD_CustPrice
{
[HotUpdate, Description("客户价格管理_表单插件")]
public class Bill : AbstractBillPlugIn
{
public override void OnLoad(EventArgs e)
{
base.OnLoad(e);
}
public override void AfterBindData(EventArgs e)
{
base.AfterBindData(e);
var limitCustomer = this.View.Model.GetValue("FLimitCustomer").Long2Int();
SetBillContral(limitCustomer == 1);
}
public override void DataChanged(DataChangedEventArgs e)
{
base.DataChanged(e);
if (e.Field.Key.EqualsIgnoreCase("FLimitCustomer"))
{
var val = e.NewValue.Long2Int();
SetBillContral(val == 1);
}
if (e.Field.Key.EqualsIgnoreCase("FCustID"))
{
var custId_Id = e.NewValue.Long2Int();
if (custId_Id > 0)
{
var custId = this.View.Model.GetValue("FCustID", e.Row) as DynamicObject;
//KHXYFL013
var creditClassificationId = custId["F_CreditClassification_Id"];
if (!creditClassificationId.IsNullOrEmptyOrWhiteSpace())
{
var creditClassification = custId["F_CreditClassification"] as DynamicObject;
var number = creditClassification["Number"].ToString();
this.View.Model.SetValue("FIsBigCust", number.EqualsIgnoreCase("KHXYFL013"), e.Row);
}
}
else
{
this.View.Model.SetValue("FIsBigCust", false, e.Row);
}
}
if (e.Field.Key.EqualsIgnoreCase("FMaterialId"))
{
var materialId_Id = e.NewValue.Long2Int();
if (materialId_Id > 0)
{
var materialId = this.View.Model.GetValue("FMaterialId", e.Row) as DynamicObject;
var cbj = materialId["F_CBJ"];
var jsj = materialId["F_JSJ"];
this.View.Model.SetValue("F_CostPrice", cbj, e.Row);
this.View.Model.SetValue("F_SettlePrice", jsj, e.Row);
}
else
{
this.View.Model.SetValue("F_CostPrice", 0, e.Row);
this.View.Model.SetValue("F_SettlePrice", 0, e.Row);
}
}
}
private void SetBillContral(bool visible)
{
visible = !visible;
this.View.GetControl("F_MaterialModelGroup").Visible = !visible;
this.View.GetControl("F_BigCustSettlePrice").Visible = !visible;
this.View.GetControl("FMaterialId").Visible = visible;
this.View.GetControl("FMaterialName").Visible = visible;
this.View.GetControl("FMaterialModel").Visible = visible;
this.View.GetControl("F_AgreePrice").Visible = visible;
this.View.GetControl("FTab_P1").Visible = visible;
//字段必录项 mustinput 必须为小写
this.View.GetControl("F_MaterialModelGroup").SetCustomPropertyValue("mustinput", !visible);
this.View.GetControl("F_BigCustSettlePrice").SetCustomPropertyValue("mustinput", !visible);
this.View.GetControl("FMaterialId").SetCustomPropertyValue("mustinput", visible);
this.View.GetControl("F_AgreePrice").SetCustomPropertyValue("mustinput", visible);
this.View.GetControl("FCustID").SetCustomPropertyValue("mustinput", visible);
}
}
}

View File

@@ -0,0 +1,46 @@
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Kingdee.BOS.Core.Metadata.FormElement;
namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.BD_CustPrice.ServicePlugIn
{
[HotUpdate, Description("客户价格管理_保存操作")]
public class Save : AbstractOperationServicePlugIn
{
public override void OnPreparePropertys(PreparePropertysEventArgs e)
{
base.OnPreparePropertys(e);
//添加需要加载的字段:
e.FieldKeys.Add("FLimitCustomer");
e.FieldKeys.Add("F_MaterialModelGroup");
e.FieldKeys.Add("FMaterialId");
e.FieldKeys.Add("FSeq");
//大客户结算底价
e.FieldKeys.Add("F_BigCustSettlePrice");
//协议客户协议价
e.FieldKeys.Add("F_AgreePrice");
e.FieldKeys.Add("FCustID");
}
public override void OnAddValidators(AddValidatorsEventArgs e)
{
base.OnAddValidators(e);
//添加检查校验器:
if (this.FormOperation.OperationId == FormOperation.Operation_Save)
{
var validator = new SaveValidator();//新增的校验器
validator.EntityKey = "FBillHead";
e.Validators.Add(validator);//添加校验器
}
}
}
}

View File

@@ -0,0 +1,159 @@
using Kingdee.BOS;
using Kingdee.BOS.Core;
using Kingdee.BOS.Core.Validation;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
using Kingdee.K3.BD.NewCode.Core.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Gatedge.K3.Pilot.PlugIn.BOSPlugIn.BD_CustPrice.ServicePlugIn
{
public class SaveValidator : AbstractValidator
{
public override void Validate(ExtendedDataEntity[] dataEntities, ValidateContext validateContext, Context ctx)
{
foreach (var data in dataEntities)
{
var limitCustomer = data.DataEntity["LimitCustomer"].Long2Int();
var entrys = data.DataEntity["BD_CustPriceEntry"] as DynamicObjectCollection;
foreach (var entry in entrys)
{
var idx = entry["Seq"].Long2Int() - 1;
//大客户
if (limitCustomer == 1)
{
if (entry["MaterialModelGroup"].IsNullOrEmptyOrWhiteSpace())
{
var title = "物料规格类型必填!";
var msg = $"限定客户类型为大客户时,{title}";
var displayToFieldKey = "F_MaterialModelGroup";
validateContext.AddError(data
, new ValidationErrorInfo(
displayToFieldKey// 出错的字段Key可以空
, data.DataEntity["Id"].ToString() // 数据包内码,必填,后续操作会据此内码避开此数据包
, data.DataEntityIndex // 出错的数据包在全部数据包中的顺序
, idx// 出错的数据行在全部数据行中的顺序如果校验基于单据头此为0
, "REF"// 错误编码,可以任意设定一个字符,主要用于追查错误来源
, msg // 错误的详细提示信息
, title// 错误的简明提示信息
, ErrorLevel.Error // 错误级别:警告、错误...
)
);
}
if (entry["BigCustSettlePrice"].Convert<decimal>() == 0M)
{
var title = "大客户底价必填!";
var msg = $"限定客户类型为大客户时,{title}";
var displayToFieldKey = "F_BigCustSettlePrice";
validateContext.AddError(data
, new ValidationErrorInfo(
displayToFieldKey// 出错的字段Key可以空
, data.DataEntity["Id"].ToString() // 数据包内码,必填,后续操作会据此内码避开此数据包
, data.DataEntityIndex // 出错的数据包在全部数据包中的顺序
, idx// 出错的数据行在全部数据行中的顺序如果校验基于单据头此为0
, "REF"// 错误编码,可以任意设定一个字符,主要用于追查错误来源
, msg // 错误的详细提示信息
, title// 错误的简明提示信息
, ErrorLevel.Error // 错误级别:警告、错误...
)
);
}
}
//协议客户
if (limitCustomer == 2)
{
if (entry["MaterialId_Id"].Long2Int() == 0)
{
var title = "物料编码必填!";
var msg = $"限定客户类型为协议客户时,{title}";
var displayToFieldKey = "FMaterialId";
validateContext.AddError(data
, new ValidationErrorInfo(
displayToFieldKey// 出错的字段Key可以空
, data.DataEntity["Id"].ToString() // 数据包内码,必填,后续操作会据此内码避开此数据包
, data.DataEntityIndex // 出错的数据包在全部数据包中的顺序
, idx // 出错的数据行在全部数据行中的顺序如果校验基于单据头此为0
, "REF"// 错误编码,可以任意设定一个字符,主要用于追查错误来源
, msg // 错误的详细提示信息
, title// 错误的简明提示信息
, ErrorLevel.Error // 错误级别:警告、错误...
)
);
}
if (entry["AgreePrice"].Convert<decimal>() == 0M)
{
var title = "协议价必填!";
var msg = $"限定客户类型为协议客户时,{title}";
var displayToFieldKey = "F_AgreePrice";
validateContext.AddError(data
, new ValidationErrorInfo(
displayToFieldKey// 出错的字段Key可以空
, data.DataEntity["Id"].ToString() // 数据包内码,必填,后续操作会据此内码避开此数据包
, data.DataEntityIndex // 出错的数据包在全部数据包中的顺序
, idx // 出错的数据行在全部数据行中的顺序如果校验基于单据头此为0
, "REF"// 错误编码,可以任意设定一个字符,主要用于追查错误来源
, msg // 错误的详细提示信息
, title// 错误的简明提示信息
, ErrorLevel.Error // 错误级别:警告、错误...
)
);
}
}
if (limitCustomer == 0)
{
var title = "限定客户必填!";
var msg = $"限定客户不能为空";
var displayToFieldKey = "FMaterialId";
validateContext.AddError(data
, new ValidationErrorInfo(
displayToFieldKey// 出错的字段Key可以空
, data.DataEntity["Id"].ToString() // 数据包内码,必填,后续操作会据此内码避开此数据包
, data.DataEntityIndex // 出错的数据包在全部数据包中的顺序
, 0 // 出错的数据行在全部数据行中的顺序如果校验基于单据头此为0
, "REF"// 错误编码,可以任意设定一个字符,主要用于追查错误来源
, msg // 错误的详细提示信息
, title// 错误的简明提示信息
, ErrorLevel.Error // 错误级别:警告、错误...
)
);
}
}
var entrys2 = data.DataEntity["BD_CustPriceCustEntry"] as DynamicObjectCollection;
if (limitCustomer != 1 && (entrys2 == null || entrys2.Count == 0))
{
var title = "客户必填!";
var msg = $"{title}";
var displayToFieldKey = "FCustID";
validateContext.AddError(data
, new ValidationErrorInfo(
displayToFieldKey// 出错的字段Key可以空
, data.DataEntity["Id"].ToString() // 数据包内码,必填,后续操作会据此内码避开此数据包
, data.DataEntityIndex // 出错的数据包在全部数据包中的顺序
, 0 // 出错的数据行在全部数据行中的顺序如果校验基于单据头此为0
, "REF"// 错误编码,可以任意设定一个字符,主要用于追查错误来源
, msg // 错误的详细提示信息
, title// 错误的简明提示信息
, ErrorLevel.Error // 错误级别:警告、错误...
)
);
}
}
}
}
}