Browse Source

i18文件以及opentab通用方法

zhuth 7 years ago
parent
commit
6032b961ca

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

@@ -5,11 +5,10 @@ Ext.define('saas.view.core.tab.Controller', {
     init: function() {
         var me = this,
         tab = me.getView(),
-        tabConfig = tab.tabViewConfig,
-        viewtype = tabConfig.viewtype;
+        viewType = tab.viewType;
 
         tab.add({
-            xtype:viewtype
+            xtype: viewType
         });
     },
 

+ 0 - 29
frontend/saas-web/app/view/main/MainController.js

@@ -7,35 +7,6 @@ Ext.define('saas.view.main.MainController', {
 
     alias: 'controller.main',
 
-    setActiveTab: function(dataset) {
-        var me = this,
-        refs = me.getReferences(),
-        mainTab = refs.mainTabPanel,
-        // existingItem = mainTab.child(type),
-        newView,
-        type = dataset.type,
-        title = dataset.text,
-        tabTitle = title + (type == 'form' ? '' : '查询'),
-        id = dataset.id,
-        tabId = 'maintab-' + type + '-' + id,
-        existingItem = mainTab.down('[id=' + tabId + ']'),
-        lastView = mainTab.getActiveTab();
-
-        if (!existingItem) {
-            existingItem = Ext.create('saas.view.core.tab.Panel', {
-                id: tabId,
-                title: tabTitle,
-                tabViewConfig: dataset
-            });
-            Ext.suspendLayouts();
-            mainTab.setActiveTab(mainTab.add(existingItem));
-            Ext.resumeLayouts(true);
-        }else {
-            mainTab.setActiveTab(existingItem);
-        }
-        
-    },
-
     onToggleNavigationSize: function () {
         var me = this,
         refs = me.getReferences(),

+ 18 - 8
frontend/saas-web/app/view/main/Navigation.js

@@ -269,22 +269,32 @@ Ext.define('saas.view.main.Navigation', {
                             Ext.Array.each(menuItemText, function(item) {
                                 item.addEventListener('click', function(e) {
                                     var target = e.target,
-                                    dataset = target.dataset;
-                                    mainView = Ext.getCmp('mainView'),
-                                    controller = mainView.getController();
+                                    dataset = target.dataset,
+                                    viewType = dataset.viewtype,
+                                    type = dataset.type,
+                                    text = dataset.text,
+                                    id = dataset.id;
+
+                                    var tabTitle = text + (type == 'form' ? '' : '查询'),
+                                    tabId = 'maintab-' + type + '-' + id;
         
-                                    controller.setActiveTab(dataset);
+                                    openTab(viewType, tabTitle, tabId);
                                     menu.hide();
                                 });
                             });
                             Ext.Array.each(menuItemIcon, function(item) {
                                 item.addEventListener('click', function(e) {
                                     var target = e.target,
-                                    dataset = target.dataset;
-                                    mainView = Ext.getCmp('mainView'),
-                                    controller = mainView.getController();
+                                    dataset = target.dataset,
+                                    viewType = dataset.viewtype,
+                                    type = dataset.type,
+                                    text = dataset.text,
+                                    id = dataset.id;
+
+                                    var tabTitle = text + (type == 'form' ? '' : '查询'),
+                                    tabId = 'maintab-' + type + '-' + id;
         
-                                    controller.setActiveTab(dataset);
+                                    openTab(viewType, tabTitle, tabId);
                                     menu.hide();
                                 });
                             });

+ 17 - 0
frontend/saas-web/overrides/i18n.js

@@ -0,0 +1,17 @@
+function openTab(xtype, title, id) {
+    var mainTab = Ext.getCmp('main-tab-panel');
+    var panel = Ext.getCmp(id);
+    if(!panel) {
+        panel = Ext.create('saas.view.core.tab.Panel', {
+            id: id,
+            title: title,
+            viewType: xtype
+        });
+
+        Ext.suspendLayouts();
+        mainTab.setActiveTab(mainTab.add(panel));
+        Ext.resumeLayouts(true);
+    }else {
+        mainTab.setActiveTab(panel);
+    }
+}