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); + } } }