二开:工程变更单保存时校验,物料启用辅助属性,辅助属性必录
1、由于在BOS设计器中配置校验不生效,目前该校验只能通过二开插件实现
2、具体步骤如下:
2.1、在保存操作上二开一个插件:获取子项物料的辅助属性,根据子项物料的辅助属性是否启用 + 工程变更单明细行上的辅助属性是否有值 + 行标识为新增或者修改后,判断物料启用辅助属性,辅助属性必录。如图所示:
2.2、保存插件具体二开实现:
(1) 二开插件继承:AbstractMfgOperationPlugIn,重写OnAddValidators:增加一个校验插件IsAuxPropMustInputValidator
(2)实现校验器IsAuxPropMustInputValidator:继承AbstractMfgServiceValidator,重写Validate
(3)组件引用:
3、具体的代码可见(供参考):
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.K3.MFG.App.ServicePlugIn;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Kingdee.K3.Core.MFG.EntityHelper;
using Kingdee.BOS;
using Kingdee.K3.MFG.App;
using Kingdee.BOS.Util;
using System.Data;
using Kingdee.BOS.App.Data;
using Kingdee.K3.MFG.App.ServiceValidator;
using Kingdee.BOS.Core;
namespace Kingdee.K3.MFG.ENG.EK.App.ServicePlugIn.ECN.Validator
{
/// <summary>
/// 校验:物料启用辅助属性,则辅助属性必录
/// </summary>
[Description("校验物料启用辅助属性,则辅助属性必录")]
public class IsAuxPropMustInputValidator : AbstractMfgServiceValidator
{
public override void Validate(ExtendedDataEntity[] dataEntities, BOS.Core.Validation.ValidateContext validateContext, Context ctx)
{
if (dataEntities.IsEmpty()) return;
base.Validate(dataEntities, validateContext, ctx);
foreach (ExtendedDataEntity item in dataEntities)
{
DynamicObject billData = item.DataEntity;
DynamicObjectCollection entryDatas = billData.GetDynamicValue<DynamicObjectCollection>("TreeEntity");
string msg = string.Empty;
bool isValidate = false;
StringBuilder sbErrMsg = new StringBuilder();
foreach (DynamicObject entryData in entryDatas)
{
//获取子项物料数据包
DynamicObject materilIdChild = entryData.GetDynamicValue<DynamicObject>("MATERIALIDCHILD");
if (materilIdChild.IsNullOrEmpty()) continue;
DynamicObjectCollection materialAuxPty = materilIdChild.GetDynamicValue<DynamicObjectCollection>("MaterialAuxPty");
if (materialAuxPty.IsEmpty()) continue;
long auxPropId = entryData.GetDynamicValue<long>("AuxPropId_Id");
string changeLabel = entryData.GetDynamicValue<string>("ChangeLabel");
if ((changeLabel =="1" || changeLabel =="2") && materialAuxPty.Any(f => f.GetDynamicValue<bool>("IsEnable1")) && auxPropId == 0)
{
int seq = entryData.GetDynamicValue<int>("Seq");
msg += seq + ",";
isValidate = true;
}
}
sbErrMsg.Append(string.Format("明细行{0}的子项物料启用了辅助属性,但辅助属性未录入值,无法进行保存操作", msg.TrimEnd(',')));
if (isValidate)
{
this.vContext.AddError(
billData,
item.DataEntityIndex,
sbErrMsg.ToString(),
this.OperationName);
}
}
}
}
}
二开:工程变更单保存时校验,物料启用辅助属性,辅助属性必录
本文2024-09-23 03:11:34发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-157296.html
- 鼎捷API-TIPTOP-3.销售信息API-取消确认销售订单数据-tt.oapi.sales.order.data.disapprove-soap_oapi00186CN02_s.pdf
- 鼎捷API-TIPTOP-3.销售信息API-创建出货单数据-tt.oapi.shipping.data.create-soap_oapi00144CN02_s.pdf
- 鼎捷API-TIPTOP-1.企业基础API-生效工作站工作中心数据-tt.oapi.workstation.data.available-soap_oapi00055CN02_s.pdf
- 鼎捷API-TIPTOP-1.企业基础API-更新税别数据-tt.oapi.tax.type.data.update-soap_oapi00310CN02_s.pdf
- 鼎捷API-TIPTOP-6.帐款信息API-创建应收帐款数据-tt.oapi.accounts.receivable.data.create-soap_oapi00290CN02_s.pdf
- 鼎捷API-TIPTOP-3.销售信息API-读取订单变更单数据-tt.oapi.sales.order.change.details.data.read.get-soap_oapi00189CN02_s.pdf
- 鼎捷API-TIPTOP-1.企业基础API-生效币别数据-tt.oapi.currency.data.available-soap_oapi00038CN02_s.pdf
- 鼎捷API-TIPTOP-5.生产信息API-更新工单完工入库单数据-tt.oapi.wo.stockin.data.update-soap_oapi00261CN02_s.pdf
- 鼎捷API-TIPTOP-2.采购信息API-读取采购单数据-tt.oapi.purchase.order.details.data.read.get-soap_oapi00156CN02_s.pdf
- 鼎捷API-TIPTOP-1.企业基础API-查询机器列表数据-tt.oapi.machine.list.data.query.get-soap_oapi00044CN02_s.pdf