Browse Source

通用基础组件调整

zhuth 7 years ago
parent
commit
524e820297

+ 8 - 2
frontend/saas-web/app/view/core/form/Panel.js → frontend/saas-web/app/view/core/form/FormPanel.js

@@ -1,4 +1,4 @@
-Ext.define('saas.view.core.form.Panel', {
+Ext.define('saas.view.core.form.FormPanel', {
     extend: 'Ext.form.Panel',
     xtype: 'core-formpanel',
 
@@ -8,9 +8,15 @@ Ext.define('saas.view.core.form.Panel', {
 
     configUrl: '',
 
+    defautls: {
+        margin: '0 2 2 0',
+        labelAlign: 'right',
+        labelWidth: 90
+    },
+
     initComponent: function() {
         var me = this;
-        me.FormUtil.getFormItems(me, me.configUrl);
+        me.configUrl && me.FormUtil.getFormItems(me, me.configUrl);
         me.callParent(arguments);
     }
 });

+ 3 - 3
frontend/saas-web/app/view/core/grid/Panel.js → frontend/saas-web/app/view/core/grid/GridPanel.js

@@ -1,4 +1,4 @@
-Ext.define('saas.view.core.grid.Panel', {
+Ext.define('saas.view.core.grid.GridPanel', {
     extend: 'Ext.grid.Panel',
     xtype: 'core-gridpanel',
 
@@ -9,8 +9,8 @@ Ext.define('saas.view.core.grid.Panel', {
 
     initComponent: function() {
         var me = this;
-        me.GridUtil.getGridColumns(me, me.configUrl, function() {
-            me.GridUtil.loadData(me, me.dataUrl);
+        me.configUrl && me.GridUtil.getGridColumns(me, me.configUrl, function() {
+            me.dataUrl && me.GridUtil.loadData(me, me.dataUrl);
         });
         me.callParent(arguments);
     }

+ 3 - 47
frontend/saas-web/app/view/core/tab/Controller.js

@@ -6,55 +6,11 @@ Ext.define('saas.view.core.tab.Controller', {
         var me = this,
             tab = me.getView(),
             tabConfig = tab.tabConfig,
-            viewType = tabConfig.viewType,
-            item;
+            viewType = tabConfig.viewType;
 
-        if(viewType === 'grid') {
-            item = me.createGrid(tabConfig);
-        }else if (viewType === 'form') {
-            item = me.createForm(tabConfig);
-        }else {
-            item = me.defaultTab(tabConfig);
-        }
-        tab.add(item);
-    },
-
-    defaultTab: function(tabConfig) {
-        var item = Ext.create('Ext.panel.Panel', {
-            html: '无效类型'
+        tab.add({
+            xtype: viewType
         });
-        
-        return item;
-    },
-
-    createGrid: function(tabConfig) {
-        var me = this,
-            tab = me.getView(),
-            controller = tabConfig.controller,
-            configUrl = tabConfig.configUrl,
-            dataUrl = tabConfig.dataUrl,
-            grid = Ext.create('saas.view.core.grid.Panel', {
-                controller: controller,
-                tabComponent: tab,
-                configUrl: configUrl,
-                dataUrl: dataUrl
-            });
-        
-        return grid;
-    },
-
-    createForm: function(tabConfig) {
-        var me = this,
-            tab = me.getView(),
-            controller = tabConfig.controller,
-            configUrl = tabConfig.configUrl,
-            form = Ext.create('saas.view.core.form.Panel', {
-                controller: controller,
-                tabComponent: tab,
-                configUrl: configUrl
-            });
-        
-        return form;
     },
 
 });

+ 2 - 10
frontend/saas-web/app/view/main/MainModel.js

@@ -28,27 +28,19 @@ Ext.define('saas.view.main.MainModel', {
                                     {
                                         id: 'list1',
                                         text: '列表界面1',
-                                        viewType: 'grid',
-                                        controller: 'salelist1',
-                                        configUrl: 'resources/json/gridColumns1.json',
-                                        dataUrl: 'resources/json/gridData1.json',
+                                        viewType: 'purchase-list-gridpanel',
                                         leaf: true
                                     },
                                     {
                                         id: 'list2',
                                         text: '列表界面2',
-                                        viewType: 'grid',
-                                        controller: 'salelist2',
-                                        configUrl: 'resources/json/gridColumns2.json',
-                                        dataUrl: 'resources/json/gridData2.json',
+                                        viewType: 'purchase-list-gridpanel',
                                         leaf: true
                                     },
                                     {
                                         id: 'form1',
                                         text: '主从表界面1',
                                         viewType: 'form',
-                                        controller: 'saledetail',
-                                        configUrl: 'resources/json/formItems.json',
                                         leaf: true
                                     },
                                     {

+ 9 - 0
frontend/saas-web/app/view/purchase/list/GridPanel.js

@@ -0,0 +1,9 @@
+Ext.define('saas.view.purchase.list.GridPanel', {
+    extend: 'saas.view.core.grid.GridPanel',
+    xtype: 'purchase-list-gridpanel',
+
+    controller: 'purchase-list-listcontroller',
+    
+    configUrl: 'resources/json/gridColumns1.json',
+    dataUrl: 'resources/json/gridData1.json'
+});

+ 12 - 0
frontend/saas-web/app/view/purchase/list/ListController.js

@@ -0,0 +1,12 @@
+Ext.define('saas.view.purchase.list.ListController', {
+    extend: 'Ext.app.ViewController',
+    alias: 'controller.purchase-list-listcontroller',
+
+    control: {
+        'grid': {
+            itemClick: function() {
+                console.log('grid1: click.....');
+            }
+        }
+    },
+});

+ 1 - 1
frontend/saas-web/resources/json/formItems.json

@@ -1,7 +1,7 @@
 [{
     "xtype": "textfield",
     "name": "text",
-    "bind": "前缀-{text}",
+    "bind": "{text}",
     "fieldLabel": "文本",
     "allowBlank": true,
     "columnWidth": 1