@bchr/bchr-front-lib 0.3.135 → 0.3.138

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.
@@ -68,24 +68,37 @@ window.AppFormulaFunctions = {
68
68
 
69
69
  return null;
70
70
  },
71
- calcOtherWaByBaseWa: function calcOtherWaByBaseWa(baseWa, percent, calcType) {
71
+
72
+ /**
73
+ * 根据基本工资计算其他工资项
74
+ * @param baseWa 级别薪资
75
+ * @param percent 百分比
76
+ * @param digitsNum 保留小数点后几位 (默认0)
77
+ * @param calcType 计算方式(默认向上取整)
78
+ * @returns {null|number}
79
+ */
80
+ calcOtherWaByBaseWa: function calcOtherWaByBaseWa(baseWa, percent, digitsNum, calcType) {
72
81
  if (!baseWa || !percent) {
73
82
  console.log("calcOtherWaByBaseWa param baseWa: " + baseWa + ",percent" + percent);
74
83
  return null;
75
84
  }
76
85
 
77
- var wa = Math.floor(parseFloat(baseWa * 100 * percent));
86
+ if (!digitsNum) {
87
+ digitsNum = 0;
88
+ }
89
+
90
+ var wa = parseFloat(baseWa * Math.pow(10, digitsNum) * percent);
78
91
 
79
92
  if (!calcType) {
80
93
  calcType = 3;
81
94
  }
82
95
 
83
96
  if (calcType == 1) {
84
- return Math.ceil(wa) / 100; //向上取整
97
+ return Math.round(wa) / Math.pow(10, digitsNum); //四舍五入
85
98
  } else if (calcType == 2) {
86
- return Math.floor(wa) / 100; //向下取整
99
+ return Math.floor(wa) / Math.pow(10, digitsNum); //向下取整
87
100
  } else {
88
- return Math.round(wa) / 100; //四舍五入
101
+ return Math.ceil(wa) / Math.pow(10, digitsNum); //向上取整
89
102
  }
90
103
  },
91
104
  //生活补贴标准级别
@@ -1238,6 +1238,10 @@ var FormForModify = /*#__PURE__*/function (_React$Component) {
1238
1238
  if (callback && typeof callback === "function") {
1239
1239
  callback(value, label, extra, ref);
1240
1240
  }
1241
+
1242
+ if (value) {
1243
+ this.formItemOnChangeForFormula(config, value);
1244
+ }
1241
1245
  }
1242
1246
  }, {
1243
1247
  key: "showModal",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bchr/bchr-front-lib",
3
- "version": "0.3.135",
3
+ "version": "0.3.138",
4
4
  "description": "bchr front lib",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -49,3 +49,4 @@
49
49
  "react-loadable": "^5.5.0"
50
50
  }
51
51
  }
52
+
@@ -73,24 +73,36 @@ window.AppFormulaFunctions = {
73
73
  return null;
74
74
  },
75
75
 
76
- calcOtherWaByBaseWa(baseWa, percent, calcType) {
76
+ /**
77
+ * 根据基本工资计算其他工资项
78
+ * @param baseWa 级别薪资
79
+ * @param percent 百分比
80
+ * @param digitsNum 保留小数点后几位 (默认0)
81
+ * @param calcType 计算方式(默认向上取整)
82
+ * @returns {null|number}
83
+ */
84
+ calcOtherWaByBaseWa(baseWa, percent, digitsNum, calcType) {
77
85
  if (!baseWa || !percent) {
78
86
  console.log("calcOtherWaByBaseWa param baseWa: " + baseWa + ",percent" + percent);
79
87
  return null;
80
88
  }
81
89
 
82
- let wa = Math.floor(parseFloat(baseWa * 100 * percent));
90
+ if (!digitsNum) {
91
+ digitsNum = 0;
92
+ }
93
+
94
+ let wa = parseFloat(baseWa * Math.pow(10, digitsNum) * percent);
83
95
 
84
96
  if (!calcType) {
85
97
  calcType = 3;
86
98
  }
87
99
 
88
100
  if (calcType == 1) {
89
- return Math.ceil(wa)/100; //向上取整
101
+ return Math.round(wa)/Math.pow(10, digitsNum); //四舍五入
90
102
  } else if (calcType == 2) {
91
- return Math.floor(wa)/100; //向下取整
103
+ return Math.floor(wa)/Math.pow(10, digitsNum); //向下取整
92
104
  } else {
93
- return Math.round(wa)/100; //四舍五入
105
+ return Math.ceil(wa)/Math.pow(10, digitsNum); //向上取整
94
106
  }
95
107
  },
96
108
 
@@ -1058,6 +1058,10 @@ class FormForModify extends React.Component{
1058
1058
  if (callback && typeof callback === "function") {
1059
1059
  callback(value, label, extra, ref);
1060
1060
  }
1061
+
1062
+ if (value) {
1063
+ this.formItemOnChangeForFormula(config, value)
1064
+ }
1061
1065
  }
1062
1066
 
1063
1067
  showModal(config) {