Browse Source

添加审批人错误问题

MaiXinRong 4 năm trước cách đây
mục cha
commit
b9ac2df512

+ 18 - 0
app/public/js/global.js

@@ -965,3 +965,21 @@ Number.prototype.format2Str = function (pattern) {
     }
     return retstr.replace(/^,+/,'').replace(/\.$/,'');
 };
+
+function transFormToChinese(num) {
+    const changeNum = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
+    const unit = ["", "十", "百", "千", "万"];
+    num = parseInt(num);
+    let getWan = (temp) => {
+        let strArr = temp.toString().split("").reverse();
+        let newNum = "";
+        for (var i = 0; i < strArr.length; i++) {
+            newNum = (i == 0 && strArr[i] == 0 ? "" : (i > 0 && strArr[i] == 0 && strArr[i - 1] == 0 ? "" : changeNum[strArr[i]] + (strArr[i] == 0 ? unit[0] : unit[i]))) + newNum;
+        }
+        return strArr.length === 2 && newNum.indexOf("一十") !== -1 ? newNum.replace('一十', '十') : newNum;
+    }
+    let overWan = Math.floor(num / 10000);
+    let noWan = num % 10000;
+    if (noWan.toString().length < 4) noWan = "0" + noWan;
+    return overWan ? getWan(overWan) + "万" + getWan(noWan) : getWan(num);
+}

+ 0 - 5
app/public/js/ledger.js

@@ -1820,7 +1820,6 @@ $(document).ready(function() {
                     return;
                 }
 
-                //const node = treeOperationObj.getSelectNode(ledgerSpread.getActiveSheet());
                 const node = posOperationObj.ledgerTreeNode;
                 if (!node) {
                     toastr.error('数据错误,请选择台账节点后再试');
@@ -1830,10 +1829,6 @@ $(document).ready(function() {
                     toastr.error('父节点不可插入计量单元');
                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
                     return;
-                } else if (newText && newText !== '' && (!node.b_code || node.b_code === '')) {
-                    toastr.error('项目节不可插入计量单元');
-                    SpreadJsObj.reLoadRowData(info.sheet, info.row);
-                    return;
                 }
 
                 const data = {};

+ 0 - 169
app/public/js/number-precision.js

@@ -1,169 +0,0 @@
-var NP = (function (exports) {
-    'use strict';
-
-    /**
-     * @desc 解决浮动运算问题,避免小数点后产生多位数和计算精度损失。
-     * 问题示例:2.3 + 2.4 = 4.699999999999999,1.0 - 0.9 = 0.09999999999999998
-     */
-    /**
-     * 把错误的数据转正
-     * strip(0.09999999999999998)=0.1
-     */
-    function strip(num, precision) {
-        if (precision === void 0) { precision = 12; }
-        return +parseFloat(num.toPrecision(precision));
-    }
-    /**
-     * Return digits length of a number
-     * @param {*number} num Input number
-     */
-    function digitLength(num) {
-        // Get digit length of e
-        var eSplit = num.toString().split(/[eE]/);
-        var len = (eSplit[0].split('.')[1] || '').length - (+(eSplit[1] || 0));
-        return len > 0 ? len : 0;
-    }
-    function powLength(num) {
-        var eSplit = num.toString().split(/[eE]/);
-        var rs = num.toString().reverse();
-        var rs1 = rs.replace('/^0+/g', '');
-        return rs.length - rs1.length;
-    }
-    /**
-     * 把小数转成整数,支持科学计数法。如果是小数则放大成整数
-     * @param {*number} num 输入数
-     */
-    function float2Fixed(num) {
-        if (num.toString().indexOf('e') === -1) {
-            return Number(num.toString().replace('.', ''));
-        }
-        var dLen = digitLength(num);
-        return dLen > 0 ? strip(num * Math.pow(10, dLen)) : num;
-    }
-    /**
-     * 检测数字是否越界,如果越界给出提示
-     * @param {*number} num 输入数
-     */
-    function checkBoundary(num) {
-        if (_boundaryCheckingState) {
-            if (num > Number.MAX_SAFE_INTEGER || num < Number.MIN_SAFE_INTEGER) {
-                console.warn(num + " is beyond boundary when transfer to integer, the results may not be accurate");
-            }
-        }
-    }
-    /**
-     * 精确乘法
-     */
-    function times(num1, num2) {
-        var others = [];
-        for (var _i = 2; _i < arguments.length; _i++) {
-            others[_i - 2] = arguments[_i];
-        }
-        if (others.length > 0) {
-            return times.apply(void 0, [times(num1, num2), others[0]].concat(others.slice(1)));
-        }
-        var num1Changed = float2Fixed(num1);
-        var num2Changed = float2Fixed(num2);
-        var baseNum = digitLength(num1) + digitLength(num2);
-        var leftValue = num1Changed * num2Changed;
-        checkBoundary(leftValue);
-        return leftValue / Math.pow(10, baseNum);
-    }
-    /**
-     * 精确加法
-     */
-    function plus(num1, num2) {
-        var others = [];
-        for (var _i = 2; _i < arguments.length; _i++) {
-            others[_i - 2] = arguments[_i];
-        }
-        if (others.length > 0) {
-            return plus.apply(void 0, [plus(num1, num2), others[0]].concat(others.slice(1)));
-        }
-        var baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2)));
-        return (times(num1, baseNum) + times(num2, baseNum)) / baseNum;
-        //return (num1 + num2) / baseNum;
-    }
-    /**
-     * 精确减法
-     */
-    function minus(num1, num2) {
-        var others = [];
-        for (var _i = 2; _i < arguments.length; _i++) {
-            others[_i - 2] = arguments[_i];
-        }
-        if (others.length > 0) {
-            return minus.apply(void 0, [minus(num1, num2), others[0]].concat(others.slice(1)));
-        }
-        var digit1 = digitLength(num1);
-        var digit2 = digitLength(num2);
-        var baseNum = Math.pow(10, Math.max(digit1, digit2));
-        return round((times(num1, baseNum) - times(num2, baseNum)) / baseNum, digit1>=digit2 ? digit1 : digit2);
-    }
-    /**
-     * 精确除法
-     */
-    function divide(num1, num2) {
-        var others = [];
-        for (var _i = 2; _i < arguments.length; _i++) {
-            others[_i - 2] = arguments[_i];
-        }
-        if (others.length > 0) {
-            return divide.apply(void 0, [divide(num1, num2), others[0]].concat(others.slice(1)));
-        }
-        var num1Changed = float2Fixed(num1);
-        var num2Changed = float2Fixed(num2);
-        checkBoundary(num1Changed);
-        checkBoundary(num2Changed);
-        return times((num1Changed / num2Changed), Math.pow(10, digitLength(num2) - digitLength(num1)));
-    }
-    /**
-     * 四舍五入
-     */
-    function round(num, ratio) {
-        var base = Math.pow(10, ratio);
-        return divide(Math.round(times(num, base)), base);
-    }
-    var _boundaryCheckingState = true;
-    /**
-     * 是否进行边界检查,默认开启
-     * @param flag 标记开关,true 为开启,false 为关闭,默认为 true
-     */
-    function enableBoundaryChecking(flag) {
-        if (flag === void 0) { flag = true; }
-        _boundaryCheckingState = flag;
-    }
-    var index = { strip: strip, plus: plus, minus: minus, times: times, divide: divide, round: round, digitLength: digitLength, float2Fixed: float2Fixed, enableBoundaryChecking: enableBoundaryChecking };
-
-    exports.strip = strip;
-    exports.plus = plus;
-    exports.minus = minus;
-    exports.times = times;
-    exports.divide = divide;
-    exports.round = round;
-    exports.digitLength = digitLength;
-    exports.float2Fixed = float2Fixed;
-    exports.enableBoundaryChecking = enableBoundaryChecking;
-    exports['default'] = index;
-
-    return exports;
-
-}({}));
-
-function transFormToChinese(num) {
-    const changeNum = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
-    const unit = ["", "十", "百", "千", "万"];
-    num = parseInt(num);
-    let getWan = (temp) => {
-        let strArr = temp.toString().split("").reverse();
-        let newNum = "";
-        for (var i = 0; i < strArr.length; i++) {
-            newNum = (i == 0 && strArr[i] == 0 ? "" : (i > 0 && strArr[i] == 0 && strArr[i - 1] == 0 ? "" : changeNum[strArr[i]] + (strArr[i] == 0 ? unit[0] : unit[i]))) + newNum;
-        }
-        return strArr.length === 2 && newNum.indexOf("一十") !== -1 ? newNum.replace('一十', '十') : newNum;
-    }
-    let overWan = Math.floor(num / 10000);
-    let noWan = num % 10000;
-    if (noWan.toString().length < 4) noWan = "0" + noWan;
-    return overWan ? getWan(overWan) + "万" + getWan(noWan) : getWan(num);
-}

+ 0 - 1
app/view/wap/list.ejs

@@ -69,7 +69,6 @@
 <script src="/public/js/bootstrap/bootstrap.min.js"></script>
 <script src="/public/js/lodash.js"></script>
 <script src="/public/js/lz-string/lz-string.js"></script>
-<script src="/public/js/number-precision.js"></script>
 <script src="/public/js/cookies.js"></script>
 <script src="/public/js/wap/global.js"></script>
 <script src="/public/js/decimal.min.js"></script>

+ 1 - 1
package.json

@@ -35,7 +35,6 @@
         "node-schedule": "^1.3.2",
         "node-uuid": "^1.4.8",
         "node-xlsx": "^0.12.0",
-        "number-precision": "^1.3.1",
         "qr-image": "^3.2.0",
         "stream-to-array": "^2.3.0",
         "stream-wormhole": "^1.1.0",
@@ -55,6 +54,7 @@
         "egg-mock": "^3.14.0",
         "eslint": "^4.17.0",
         "eslint-config-egg": "^5.0.0",
+        "number-precision": "^1.3.1",
         "pdfkit": "^0.8.2",
         "webstorm-disable-index": "^1.2.0"
     },

+ 0 - 1
test/app/extend/helper.test.js

@@ -10,7 +10,6 @@
 const { app, assert } = require('egg-mock/bootstrap');
 const _ = require('lodash');
 const math = require('mathjs');
-const np = require('number-precision');
 const decimal = require('decimal.js');
 
 describe('test/app/extend/helper.test.js', () => {