nc65 表体编辑事件
//本示例判断编辑后是否与存在的值是否重复
1.配置xml文件
<!-- 事件监听newadd --> <bean id="bmModelEventMediator" class="nc.ui.pubapp.uif2app.model.AppEventHandlerMediator"> <property name="model" ref="bmModel" /> <property name="handlerGroup"> <list> <!-- 表体字段编辑前事件 --> <bean class="nc.ui.pubapp.uif2app.event.EventHandlerGroup"> <property name="event" value="nc.ui.pubapp.uif2app.event.card.CardBodyBeforeEditEvent" /> <property name="handler"> <bean class="nc.ui.hfdm.hfdm_dormcheckin.ace.handler.AceBodyBeforeEditHandler" /> </property> </bean> <!-- 表体字段编辑后事件 --> <bean class="nc.ui.pubapp.uif2app.event.EventHandlerGroup"> <property name="event" value="nc.ui.pubapp.uif2app.event.card.CardBodyAfterEditEvent" /> <property name="handler"> <bean class="nc.ui.hfdm.hfdm_dormcheckin.ace.handler.AceBodyAfterEditHandler" /> </property> </bean> <!-- 表头表尾字段编辑前事件 --> <bean class="nc.ui.pubapp.uif2app.event.EventHandlerGroup"> <property name="event" value="nc.ui.pubapp.uif2app.event.card.CardHeadTailBeforeEditEvent" /> <property name="handler"> <bean class="nc.ui.hfdm.hfdm_dormcheckin.ace.handler.AceHeadTailBeforeEditHandler" /> </property> </bean> <!-- 表头表尾字段编辑后事件 --> <bean class="nc.ui.pubapp.uif2app.event.EventHandlerGroup"> <property name="event" value="nc.ui.pubapp.uif2app.event.card.CardHeadTailAfterEditEvent" /> <property name="handler"> <bean class="nc.ui.hfdm.hfdm_dormcheckin.ace.handler.AceHeadTailAfterEditHandler" /> </property> </bean> <!-- nc.ui.pubapp.uif2app.event.OrgChangedEvent --> <bean class="nc.ui.pubapp.uif2app.event.EventHandlerGroup"> <property name="event" value="nc.ui.pubapp.uif2app.event.OrgChangedEvent" /> <property name="handler"> <bean class="nc.ui.hfdm.hfdm_dormcheckin.ace.handler.AceOrgChangeHandler" > <property name="billForm" ref="billForm" /> </bean> </property> </bean> <!-- nc.ui.pubapp.uif2app.event.billform.AddEvent --> <bean class="nc.ui.pubapp.uif2app.event.EventHandlerGroup"> <property name="event" value="nc.ui.pubapp.uif2app.event.billform.AddEvent" /> <property name="handler"> <bean class="nc.ui.hfdm.hfdm_dormcheckin.ace.handler.AceAddHandler" /> </property> </bean> </list> </property> </bean>
2.event 类
/* */ package nc.ui.pubapp.uif2app.event.card; /* */ /* */ import java.util.ArrayList; /* */ import java.util.List; /* */ import nc.ui.bd.ref.AbstractRefModel; /* */ import nc.ui.pub.beans.UIRefPane; /* */ import nc.ui.pub.bill.BillCardPanel; /* */ import nc.ui.pub.bill.BillEditEvent; /* */ import nc.ui.pub.bill.BillItem; /* */ import nc.vo.jcom.lang.StringUtil; /* */ import nc.vo.pub.lang.UFDouble; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class CardBodyAfterEditEvent /* */ extends CardPanelEvent /* */ { /* */ public static final int NOTBATCHCOPY = -1; /* */ public static final int BATCHCOPYBEGIN = 1; /* */ public static final int BATCHCOPING = 2; /* */ public static final int BATCHCOPYEND = 3; /* */ private String key; /* */ private Object oldValue; /* */ private Object pkValue; /* 33 */ private int row = -1; /* */ /* */ /* */ private String tableCode; /* */ /* */ /* */ private Object value; /* */ /* */ private int afterEditEventState; /* */ /* */ private List<Integer> afterEditIndexList; /* */ /* 45 */ private boolean isExcelImprting = false; /* */ /* */ public List<Integer> getAfterEditIndexList() { /* 48 */ if (afterEditIndexList == null) { /* 49 */ afterEditIndexList = new ArrayList(); /* */ } /* 51 */ return afterEditIndexList; /* */ } /* */ /* */ public int getAfterEditEventState() { /* 55 */ return afterEditEventState; /* */ } /* */ /* */ public void setAfterEditEventState(int afterEditEventState) { /* 59 */ this.afterEditEventState = afterEditEventState; /* */ } /* */ /* */ public CardBodyAfterEditEvent(BillCardPanel cardPanel, BillEditEvent e, Object oldValue) /* */ { /* 64 */ this(cardPanel, e.getTableCode(), e.getRow(), e.getKey(), e.getValue(), oldValue); /* */ /* 66 */ setSource(e.getSource()); /* */ } /* */ /* */ public CardBodyAfterEditEvent(BillCardPanel cardPanel, String tableCode, int row, String key, Object value, Object oldValue) /* */ { /* 71 */ super(cardPanel, CardBodyAfterEditEvent.class.getName()); /* 72 */ this.tableCode = tableCode; /* 73 */ this.row = row; /* 74 */ this.key = key; /* 75 */ this.value = value; /* 76 */ this.oldValue = oldValue; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public String getKey() /* */ { /* 85 */ return key; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public Object getOldValue() /* */ { /* 94 */ return oldValue; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public int getRow() /* */ { /* 103 */ return row; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public String getTableCode() /* */ { /* 112 */ return tableCode; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public Object getValue() /* */ { /* 121 */ return getPkValue(); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ private Object getPkValue() /* */ { /* 130 */ if (pkValue == null) { BillItem item; /* */ BillItem item; /* 132 */ if (StringUtil.isEmpty(tableCode)) { /* 133 */ item = getBillCardPanel().getBodyItem(key); /* */ } else { /* 135 */ item = getBillCardPanel().getBodyItem(tableCode, key); /* */ } /* 137 */ int type = item.getDataType(); /* 138 */ if (5 == type) { /* 139 */ UIRefPane refPane = (UIRefPane)item.getComponent(); /* 140 */ if (refPane.getRefModel() != null) { /* 141 */ pkValue = refPane.getRefModel().getPkValue(); /* */ } /* */ } /* 144 */ else if ((1 == type) || (2 == type) || (18 == type)) /* */ { /* 146 */ if (value != null) { /* 147 */ pkValue = new UFDouble(value.toString()); /* */ } /* */ } /* */ else { /* 151 */ pkValue = value; /* */ } /* */ } /* 154 */ return pkValue; /* */ } /* */ /* */ public void setExcelImprting(boolean isExcelImprting) { /* 158 */ this.isExcelImprting = isExcelImprting; /* */ } /* */ /* */ public boolean isExcelImprting() { /* 162 */ return isExcelImprting; /* */ } /* */ }
3.事件处理
package nc.ui.hfdm.hfdm_dormcheckin.ace.handler; import nc.ui.pub.bill.BillCardPanel; import nc.ui.pubapp.uif2app.event.IAppEventHandler; import nc.ui.pubapp.uif2app.event.card.CardBodyAfterEditEvent; import nc.ui.uif2.ShowStatusBarMsgUtil; //单据表体字段编辑后事件 public class AceBodyAfterEditHandler implements IAppEventHandler<CardBodyAfterEditEvent> { @Override public void handleAppEvent(CardBodyAfterEditEvent e) { //获取卡片界面 BillCardPanel card = e.getBillCardPanel(); String key = e.getKey(); int row = e.getRow(); int rowcount = card.getRowCount(); String rowvalue = ""; if("beds".equals(key)){ String value = (String) (null == e.getValue() ? "" : e.getValue()); for(int i = 0; i < rowcount; i++){ if(i != row){ rowvalue = (String) card.getBodyValueAt(i, key); if(value.equals(rowvalue)){ card.setBodyValueAt(null, row, key); //判断是重复床位或者重复房间类型 ShowStatusBarMsgUtil.showErrorMsg("重复的床位,请修改数据!", "重复的床位,请修改数据!", e.getContext()); } } } } } }
3.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构