Browse Source

code sync

TonyKang 6 years ago
parent
commit
05e3c22a36
3 changed files with 25 additions and 8 deletions
  1. 6 1
      modules/reports/rpt_component/jpc_flow_tab.js
  2. 2 7
      operation.js
  3. 17 0
      public/stringUtil.js

+ 6 - 1
modules/reports/rpt_component/jpc_flow_tab.js

@@ -922,7 +922,12 @@ JpcFlowTabSrv.prototype.createNew = function(){
             if (pageStatus[band[JV.BAND_PROP_DISPLAY_TYPE]]) {
                 let tab_fields = me.seg_sum_tab_fields;
                 for (let i = 0; i < tab_fields.length; i++) {
-                    let cellItem = JpcCommonOutputHelper.createCommonOutput(tab_fields[i], me.segSumValLst[segIdx][i], controls);
+                    let sumVal = 0;
+                    if (me.segSumValLst[segIdx] && me.segSumValLst[segIdx].length > i) {
+                        sumVal = me.segSumValLst[segIdx][i];
+                    }
+                    //备注:考虑到有时候会出现没有数据可合计的scenario,得有容错处理
+                    let cellItem = JpcCommonOutputHelper.createCommonOutput(tab_fields[i], sumVal, controls);
                     cellItem[JV.PROP_AREA] = JpcAreaHelper.outputArea(tab_fields[i][JV.PROP_AREA], band, unitFactor, 1, 0, 1, 0, me.multiCols, 0, true, false);
                     rst.push(cellItem);
                 }

+ 2 - 7
operation.js

@@ -93,13 +93,8 @@ app.use(function(err, req, res, next) {
 });
 
 //设置Date Format函数
-fs.readFile(__dirname + '/public/web/date_util.js', 'utf8', 'r', function (err, data) {
-    eval(data);
-    // let dt = new Date();
-    // console.log(dt.Format('yyyy-M-dd'));
-    // console.log(dt.Format('yyyy 年 M 月 dd 日'));
-    // console.log(dt.Format('yyyy 年 M 月 20 日'));
-});
+//备注: 经过测试nodejs 8.9.3版本不支持eval的方式修改prototype,为兼容考虑,把方法调整到stringUtil文件里
+require('./public/stringUtil').setupDateFormat();
 
 //定时任务
 let sysSchedule = require('./modules/sys_tools/models/sys_model');

+ 17 - 0
public/stringUtil.js

@@ -263,5 +263,22 @@ module.exports = {
             }
         }
         return rst;
+    },
+    setupDateFormat: function () {
+        Date.prototype.Format = function (fmt) {
+            let o = {
+                "M+": this.getMonth() + 1, //月份
+                "d+": this.getDate(), //日
+                "h+": this.getHours(), //小时
+                "m+": this.getMinutes(), //分
+                "s+": this.getSeconds(), //秒
+                "q+": Math.floor((this.getMonth() + 3) / 3), //季度
+                "S": this.getMilliseconds() //毫秒
+            };
+            if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
+            for (let k in o)
+                if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
+            return fmt;
+        };
     }
 }