首页 > 技术文章 > NC模拟前台表头表体编辑前后工具类

lzul 2021-03-18 10:37 原文

package nc.ui.pubapp.util;

import nc.ui.pub.bill.BillCardPanel;
import nc.ui.pub.bill.BillEditEvent;
import nc.ui.pub.bill.BillItemEvent;
import nc.ui.pubapp.uif2app.event.card.CardBodyAfterEditEvent;
import nc.ui.pubapp.uif2app.event.card.CardHeadTailAfterEditEvent;
import nc.ui.pubapp.uif2app.event.card.CardHeadTailBeforeEditEvent;
import nc.ui.uif2.model.AbstractAppModel;

public class CardEditEventUtils {
    
    private BillCardPanel card;
    
    private AbstractAppModel  model;

    public CardEditEventUtils(BillCardPanel cardPanel,AbstractAppModel model) {
      this.card = cardPanel;
      this.model = model;
    }
    
    

     /**
    * @Title: setHeadAfterEditEvent
    * @Description: 模拟前台 表头执行编辑后事件
    * @param key 表头字段
    * @author lzl
    * @date 2021年3月18日
    * @throws
    */
    public void setHeadAfterEditEvent(String headkey) {
         Object value=this.card.getHeadItem(headkey).getValue();
         if(value!=null) {                   
             CardHeadTailAfterEditEvent event=new CardHeadTailAfterEditEvent(this.card,
                 new BillEditEvent(this.card.getHeadItem(headkey), value, headkey), null);
             model.fireEvent(event);            
         }
     }
    
    
    
    /**
     * @Title: setHeadBeforeEditEvent
     * @Description: 模拟前台 表头执行编辑前事件
     * @param key 表头字段
     * @author lzl
     * @date 2021年3月18日
     * @throws
     */
     public void setHeadBeforeEditEvent(String headkey) {
          Object value=this.card.getHeadItem(headkey).getValue();
          if(value!=null) {                   
              CardHeadTailBeforeEditEvent event=new CardHeadTailBeforeEditEvent(this.card,
                  new BillItemEvent(this.card.getHeadItem(headkey)));
              this.model.fireEvent(event);            
          }
      }
     
     

      /**
    * @Title: setBodyAfterEditEvent
    * @Description: 表体指定行指定字段编辑后事件
    * @param row 表体行
    * @param key 表体字段
    * @author lzl
    * @date 2021年3月18日
    * @throws
    */
    public void setBodyAfterEditEvent(int row,String bodykey) {
          Object value=this.card.getBodyValueAt(row, bodykey);
          if(value!=null) {
              CardBodyAfterEditEvent event = new CardBodyAfterEditEvent(this.card,
                  new BillEditEvent(this.card.getBodyItem(bodykey),this.card.getBodyValueAt(row, bodykey), bodykey, row), 
                  null);
              this.model.fireEvent(event);             
          }
          
      }
    
    
    /**
    * @Title: setBodyAfterEditEvent
    * @Description: 表体指定字段所有行执行编辑后事件
    * @param bodykey void
    * @author lzl
    * @date 2021年3月18日
    * @throws
    */
    public void setBodyAfterEditEvent(String bodykey) {
       int row= this.card.getBillModel().getRowCount();        
       for (int i = 0; i <row; i++) {
            setBodyAfterEditEvent(i, bodykey);
        }        
    }

}

 

推荐阅读