浏览代码

字符串大小写。

Chenshilong 7 年之前
父节点
当前提交
ee65308094

+ 1 - 0
config/gulpConfig.js

@@ -45,6 +45,7 @@ module.exports = {
         'lib/lodash/lodash.js',
         // 'test/tmp_data/test_ration_calc/ration_calc_base.js',
         'web/building_saas/main/js/models/main_consts.js',
+        'public/web/common_util.js',
         'web/building_saas/glj/js/project_glj.js',
         'web/building_saas/glj/js/composition.js',
         'web/building_saas/glj/js/common_spread.js',

+ 0 - 12
public/calc_util.js

@@ -1,12 +0,0 @@
-/**
- * Created by Tony on 2017/6/21.
- * Modified by CSL, 2017-08-01 引入多套计算程序、费率同步、人工系数同步、改进基数计算、费字段映射等。
- * added by CSL, 2017-09-01 增加公式解析对象analyzer,用于解析用户修改公式、自定义表达式。
- */
-
-class Calculation {
-
-};
-
-/*
-export default analyzer;*/

+ 0 - 20
public/common_util.js

@@ -1,20 +0,0 @@
-/**
- * Created by CSL on 2017-06-06.
- * public functions.
- */
-
-function deleteEmptyObject(arr) {
-    function isEmptyObject(e) {
-        var t;
-        for (t in e)
-            return !1;
-        return !0
-    };
-
-    for (var i = 0; i < arr.length; i++) {
-        if (isEmptyObject(arr[i])) {
-            arr.splice(i, 1);
-            i = i - 1;
-        };
-    };
-};

+ 0 - 28
public/debug.js

@@ -1,28 +0,0 @@
-/**
- * Created by CSL on 2017-05-19.
- * 用于展示未知对象的内容。如:debug.m(GC.Spread.Sheets.Events);
- */
-
-debug = {
-    m: function (flag, obj) {
-        alert(flag + this.objStr(obj));
-    },
-
-    d: function (flag, obj) {
-        alert(flag + JSON.stringify(obj));
-    },
-
-    objStr: function (obj) {
-        var str = "";
-        var spr = "";
-        for (var x in obj) {
-            if (obj.hasOwnProperty(x)) {
-                if (str == '') {
-                    spr = ''
-                } else { spr = ', ' } ;
-                str += spr + x + ':' + obj[x];
-            }
-        }
-        return str;
-    }
-}

+ 15 - 0
public/web/common_util.js

@@ -0,0 +1,15 @@
+/**
+ * Created by CSL on 2017-06-06.
+ * public functions for web.
+ */
+
+// 忽略大小写判断字符串是否和参数指定的字符串相同
+String.prototype.sameText = function (str) {
+    return this.toLowerCase() == str.toLowerCase();
+};
+
+// 忽略大小写判断字符串是否有参数指定的子串
+String.prototype.hasSubStr = function (str) {
+    return this.toLowerCase().indexOf(str.toLowerCase()) > -1;
+};
+

+ 2 - 2
web/building_saas/main/html/main.html

@@ -623,6 +623,8 @@
         <!-- inject:js -->
         <!--<script type="text/javascript" src="/test/tmp_data/test_ration_calc/ration_calc_base.js"></script>-->
         <script type="text/javascript" src="/web/building_saas/main/js/models/main_consts.js"></script>
+        <script type="text/javascript" src="/public/web/common_util.js"></script>
+
         <script type="text/javascript" src="/web/building_saas/glj/js/project_glj.js"></script>
         <script type="text/javascript" src="/web/building_saas/glj/js/composition.js"></script>
         <script type="text/javascript" src="/web/building_saas/glj/js/common_spread.js"></script>
@@ -729,8 +731,6 @@
             autoFlashHeight();
         </script>
 
-        <script src="/public/debug.js"></script>
-
         <SCRIPT type="text/javascript">
             <!--
 //            var zNodes =[

+ 0 - 3
web/building_saas/main/js/models/calc_program.js

@@ -779,9 +779,6 @@ class CalcProgram {
     // 计算本节点(默认同时递归计算所有父节点,可选)
     calculate(treeNode, calcParents = true){
         let me = this;
-        console.log(decimalObj.decimal('unitPrice', treeNode));
-        console.log(decimalObj.decimal('unitFee', treeNode));
-        console.log(decimalObj.decimal('UnitFee', treeNode));
         let isRation = treeNode.sourceType === me.project.Ration.getSourceType();
         let isBill = treeNode.sourceType === me.project.Bills.getSourceType();
         let isBillPriceCalc = me.project.projSetting.billsCalcMode === leafBillGetFeeType.billsPrice;

+ 2 - 2
web/building_saas/main/js/views/project_property_decimal_view.js

@@ -22,8 +22,8 @@ decimalObj.decimal = function (field, node) {
         if(field === 'feeRate'){
             return this[field];
         }
-        else if (field === 'unitFee') field = 'unitPrice'
-        else if (field === 'totalFee') field = 'totalPrice';
+        else if (field.sameText('unitFee')) field = 'unitPrice'
+        else if (field.sameText('totalFee')) field = 'totalPrice';
 
         if(isDef(node)){
             if(node.sourceType === projectObj.project.Bills.getSourceType()){

+ 2 - 2
web/building_saas/main/js/views/project_view.js

@@ -387,9 +387,9 @@ var projectObj = {
                     }
 
                     // for test digit. CSLAAAAA
-                    if (col.data.field.indexOf("totalFee") > -1 || col.data.field.indexOf("TotalFee") > -1)
+                    if (col.data.field.hasSubStr("totalFee"))
                        col.data.formatter = MainTreeCol.getNumberFormatter(decimalObj.ration.totalPrice, true)
-                    else if (col.data.field.indexOf("unitFee") > -1 || col.data.field.indexOf("UnitFee") > -1)
+                    else if (col.data.field.hasSubStr("unitFee"))
                         col.data.formatter = MainTreeCol.getNumberFormatter(decimalObj.ration.unitPrice, true)
                     else if (col.data.field == "quantity")
                         col.data.formatter = MainTreeCol.getNumberFormatter(decimalObj.ration.quantity, true);