@netang/quasar 0.0.27 → 0.0.28
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.
|
@@ -121,6 +121,12 @@ export default {
|
|
|
121
121
|
// 是否为人民币的分转元(值为分, 显示为元)
|
|
122
122
|
// 如果为 true, 则 min / max / step 的值默认的单位为人民币的分
|
|
123
123
|
centToYuan: Boolean,
|
|
124
|
+
// 精度舍入模式(默认: 向下取整)
|
|
125
|
+
// 参考文档: https://mikemcl.github.io/bignumber.js/#constructor-properties
|
|
126
|
+
roundMode: {
|
|
127
|
+
type: Number,
|
|
128
|
+
default: BigNumber.ROUND_DOWN,
|
|
129
|
+
},
|
|
124
130
|
},
|
|
125
131
|
|
|
126
132
|
/**
|
|
@@ -347,18 +353,14 @@ export default {
|
|
|
347
353
|
}
|
|
348
354
|
|
|
349
355
|
// 如果设置了小数位数
|
|
350
|
-
if (currentDecimalLength.value
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
if (val.dp() > currentDecimalLength.value) {
|
|
354
|
-
// 将值向下舍入 xx 位精度(如 68.345 -> 68.34)
|
|
355
|
-
val = val.dp(currentDecimalLength.value, BigNumber.ROUND_DOWN)
|
|
356
|
-
}
|
|
356
|
+
if (currentDecimalLength.value) {
|
|
357
|
+
// 将值舍入 xx 位精度(如 68.345 -> 68.34)
|
|
358
|
+
val = val.dp(currentDecimalLength.value, props.roundMode)
|
|
357
359
|
|
|
358
360
|
// 否则值为整数
|
|
359
361
|
} else {
|
|
360
|
-
//
|
|
361
|
-
val = val.integerValue(
|
|
362
|
+
// 将值取整
|
|
363
|
+
val = val.integerValue(props.roundMode)
|
|
362
364
|
}
|
|
363
365
|
}
|
|
364
366
|
|
|
@@ -388,12 +390,8 @@ export default {
|
|
|
388
390
|
if (props.centToYuan) {
|
|
389
391
|
// 乘以 100
|
|
390
392
|
val = val.times(100)
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
if (val.dp()) {
|
|
394
|
-
// 将值向下取整
|
|
395
|
-
val = val.integerValue(BigNumber.ROUND_DOWN)
|
|
396
|
-
}
|
|
393
|
+
// 再取整(分必须是整数)
|
|
394
|
+
.integerValue(props.roundMode)
|
|
397
395
|
}
|
|
398
396
|
|
|
399
397
|
// 将值转为数字
|