Browse Source

系统设置查询列表统一添加回车查询

zhuth 7 years ago
parent
commit
cfd46a0034

+ 7 - 1
frontend/saas-web/app/view/sys/account/DataList.js

@@ -10,6 +10,10 @@ Ext.define('saas.view.sys.account.DataList', {
     _openUrl:'/api/account/account/enable',
     _closeUrl:'/api/account/account/disable',              
 
+    plugins: [{
+        ptype: 'menuclipboard'
+    }],
+
     tbar: [{
         width: 150,
         name: 'username',
@@ -337,7 +341,9 @@ Ext.define('saas.view.sys.account.DataList', {
     getConditions: function() {
         var me = this,
         tbar = me.getDockedItems()[0],
-        items = tbar.items.items,
+        items = Ext.Array.filter(tbar.items.items, function(item) {
+            return !!item.name;
+        }),
         conditions = [];
         for(var i = 0; i < items.length; i++) {
             var item = items[i];

+ 91 - 51
frontend/saas-web/app/view/sys/invitation/DataList.js

@@ -1,6 +1,3 @@
-/**
- * Created by zhouy on 2018/10/18.
- */
 Ext.define('saas.view.sys.invitation.DataList', {
     extend: 'Ext.grid.Panel',
     xtype: 'sys-invitation-datalist',
@@ -14,13 +11,27 @@ Ext.define('saas.view.sys.invitation.DataList', {
     plugins: [{
         ptype: 'cellediting',
         clicksToEdit: 1
+    }, {
+        ptype: 'menuclipboard'
     }],
 
     tbar: [{
         width: 110,
-        name: 'username',
+        name: 're_applyname',
         xtype: 'textfield',
-        emptyText : '姓名'
+        emptyText : '姓名',
+        enableKeyEvents: true,
+        listeners: {
+            keydown: {
+                fn: function(th, e, eOpts) {
+                    if(e.keyCode == 13) {
+                        var grid = th.up('grid');
+                        grid.condition = grid.getConditions();
+                        grid.store.loadPage(1);
+                    }
+                }
+            }
+        }
     },{
         width: 140,
         name: 're_status',
@@ -45,6 +56,18 @@ Ext.define('saas.view.sys.invitation.DataList', {
             }else {
                 return 're_status=\'' + value + '\'';
             }
+        },
+        enableKeyEvents: true,
+        listeners: {
+            keydown: {
+                fn: function(th, e, eOpts) {
+                    if(e.keyCode == 13) {
+                        var grid = th.up('grid');
+                        grid.condition = grid.getConditions();
+                        grid.store.loadPage(1);
+                    }
+                }
+            }
         }
     },{
         xtype:'button',
@@ -52,17 +75,7 @@ Ext.define('saas.view.sys.invitation.DataList', {
         listeners: {
             click:function(b){
                 var grid = b.ownerCt.ownerCt;
-                var tbar = b.ownerCt;
-                grid.condition = '';
-                var items = [];
-                var fields = tbar.items.items.map(f => f.name);
-                Ext.each(fields, function(f, index){
-                    var field = tbar.down('[name='+f+']');
-                    if(field){
-                        items.push(field);
-                    }
-                });
-                grid.condition = grid.getCondition(items);
+                grid.condition = grid.getConditions();
                 grid.store.loadPage(1);
             }
         }
@@ -277,10 +290,13 @@ Ext.define('saas.view.sys.invitation.DataList', {
     /**
      * 获得过滤条件
      */
-    getCondition: function(items) {
+    getConditions: function() {
         var me = this,
+        tbar = me.getDockedItems()[0],
+        items = Ext.Array.filter(tbar.items.items, function(item) {
+            return !!item.name;
+        }),
         conditions = [];
-
         for(var i = 0; i < items.length; i++) {
             var item = items[i];
             var field = item.name,
@@ -295,10 +311,9 @@ Ext.define('saas.view.sys.invitation.DataList', {
                         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;
@@ -312,38 +327,58 @@ Ext.define('saas.view.sys.invitation.DataList', {
                 }
                 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)) {
+        if (me.isContainsAny(xtypes, ['numberfield', 'datefield', 'dbfindtrigger'])) {
             operation = '=';
-        }else if(Ext.Array.contains(['datefield'], xtype)) {
-            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';
         }
 
@@ -353,30 +388,35 @@ Ext.define('saas.view.sys.invitation.DataList', {
     /**
      * 处理部分字段值
      */
-    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;
-    },
-
-    refresh:function(){
-        this.store.load()
     }
 
 })

+ 3 - 1
frontend/saas-web/app/view/sys/maxnumbers/DataList.js

@@ -306,7 +306,9 @@ Ext.define('saas.view.sys.maxnumbers.DataList', {
     getConditions: function() {
         var me = this,
         tbar = me.getDockedItems()[0],
-        items = tbar.items.items,
+        items = Ext.Array.filter(tbar.items.items, function(item) {
+            return !!item.name;
+        }),
         conditions = [];
         for(var i = 0; i < items.length; i++) {
             var item = items[i];

+ 7 - 1
frontend/saas-web/app/view/sys/messagelog/DataList.js

@@ -7,6 +7,10 @@ Ext.define('saas.view.sys.messagelog.DataList', {
     layout:'fit',
     dataUrl:'/api/commons/messagelog/list',
 
+    plugins: [{
+        ptype: 'menuclipboard'
+    }],
+
     tbar: [{
         width: 110,
         name: 'ml_name',
@@ -181,7 +185,9 @@ Ext.define('saas.view.sys.messagelog.DataList', {
     getConditions: function() {
         var me = this,
         tbar = me.getDockedItems()[0],
-        items = tbar.items.items,
+        items = Ext.Array.filter(tbar.items.items, function(item) {
+            return !!item.name;
+        }),
         conditions = [];
         for(var i = 0; i < items.length; i++) {
             var item = items[i];

+ 2 - 2
frontend/saas-web/ext/packages/ux/src/plugin/MenuClipboard.js

@@ -80,10 +80,10 @@ Ext.define('Ext.ux.plugin.MenuClipboard', {
     createMenu : function() {
 		var me = this;
 		return Ext.create('Ext.menu.Menu', {
-			bodyCls:'copyMenu',
+			cls: 'x-copy-menu',
 			items: [{
 				copyType : 'cell',
-				iconCls : 'x-button-icon-copy',
+				iconCls : 'x-fa fa-copy',
 				text : '复制单元格',
 				handler: function(item) {
 					if(me.execable) {