// 参照Elmenent ui statistic组件
function dispose(value = '', precision = null, groupSeparator = '', rate = 1000 ) {
if (!isNumber(value)) return false;
let [integer, decimal] = String(value).split('.');
if (precision) {
decimal = `${decimal || ''}${(1)
.toFixed(precision)
.replace('.', '')
.slice(1)}`;
decimal = decimal.slice(0, precision);
}
let result = 0;
if (groupSeparator) {
integer = this.magnification(integer, rate, groupSeparator);
}
result = [integer, decimal].join(
decimal ? this.decimalSeparator : ''
);
this.disposeValue = result;
return result;
}
function magnification(num, mulriple = 1000, groupSeparator = ',') {
// magnification factor
const level = String(mulriple).length - 1;
const reg = new RegExp(`\\d{1,${level}}(?=(\\d{${level}})+$)`, 'g');
const result = String(num)
.replace(reg, '$&,')
.split(',')
.join(groupSeparator);
return result;
}