付款单根据业务小类设置 成本中心,利润中心是否必填 #afterBindData #propertyChanged

s
This commit is contained in:
weiyunlong 2025-05-16 18:08:55 +08:00
parent 8f8f2b7e39
commit eb087d77c4
1 changed files with 44 additions and 6 deletions

View File

@ -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");
// Map<String, Object> 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);
}
}
@Override
public void propertyChanged(PropertyChangedArgs e) {
super.propertyChanged(e);
// 获取成本中心和利润中心的控件
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);
}
}
}