money=money.replace(/^(\d*)$/,"$1.");
money=(money+"00").replace(/(\d*\.\d\d)\d*/,"$1");
money=money.replace(".",",");
var re=https://www.jb51.net/(\d)(\d{3},)/;
while(re.test(money)){
money=money.replace(re,"$1,$2");
}
money=money.replace(/,(\d\d)$/,".$1");
var money = money_flag+""+money.replace(/^\./,"0.")
return money;
}
/** 金额格式化 去“,”分隔符 */
function delComma(value) {
var rtnVal = value + "";
return rtnVal.replace(/,/g,"");
}
/**
* 金额格式化 字符串添加小数点
*/
function addPoint(money){
if(/[^0-9\.]/.test(money)){
return money;
}
if(money.length < 3 || money.indexOf(".") > -1){
return money;
}
return money.substring(0,money.length - 2) + "." + money.substring(money.length - 2,money.length);
}
/**
* 金额格式化 数字去小数点
*/
function removePoint(money){
if(/[^0-9\.]/.test(money)){
return money;
}
var valueFloat = parseFloat(money) * 100;
var valueInt = parseInt(valueFloat);
return valueInt;
}
/* 格式化小数点后两位数字 以百分比显示 */
function addPercent(str){
var percent = Math.floor(str * 100) / 100;
percent=(percent.toFixed(2));
return percent+'%';
}
/** 字符格式化 添加 空格 分隔符 */
function addSpace(value) {
if(value == null || value == ""){
return "";
}
var value = value + "";
var tmpStr = "";
while (value.length > 4) {
tmpStr = tmpStr + value.substring(0,4)+ " ";
value = value.substring(4,value.length);
}
tmpStr = tmpStr + value;
return tmpStr;
}
/** 字符格式化 去除 空格 分隔符 */
function removeSpace(value) {
var rtnVal = value + "";
return rtnVal.replace(/ /g,"");
}
// 格式化日期时间字符串
// YYYYMMDD-》YYYY-MM-DD
// YYYYMMDDhhmmss-》YYYY-MM-DD hh:mm:ss
function formatDatetime(oldvalue){
if(oldvalue == null){
return "";
}else if(oldvalue.length == 8){
return oldvalue.substring(0,4) +
"-" + oldvalue.substring(4,6) +
"-" + oldvalue.substring(6,8);
}else if(oldvalue.length == 14){
return oldvalue.substring(0,4) +
"-" + oldvalue.substring(4,6) +
"-" + oldvalue.substring(6,8) +
" " + oldvalue.substring(8,10) +
":" + oldvalue.substring(10,12) +
":" + oldvalue.substring(12,14);
}else if(oldvalue.length == 6){
return oldvalue.substring(0,2) +
":" + oldvalue.substring(2,4) +
":" + oldvalue.substring(4,6);
}else{
return oldvalue;
}
}
function StringToDate(str){
var datainfo=str.split('-');
return new Date(datainfo[0],datainfo[1],datainfo[2]);
}