作者:鹏63213 | 来源:互联网 | 2023-02-13 11:04
//本示例判断编辑后是否与存在的值是否重复
1.配置xml文件
<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>
<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>
<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 afterEditIndexList;
/* */
/* 45 */ private boolean isExcelImprting = false;
/* */
/* */ public List 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 {
@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 ){
if(i != row){
rowvalue = (String) card.getBodyValueAt(i, key);
if(value.equals(rowvalue)){
card.setBodyValueAt(null, row, key);
//判断是重复床位或者重复房间类型
ShowStatusBarMsgUtil.showErrorMsg("重复的床位,请修改数据!", "重复的床位,请修改数据!", e.getContext());
}
}
}
}
}
}3.