Browse Source

操作日志页面使用basepanel

zhuth 7 years ago
parent
commit
5811bc2fe3
1 changed files with 66 additions and 309 deletions
  1. 66 309
      frontend/saas-web/app/view/sys/messagelog/DataList.js

+ 66 - 309
frontend/saas-web/app/view/sys/messagelog/DataList.js

@@ -1,317 +1,74 @@
+/**
+ * 操作日志
+ */
 Ext.define('saas.view.sys.messagelog.DataList', {
-    extend: 'Ext.grid.Panel',
+    extend: 'saas.view.core.base.BasePanel',
     xtype: 'sys-messagelog-datalist',
 
-    autoScroll: true,
-    frame:true,
-    layout:'fit',
-    dataUrl:'/api/commons/messagelog/list',
-
-    plugins: [{
-        ptype: 'menuclipboard'
-    }],
-
-    tbar: [{
-        width: 110,
-        name: 'ml_name',
-        xtype: 'textfield',
-        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: 150,
-        name: 'ml_code',
-        xtype: 'textfield',
-        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: 110,
-        name: 'ml_man',
-        xtype: 'textfield',
-        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);
-                    }
-                }
-            }
-        }
-    },{
-        cls:'x-formpanel-btn-blue',
-        xtype:'button',
-        text:'查询',
-        listeners: {
-            click:function(b){
-                var grid = b.ownerCt.ownerCt;
-                grid.condition = grid.getConditions();
-                grid.store.loadPage(1);
-            }
-        }
-    },'->'],
-
-    //字段属性
-    columns : [{
-        text : "id", 
-        width : 0, 
-        dataIndex : "id", 
-        xtype : "numbercolumn",   
-    },{
-        text:'单据类型',
-        dataIndex : "ml_name",
-        width : 110.0, 
-    },{
-        text : "单据编号", 
-        width : 150.0, 
-        dataIndex : "ml_code", 
-    }, 
-    {
-        text : "操作", 
-        dataIndex : "ml_content", 
-        width : 200.0, 
-    }, 
-    {
-        xtype:'datecolumn',
-        format:'Y-m-d H:i:s',
-        text : "操作时间", 
-        dataIndex : "createTime", 
-        width : 150.0, 
-    },
-    {
-        text : "结果", 
-        dataIndex : "ml_result", 
-        width : 150.0, 
-    }, 
-    {
-        text : "操作人员", 
-        dataIndex : "ml_man", 
-        width : 110, 
-    }, {
-        dataIndex: '',
-        flex: 1
-    }],
-
-    condition:'',
-
-    listeners:{
-        boxready: function(grid, width, height, eOpts) {
-            var store = grid.getStore(),
-            gridBodyBox = grid.body.dom.getBoundingClientRect(),
-            gridBodyBoxHeight = gridBodyBox.height;
-
-            var pageSize = Math.floor(gridBodyBoxHeight / 32);
-
-            store.setPageSize(pageSize);
-
-            grid.ownerCt.el.dom.style.left = '8px';
-            grid.el.dom.style.padding = '0px'
-        }
-    },
-
-    initComponent: function() {
+    viewName: 'sys-messagelog-datalist',
+    dataUrl: '/api/commons/messagelog/list',
+    initComponent: function () {
         var me = this;
-        if(me.columns){
-            var fields = me.columns.map(column => column.dataIndex);
-            me.store = Ext.create('Ext.data.Store',{
-                fields:fields,
-                autoLoad: true,
-                pageSize: 11,
-                data: [],
-                proxy: {
-                    timeout:8000,
-                    type: 'ajax',
-                    url: me.dataUrl,
-                    actionMethods: {
-                        read: 'GET'
-                    },
-                    reader: {
-                        type: 'json',
-                        rootProperty: 'data.list',
-                        totalProperty: 'data.total',
-                    }
+        Ext.apply(this, {
+            searchField: [{
+                width: 110,
+                name: 'ml_name',
+                xtype: 'textfield',
+                emptyText : '单据类型',
+            }, {
+                width: 150,
+                name: 'ml_code',
+                xtype: 'textfield',
+                emptyText : '单据编号',
+            }, {
+                width: 110,
+                name: 'ml_man',
+                xtype: 'textfield',
+                emptyText : '操作人员',
+            }],
+
+            gridConfig: {
+                dataUrl: me.dataUrl,
+                actionColumn: [],
+                selModel: {
+                    type: 'cellmodel'
                 },
-                listeners: {
-                    beforeload: function (store, op) {
-                        var condition = me.condition;
-                        if (Ext.isEmpty(condition)) {
-                            condition = "";
-                        }
-                        Ext.apply(store.proxy.extraParams, {
-                            number: op._page,
-                            size: store.pageSize,
-                            condition: JSON.stringify(condition)
-                        });
-                    }
-                }
-            });
-
-            Ext.apply(me, {
-                dockedItems:[{
-                    xtype: 'pagingtoolbar',
-                    dock: 'bottom',
-                    displayInfo: true,
-                    store: me.store
+                hiddenTools: true,
+                data: [],
+                columns: [{
+                    text : "id", 
+                    width : 0, 
+                    dataIndex : "id", 
+                    xtype : "numbercolumn",   
+                }, {
+                    text:'单据类型',
+                    dataIndex : "ml_name",
+                    width : 110.0, 
+                }, {
+                    text : "单据编号", 
+                    width : 150.0, 
+                    dataIndex : "ml_code", 
+                }, {
+                    text : "操作", 
+                    dataIndex : "ml_content", 
+                    width : 200.0, 
+                }, {
+                    xtype:'datecolumn',
+                    format:'Y-m-d H:i:s',
+                    text : "操作时间", 
+                    dataIndex : "createTime", 
+                    width : 150.0, 
+                }, {
+                    text : "结果", 
+                    dataIndex : "ml_result", 
+                    width : 150.0, 
+                }, {
+                    text : "操作人员", 
+                    dataIndex : "ml_man", 
+                    width : 110, 
                 }]
-            });
-        }
-        me.callParent(arguments);
-    },
-
-    /**
-     * 获得过滤条件
-     */
-    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,
-            func = item.getCondition,
-            value = item.value,
-            condition;
-
-            if(value&&value!=''){
-                if(typeof func == 'function') {
-                    condition = {
-                        type: 'condition',
-                        value: func(value)
-                    }
-                }else {
-                    var type = item.fieldType || me.getDefaultFieldType(item),
-                    operation = item.operation || me.getDefaultFieldOperation(item),
-                    conditionValue = me.getConditionValue(item, value);
-        
-                    if(!conditionValue) {
-                        continue;
-                    }
-                    condition = {
-                        type: type,
-                        field: field,
-                        operation: operation,
-                        value: conditionValue
-                    }
-                }
-                conditions.push(condition);
-            }
-        }
-
-        return conditions;
-    },
-
-    /**
-     * 只要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 (me.isContainsAny(xtypes, ['numberfield'])) {
-            type = 'number';
-        } else if (me.isContainsAny(xtypes, ['datefield', 'condatefield', 'conmonthfield'])) {
-            type = 'date';
-        } else if (me.isContainsAny(xtypes, ['dbfindtrigger'])) {
-            type = 'enum';
-        } else if (me.isContainsAny(xtypes, ['combobox', 'multicombo', 'combo', 'radiofield', 'radio'])) {
-            type = 'enum';
-        } else {
-            type = 'string';
-        }
-
-        return type;
-    },
-
-    getDefaultFieldOperation: function (field) {
-        var me = this,
-            xtypes = field.getXTypes().split('/'),
-            operation;
-
-        if (me.isContainsAny(xtypes, ['numberfield', 'datefield', 'dbfindtrigger'])) {
-            operation = '=';
-        } else if (me.isContainsAny(xtypes, ['condatefield', 'conmonthfield'])) {
-            operation = 'between';
-        } else if (me.isContainsAny(xtypes, ['multidbfindtrigger', 'combobox', 'multicombo', 'combo'])) {
-            operation = 'in';
-        } else {
-            operation = 'like';
-        }
-
-        return operation;
-    },
-
-    /**
-     * 处理部分字段值
-     */
-    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 (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;
-
-            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 (me.isContainsAny(xtypes, ['dbfindtrigger'])) {
-            conditionValue = value;
-        } else if (me.isContainsAny(xtypes, ['combobox', 'combo'])) {
-            conditionValue = '\'' + value + '\'';
-        } else if (me.isContainsAny(xtypes, ['multicombo'])) {
-            conditionValue = value.map ? value.map(function (v) {
-                return '\'' + v.value + '\'';
-            }).join(',') : '';
-        } else {
-            conditionValue = value;
-        }
-
-        return conditionValue;
+            },
+        });
+        this.callParent(arguments);
     }
-
 });