From eb087d77c4e432c824e70254e87041e61a66bcd7 Mon Sep 17 00:00:00 2001 From: weiyunlong Date: Fri, 16 May 2025 18:08:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=98=E6=AC=BE=E5=8D=95=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E5=B0=8F=E7=B1=BB=E8=AE=BE=E7=BD=AE=20?= =?UTF-8?q?=E6=88=90=E6=9C=AC=E4=B8=AD=E5=BF=83,=E5=88=A9=E6=B6=A6?= =?UTF-8?q?=E4=B8=AD=E5=BF=83=E6=98=AF=E5=90=A6=E5=BF=85=E5=A1=AB=20#after?= =?UTF-8?q?BindData=20=20=20#propertyChanged=20s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fi/fi/plugin/form/TextFieldDemo.java | 50 ++++++++++++++++--- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/main/java/shjh/jhzj7/fi/fi/plugin/form/TextFieldDemo.java b/main/java/shjh/jhzj7/fi/fi/plugin/form/TextFieldDemo.java index 42ebd17..9b08e5d 100644 --- a/main/java/shjh/jhzj7/fi/fi/plugin/form/TextFieldDemo.java +++ b/main/java/shjh/jhzj7/fi/fi/plugin/form/TextFieldDemo.java @@ -1,7 +1,11 @@ package shjh.jhzj7.fi.fi.plugin.form; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.entity.datamodel.events.PropertyChangedArgs; import kd.bos.form.ClientProperties; +import kd.bos.form.field.BasedataEdit; import kd.bos.form.plugin.AbstractFormPlugin; +import kd.bos.servicehelper.BusinessDataServiceHelper; import java.util.EventObject; import java.util.HashMap; @@ -16,13 +20,47 @@ public class TextFieldDemo extends AbstractFormPlugin { @Override public void afterBindData(EventObject e) { -// this.getView().setEnable(false, "settletype"); -// this.getView().setEnable(true, "settletype"); + // 获取成本中心和利润中心的控件 + BasedataEdit shjh_costcenter = this.getView().getControl("shjh_costcenter"); + BasedataEdit shjh_profitcenter = this.getView().getControl("shjh_pc"); + //根据业务小类设置 成本中心,利润中心是否必填 + DynamicObject shjhBizsmall = (DynamicObject)this.getView().getModel().getValue("shjh_bizsmall"); + if (null != shjhBizsmall) { + shjhBizsmall = BusinessDataServiceHelper.loadSingle(shjhBizsmall.getPkValue(),"shjh_bizsmalltype"); + // 获取成本中心和利润中心的必填配置 + boolean shjhCc = shjhBizsmall.getBoolean("shjh_cc"); + boolean shjhPc = shjhBizsmall.getBoolean("shjh_pc"); + // 设置成本中心必填状态 + shjh_costcenter.setMustInput(shjhCc); + // 设置利润中心必填状态 + shjh_profitcenter.setMustInput(shjhPc); + }else { + shjh_costcenter.setMustInput(false); + shjh_profitcenter.setMustInput(false); + } + } + @Override + public void propertyChanged(PropertyChangedArgs e) { + super.propertyChanged(e); - -// Map ctlMap = new HashMap<>(); -// ctlMap.put(ClientProperties.Editable, true); -// this.getView().updateControlMetadata("settletype", ctlMap); + // 获取成本中心和利润中心的控件 + BasedataEdit shjh_costcenter = this.getView().getControl("shjh_costcenter"); + BasedataEdit shjh_profitcenter = this.getView().getControl("shjh_pc"); + //根据业务小类设置 成本中心,利润中心是否必填 + DynamicObject shjhBizsmall = (DynamicObject)this.getView().getModel().getValue("shjh_bizsmall"); + if (null != shjhBizsmall) { + shjhBizsmall = BusinessDataServiceHelper.loadSingle(shjhBizsmall.getPkValue(),"shjh_bizsmalltype"); + // 获取成本中心和利润中心的必填配置 + boolean shjhCc = shjhBizsmall.getBoolean("shjh_cc"); + boolean shjhPc = shjhBizsmall.getBoolean("shjh_pc"); + // 设置成本中心必填状态 + shjh_costcenter.setMustInput(shjhCc); + // 设置利润中心必填状态 + shjh_profitcenter.setMustInput(shjhPc); + }else { + shjh_costcenter.setMustInput(false); + shjh_profitcenter.setMustInput(false); + } } }