Browse Source

报表放大镜条件改为全等

zhuth 7 years ago
parent
commit
44adeddd9b

+ 65 - 43
frontend/saas-web/app/view/core/report/ReportPanel.js

@@ -218,24 +218,28 @@ Ext.define('saas.view.core.report.ReportPanel', {
                     type: 'json',
                     // rootProperty: 'data.list',
                     rootProperty: function(data) {
-                        var grid = me.items.items[1],
-                        columns = grid.columns,
-                        summaryData = data.data.calculate || [];
-
-                        Ext.Array.each(columns, function(c) {
-                            var type = c.summaryType,
-                            name = c.dataIndex;
-
-                            var d = Ext.Array.findBy(summaryData, function(s) {
-                                return s.hasOwnProperty(name);
-                            })
-                            if(type && d) {
-                                c.summaryValue = Ext.util.Format.number(d[name], c.format || '0.00');
-                            }else {
-                                c.summaryValue = 0;
-                            }
-                        });
-                        return data.data.list.list;
+                        try {
+                            var grid = me.items.items[1],
+                            columns = grid.columns,
+                            summaryData = data.data.calculate || [];
+    
+                            Ext.Array.each(columns, function(c) {
+                                var type = c.summaryType,
+                                name = c.dataIndex;
+    
+                                var d = Ext.Array.findBy(summaryData, function(s) {
+                                    return s.hasOwnProperty(name);
+                                })
+                                if(type && d) {
+                                    c.summaryValue = Ext.util.Format.number(d[name], c.format || '0.00');
+                                }else {
+                                    c.summaryValue = 0;
+                                }
+                            });
+                            return data.data.list.list;
+                        }catch(e) {
+                            saas.util.BaseUtil.showErrorToast(e.message);
+                        }
                     },
                     totalProperty: 'data.list.total',
                 },
@@ -413,7 +417,8 @@ Ext.define('saas.view.core.report.ReportPanel', {
 
     getConditions: function() {
         var me = this,
-        formItems = me.searchItems,
+        form = me.down('form'),
+        formItems = form.items.items,
         viewModel = me.getViewModel(),
         viewModelData = viewModel.getData(),
         bindItems = viewModelData['form'],
@@ -435,10 +440,10 @@ Ext.define('saas.view.core.report.ReportPanel', {
                     value: func(value)
                 }
             }else {
-                var xtype = item.xtype || 'textfield',
-                type = item.fieldType || me.getDefaultFieldType(xtype),
-                operation = item.operation || me.getDefaultFieldOperation(xtype),
-                conditionValue = me.getConditionValue(xtype, value);
+                // var xtype = item.xtype || 'textfield',
+                type = item.fieldType || me.getDefaultFieldType(item),
+                operation = item.operation || me.getDefaultFieldOperation(item),
+                conditionValue = me.getConditionValue(item, value);
     
                 if(!conditionValue) {
                     continue;
@@ -456,14 +461,16 @@ Ext.define('saas.view.core.report.ReportPanel', {
         return conditions;
     },
 
-    getDefaultFieldType: function(xtype) {
-        var type;
+    getDefaultFieldType: function(field) {
+        var me = this,
+        xtypes = field.getXTypes().split('/'),
+        type;
 
-        if(Ext.Array.contains(['numberfield'], xtype)) {
+        if(me.isContainsAny(xtypes, ['numberfield'])) {
             type = 'number';
-        }else if(Ext.Array.contains(['datefield', 'condatefield'], xtype)) {
+        }else if(me.isContainsAny(xtypes, ['datefield', 'condatefield'])) {
             type = 'date';
-        }else if(Ext.Array.contains(['combobox', 'multicombo', 'combo', 'radiofield', 'radio'], xtype)) {
+        }else if(me.isContainsAny(xtypes, ['combobox', 'multicombo', 'combo', 'radiofield', 'radio'])) {
             type = 'enum';
         }else {
             type = 'string';
@@ -472,16 +479,29 @@ Ext.define('saas.view.core.report.ReportPanel', {
         return type;
     },
 
-    getDefaultFieldOperation: function(xtype) {
-        var operation;
+    /**
+     * 只要arr1和arr2中存在相同项即返回真
+     */
+    isContainsAny: function(arr1, arr2) {
+        for(var i = 0; i < arr2.length; i++) {
+            var a2 = arr2[i];
+            if(!!arr1.find(function(a1) {return a1==a2})) {
+                return true;
+            }
+        }
+        return false;
+    },
 
-        if(Ext.Array.contains(['numberfield'], xtype)) {
-            operation = '=';
-        }else if(Ext.Array.contains(['datefield'], xtype)) {
+    getDefaultFieldOperation: function(field) {
+        var me = this,
+        xtypes = field.getXTypes().split('/'),
+        operation;
+
+        if(me.isContainsAny(xtypes, ['numberfield', 'datefield', 'dbfindtrigger'])) {
             operation = '=';
-        }else if(Ext.Array.contains(['condatefield'], xtype)) {
+        }else if(me.isContainsAny(xtypes, ['condatefield'])) {
             operation = 'between';
-        }else if(Ext.Array.contains(['combobox', 'multicombo', 'combo'], xtype)) {
+        }else if(me.isContainsAny(xtypes, ['multidbfindtrigger', 'combobox', 'multicombo', 'combo'])) {
             operation = 'in';
         }else {
             operation = 'like';
@@ -493,21 +513,23 @@ Ext.define('saas.view.core.report.ReportPanel', {
     /**
      * 处理部分字段值
      */
-    getConditionValue: function(xtype, value) {
-        var conditionValue;
-        if(xtype == 'datefield') {
+    getConditionValue: function(field, value) {
+        var me = this,
+        xtypes = field.getXTypes().split('/'),
+        conditionValue;
+        if(me.isContainsAny(xtypes, ['datefield'])) {
             conditionValue = Ext.Date.format(new Date(from), 'Y-m-d H:i:s');
-        }else if(xtype == 'condatefield') {
+        }else if(me.isContainsAny(xtypes, ['condatefield'])) {
             var from = value.from,
             to = value.to;
 
             conditionValue = Ext.Date.format(new Date(from), 'Y-m-d 00:00:00') + ',' + Ext.Date.format(new Date(to), 'Y-m-d 23:59:59');
-        }else if(xtype == 'combobox' || xtype == 'combo') {
+        }else if(me.isContainsAny(xtypes, ['combobox', 'combo'])) {
             conditionValue = '\'' + value + '\'';
-        }else if(xtype == 'multicombo') {
-            conditionValue = value.map(function(v) {
+        }else if(me.isContainsAny(xtypes, ['multicombo'])) {
+            conditionValue = value.map ? value.map(function(v) {
                 return '\'' + v.value + '\'';
-            }).join(',');
+            }).join(',') : '';
         }else {
             conditionValue = value;
         }

+ 1 - 3
frontend/saas-web/app/view/main/Main.js

@@ -54,9 +54,7 @@ Ext.define('saas.view.main.Main', {
                     },
                     arrowVisible: true,
                     menu: {
-                        items: [{
-                            xtype: 'menuseparator'
-                        }]
+                        items: []
                     }
                 },
                 '->',

+ 1 - 1
frontend/saas-web/app/view/main/Navigation.scss

@@ -1,5 +1,5 @@
 $nav-font-size: 16px;
-$nav-font-color: #9697AC;
+$nav-font-color: #EEEEF2;
 $nav-font-color-over: #fff;
 
 .x-navpanel {