Merge branch 'dev' of codeup.aliyun.com:61c14a7efa282c88e103c23f/oak-domain into dev
This commit is contained in:
commit
f641a86710
|
|
@ -2,5 +2,5 @@ declare const ToCent: (float: number) => number;
|
||||||
declare const ToYuan: (int: number) => number;
|
declare const ToYuan: (int: number) => number;
|
||||||
declare const StringToCent: (value: string, allowNegative?: true) => number | undefined;
|
declare const StringToCent: (value: string, allowNegative?: true) => number | undefined;
|
||||||
declare const CentToString: (value: number) => string | undefined;
|
declare const CentToString: (value: number) => string | undefined;
|
||||||
declare const ThousandCont: (value: number) => string | undefined;
|
declare const ThousandCont: (value: number, decimalPlaces?: number) => string | undefined;
|
||||||
export { ToCent, ToYuan, StringToCent, CentToString, ThousandCont };
|
export { ToCent, ToYuan, StringToCent, CentToString, ThousandCont };
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ const CentToString = (value) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
exports.CentToString = CentToString;
|
exports.CentToString = CentToString;
|
||||||
const ThousandCont = (value) => {
|
const ThousandCont = (value, decimalPlaces) => {
|
||||||
let value1 = `${value}`;
|
let value1 = `${value}`;
|
||||||
const numArr = value1.split('.');
|
const numArr = value1.split('.');
|
||||||
value1 = numArr[0];
|
value1 = numArr[0];
|
||||||
|
|
@ -34,7 +34,18 @@ const ThousandCont = (value) => {
|
||||||
if (value1) {
|
if (value1) {
|
||||||
result = value1 + result;
|
result = value1 + result;
|
||||||
}
|
}
|
||||||
|
if (decimalPlaces && decimalPlaces > 0) {
|
||||||
|
if (numArr[1]) {
|
||||||
|
const decimalPart = numArr[1].padEnd(decimalPlaces, '0').slice(0, decimalPlaces);
|
||||||
|
result = result + '.' + decimalPart;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result = result + '.' + '0'.repeat(decimalPlaces);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
result = numArr[1] ? result + '.' + numArr[1] : result;
|
result = numArr[1] ? result + '.' + numArr[1] : result;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
exports.ThousandCont = ThousandCont;
|
exports.ThousandCont = ThousandCont;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ const CentToString: (value: number) => string | undefined = (value) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const ThousandCont: (value: number) => string | undefined = (value) => {
|
const ThousandCont: (value: number, decimalPlaces?: number) => string | undefined = (value, decimalPlaces) => {
|
||||||
let value1 = `${value}`;
|
let value1 = `${value}`;
|
||||||
const numArr = value1.split('.');
|
const numArr = value1.split('.');
|
||||||
value1 = numArr[0];
|
value1 = numArr[0];
|
||||||
|
|
@ -34,7 +34,16 @@ const ThousandCont: (value: number) => string | undefined = (value) => {
|
||||||
if (value1) {
|
if (value1) {
|
||||||
result = value1 + result;
|
result = value1 + result;
|
||||||
}
|
}
|
||||||
|
if (decimalPlaces && decimalPlaces > 0) {
|
||||||
|
if (numArr[1]) {
|
||||||
|
const decimalPart = numArr[1].padEnd(decimalPlaces, '0').slice(0, decimalPlaces);
|
||||||
|
result = result + '.' + decimalPart;
|
||||||
|
} else {
|
||||||
|
result = result + '.' + '0'.repeat(decimalPlaces);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
result = numArr[1] ? result + '.' + numArr[1] : result;
|
result = numArr[1] ? result + '.' + numArr[1] : result;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue