|
|
@@ -1084,4 +1084,68 @@ function getParam(param) {
|
|
|
var reg = new RegExp("(^|&)"+param+"=([^&]*)(&|$)");
|
|
|
var r = window.location.search.substr(1).match(reg);
|
|
|
if (r != null) return unescape(r[2]); return null;
|
|
|
+}
|
|
|
+// 加法
|
|
|
+function accAdd(arg1, arg2,pointWs) {
|
|
|
+ var r1, r2, max;
|
|
|
+ try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 }
|
|
|
+ try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 }
|
|
|
+ max = Math.pow(10, Math.max(r1, r2))
|
|
|
+ if (isEmpty(pointWs)) {
|
|
|
+ return ((arg1 * max + arg2 * max) / max);
|
|
|
+ } else {
|
|
|
+// return ((arg1 * max + arg2 * max) / max).toFixed(pointWs);
|
|
|
+ return Math.round(((arg1 * max + arg2 * max) / max)*Math.pow(10, pointWs))/Math.pow(10, pointWs);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+// 减法
|
|
|
+function accSub(arg1, arg2,pointWs) {
|
|
|
+ var r1, r2, max, min;
|
|
|
+ try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 }
|
|
|
+ try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 }
|
|
|
+ max = Math.pow(10, Math.max(r1, r2));
|
|
|
+ //动态控制精度长度
|
|
|
+ min = (r1 >= r2) ? r1 : r2;
|
|
|
+ if (isEmpty(pointWs)) {
|
|
|
+ return ((arg1 * max - arg2 * max) / max).toFixed(min);
|
|
|
+ } else {
|
|
|
+// return ((arg1 * max - arg2 * max) / max).toFixed(pointWs);
|
|
|
+ return Math.round(((arg1 * max - arg2 * max) / max)*Math.pow(10, pointWs))/Math.pow(10, pointWs);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 乘法
|
|
|
+// pointWs:小数点位数
|
|
|
+function accMul(arg1, arg2, pointWs) {
|
|
|
+ var max = 0, s1 = arg1.toString(), s2 = arg2.toString();
|
|
|
+ try { max += s1.split(".")[1].length } catch (e) { }
|
|
|
+ try { max += s2.split(".")[1].length } catch (e) { }
|
|
|
+ var resData = Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, max);
|
|
|
+ if(!isEmpty(pointWs)) {
|
|
|
+ // 四舍五入
|
|
|
+// return resData.toFixed(pointWs);
|
|
|
+ return Math.round(resData*Math.pow(10, pointWs))/Math.pow(10, pointWs);
|
|
|
+ }
|
|
|
+ return resData;
|
|
|
+}
|
|
|
+
|
|
|
+// 除法
|
|
|
+//pointWs:小数点位数
|
|
|
+function accDivFun(arg1, arg2, pointWs) {
|
|
|
+ var t1 = 0, t2 = 0, r1, r2;
|
|
|
+ try { t1 = arg1.toString().split(".")[1].length } catch (e) { }
|
|
|
+ try { t2 = arg2.toString().split(".")[1].length } catch (e) { }
|
|
|
+ with (Math) {
|
|
|
+ r1 = Number(arg1.toString().replace(".", ""))
|
|
|
+ r2 = Number(arg2.toString().replace(".", ""))
|
|
|
+ var resData = (r1 / r2) * pow(10, t2 - t1);
|
|
|
+ if(!isEmpty(pointWs)) {
|
|
|
+ // 四舍五入
|
|
|
+// return resData.toFixed(pointWs);
|
|
|
+ return Math.round(resData*Math.pow(10, pointWs))/Math.pow(10, pointWs);
|
|
|
+ }
|
|
|
+ return resData;
|
|
|
+ }
|
|
|
}
|