Explorar el Código

basePanel查询逻辑/样式微调

zhuth hace 7 años
padre
commit
5d504bb56f

+ 69 - 42
frontend/saas-web/app/view/core/base/BasePanelController.js

@@ -8,14 +8,8 @@ Ext.define('saas.view.core.base.BasePanelController', {
     query: function() {
         var form = this.view;
         var grid = form.down('core-base-gridpanel');
-        grid.condition = '';
-        var fields = form.searchField.map(f => f.name);
-        var items = [];
-        Ext.each(fields, function(f, index){
-            var field = form.dockedItems.items[0].down('[name='+f+']');
-            items.push(field);
-        });
-        grid.condition = this.getCondition(items);
+        
+        grid.condition = this.getConditions();
         grid.store.loadPage(1);
     },
 
@@ -25,11 +19,16 @@ Ext.define('saas.view.core.base.BasePanelController', {
         saas.util.BaseUtil.openTab(form.xtype,'新增' + form._title,id);
     },
 
-    getCondition: function(items) {
-        var me = this,
-        conditions = [];
+    /**
+     * 获得过滤条件
+     */
+    getConditions: function() {
+        var me = this;
+        var form = this.view;
+        var items = form.dockedItems.items[0].items.items;
+        var conditions = [];
 
-        for(var i = 0; i < items.length; i++) {
+        for(let i = 0; i < items.length; i++) {
             var item = items[i];
             var field = item.name,
             func = item.getCondition,
@@ -43,10 +42,9 @@ Ext.define('saas.view.core.base.BasePanelController', {
                         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 type = item.fieldType || me.getDefaultFieldType(item),
+                    operation = item.operation || me.getDefaultFieldOperation(item),
+                    conditionValue = me.getConditionValue(item, value);
         
                     if(!conditionValue) {
                         continue;
@@ -60,38 +58,58 @@ Ext.define('saas.view.core.base.BasePanelController', {
                 }
                 conditions.push(condition);
             }
-        };
+        }
+
         return conditions;
     },
 
-    getDefaultFieldType: function(xtype) {
-        var type;
+    /**
+     * 只要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;
+    },
+
+    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', 'conmonthfield'])) {
             type = 'date';
-        }else if(Ext.Array.contains(['combobox', 'multicombo', 'combo', 'radiofield', 'radio'], xtype)) {
+        } else if (me.isContainsAny(xtypes, ['dbfindtrigger'])) {
             type = 'enum';
-        }else {
+        } else if (me.isContainsAny(xtypes, ['combobox', 'multicombo', 'combo', 'radiofield', 'radio'])) {
+            type = 'enum';
+        } else {
             type = 'string';
         }
 
         return type;
     },
 
-    getDefaultFieldOperation: function(xtype) {
-        var operation;
+    getDefaultFieldOperation: function (field) {
+        var me = this,
+            xtypes = field.getXTypes().split('/'),
+            operation;
 
-        if(Ext.Array.contains(['numberfield'], xtype)) {
-            operation = '=';
-        }else if(Ext.Array.contains(['datefield'], xtype)) {
+        if (me.isContainsAny(xtypes, ['numberfield', 'datefield', 'dbfindtrigger'])) {
             operation = '=';
-        }else if(Ext.Array.contains(['condatefield'], xtype)) {
+        } else if (me.isContainsAny(xtypes, ['condatefield', 'conmonthfield'])) {
             operation = 'between';
-        }else if(Ext.Array.contains(['combobox', 'multicombo', 'combo'], xtype)) {
+        } else if (me.isContainsAny(xtypes, ['multidbfindtrigger', 'combobox', 'multicombo', 'combo'])) {
             operation = 'in';
-        }else {
+        } else {
             operation = 'like';
         }
 
@@ -101,25 +119,34 @@ Ext.define('saas.view.core.base.BasePanelController', {
     /**
      * 处理部分字段值
      */
-    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, ['conmonthfield'])) {
+            var from = value.from,
+                to = value.to;
+
+            conditionValue = from + ',' + to;
+        } else if (me.isContainsAny(xtypes, ['condatefield'])) {
             var from = value.from,
-            to = value.to;
+                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, ['dbfindtrigger'])) {
+            conditionValue = value;
+        } 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(',');
-        }else {
+            }).join(',') : '';
+        } else {
             conditionValue = value;
         }
 
         return conditionValue;
-    }
+    },
 });

+ 2 - 1
frontend/saas-web/app/view/core/dbfind/DbfindGridPanel.scss

@@ -34,7 +34,7 @@
     .x-window-body{
         padding-top: 0px !important;
     }
-    .x-toolbar-default {
+    .x-toolbar-docked-top {
         padding: 6px 0 12px 0px;
     }
     .x-grid-header-ct {
@@ -46,6 +46,7 @@
         border-right-width: 1px !important;
         border-left-width: 1px !important;
         border-top-width: 0px !important;
+        border-bottom-width: 1px !important;
     }
     .x-grid-paging-toolbar{
         border: 1px solid #abdaff !important;

+ 2 - 0
frontend/saas-web/app/view/home/charts/KeyData.scss

@@ -14,6 +14,7 @@
             cursor: pointer;
             transition: all 0.3s ease;
             outline: none !important;
+            background: transparent;
 
             // &:hover {
             //     box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
@@ -71,6 +72,7 @@
                     border-radius: 4px 4px 0 0;
                 }
                 .x-contain {
+                    background: #fff;
                     border-style: solid;
                     border-width: 0 1px 1px 1px;
                     border-radius: 0 0 4px 4px;

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

@@ -210,7 +210,7 @@ $treelist-nav-ui: (
 }
 body > .x-mask {
     background-image: none;
-    background-color: rgba(142, 141, 141, 0.75);
+    background-color: rgba(0, 0, 0, 0.3);
 }
 .icon-usoftchina{
     margin-top: 0px;