//中文大写金额转换:转换为列表,最多可转换到亿 function toAmountInWords(val) { var output = null; do { num = parseInt(val); if (isNaN(num)) break; if ((num + '') != (val + '')) { console.warn('传入参数被截断'); }
//中文大写金额转换:转换为列表,最多可转换到亿
function toAmountInWords(val) {
var output = null;
do {
num = parseInt(val);
if (isNaN(num))
break;
if ((num + '') != (val + '')) {
console.warn('传入参数被截断');
}
var list = [
{ value: '', text: '亿' },
{ value: '', text: '仟' },
{ value: '', text: '佰' },
{ value: '', text: '拾' },
{ value: '', text: '万' },
{ value: '', text: '仟' },
{ value: '', text: '佰' },
{ value: '', text: '拾' },
{ value: '', text: '圆' },
];
var chars = ['壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖']
var step = 0;
var div = 100000000;
var d = parseInt(num / div);
if (!!d) {
list[step].value = chars[d - 1];
}
step++;
var temp = num;
for (var i = 0; i < 8; ++i) {
temp = temp - (d * div);
div = div / 10;
d = parseInt(temp / div);
if (!!d) {
if (step > 0)
list[step].value = chars[d - 1];
}
else {
if (list[step - 1].value != '') {
list[step].value = '零';
}
}
step++;
}
output = list;
} while (false);
return output;
}