JS:
报销单:pc
var A4ShuLiang = mini.get('A4ShuLiang'); var A4DanJia = mini.get('A4DanJia'); var A3ShuLiang = mini.get('A3ShuLiang'); var A3DanJia = mini.get('A3DanJia'); A4ShuLiang.on('valuechanged', codeValue); A4DanJia.on('valuechanged', codeValue); A3ShuLiang.on('valuechanged', codeValue); A3DanJia.on('valuechanged', codeValue); function codeValue() { var H1Value = A4ShuLiang.getValue()== ''?0:A4ShuLiang.getValue(); //若控件值为空赋值为0,否则取对应的值 var H2Value = A4DanJia.getValue()== ''?0:A4DanJia.getValue(); var H3Value = A3ShuLiang.getValue()== ''?0:A3ShuLiang.getValue(); var H4Value = A3DanJia.getValue()== ''?0:A3DanJia.getValue(); var H1IntValue = parseFloat(H1Value); //文本转为数值 var H2IntValue = parseFloat(H2Value); var H3IntValue = parseFloat(H3Value); var H4IntValue = parseFloat(H4Value); var sum1 = Math.abs(H1IntValue * H2IntValue ); //乘法 mini.get('A4JinE').setValue(sum1); //计算结果赋值 var sum2 = Math.abs(H3IntValue * H4IntValue ); //乘法 mini.get('A3JinE').setValue(sum2); //计算结果赋值 var sum3 = Math.abs(sum1 + sum2); //加法 mini.get('HJJE').setValue(sum3); //计算结果赋值 var sum4 = Math.abs(H1IntValue / 5); //除法 mini.get('A4Xiang').setValue(sum4); //计算结果赋值 var sum5 = Math.abs(H3IntValue / 5); //除法 mini.get('A3Xiang').setValue(sum5); //计算结果赋值 //数字转大写 setTimeout(function(){ var money = sum3; var cMoney = convertCurrency(money); mini.get('JinEDaXie').setValue(cMoney); },100);//0.1秒后触发setTimeout函数 //代码如下所示: function convertCurrency(money) { //汉字的数字 var cnNums = new Array('零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'); //基本单位 var cnIntRadice = new Array('', '拾', '佰', '仟'); //对应整数部分扩展单位 var cnIntUnits = new Array('', '万', '亿', '兆'); //对应小数部分单位 var cnDecUnits = new Array('角', '分', '毫', '厘'); //整数金额时后面跟的字符 var cnInteger = '整'; //整型完以后的单位 var cnIntLast = '元'; //最大处理的数字 var maxNum = 999999999999999.9999; //金额整数部分 var integerNum; //金额小数部分 var decimalNum; //输出的中文金额字符串 var chineseStr = ''; //分离金额后用的数组,预定义 var parts; if (money == '') { return ''; } money = parseFloat(money); if (money >= maxNum) { //超出最大处理数字 return ''; } if (money == 0) { chineseStr = cnNums[0] + cnIntLast + cnInteger; return chineseStr; } //转换为字符串 money = money.toString(); if (money.indexOf('.') == -1) { integerNum = money; decimalNum = ''; } else { parts = money.split('.'); integerNum = parts[0]; decimalNum = parts[1].substr(0, 4); } //获取整型部分转换 if (parseInt(integerNum, 10) > 0) { var zeroCount = 0; var IntLen = integerNum.length; for (var i = 0; i < IntLen; i++) { var n = integerNum.substr(i, 1); var p = IntLen - i - 1; var q = p / 4; var m = p % 4; if (n == '0') { zeroCount++; } else { if (zeroCount > 0) { chineseStr += cnNums[0]; } //归零 zeroCount = 0; chineseStr += cnNums[parseInt(n)] + cnIntRadice[m]; } if (m == 0 && zeroCount < 4) { chineseStr += cnIntUnits[q]; } } chineseStr += cnIntLast; } //小数部分 if (decimalNum != '') { var decLen = decimalNum.length; for (var i = 0; i < decLen; i++) { var n = decimalNum.substr(i, 1); if (n != '0') { chineseStr += cnNums[Number(n)] + cnDecUnits[i]; } } } if (chineseStr == '') { chineseStr += cnNums[0] + cnIntLast + cnInteger; } else if (decimalNum == '') { chineseStr += cnInteger; } return chineseStr; } };
报销-移动端
var $H1 = $('#A4ShuLiang', this.parentView.el); // 根据id获取控件对象 var $H2 = $('#A4DanJia', this.parentView.el); var $H3 = $('#A3ShuLiang', this.parentView.el); var $H4 = $('#A3DanJia', this.parentView.el); var $H5 = $('#A4JinE', this.parentView.el); var $H6 = $('#A3JinE', this.parentView.el); var $H7 = $('#HJJE', this.parentView.el); var $H8 = $('#A4Xiang', this.parentView.el); var $H9 = $('#A3Xiang', this.parentView.el); var $H10 = $('#JinEDaXie', this.parentView.el); $H1.change(codeValue); //一旦值发生改变,触发codeValue函数 $H2.change(codeValue); $H3.change(codeValue); $H4.change(codeValue); $H5.change(codeValue); $H6.change(codeValue); $H7.change(codeValue); $H8.change(codeValue); $H9.change(codeValue); $H10.change(codeValue); function codeValue() { var H1Value = $H1.val()== ''?0:$H1.val(); //若控件值为空赋值为0,否则取对应的值 var H2Value = $H2.val()== ''?0:$H2.val(); var H3Value = $H3.val()== ''?0:$H3.val(); var H4Value = $H4.val()== ''?0:$H4.val(); var H1FloatValue = parseFloat(H1Value); //文本转为数值 var H2FloatValue = parseFloat(H2Value); var H3FloatValue = parseFloat(H3Value); var H4FloatValue = parseFloat(H4Value); var sum1=H1FloatValue * H2FloatValue; //求和 $H5.val(sum1); //计算结果赋值 var sum2=H3FloatValue * H4FloatValue; //求和 $H6.val(sum2); //计算结果赋值 var sum3=sum1 + sum2; //求和 $H7.val(sum3); //计算结果赋值 var sum4=H1FloatValue / 5;//求商 $H8.val(sum4); //计算结果赋值 var sum5=H3FloatValue / 5;//求商 $H9.val(sum5); //计算结果赋值 //数字转大写 setTimeout(function(){ var money = sum3; var cMoney = convertCurrency(money); $H10.val(cMoney); },100);//0.1秒后触发 setTimeout //代码如下所示: function convertCurrency(money) { //汉字的数字 var cnNums = new Array('零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'); //基本单位 var cnIntRadice = new Array('', '拾', '佰', '仟'); //对应整数部分扩展单位 var cnIntUnits = new Array('', '万', '亿', '兆'); //对应小数部分单位 var cnDecUnits = new Array('角', '分', '毫', '厘'); //整数金额时后面跟的字符 var cnInteger = '整'; //整型完以后的单位 var cnIntLast = '元'; //最大处理的数字 var maxNum = 999999999999999.9999; //金额整数部分 var integerNum; //金额小数部分 var decimalNum; //输出的中文金额字符串 var chineseStr = ''; //分离金额后用的数组,预定义 var parts; if (money == '') { return ''; } money = parseFloat(money); if (money >= maxNum) { //超出最大处理数字 return ''; } if (money == 0) { chineseStr = cnNums[0] + cnIntLast + cnInteger; return chineseStr; } //转换为字符串 money = money.toString(); if (money.indexOf('.') == -1) { integerNum = money; decimalNum = ''; } else { parts = money.split('.'); integerNum = parts[0]; decimalNum = parts[1].substr(0, 4); } //获取整型部分转换 if (parseInt(integerNum, 10) > 0) { var zeroCount = 0; var IntLen = integerNum.length; for (var i = 0; i < IntLen; i++) { var n = integerNum.substr(i, 1); var p = IntLen - i - 1; var q = p / 4; var m = p % 4; if (n == '0') { zeroCount++; } else { if (zeroCount > 0) { chineseStr += cnNums[0]; } //归零 zeroCount = 0; chineseStr += cnNums[parseInt(n)] + cnIntRadice[m]; } if (m == 0 && zeroCount < 4) { chineseStr += cnIntUnits[q]; } } chineseStr += cnIntLast; } //小数部分 if (decimalNum != '') { var decLen = decimalNum.length; for (var i = 0; i < decLen; i++) { var n = decimalNum.substr(i, 1); if (n != '0') { chineseStr += cnNums[Number(n)] + cnDecUnits[i]; } } } if (chineseStr == '') { chineseStr += cnNums[0] + cnIntLast + cnInteger; } else if (decimalNum == '') { chineseStr += cnInteger; } return chineseStr; } };
出库单PC:
var A4ShuLiang = mini.get('A4ShuLiang'); var A4DanJia = mini.get('A4DanJia'); var A3ShuLiang = mini.get('A3ShuLiang'); var A3DanJia = mini.get('A3DanJia'); A4ShuLiang.on('valuechanged', codeValue); A4DanJia.on('valuechanged', codeValue); A3ShuLiang.on('valuechanged', codeValue); A3DanJia.on('valuechanged', codeValue); function codeValue() { var H1Value = A4ShuLiang.getValue()== ''?0:A4ShuLiang.getValue(); //若控件值为空赋值为0,否则取对应的值 var H2Value = A4DanJia.getValue()== ''?0:A4DanJia.getValue(); var H3Value = A3ShuLiang.getValue()== ''?0:A3ShuLiang.getValue(); var H4Value = A3DanJia.getValue()== ''?0:A3DanJia.getValue(); var H1IntValue = parseFloat(H1Value); //文本转为数值 var H2IntValue = parseFloat(H2Value); var H3IntValue = parseFloat(H3Value); var H4IntValue = parseFloat(H4Value); var sum1 = Math.abs(H1IntValue * H2IntValue ); //乘法 mini.get('A4JinE').setValue(sum1); //计算结果赋值 var sum2 = Math.abs(H3IntValue * H4IntValue ); //乘法 mini.get('A3JinE').setValue(sum2); //计算结果赋值 var sum3 = Math.abs(sum1 + sum2); //加法 mini.get('HJJE').setValue(sum3); //计算结果赋值 var sum4 = Math.abs(H1IntValue / 5); //除法 mini.get('A4Xiang').setValue(sum4); //计算结果赋值 var sum5 = Math.abs(H3IntValue / 5); //除法 mini.get('A3Xiang').setValue(sum5); //计算结果赋值 //数字转大写 setTimeout(function(){ var money = sum3; var cMoney = convertCurrency(money); mini.get('JinEDaXie').setValue(cMoney); },100);//0.1秒后触发setTimeout函数 //代码如下所示: function convertCurrency(money) { //汉字的数字 var cnNums = new Array('零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'); //基本单位 var cnIntRadice = new Array('', '拾', '佰', '仟'); //对应整数部分扩展单位 var cnIntUnits = new Array('', '万', '亿', '兆'); //对应小数部分单位 var cnDecUnits = new Array('角', '分', '毫', '厘'); //整数金额时后面跟的字符 var cnInteger = '整'; //整型完以后的单位 var cnIntLast = '元'; //最大处理的数字 var maxNum = 999999999999999.9999; //金额整数部分 var integerNum; //金额小数部分 var decimalNum; //输出的中文金额字符串 var chineseStr = ''; //分离金额后用的数组,预定义 var parts; if (money == '') { return ''; } money = parseFloat(money); if (money >= maxNum) { //超出最大处理数字 return ''; } if (money == 0) { chineseStr = cnNums[0] + cnIntLast + cnInteger; return chineseStr; } //转换为字符串 money = money.toString(); if (money.indexOf('.') == -1) { integerNum = money; decimalNum = ''; } else { parts = money.split('.'); integerNum = parts[0]; decimalNum = parts[1].substr(0, 4); } //获取整型部分转换 if (parseInt(integerNum, 10) > 0) { var zeroCount = 0; var IntLen = integerNum.length; for (var i = 0; i < IntLen; i++) { var n = integerNum.substr(i, 1); var p = IntLen - i - 1; var q = p / 4; var m = p % 4; if (n == '0') { zeroCount++; } else { if (zeroCount > 0) { chineseStr += cnNums[0]; } //归零 zeroCount = 0; chineseStr += cnNums[parseInt(n)] + cnIntRadice[m]; } if (m == 0 && zeroCount < 4) { chineseStr += cnIntUnits[q]; } } chineseStr += cnIntLast; } //小数部分 if (decimalNum != '') { var decLen = decimalNum.length; for (var i = 0; i < decLen; i++) { var n = decimalNum.substr(i, 1); if (n != '0') { chineseStr += cnNums[Number(n)] + cnDecUnits[i]; } } } if (chineseStr == '') { chineseStr += cnNums[0] + cnIntLast + cnInteger; } else if (decimalNum == '') { chineseStr += cnInteger; } return chineseStr; } };
出库单-移动:
var $H1 = $('#A4ShuLiang', this.parentView.el); // 根据id获取控件对象 var $H2 = $('#A4DanJia', this.parentView.el); var $H3 = $('#A3ShuLiang', this.parentView.el); var $H4 = $('#A3DanJia', this.parentView.el); var $H5 = $('#A4JinE', this.parentView.el); var $H6 = $('#A3JinE', this.parentView.el); var $H7 = $('#HJJE', this.parentView.el); var $H8 = $('#A4Xiang', this.parentView.el); var $H9 = $('#A3Xiang', this.parentView.el); var $H10 = $('#JinEDaXie', this.parentView.el); $H1.change(codeValue); //一旦值发生改变,触发codeValue函数 $H2.change(codeValue); $H3.change(codeValue); $H4.change(codeValue); $H5.change(codeValue); $H6.change(codeValue); $H7.change(codeValue); $H8.change(codeValue); $H9.change(codeValue); $H10.change(codeValue); function codeValue() { var H1Value = $H1.val()== ''?0:$H1.val(); //若控件值为空赋值为0,否则取对应的值 var H2Value = $H2.val()== ''?0:$H2.val(); var H3Value = $H3.val()== ''?0:$H3.val(); var H4Value = $H4.val()== ''?0:$H4.val(); var H1FloatValue = parseFloat(H1Value); //文本转为数值 var H2FloatValue = parseFloat(H2Value); var H3FloatValue = parseFloat(H3Value); var H4FloatValue = parseFloat(H4Value); var sum1=H1FloatValue * H2FloatValue; //求和 $H5.val(sum1); //计算结果赋值 var sum2=H3FloatValue * H4FloatValue; //求和 $H6.val(sum2); //计算结果赋值 var sum3=sum1 + sum2; //求和 $H7.val(sum3); //计算结果赋值 var sum4=H1FloatValue / 5;//求商 $H8.val(sum4); //计算结果赋值 var sum5=H3FloatValue / 5;//求商 $H9.val(sum5); //计算结果赋值 //数字转大写 setTimeout(function(){ var money = sum3; var cMoney = convertCurrency(money); $H10.val(cMoney); },100);//0.1秒后触发 setTimeout //代码如下所示: function convertCurrency(money) { //汉字的数字 var cnNums = new Array('零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'); //基本单位 var cnIntRadice = new Array('', '拾', '佰', '仟'); //对应整数部分扩展单位 var cnIntUnits = new Array('', '万', '亿', '兆'); //对应小数部分单位 var cnDecUnits = new Array('角', '分', '毫', '厘'); //整数金额时后面跟的字符 var cnInteger = '整'; //整型完以后的单位 var cnIntLast = '元'; //最大处理的数字 var maxNum = 999999999999999.9999; //金额整数部分 var integerNum; //金额小数部分 var decimalNum; //输出的中文金额字符串 var chineseStr = ''; //分离金额后用的数组,预定义 var parts; if (money == '') { return ''; } money = parseFloat(money); if (money >= maxNum) { //超出最大处理数字 return ''; } if (money == 0) { chineseStr = cnNums[0] + cnIntLast + cnInteger; return chineseStr; } //转换为字符串 money = money.toString(); if (money.indexOf('.') == -1) { integerNum = money; decimalNum = ''; } else { parts = money.split('.'); integerNum = parts[0]; decimalNum = parts[1].substr(0, 4); } //获取整型部分转换 if (parseInt(integerNum, 10) > 0) { var zeroCount = 0; var IntLen = integerNum.length; for (var i = 0; i < IntLen; i++) { var n = integerNum.substr(i, 1); var p = IntLen - i - 1; var q = p / 4; var m = p % 4; if (n == '0') { zeroCount++; } else { if (zeroCount > 0) { chineseStr += cnNums[0]; } //归零 zeroCount = 0; chineseStr += cnNums[parseInt(n)] + cnIntRadice[m]; } if (m == 0 && zeroCount < 4) { chineseStr += cnIntUnits[q]; } } chineseStr += cnIntLast; } //小数部分 if (decimalNum != '') { var decLen = decimalNum.length; for (var i = 0; i < decLen; i++) { var n = decimalNum.substr(i, 1); if (n != '0') { chineseStr += cnNums[Number(n)] + cnDecUnits[i]; } } } if (chineseStr == '') { chineseStr += cnNums[0] + cnIntLast + cnInteger; } else if (decimalNum == '') { chineseStr += cnInteger; } return chineseStr; } };
标签:用纸,滨州,val,money,decimalNum,JS,chineseStr,codeValue,var From: https://www.cnblogs.com/xiaoweihongyan/p/17532693.html