XML配置:
<!-- 编辑事件 -->
<bean id="appEventHandlerMediator" class="nc.ui.pubapp.uif2app.model.AppEventHandlerMediator">
<property name="model" ref="bmModel" />
<property name="handlerMap">
<map>
<!-- 表头表尾编辑前事件 -->
<entry key="nc.ui.pubapp.uif2app.event.card.CardHeadTailBeforeEditEvent">
<list>
<bean
class="nc.ui.ct.fb30.hander.Fb30HeadTailBeforeEditHand">
</bean>
</list>
</entry>
<!-- 表体编辑前事件-->
<entry key="nc.ui.pubapp.uif2app.event.card.CardBodyBeforeEditEvent">
<list>
<bean class="nc.ui.ct.fb30.hander.Fb30BodyTailBeforeEditHandler">
</bean>
</list>
</entry>
<!-- 表体编辑后事件 -->
<entry key="nc.ui.pubapp.uif2app.event.card.CardBodyAfterEditEvent">
<list>
<bean class="nc.ui.ct.fb30.hander.Fb30BodyTailAfterEditHandler">
</bean>
</list>
</entry>
<!-- 表头表尾编辑后事件 -->
<entry key="nc.ui.pubapp.uif2app.event.card.CardHeadTailAfterEditEvent">
<list>
<bean
class="nc.ui.ct.fb30.hander.Fb30HeadTailAfterEditHandler">
</bean>
</list>
</entry>
</map>
</property>
</bean>
事件:
1、表头表尾编辑前事件 Fb30HeadTailBeforeEditHand
public class Fb30HeadTailBeforeEditHand implements IAppEventHandler<CardHeadTailBeforeEditEvent> {
@Override
public void handleAppEvent(CardHeadTailBeforeEditEvent e) {
BillCardPanel billCardPanel = e.getBillCardPanel();
String key = e.getKey();
IUAPQueryBS qbs = (IUAPQueryBS) NCLocator.getInstance().lookup(
IUAPQueryBS.class);
e.setReturnValue(Boolean.valueOf(true));
if("pk_bbpro1".equals(key)){
// UIRefPane refPane =(UIRefPane)billCardPanel.getHeadItem(key).getComponent();
// nc.ui.bzyct.pub.refmodel.ProjPrepRefModel refModel =(ProjPrepRefModel) refPane.getRefModel();
// String dept = billCardPanel.getHeadItem("pk_dept").getValue();
// String wherePart="" ;
// if(dept!=null){
// wherePart = " and pro.pk_dept='" + dept + "' ";
// }
// refModel.addWherePart(wherePart);
}else if ("pk_zht1".equals(key)) {
UIRefPane refPane =(UIRefPane)billCardPanel.getHeadItem(key).getComponent();
nc.ui.ct.ap.pub.refmodel.CtArzhRefModel refModel = (CtArzhRefModel) refPane.getRefModel();
String pk_pro1 = billCardPanel.getHeadItem("pk_bbpro1").getValue();
// if (StringUtil.isEmpty(pk_pro1)) {
// refPane.setEnabled(false);
// } else {
refPane.setEnabled(true);
String wherePart = " and ar30.vprojno_30='" + pk_pro1 + "' ";
refModel.addWherePart(wherePart);
// }
}else if ("pk_fbht1".equals(key)) {
// UIRefPane refPane =(UIRefPane)billCardPanel.getHeadItem(key).getComponent();
// nc.ui.bgbd.progresschart.refmodel.CttypeRefModel refModel = (CttypeRefModel) refPane.getRefModel();
// String pk_pro1 = billCardPanel.getHeadItem("pk_zht1").getValue();
if (StringUtil.isEmpty(pk_pro1)) {
refPane.setEnabled(false);
} else {
// refPane.setEnabled(true);
// String wherePart = " and ap30.pk_mainct_30='" + pk_pro1 + "' ";
// refModel.addWherePart(wherePart);
//
}
}else if ("def6".equals(key)){
UIRefPane refPane =(UIRefPane)billCardPanel.getHeadItem(key).getComponent();
refPane.setMultiSelectedEnabled(true);//自定义参照复选框
nc.ui.bgbd.sdeptincdis.ref.SdeptIncDisRefModel refModel = (SdeptIncDisRefModel) refPane.getRefModel();
String pk_dept = billCardPanel.getHeadItem("pk_dept").getValue();
refPane.setEnabled(true);
String wherePart = " and bgbd_funds_claim.cdeptid='"+pk_dept+"' ";
refModel.addWherePart(wherePart);
// }
}
}
}
2、表体编辑前事件 Fb30BodyTailBeforeEditHandler
public class Fb30BodyTailBeforeEditHandler implements IAppEventHandler<CardBodyBeforeEditEvent> {
@Override
public void handleAppEvent(CardBodyBeforeEditEvent e) {
e.setReturnValue(Boolean.valueOf(true));
String key=e.getKey();
IUAPQueryBS qbs = (IUAPQueryBS) NCLocator.getInstance().lookup(
IUAPQueryBS.class);
BillCardPanel billCardPanel = e.getBillCardPanel();
int row=e.getRow();
if(key.equals("pk_pro1")){
UIRefPane refPane =(UIRefPane)billCardPanel.getBodyItem(key).getComponent();
nc.ui.pmpub.ref.ProjectDefaultRefModel refModel = (ProjectDefaultRefModel) refPane.getRefModel();
String pk_dept = billCardPanel.getHeadItem("pk_dept").getValue();
String wherePart = " and pk_duty_dept='"+pk_dept+"' ";
refModel.addWherePart(wherePart);
}
}
}
3、表体编辑后事件 Fb30BodyTailAfterEditHandler
public class Fb30BodyTailAfterEditHandler implements IAppEventHandler<CardBodyAfterEditEvent>{
@Override
public void handleAppEvent(CardBodyAfterEditEvent e) {
String key=e.getKey();//获取关键字
IUAPQueryBS qbs = (IUAPQueryBS) NCLocator.getInstance().lookup(
IUAPQueryBS.class);
BillCardPanel card = e.getBillCardPanel();
int row=e.getRow();
if(key.equals("bxnum")){
int rowcount=e.getBillCardPanel().getRowCount();
UFDouble znum=UFDouble.ZERO_DBL;
for(int i=0;i<rowcount;i++){
UFDouble num= new UFDouble(card.getBodyValueAt(i, "bxnum")==null?"0":card.getBodyValueAt(i, "bxnum").toString()) ;
znum=znum.add(num);
}
card.setHeadItem("znum", znum);
//收款比例就是已收款金额除以主合同金额加变更金额
//流程中支付金额
UFDouble lczmny = SafeUFDoubleUtil.valueOf((card.getHeadItem("def7").getValueObject()));
UFDouble fbhtnum = new UFDouble(card.getHeadItem("fbhtnum").getValue());
UFDouble yzfnum = new UFDouble(card.getHeadItem("yzfnum").getValue());
if (fbhtnum.compareTo(UFDouble.ZERO_DBL) > 0) {
//分院内部结算不知道为什么注释掉了?
//TODO
// card.setHeadItem("ljfkbl", (yzfnum.add(znum).add(lczmny)).div(fbhtnum).multiply(new UFDouble(100)));
}
}
}
}
4、表头表尾编辑后事件 Fb30HeadTailAfterEditHandler
public class Fb30HeadTailAfterEditHandler implements IAppEventHandler<CardHeadTailAfterEditEvent> {
@Override
public void handleAppEvent(CardHeadTailAfterEditEvent e) {
BillCardPanel billCardPanel = e.getBillCardPanel();
String key = e.getKey();
IUAPQueryBS qbs = (IUAPQueryBS) NCLocator.getInstance().lookup(
IUAPQueryBS.class);
UFDouble lcznum=UFDouble.ZERO_DBL;
if (key.equals("pk_zht1") || key.equals("ysknum")||key.equals("vdef4")){
UFDouble zhtnum = new UFDouble(billCardPanel.getHeadItem("zhtnum").getValue());
UFDouble ysknum = new UFDouble(billCardPanel.getHeadItem("ysknum")
.getValue());
UFDouble zbgnum = new UFDouble(billCardPanel.getHeadItem("dmainchngmny")
.getValue());
billCardPanel.setHeadItem("zskbl", ysknum.div(zhtnum.add(zbgnum)).multiply(new UFDouble(100)));
String oldzhtpk =billCardPanel.getHeadItem("oldzhtpk")==null?null:billCardPanel.getHeadItem("oldzhtpk").getValue();
if(oldzhtpk!=null && !oldzhtpk.equals(e.getValue())){
billCardPanel.setHeadItem("vdef20", null);
billCardPanel.setHeadItem("pk_fbht1", null);
billCardPanel.setHeadItem("vdef19", null);
billCardPanel.setHeadItem("pk_supplier", null);
billCardPanel.setHeadItem("fbhtcode", null);
billCardPanel.setHeadItem("fbhtnum", null);
billCardPanel.setHeadItem("dpuchngmny", null);
billCardPanel.setHeadItem("yzfnum", null);
billCardPanel.setHeadItem("znum", null);
billCardPanel.setHeadItem("def6", null);
billCardPanel.setHeadItem("ljfkbl", null);
billCardPanel.setHeadItem("print1", null);
billCardPanel.setHeadItem("print2", null);
billCardPanel.setHeadItem("bisfile", null);
billCardPanel.setHeadItem("vdef1", null);
}
billCardPanel.setHeadItem("oldzhtpk", e.getValue());
// billCardPanel.setHeadItem("zskbl", ysknum.div(zhtnum).multiply(new UFDouble(100)));
}else if(key.equals("pk_fbht1")){
String fbhtcode = billCardPanel.getHeadItem("fbhtcode").getValue();
UFDouble fbhtnum = new UFDouble(billCardPanel.getHeadItem("fbhtnum")
.getValue());
UFDouble znum = new UFDouble(billCardPanel.getHeadItem("znum")
.getValue());
UFDouble def3 = new UFDouble(billCardPanel.getHeadItem("def3")
.getValue());
UFDouble zfbbxnum = new UFDouble(billCardPanel.getHeadItem("yzfnum")
.getValue());
UFDouble fbbgnum = new UFDouble(billCardPanel.getHeadItem("dpuchngmny")
.getValue());
if(zfbbxnum.toDouble() == 0){
billCardPanel.setHeadItem("yzfnum", 0);
}
String pk_fbht1=billCardPanel.getHeadItem("pk_fbht1").getValue();
if(pk_fbht1!=null && !pk_fbht1.equals("")){
String sql="select sum(znum) from ct_fbpayapply where pk_fbht1='"
+pk_fbht1 + "' and nvl(dr,0)=0 and approvestatus in (2) ";
String yzfSql = " select nvl(cap.vdef2,0) from ct_ap cap where cap.pk_ct_ap = '"
+pk_fbht1 + "' and nvl(cap.dr,0)=0 ";
try {
lcznum = SafeUFDoubleUtil.valueOf(qbs.executeQuery(sql,
new ColumnProcessor()));
Object numAlready = qbs.executeQuery(yzfSql, new ColumnProcessor());
UFDouble alreadynum = null;
if(numAlready == null){
alreadynum = new UFDouble(0);
}else{
alreadynum = new UFDouble(numAlready.toString());
}
billCardPanel.setHeadItem("def7", lcznum);
billCardPanel.setHeadItem("yzfnum", alreadynum);
//billCardPanel.setHeadItem("ljfkbl", (zfbbxnum.add(def3).add(lcznum)).div(fbhtnum).multiply(new UFDouble(100)));
billCardPanel.setHeadItem("ljfkbl", (zfbbxnum.add(def3).add(lcznum)).div(fbhtnum.add(fbbgnum)).multiply(new UFDouble(100)));
billCardPanel.setHeadItem("ljfkbl", (zfbbxnum.add(znum).add(lcznum)).div(fbhtnum.add(fbbgnum)).multiply(new UFDouble(100)));
//pk_supplier->getcolvalue( ct_ap,cvendorid ,pk_ct_ap , pk_fbht1) ;
String sql2="select name from bd_supplier where pk_supplier =(select cvendorid from ct_ap where pk_ct_ap='"+ billCardPanel.getHeadItem("pk_fbht1").getValue()+"' and nvl(dr,0)=0 ) and nvl(dr,0)=0";
String name=qbs.executeQuery(sql2,
new ColumnProcessor())==null?null:qbs.executeQuery(sql2,
new ColumnProcessor()).toString();
if(name!=null){
int rowcount=e.getBillCardPanel().getRowCount();
for(int i=0;i<rowcount;i++){
billCardPanel.setBodyValueAt(name, i, "skdw");
//billCardPanel.execBodyFormula(i, "skdw");
}
}
} catch (BusinessException e1) {
// TODO 自动生成的 catch 块
e1.printStackTrace();
}
}else{
int rowcount=e.getBillCardPanel().getRowCount();
for(int i=0;i<rowcount;i++){
billCardPanel.setBodyValueAt(null, i, "skdw");
//billCardPanel.execBodyFormula(i, "skdw");
}
}
}else if ("yzfnum".equals(key) ||"def3".equals(key) ){
UFDouble fbhtnum = new UFDouble(billCardPanel.getHeadItem("fbhtnum")
.getValue());
UFDouble yzfnum = new UFDouble(billCardPanel.getHeadItem("yzfnum")
.getValue());
UFDouble def3 = new UFDouble(billCardPanel.getHeadItem("def3")
.getValue());
UFDouble def7 = new UFDouble(billCardPanel.getHeadItem("def7")
.getValue());
UFDouble fbbgnum = new UFDouble(billCardPanel.getHeadItem("dpuchngmny")
.getValue());
billCardPanel.setHeadItem("ljfkbl", (yzfnum.add(def3).add(def7)).div(fbhtnum.add(fbbgnum)).multiply(new UFDouble(100)));
billCardPanel.setHeadItem("ljfkbl", (yzfnum.add(def3).add(lcznum)).div(fbhtnum).multiply(new UFDouble(100)));
}else if("vpaystatus".equals(key)){
String sta= billCardPanel.getHeadItem("vpaystatus").getValue()==null?"":billCardPanel.getHeadItem("vpaystatus").getValue().toString();
if(sta.equals("3")){
billCardPanel.getHeadItem("vevaluationno").setNull(true);
}else{
billCardPanel.getHeadItem("vevaluationno").setNull(false);
}
}else if("pk_bbpro1".equals(key)){
String pk_bbpro1= billCardPanel.getHeadItem("pk_bbpro1").getValue()==null?null:billCardPanel.getHeadItem("pk_bbpro1").getValue().toString();
if(pk_bbpro1!=null){
String sql="select pk_project from bd_project where def27='"+pk_bbpro1+"' and nvl(dr,0)=0 ";
try {
String pk_project=qbs.executeQuery(sql,
new ColumnProcessor()) ==null?null:qbs.executeQuery(sql,
new ColumnProcessor()).toString();
if(pk_project!=null){
int rowcount=e.getBillCardPanel().getRowCount();
for(int i=0;i<rowcount;i++){
billCardPanel.setBodyValueAt(pk_project, i, "pk_pro1");
//billCardPanel.execBodyFormula(i, "pk_pro1");
}
}
} catch (BusinessException e1) {
// TODO 自动生成的 catch 块
e1.printStackTrace();
}
}
billCardPanel.setHeadItem("pk_zht1", null);
billCardPanel.setHeadItem("zhtcode", null);
billCardPanel.setHeadItem("zhtnum", null);
billCardPanel.setHeadItem("ysknum", null);
billCardPanel.setHeadItem("zskbl", null);
billCardPanel.setHeadItem("pk_fbht1", null);
billCardPanel.setHeadItem("fbhtcode", null);
billCardPanel.setHeadItem("fbhtnum", null);
billCardPanel.setHeadItem("pk_supplier", null);
billCardPanel.setHeadItem("yzfnum", 0);
billCardPanel.setHeadItem("ljfkbl", null);
int rowcount=e.getBillCardPanel().getRowCount();
for(int i=0;i<rowcount;i++){
billCardPanel.setBodyValueAt(null, i, "skdw");
billCardPanel.setBodyValueAt(null, i, "pk_pro1");
}
}
else if ("def6".equals(key)){//bgbd_funds_claim ,nclaimmoney , pk_fundsclaim,def6
UIRefPane refPane =(UIRefPane)billCardPanel.getHeadItem(key).getComponent();
String[] def6=refPane.getRefPKs();
if(def6.length>0){
StringBuffer wherepar=new StringBuffer();
for(int i=0;i<def6.length;i++){
if(i==def6.length-1){
wherepar.append("'"+def6[i]+"'");
}else{
wherepar.append("'"+def6[i]+"',");
}
}
String sql="select sum(nclaimmoney) from bgbd_funds_claim where pk_fundsclaim in ("+wherepar.toString()+") and nvl(dr,0)=0";
try {
UFDouble bcsqnum = qbs.executeQuery(sql,
new ColumnProcessor()) == null ? UFDouble.ZERO_DBL
: new UFDouble(qbs.executeQuery(sql,
new ColumnProcessor()).toString());
// billCardPanel.setHeadItem("def3", bcsqnum);
if(bcsqnum.compareTo(UFDouble.ZERO_DBL)>0){
UFDouble fbhtnum = new UFDouble(billCardPanel.getHeadItem("fbhtnum")
.getValue());
UFDouble yzfnum = new UFDouble(billCardPanel.getHeadItem("yzfnum")
.getValue());
UFDouble def7 = new UFDouble(billCardPanel.getHeadItem("def7")
.getValue());
UFDouble fbbgnum = new UFDouble(billCardPanel.getHeadItem("dpuchngmny")
.getValue());
if(fbhtnum.compareTo(UFDouble.ZERO_DBL)>0){
billCardPanel.setHeadItem("ljfkbl", (yzfnum.add(bcsqnum).add(def7)).div(fbhtnum.add(fbbgnum)).multiply(new UFDouble(100)));
billCardPanel.setHeadItem("ljfkbl", (yzfnum.add(bcsqnum).add(lcznum)).div(fbhtnum).multiply(new UFDouble(100)));
}
}
} catch (NumberFormatException e1) {
// TODO 自动生成的 catch 块
e1.printStackTrace();
} catch (BusinessException e1) {
// TODO 自动生成的 catch 块
e1.printStackTrace();
}
}
}
}
}