Browse Source

mysummary bug

zhuth 7 years ago
parent
commit
a37a2e6bdd

+ 4 - 3
frontend/saas-web/app/view/core/report/ReportPanel.js

@@ -239,8 +239,8 @@ Ext.define('saas.view.core.report.ReportPanel', {
                                 if(type && d) {
                                     if(type == 'count') {
                                         c.summaryValue = Ext.util.Format.number(d[name], c.format || '0');
-                                    }else if(typeof c.summaryRender == 'function') {
-                                        c.summaryValue = c.summaryRender(d[name]);
+                                    }else if(typeof c.summaryRenderer == 'function') {
+                                        c.summaryValue = c.summaryRenderer(d[name]);
                                     }else if(typeof c.renderer == 'function') {
                                         c.summaryValue = c.renderer(d[name]);
                                     }else {
@@ -345,7 +345,7 @@ Ext.define('saas.view.core.report.ReportPanel', {
                 })
             }else if(c.xtype == 'numbercolumn') {
                 Ext.applyIf(c, {
-                    align: 'end',
+                    align: 'end', // 数字右对齐
                     renderer : function(v) {
                         var arr = (v + '.').split('.');
                         var xr = (new Array(arr[1].length)).fill('0');
@@ -375,6 +375,7 @@ Ext.define('saas.view.core.report.ReportPanel', {
             column.summaryTypeName = summaryType;
         }
         if(summaryType == 'sum') {
+            column._summaryType = 'sum';
             // 原生的求和方法使用的是Store.sum,在数据存在null时计算结果为NaN,这里重写一下
             column.summaryType = function(records, values) {
                 return Ext.Array.sum(values);

+ 15 - 2
frontend/saas-web/app/view/sale/report/Sale.js

@@ -127,7 +127,7 @@ Ext.define('saas.view.sale.report.Sale', {
         xtype: 'numbercolumn',
         renderer : function(v) {
             var arr = (v + '.').split('.');
-            var xr = (new Array(arr[1].length > 3 ? 3 : arr[1].length)).fill('0');
+            var xr = (new Array(arr[1].length > 8 ? 8 : arr[1].length)).fill('0');
             var format = '0,000.' + xr.join();
             return Ext.util.Format.number(v, format);
         }
@@ -137,7 +137,7 @@ Ext.define('saas.view.sale.report.Sale', {
         xtype: 'numbercolumn',
         renderer : function(v) {
             var arr = (v + '.').split('.');
-            var xr = (new Array(arr[1].length > 3 ? 3 : arr[1].length)).fill('0');
+            var xr = (new Array(arr[1].length > 8 ? 8 : arr[1].length)).fill('0');
             var format = '0,000.' + xr.join();
             return Ext.util.Format.number(v, format);
         }
@@ -154,6 +154,12 @@ Ext.define('saas.view.sale.report.Sale', {
         xtype: 'numbercolumn',
         dataIndex: 'sd_total',
         xtype: 'numbercolumn',
+        renderer : function(v) {
+            var arr = (v + '.').split('.');
+            var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0');
+            var format = '0.' + xr.join();
+            return Ext.util.Format.number(v, format);
+        },
         summaryType: 'sum',
         summaryRenderer: function(v) {
             var arr = (v + '.').split('.');
@@ -166,11 +172,18 @@ Ext.define('saas.view.sale.report.Sale', {
         xtype: 'numbercolumn',
         dataIndex: 'sd_nettotal',
         xtype: 'numbercolumn',
+        renderer : function(v) {
+            var arr = (v + '.').split('.');
+            var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0');
+            var format = '0.' + xr.join();
+            return Ext.util.Format.number(v, format);
+        },
         summaryType: 'sum',
         summaryRenderer: function(v) {
             var arr = (v + '.').split('.');
             var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0');
             var format = '0,000.' + xr.join();
+            console.log(v, format, Ext.util.Format.number(v, format));
             return Ext.util.Format.number(v, format);
         }
     }, {

+ 5 - 3
frontend/saas-web/ext/packages/ux/src/feature/MySummary.js

@@ -101,12 +101,14 @@ Ext.define('Ext.ux.feature.MySummary', {
         };
 
         Ext.Array.each(columns, function(c) {
-            if(c.summaryType) {
+            var summaryType = c._summaryType || c.summaryType;
+
+            if(summaryType) {
                 summarys.push({
                     name: c.dataIndex,
                     label: c.text,
-                    type: c.summaryType,
-                    typeLabel: c.summaryType ? typeLabels[c.summaryType] : '',
+                    type: summaryType,
+                    typeLabel: summaryType ? typeLabels[summaryType] : '',
                     value: c.summaryValue || 0
                 });
             }