关于DEP如何实现减法运算?原创
金蝶云社区-Hadwin
Hadwin
4人赞赏了该文章 603次浏览 未经作者许可,禁止转载编辑于2020年06月04日 13:18:59

问题:

如下图总金额=油费+差旅费,现在总金额不变的情况下,输入油费自动算出差旅费,输入差旅费自动算出油费

image.png

分析:为分录加上监听,总金额不变的情况下控制其余两个数值变化

实现思路:

1、打开编辑界面--扩展定义

image.png

2、输入以下脚本实现如下图:

image.png

3、实现效果

image.png

4、参考脚本

pluginCtx.getKDTable("kdtEntrys").addKDTEditListener(function(event,methodName){

if(methodName == "equals"){

         return this ==event;

     }

if(methodName == "editStopped"){

var table = pluginCtx.getKDTable("kdtEntrys");

var curRow =  table.getRow(event.getRowIndex());

           var colName=table.getColumn(event.getColIndex()).getKey();

             //如果当前列为数量列

           var totalMoney= curRow.getCell("totalMoney").getValue(); 

           if(totalMoney!=null){

              if("travelPrice"==colName ){

                    var travelPrice = curRow.getCell("travelPrice").getValue(); //取差旅费用

                        var difference = com.kingdee.bos.ui.face.UIRuleUtil.getIntValue(totalMoney)-com.kingdee.bos.ui.face.UIRuleUtil.getIntValue(travelPrice);

                        curRow.getCell("oilPrice").setValue(difference); //为油费赋值

                }

               if("oilPrice"==colName ){

                    var carPrice = curRow.getCell("oilPrice").getValue(); 

                        var difference1 = com.kingdee.bos.ui.face.UIRuleUtil.getIntValue(totalMoney)-com.kingdee.bos.ui.face.UIRuleUtil.getIntValue(carPrice);

                        curRow.getCell("travelPrice").setValue(difference1);//为 差旅费赋值        

                }

        }

}

});

至于加法,乘法等计算逻辑也是通过监听去实现,代码不同而已,不在赘述。



赞 4