PC
//获取控件'KXSL'、'SQSL'的值 var JinE01 = mini.get('KXSL'); var JinE02 = mini.get('SQSL'); //一旦值发生改变,触发codeValue函数 JinE01.on('valuechanged', codeValue); JinE02.on('valuechanged', codeValue); function codeValue() { var H1Value = JinE01.getValue()== ''?0:JinE01.getValue(); //若控件值为空赋值为0,否则取对应的值 var H2Value = JinE02.getValue()== ''?0:JinE02.getValue(); var H1IntValue = parseFloat(H1Value); //文本转为数值 var H2IntValue = parseFloat(H2Value); if(H1IntValue >= H2IntValue){ var sum = Math.abs(H1IntValue - H2IntValue); //减法 mini.get('SYSL').setValue(sum); //计算结果赋值 }else if(H1IntValue < H2IntValue){ alert("资产申请数量超过可申请数量,请重新填写!"); } }
移动:
//获取控件'KXSL'、'SQSL'的值 JQUERY var $H1 = $('#KXSL', this.parentView.el); // 根据id获取控件对象 var $H2 = $('#SQSL', this.parentView.el); var $H3 = $('#SYSL', this.parentView.el); $H1.change(codeValue); //一旦值发生改变,触发codeValue函数 $H2.change(codeValue); $H3.change(codeValue); $H4.change(codeValue); $H5.change(codeValue); function codeValue() { var H1Value = $H1.val()== ''?0:$H1.val(); //若控件值为空赋值为0,否则取对应的值 var H2Value = $H2.val()== ''?0:$H2.val(); var H1FloatValue = parseFloat(H1Value); //文本转为数值 var H2FloatValue = parseFloat(H2Value); if(H1FloatValue >= H2FloatValue){ var sum=H1FloatValue - H2FloatValue; //减法 $H3.val(sum); //计算结果赋值 }else if(H1FloatValue < H2FloatValue){ alert("资产申请数量超过可申请数量,请重新填写!"); } }
标签:JinE02,控件,滨州,val,JS,change,codeValue,var,空闲 From: https://www.cnblogs.com/xiaoweihongyan/p/17532701.html