let NumUtils = {};
// import NP from 'number-precision';

NumUtils.splitThousand = function (value,precision,type) {
    if(isNaN(Number(value + ''))){
        return value;
    }
    if(value == undefined || value == null){
        return "0.00";
    }
    value = this.unSplitThousand(value);
    if(type){
        value = (value == '-' ? value :value);
    }else{
        value = (value == '-' ? value : NP.round(parseFloat(value),precision));
    }
    value = "" + value.toFixed(precision);
    let decimal = value.split('.').length > 1 ? value.split('.')[1] : '';//小数位
    let num = value.split('.')[0];//整数位
    num = num.replace(/\d{1,3}(?=(\d{3})+$)/g, function (s) { return s + ',' });
    
    return num == '-' ? num : (num + (precision>0 ? ('.' + decimal):""));
}

NumUtils.unSplitThousand = function (value) {
    return String(value).indexOf(",")>-1?Number(String(value).replace(/,/g,"")):Number(value);
}
export default NumUtils;