doway-coms 2.11.67 → 2.11.68

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doway-coms",
3
- "version": "2.11.67",
3
+ "version": "2.11.68",
4
4
  "description": "doway组件库",
5
5
  "author": "dowaysoft",
6
6
  "main": "packages/index.js",
@@ -442,6 +442,14 @@ export function secondDisplayTime(value) {
442
442
  * @param {*} colInfo
443
443
  */
444
444
  export function gridDefaultValueDisplay(rowInfo,colInfo){
445
+
446
+ //获取全局配置,数字是否显示小数点补零
447
+ let girdNumberPointZero = 2
448
+ if(store.getters.baseSetting && store.getters.baseSetting.pointZero){
449
+ girdNumberPointZero = XEUtils.toInteger(store.getters.baseSetting.pointZero)
450
+ }
451
+
452
+
445
453
  let colControlType = colInfo.params.controlType
446
454
  let displayValue = rowInfo[colInfo.field]
447
455
  if(displayValue===null){
@@ -475,11 +483,23 @@ export function gridDefaultValueDisplay(rowInfo,colInfo){
475
483
  if(colInfo.params.thousandDigit===true){
476
484
  displayValue = displayValue.toLocaleString('en-US',{ maximumFractionDigits: 10 })
477
485
  }
486
+ //查看是否小数点补零位数
487
+ if(girdNumberPointZero>0){
488
+ girdNumberPointZero = girdNumberPointZero>XEUtils.toInteger(colInfo.params.precision)?
489
+ girdNumberPointZero:XEUtils.toInteger(colInfo.params.precision)
490
+ displayValue = setNumberZero(displayValue,girdNumberPointZero)
491
+ }
478
492
  displayValue = displayValue+'%'
479
493
  }else{
480
494
  if(colInfo.params.thousandDigit===true){
481
495
  displayValue = displayValue.toLocaleString('en-US',{ maximumFractionDigits: 10 })
482
496
  }
497
+ //查看是否小数点补零位数
498
+ if(girdNumberPointZero>0){
499
+ girdNumberPointZero = girdNumberPointZero>XEUtils.toInteger(colInfo.params.precision)?
500
+ girdNumberPointZero:XEUtils.toInteger(colInfo.params.precision)
501
+ displayValue = setNumberZero(displayValue,girdNumberPointZero)
502
+ }
483
503
  }
484
504
  }
485
505
 
@@ -493,4 +513,31 @@ export function gridDefaultValueDisplay(rowInfo,colInfo){
493
513
  break
494
514
  }
495
515
  return displayValue
516
+ }
517
+ export function setNumberZero(value,numberPointZero){
518
+ //转成字符串,防止是数字
519
+ // 转成字符串,防止是数字
520
+ //判断是否存在小数点,如果不存在就直接补小数点和对应的0,如果存在就判断小数点后面存在几个字符,如果小于设定的字符数就补零
521
+ let strValue = value + '';
522
+
523
+ // 判断是否存在小数点
524
+ const decimalIndex = strValue.indexOf('.');
525
+
526
+ if (decimalIndex === -1) {
527
+ // 不存在小数点,直接补小数点和对应的0
528
+ if (numberPointZero > 0) {
529
+ strValue += '.' + '0'.repeat(numberPointZero);
530
+ }
531
+ } else {
532
+ // 存在小数点,判断小数点后的位数
533
+ const decimalPart = strValue.substring(decimalIndex + 1);
534
+ const decimalLength = decimalPart.length;
535
+
536
+ if (decimalLength < numberPointZero) {
537
+ // 不足位数则补零
538
+ strValue += '0'.repeat(numberPointZero - decimalLength);
539
+ }
540
+ }
541
+ return strValue;
542
+
496
543
  }