解答:
多选下拉列表取值
根据值,获取名称
赋值到文本字段
效果图
插件代码:
Java | |
package kd.bos.ecos; import java.util.Arrays; import java.util.List; import kd.bos.dataentity.metadata.IDataEntityProperty; import kd.bos.dataentity.utils.StringUtils; import kd.bos.entity.ValueMapItem; import kd.bos.entity.datamodel.events.ChangeData; import kd.bos.entity.datamodel.events.PropertyChangedArgs; import kd.bos.entity.property.ComboProp; import kd.bos.form.field.MulComboEdit; import kd.bos.form.plugin.AbstractFormPlugin;
public class Test0402 extends AbstractFormPlugin { @Override public void propertyChanged(PropertyChangedArgs e) { // TODO Auto-generated method stub super.propertyChanged(e); String fieldKey = e.getProperty().getName(); // 多选下拉列表,即时触发值更新属性打开 if (StringUtils.equals("kdec_mulcombofield", fieldKey)) { // TODO 在此添加业务逻辑 ChangeData[] change = e.getChangeSet(); for (ChangeData changeData : change) { Object oldValue = changeData.getOldValue(); Object newValue = changeData.getNewValue(); if (newValue == null) return; MulComboEdit mulComboEdit = this.getControl("kdec_mulcombofield"); IDataEntityProperty prop = mulComboEdit.getProperty(); String txt = getComboName(prop, newValue.toString()); this.getModel().setValue("kdec_textfield", txt); } } } private String getComboName(IDataEntityProperty data, String value) { StringBuffer result = new StringBuffer(); // ,3, List<String> sList = Arrays.asList(value.substring(0, value.length() - 1).split(",")); ComboProp comboProp = (ComboProp) data; List<ValueMapItem> comboltems = comboProp.getComboItems(); for (ValueMapItem comboltem : comboltems) { if(sList.contains(comboltem.getValue())) { result.append(comboltem.getName().toString()).append(","); } } if(result!=null) { result.deleteCharAt(result.length() - 1); } return result.toString(); } } |
推荐阅读