Browse Source

code sync from cost

TonyKang 7 years ago
parent
commit
c73c33faf1

+ 16 - 14
modules/reports/rpt_component/helper/jpc_helper_flow_tab.js

@@ -2,33 +2,35 @@ let JV = require('../jpc_value_define');
 let JpcCommonHelper = require('./jpc_helper_common');
 
 let JpcFlowTabHelper = {
-    getMaxRowsPerPage: function(bands, rptTpl) {
+    getMaxRowsPerPage: function(bands, rptTpl, isEx) {
         let rst = 1;
-        let tab = rptTpl[JV.NODE_FLOW_INFO][JV.NODE_FLOW_CONTENT];
+        let FLOW_INFO_STR = (!isEx)?JV.NODE_FLOW_INFO:JV.NODE_FLOW_INFO_EX;
+        let tab = rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT];
         let band = bands[tab[JV.PROP_BAND_NAME]];
         if (band) {
             let maxFieldMeasure = 1.0;
             if (JV.CAL_TYPE_ABSTRACT === JpcCommonHelper.getPosCalculationType(tab[JV.PROP_CALCULATION])) {
                 let unitFactor = JpcCommonHelper.getUnitFactor(rptTpl);
-                maxFieldMeasure = 1.0 * rptTpl[JV.NODE_FLOW_INFO][JV.NODE_FLOW_CONTENT][JV.PROP_CMN_HEIGHT] * unitFactor;
+                maxFieldMeasure = 1.0 * rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT][JV.PROP_CMN_HEIGHT] * unitFactor;
             } else {
-                maxFieldMeasure = (band.Bottom - band.Top) * rptTpl[JV.NODE_FLOW_INFO][JV.NODE_FLOW_CONTENT][JV.PROP_CMN_HEIGHT] / JV.HUNDRED_PERCENT;
+                maxFieldMeasure = (band.Bottom - band.Top) * rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT][JV.PROP_CMN_HEIGHT] / JV.HUNDRED_PERCENT;
             }
             rst = Math.floor((band.Bottom - band.Top) / maxFieldMeasure);
         }
         return rst;
     },
-    getActualContentAreaHeight: function(bands, rptTpl, segments, page) {
+    getActualContentAreaHeight: function(bands, rptTpl, segments, page, isEx) {
         let rst = 1;
-        let tab = rptTpl[JV.NODE_FLOW_INFO][JV.NODE_FLOW_CONTENT];
+        let FLOW_INFO_STR = (!isEx)?JV.NODE_FLOW_INFO:JV.NODE_FLOW_INFO_EX;
+        let tab = rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT];
         let band = bands[tab[JV.PROP_BAND_NAME]];
         if (band) {
             let maxFieldMeasure = 1.0;
             if (JV.CAL_TYPE_ABSTRACT === JpcCommonHelper.getPosCalculationType(tab[JV.PROP_CALCULATION])) {
                 let unitFactor = JpcCommonHelper.getUnitFactor(rptTpl);
-                maxFieldMeasure = 1.0 * rptTpl[JV.NODE_FLOW_INFO][JV.NODE_FLOW_CONTENT][JV.PROP_CMN_HEIGHT] * unitFactor;
+                maxFieldMeasure = 1.0 * rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT][JV.PROP_CMN_HEIGHT] * unitFactor;
             } else {
-                maxFieldMeasure = (band.Bottom - band.Top) * rptTpl[JV.NODE_FLOW_INFO][JV.NODE_FLOW_CONTENT][JV.PROP_CMN_HEIGHT] / JV.HUNDRED_PERCENT;
+                maxFieldMeasure = (band.Bottom - band.Top) * rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT][JV.PROP_CMN_HEIGHT] / JV.HUNDRED_PERCENT;
             }
             if (segments.length >= page) {
                 rst = segments[page - 1].length * maxFieldMeasure;
@@ -36,17 +38,17 @@ let JpcFlowTabHelper = {
         }
         return rst;
     },
-    chkSegEnd: function (bands, rptTpl, sortedSequence, segIdx, preRec, nextRec) {
-        let me = this, rst = true;
+    chkSegEnd: function (bands, rptTpl, sortedSequence, segIdx, preRec, nextRec, isEx) {
+        let me = this;
         let remainAmt = preRec + nextRec - sortedSequence[segIdx].length;
-        rst = me.hasEnoughSpace(rptTpl, bands, remainAmt);
-        return rst;
+        return me.hasEnoughSpace(rptTpl, bands, remainAmt, isEx);
     },
-    hasEnoughSpace: function (rptTpl, bands, remainAmt) {
+    hasEnoughSpace: function (rptTpl, bands, remainAmt, isEx) {
         if (remainAmt < 0) return false;
         let rst = true, measurement = 1.0, douDiffForCompare = 0.00001;
         let unitFactor = JpcCommonHelper.getUnitFactor(rptTpl);
-        let tab = rptTpl[JV.NODE_FLOW_INFO][JV.NODE_FLOW_CONTENT];
+        let FLOW_INFO_STR = (!isEx)?JV.NODE_FLOW_INFO:JV.NODE_FLOW_INFO_EX;
+        let tab = rptTpl[FLOW_INFO_STR][JV.NODE_FLOW_CONTENT];
         let band = bands[tab[JV.PROP_BAND_NAME]];
         if (band !== null && band !== undefined) {
             measurement = 1.0 * tab[JV.PROP_CMN_HEIGHT] * unitFactor;

+ 4 - 3
modules/reports/rpt_component/jpc_data.js

@@ -1,4 +1,5 @@
 let JV = require('./jpc_value_define');
+let jpc_common_helper = require("./helper/jpc_helper_common");
 let JpcData = {
     createNew: function() {
         let JpcDataRst = {};
@@ -11,14 +12,14 @@ let JpcData = {
                 let masterIDs = [];
                 for (let i = 0; i < rptTpl[JV.NODE_FIELD_MAP][MASTER_FIELD_STR].length; i++) {
                     let mstFieldObj = rptTpl[JV.NODE_FIELD_MAP][MASTER_FIELD_STR][i];
-                    if ((mstFieldObj[JV.PROP_IS_ID]) && (mstFieldObj[JV.PROP_IS_ID] === 'T')) {
+                    if (jpc_common_helper.getBoolean(mstFieldObj[JV.PROP_IS_ID])) {
                         masterIDs.push({"idx": i, "seq": mstFieldObj[JV.PROP_ID_SEQ]});
                     }
                 }
                 let detailIDs = [];
                 for (let i = 0; i < rptTpl[JV.NODE_FIELD_MAP][DETAIL_FIELD_STR].length; i++) {
                     let dtlFieldObj = rptTpl[JV.NODE_FIELD_MAP][DETAIL_FIELD_STR][i];
-                    if ((dtlFieldObj[JV.PROP_IS_ID]) && (dtlFieldObj[JV.PROP_IS_ID] === 'T')) {
+                    if (jpc_common_helper.getBoolean(dtlFieldObj[JV.PROP_IS_ID])) {
                         detailIDs.push({"idx": i, "seq": dtlFieldObj[JV.PROP_ID_SEQ]});
                     }
                 }
@@ -100,6 +101,6 @@ let JpcData = {
         };
         return JpcDataRst;
     }
-}
+};
 
 module.exports = JpcData;

+ 9 - 0
modules/reports/rpt_component/jpc_ex.js

@@ -85,10 +85,14 @@ JpcExSrv.prototype.createNew = function(){
         if (rptTpl[JV.NODE_FLOW_INFO]) {
             me.flowTab = JpcFlowTab.createNew();
             me.flowTab.initialize(false);
+            me.isFollowMode = false;
         }
         if (rptTpl[JV.NODE_FLOW_INFO_EX]) {
             me.flowTabEx = JpcFlowTab.createNew();
             me.flowTabEx.initialize(true);
+            if (rptTpl[JV.NODE_FLOW_INFO_EX][JV.PROP_FLOW_EX_DISPLAY_MODE] === JV.DISPLAY_MODE_FOLLOW) {
+                me.isFollowMode = true;
+            }
         }
         if (rptTpl[JV.NODE_BILL_INFO]) {
             me.billTab = JpcBillTab.createNew();
@@ -137,6 +141,11 @@ JpcExSrv.prototype.createNew = function(){
     JpcResult.paging = function(rptTpl, dataObj, defProperties, option) {
         let me = this, dftPagingOption = option||JV.PAGING_OPTION_NORMAL;
         if (me.flowTab) {
+            if (me.isFollowMode) {
+                //
+            } else {
+                //
+            }
             me.totalPages = me.flowTab.preSetupPages(rptTpl, dataObj, defProperties, dftPagingOption);
             if (me.flowTabEx) {
                 me.exTotalPages = me.flowTabEx.preSetupPages(rptTpl, dataObj, defProperties, dftPagingOption);

+ 3 - 3
modules/reports/rpt_component/jpc_flow_tab.js

@@ -104,7 +104,7 @@ JpcFlowTabSrv.prototype.createNew = function(){
             }
             function private_resetBandArea() {
                 JpcBandHelper.setBandArea(bands, rptTpl, pageStatus, !me.isEx, me.isEx);
-                maxRowRec = JpcFlowTabHelper.getMaxRowsPerPage(bands, rptTpl);
+                maxRowRec = JpcFlowTabHelper.getMaxRowsPerPage(bands, rptTpl, me.isEx);
             }
             for (let segIdx = 0; segIdx < me.segments.length; segIdx++) {
                 private_resetBandArea();
@@ -112,7 +112,7 @@ JpcFlowTabSrv.prototype.createNew = function(){
                 let rowSplitCnt = Math.ceil(1.0 * me.segments[segIdx].length / orgMaxRowRec);
                 pageStatus[JV.STATUS_SEGMENT_END] = true;
                 private_resetBandArea();
-                let hasAdHocRow = !JpcFlowTabHelper.chkSegEnd(bands, rptTpl, me.segments, segIdx, (rowSplitCnt - 1) * orgMaxRowRec, maxRowRec);
+                let hasAdHocRow = !JpcFlowTabHelper.chkSegEnd(bands, rptTpl, me.segments, segIdx, (rowSplitCnt - 1) * orgMaxRowRec, maxRowRec, me.isEx);
                 if (hasAdHocRow) rowSplitCnt++;
                 if (rowSplitCnt % me.multiCols > 0) {
                     rowSplitCnt++
@@ -145,7 +145,7 @@ JpcFlowTabSrv.prototype.createNew = function(){
             //2. then reset the band height
             let tab = rptTpl[JV.NODE_FLOW_INFO][JV.NODE_FLOW_CONTENT];
             let flowContentBand = bands[tab[JV.PROP_BAND_NAME]];
-            let actH = JpcFlowTabHelper.getActualContentAreaHeight(bands, rptTpl, me.segments, page);
+            let actH = JpcFlowTabHelper.getActualContentAreaHeight(bands, rptTpl, me.segments, page, me.isEx);
             let offsetY = actH - (flowContentBand.Bottom - flowContentBand.Top);
             JpcBandHelper.resetBandPos(rptTpl[JV.NODE_BAND_COLLECTION], bands, flowContentBand, 0, offsetY);
             // 2.1 Content-Tab

+ 28 - 3
modules/reports/rpt_component/jpc_rte.js

@@ -46,15 +46,40 @@ let JE = {
         }
         return rst;
     },
-    setFieldValue: function (field, newValue, dataObj, valIdx) {
-        if (!(field.DataNodeName)) {
+    setFieldValue: function (field, dataObj, valIdx, newValue) {
+        if (field.DataNodeName === "NA") {
+            if (!field[JV.PROP_AD_HOC_DATA]) {
+                field[JV.PROP_AD_HOC_DATA] = [];
+            }
+            field[JV.PROP_AD_HOC_DATA][valIdx] = newValue;
+        } else if (!field.DataNodeName) {
+            //that means this is a self-defined discrete field!
+            field.DataNodeName = JV.DATA_DISCRETE_DATA;
+            let len = dataObj[JV.DATA_DISCRETE_DATA].length;
+            field.DataSeq = len;
+            dataObj[JV.DATA_DISCRETE_DATA].push([]);
+            dataObj[field.DataNodeName][field.DataSeq][valIdx] = newValue;
+        } else {
+            dataObj[field.DataNodeName][field.DataSeq][valIdx] = newValue;
+        }
+    },
+    getFieldValue: function (field, dataObj, valIdx, dftVal) {
+        let rst = dftVal;
+        if (!field.DataNodeName) {
             //that means this is a self-defined discrete field!
             field.DataNodeName = JV.DATA_DISCRETE_DATA;
             let len = dataObj[JV.DATA_DISCRETE_DATA];
             field.DataSeq = len;
             dataObj[JV.DATA_DISCRETE_DATA].push([]);
         }
-        dataObj[field.DataNodeName][field.DataSeq][valIdx] = newValue;
+        if (dataObj[field.DataNodeName][field.DataSeq].length > valIdx) {
+            rst = dataObj[field.DataNodeName][field.DataSeq][valIdx];
+        } else {
+            if (dftVal === null && dataObj[field.DataNodeName][field.DataSeq].length > 0) {
+                rst = dataObj[field.DataNodeName][field.DataSeq][dataObj[field.DataNodeName][field.DataSeq].length - 1];
+            }
+        }
+        return rst;
     }
 }
 

+ 112 - 2
modules/reports/util/rpt_construct_data_util.js

@@ -161,8 +161,8 @@ class Rpt_Data_Extractor {
         // console.log(JV.DATA_MASTER_DATA_EX);
         // console.log(rptDataObj[JV.DATA_MASTER_DATA_EX]);
         assembleFields(tpl[JV.NODE_FIELD_MAP][JV.NODE_DETAIL_FIELDS_EX], rptDataObj[JV.DATA_DETAIL_DATA_EX], $PROJECT);
-        console.log(JV.DATA_DETAIL_DATA_EX);
-        console.log(rptDataObj[JV.DATA_DETAIL_DATA_EX]);
+        // console.log(JV.DATA_DETAIL_DATA_EX);
+        // console.log(rptDataObj[JV.DATA_DETAIL_DATA_EX]);
         return rptDataObj;
     };
 
@@ -340,10 +340,18 @@ function sortData(sourceData, sortCfg) {
 
 function setupFunc(obj, prop, ownRawObj) {
     obj[prop] = {};
+    // if (prop === projectConst.CALC_PROGRAM) {
+    //     obj[prop]["myOwnRawDataObj"] = ownRawObj.data;
+    // } else {
+    //     obj[prop]["myOwnRawDataObj"] = ownRawObj;
+    // }
     obj[prop]["myOwnRawDataObj"] = ownRawObj;
     obj[prop].getProperty = ext_getPropety;
     obj[prop].getFee = ext_getFee;
     obj[prop].getPropertyByForeignId = ext_getPropertyByForeignId;
+    obj[prop].getArrayItemByKey = ext_getArrayItemByKey;
+    if (prop === projectConst.CALC_PROGRAM) obj[prop].getCalcProperty = ext_getCalcProperty;
+    if (prop === projectConst.FEERATE) obj[prop].getFeeRate = ext_getFeeRate;
 }
 
 function assembleFields(fieldList, rstDataArr, $PROJECT) {
@@ -449,6 +457,103 @@ function ext_getFee(feeKey, dtlFeeKey) {
     return rst;
 }
 
+function ext_getCalcProperty(templateIDs, calcItemKey, calcItemKeyVal, calcItemRstKey){
+    let rst = [], parentObj = this; //this should be "calc_program" object
+    let dtObj = parentObj["myOwnRawDataObj"];
+    let optimizeObj = {};
+    let private_getProperty = function (cId) {
+        let calcTplObj = optimizeObj["calc_program_" + cId];
+        if (!calcTplObj) {
+            let templates = (dtObj.data._doc)?dtObj.data._doc.templates:dtObj.data.templates;
+            for (let tpl of templates) {
+                if (cId === tpl.ID) {
+                    optimizeObj["calc_program_" + cId] = tpl;
+                    calcTplObj = tpl;
+                    break;
+                }
+            }
+        }
+        if (calcTplObj) {
+            for (let calcItem of calcTplObj.calcItems) {
+                if (calcItem[calcItemKey] === calcItemKeyVal) {
+                    rst.push(calcItem[calcItemRstKey]);
+                    break;
+                }
+            }
+        }
+    };
+    if (templateIDs instanceof Array) {
+        for (let tplId of templateIDs) {
+            private_getProperty(tplId);
+        }
+    } else {
+        private_getProperty(templateIDs);
+    }
+    optimizeObj = null;
+    return rst;
+}
+
+function ext_getFeeRate(fee_Ids){
+    let rst = [], parentObj = this; //this should be "feeRate" object
+    let dtObj = parentObj["myOwnRawDataObj"];
+    let optimizeObj = {};
+    let private_getFeeRate = function (fId) {
+        let feeRateItemObj = optimizeObj["fee_rates_" + fId];
+        if (!feeRateItemObj) {
+            let rates = (dtObj.data._doc)?dtObj.data._doc.rates:dtObj.data.rates;
+            for (let feeItem of rates) {
+                if (fId === feeItem.ID) {
+                    optimizeObj["fee_rates_" + fId] = feeItem;
+                    feeRateItemObj = feeItem;
+                    break;
+                }
+            }
+        }
+        if (feeRateItemObj) {
+            rst.push(feeRateItemObj.rate);
+        } else {
+            rst.push(0);
+        }
+    };
+    if (fee_Ids instanceof Array) {
+        for (let fId of fee_Ids) {
+            private_getFeeRate(fId);
+        }
+    } else {
+        private_getFeeRate(fee_Ids);
+    }
+    optimizeObj = null;
+    return rst;
+}
+
+function ext_getArrayItemByKey(arrayKey, itemKey, itemKeyValue, itemRstKey){
+    let rst = [], parentObj = this;
+    let dtObj = parentObj["myOwnRawDataObj"];
+    let private_getItemValue = function (arr, dtlItKV) {
+        for (let item of arr) {
+            if (item[itemKey] === dtlItKV) {
+                if (itemRstKey) {
+                    rst.push(item[itemRstKey]);
+                } else {
+                    rst.push(item);
+                }
+                break;
+            }
+        }
+    };
+    let arr = dtObj[arrayKey];
+    if (arr && arr instanceof Array) {
+        if (itemKeyValue instanceof Array) {
+            for (let dtlItemKeyVal of itemKeyValue) {
+                private_getItemValue(arr, dtlItemKeyVal);
+            }
+        } else {
+            private_getItemValue(arr, itemKeyValue);
+        }
+    }
+
+}
+
 function ext_getPropertyByForeignId(foreignIdVal, adHocIdKey, propKey) {
     let rst = [], parentObj = this;
     let IdKey = (adHocIdKey)?adHocIdKey:"ID";
@@ -468,6 +573,11 @@ function ext_getPropertyByForeignId(foreignIdVal, adHocIdKey, propKey) {
                                 if (i === 0) {
                                     rstP = item[splitPKey[i]];
                                 } else {
+                                    if (splitPKey[i].indexOf("[") === 0 && splitPKey[i].indexOf("]") === (splitPKey[i].length - 1)) {
+                                        //考虑数组情况^_^!!!
+                                    } else {
+                                        //
+                                    }
                                     rstP = rstP[splitPKey[i]];
                                 }
                             }

+ 42 - 42
public/stringUtil.js

@@ -1,5 +1,5 @@
-var pinyin = (function (){
-    var Pinyin = function (ops){
+let pinyin = (function (){
+    let Pinyin = function (ops){
             this.initialize(ops);
         },
 
@@ -23,10 +23,10 @@ var pinyin = (function (){
 
         // 提取拼音, 返回首字母大写形式
         getFullChars: function(str){
-            var result = '', name;
-            var reg = new RegExp('[a-zA-Z0-9\- ]');
-            for (var i=0, len = str.length; i < len; i++){
-                var ch = str.substr(i,1), unicode = ch.charCodeAt(0);
+            let result = '', name;
+            let reg = new RegExp('[a-zA-Z0-9\- ]');
+            for (let i=0, len = str.length; i < len; i++){
+                let ch = str.substr(i,1), unicode = ch.charCodeAt(0);
                 if(unicode > 40869 || unicode < 19968){
                     result += ch;
                 }else{
@@ -43,10 +43,10 @@ var pinyin = (function (){
         getCamelChars: function(str){
             if(typeof(str) !== 'string')
                 throw new Error(-1, "函数getFisrt需要字符串类型参数!");
-            var chars = []; //保存中间结果的数组
-            for(var i=0,len=str.length; i < len; i++){
+            let chars = []; //保存中间结果的数组
+            for(let i=0,len=str.length; i < len; i++){
                 //获得unicode码
-                var ch = str.charAt(i);
+                let ch = str.charAt(i);
                 //检查该unicode码是否在处理范围之内,在则返回该码对映汉字的拼音首字母,不在则调用其它函数处理
                 chars.push(this._getChar(ch));
             }
@@ -57,9 +57,9 @@ var pinyin = (function (){
 
         // 提取拼音
         _getFullChar: function(str){
-            for (var key in this.full_dict){
+            for (let key in this.full_dict){
                 if(-1 !== this.full_dict[key].indexOf(str)){
-                    return this._capitalize(key); break;
+                    return this._capitalize(key);
                 }
             }
             return false;
@@ -68,14 +68,14 @@ var pinyin = (function (){
         // 首字母大写
         _capitalize: function(str){
             if(str.length>0){
-                var first = str.substr(0,1).toUpperCase();
-                var spare = str.substr(1,str.length);
+                let first = str.substr(0,1).toUpperCase();
+                let spare = str.substr(1,str.length);
                 return first + spare;
             }
         },
 
         _getChar: function(ch){
-            var unicode = ch.charCodeAt(0);
+            let unicode = ch.charCodeAt(0);
             //如果不在汉字处理范围之内,返回原字符,也可以调用自己的处理函数
             if(unicode > 40869 || unicode < 19968)
                 return ch; //dealWithOthers(ch);
@@ -88,21 +88,21 @@ var pinyin = (function (){
         _getResult: function(chars){
             if(!this.options.checkPolyphone)
                 return chars.join('');
-            var result = [''];
-            for(var i=0,len=chars.length;i<len;i++){
-                var str = chars[i], strlen = str.length;
+            let result = [''];
+            for(let i=0,len=chars.length;i<len;i++){
+                let str = chars[i], strlen = str.length;
                 if(strlen == 1){
-                    for(var j=0; j < result.length; j++){
+                    for(let j=0; j < result.length; j++){
                         result[k] += str;
                     }
                 }else{
-                    var swap1 = result.slice(0);
+                    let swap1 = result.slice(0);
                     result = [];
-                    for(var j=0; j < strlen; j++){
+                    for(let j=0; j < strlen; j++){
                         //复制一个相同的arrRslt
-                        var swap2 = swap1.slice(0);
+                        let swap2 = swap1.slice(0);
                         //把当前字符str[k]添加到每个元素末尾
-                        for(var k=0; k < swap2.length; k++){
+                        for(let k=0; k < swap2.length; k++){
                             swap2[k] += str.charAt(j);
                         }
                         //把复制并修改后的数组连接到arrRslt上
@@ -115,8 +115,8 @@ var pinyin = (function (){
 
     };
 
-    var extend = function(dst, src){
-        for(var property in src){
+    let extend = function(dst, src){
+        for(let property in src){
             dst[property] = src[property];
         }
         return dst;
@@ -127,51 +127,51 @@ var pinyin = (function (){
 
 module.exports = {
     isEmptyString: function(str) {
-        var rst = false;
-        if (str == null || str == undefined) {
+        let rst = false;
+        if (str === null || str === undefined) {
             rst = true;
         } else if (typeof str) {
-            var reg = /^\s*$/;
+            let reg = /^\s*$/;
             rst = reg.test(str);
         }
         return rst;
     },
     convertNumToChinese : function(num, isCurrency) {
         if (!/^\d*(\.\d*)?$/.test(num)) { return "Number is wrong!"; }
-        var AA, BB;
+        let AA, BB;
         if (isCurrency) {
-            AA = new Array("零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖");
-            BB = new Array("", "拾", "佰", "仟", "萬", "億", "点", "");
+            AA = ["零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"];
+            BB = ["", "拾", "佰", "仟", "萬", "億", "点", ""];
         } else {
             AA = ['零','一','二','三','四','五','六','七','八','九'];
-            BB = new Array("", "十", "百", "千", "万", "亿", "点", "");
+            BB = ["", "十", "百", "千", "万", "亿", "点", ""];
         }
-        //var AA = new Array("零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖");
-        //var BB = new Array("", "拾", "佰", "仟", "萬", "億", "点", "");
-        var a = ("" + num).replace(/(^0*)/g, "").split("."), k = 0, re = "";
-        for (var i = a[0].length - 1; i >= 0; i--) {
+        //let AA = new Array("零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖");
+        //let BB = new Array("", "拾", "佰", "仟", "萬", "億", "点", "");
+        let a = ("" + num).replace(/(^0*)/g, "").split("."), k = 0, re = "";
+        for (let i = a[0].length - 1; i >= 0; i--) {
             switch (k) {
                 case 0: re = BB[7] + re; break;
                 case 4: if (!new RegExp("0{4}\\d{" + (a[0].length - i - 1) + "}$").test(a[0]))
                     re = BB[4] + re; break;
                 case 8: re = BB[5] + re; BB[7] = BB[5]; k = 0; break;
             }
-            if (k % 4 == 2 && a[0].charAt(i + 2) != 0 && a[0].charAt(i + 1) == 0) re = AA[0] + re;
-            if (a[0].charAt(i) != 0) re = AA[a[0].charAt(i)] + BB[k % 4] + re; k++;
+            if (k % 4 === 2 && a[0].charAt(i + 2) !== 0 && a[0].charAt(i + 1) === 0) re = AA[0] + re;
+            if (a[0].charAt(i) !== 0) re = AA[a[0].charAt(i)] + BB[k % 4] + re; k++;
         }
 
         if (a.length > 1) //加上小数部分(如果有小数部分)
         {
             re += BB[6];
-            for (var i = 0; i < a[1].length; i++) re += AA[a[1].charAt(i)];
+            for (let i = 0; i < a[1].length; i++) re += AA[a[1].charAt(i)];
         }
         return re;
     },
     convertStrToBoolean: function(str) {
-        var rst = false, me = this;
+        let rst = false, me = this;
         if (!me.isEmptyString(str)) {
-            var upperStr = str.toUpperCase();
-            if (upperStr == 'T' || upperStr == 'Y' || upperStr == 'YES' || upperStr == 'TRUE') {
+            let upperStr = str.toUpperCase();
+            if (upperStr === 'T' || upperStr === 'Y' || upperStr === 'YES' || upperStr === 'TRUE') {
                 rst = true;
             }
         }
@@ -183,4 +183,4 @@ module.exports = {
     getPinYinCamelChars: function(value) {
         return pinyin.getCamelChars(value);
     }
-}
+};

+ 7 - 7
public/web/string_util_light.js

@@ -5,23 +5,23 @@
 
 let stringUtil = {
     isEmptyString: function(str) {
-        var rst = false;
-        if (str == null || str == undefined) {
+        let rst = false;
+        if (str === null || str === undefined) {
             rst = true;
         } else if (typeof str) {
-            var reg = /^\s*$/;
+            let reg = /^\s*$/;
             rst = reg.test(str);
         }
         return rst;
     },
     convertStrToBoolean: function(str) {
-        var rst = false, me = this;
+        let rst = false, me = this;
         if (!me.isEmptyString(str)) {
-            var upperStr = str.toUpperCase();
-            if (upperStr == 'T' || upperStr == 'Y' || upperStr == 'YES' || upperStr == 'TRUE') {
+            let upperStr = str.toUpperCase();
+            if (upperStr === 'T' || upperStr === 'Y' || upperStr === 'YES' || upperStr === 'TRUE') {
                 rst = true;
             }
         }
         return rst;
     }
-}
+};