Commit a7d9b350fb205c6f1c061ca79e1cff3ef93e8cc4
Merge remote-tracking branch 'origin/master'
Showing
1 changed file
with
21 additions
and
0 deletions
src/main/webapp/static/js/jsutil.js
| @@ -231,6 +231,27 @@ jsutil.isVehicleNumber=function(vehicleNumber){ | @@ -231,6 +231,27 @@ jsutil.isVehicleNumber=function(vehicleNumber){ | ||
| 231 | return result; | 231 | return result; |
| 232 | } | 232 | } |
| 233 | 233 | ||
| 234 | +/** | ||
| 235 | + * 金额分转元格式显示.<br/> | ||
| 236 | + */ | ||
| 237 | +jsutil.fenToYuan=function(fen){ | ||
| 238 | + if( fen != null && fen.length>0 && isNaN(fen) == false){ | ||
| 239 | + return ""; | ||
| 240 | + } | ||
| 241 | + var yuan = Math.round(fen); | ||
| 242 | + yuan = yuan.toString() | ||
| 243 | + var before = yuan.substr(0, yuan.length - 2); | ||
| 244 | + var end = yuan.substr(yuan.length - 2, 2); | ||
| 245 | + yuan = before + "." + end; | ||
| 246 | + var re = /(-?\d+)(\d{3})/; | ||
| 247 | + while (re.test(yuan)) { | ||
| 248 | + yuan = yuan.replace(re, "$1,$2") | ||
| 249 | + } | ||
| 250 | + return yuan; | ||
| 251 | +} | ||
| 252 | + | ||
| 253 | + | ||
| 254 | + | ||
| 234 | 255 | ||
| 235 | 256 | ||
| 236 | 257 |