n20-common-lib 2.4.22 → 2.4.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,46 +1,4 @@
|
|
|
1
1
|
const CHINESE_NUMERALS = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖']
|
|
2
|
-
const MONETARY_UNIT = ['圆', '拾', '佰', '仟', '万', '分', '角']
|
|
3
|
-
const DEFAULT_OPTIONS = {
|
|
4
|
-
suffix: '',
|
|
5
|
-
prefix: ''
|
|
6
|
-
}
|
|
7
|
-
const ZEROTEXT = '零'
|
|
8
|
-
const INTTEXT = '整'
|
|
9
|
-
|
|
10
|
-
/**格式数据,
|
|
11
|
-
* 排除xx., xx.00, xx.x0等无用的尾数0
|
|
12
|
-
* 排除00000.xx
|
|
13
|
-
* */
|
|
14
|
-
export const formatter = (num) => {
|
|
15
|
-
try {
|
|
16
|
-
num = Number(num)
|
|
17
|
-
|
|
18
|
-
if (isNaN(num)) {
|
|
19
|
-
return NaN
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
num = num.toString()
|
|
23
|
-
|
|
24
|
-
if (num.indexOf('.') > 1) {
|
|
25
|
-
const handler = (num) => {
|
|
26
|
-
const lastIndex = num.length - 1
|
|
27
|
-
|
|
28
|
-
if (['0', '.'].includes(num[lastIndex])) {
|
|
29
|
-
num = num.substring(0, lastIndex)
|
|
30
|
-
num = handler(num)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return num
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return handler(num)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return num
|
|
40
|
-
} catch (e) {
|
|
41
|
-
console.error(e)
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
2
|
|
|
45
3
|
/**
|
|
46
4
|
*
|
|
@@ -56,6 +14,9 @@ export const convert = (amount) => {
|
|
|
56
14
|
const decimals = ['角', '分']
|
|
57
15
|
const digits = ['仟', '佰', '拾', '', '块']
|
|
58
16
|
|
|
17
|
+
if (typeof amount === 'string') {
|
|
18
|
+
amount = amount.replace(/,/g, '')
|
|
19
|
+
}
|
|
59
20
|
let [integerPart, decimalPart] = String(amount).split('.')
|
|
60
21
|
let result = ''
|
|
61
22
|
|