hy 7 years ago
parent
commit
50bc56e6fa

+ 1 - 2
frontend/saas-web/app/util/FormUtil.js

@@ -25,8 +25,7 @@ Ext.define('saas.util.FormUtil', {
                 var config = res.data, items = [];
                 if(config) {
                     items = config.items,
-                    viewModel = form.getViewModel();  
-                    form.add(items);
+                    form.addItems(items);
                 }
 
                 form.fireEvent('afterSetItems', form, items);

+ 30 - 26
frontend/saas-web/app/view/core/form/FormPanel.js

@@ -27,38 +27,14 @@ Ext.define('saas.view.core.form.FormPanel', {
         blankText: '该字段不能为空'
     },
 
-    dockedItems: [{
-        xtype: 'toolbar',
-        dock: 'top',
-        style: {
-            'border-bottom': '1px solid #35baf6 !important'
-        },
-        items: [{
-            xtype: 'tbtext',
-            bind: '单据编号:{id}'
-        }, '->', {
-            xtype: 'button',
-            text: '新增',
-            handler: 'add'
-        }, {
-            xtype: 'button',
-            text: '保存',
-            handler: 'save'
-        }, {
-            xtype: 'button',
-            text: '审核',
-            handler: "audit"
-        }]
-    }],
-
     items: [],
 
     remoteConfig: true, // 是否需要从远端读取form配置
     bindFields: [], // 已绑定字段(需要保存到数据库)
+    toolBtns: [], // 自定义按钮
 
     initComponent: function() {
         var me = this,
-        remoteConfig = me.remoteConfig;
 
         //判断是否加载数据
         if(me.initId&&me.initId!=0){
@@ -78,9 +54,37 @@ Ext.define('saas.view.core.form.FormPanel', {
             .catch(function(response) {
             });
         }
+
+        Ext.apply(me, {
+            remoteConfig: me.remoteConfig,
+            dockedItems: [{
+                xtype: 'toolbar',
+                dock: 'top',
+                style: {
+                    'border-bottom': '1px solid #35baf6 !important'
+                },
+                items: me.toolBtns.concat(['->', {
+                    xtype: 'button',
+                    text: '新增',
+                    handler: 'add'
+                }, {
+                    xtype: 'button',
+                    text: '保存',
+                    handler: 'save'
+                }, {
+                    xtype: 'button',
+                    text: '审核',
+                    handler: "audit"
+                }])
+            }]
+        });
         
-        remoteConfig && me.FormUtil.setItems(me);
+        me.remoteConfig && me.FormUtil.setItems(me);
         me.callParent(arguments);
+    },
+
+    addItems: function(items) {
+        this.add(items);
     }
     
 });

+ 11 - 0
frontend/saas-web/app/view/test/order/FormPanel.js

@@ -4,9 +4,20 @@ Ext.define('saas.view.test.order.FormPanel', {
 
     controller: 'test-order-formcontroller',
     viewModel: 'test-order-formmodel',
+<<<<<<< HEAD
     
     _codeField: 'puCode',
     _statusField: 'puStatuscode',
     _idField: 'puId',
     initId : 11
+=======
+
+    toolBtns: [{
+        xtype: 'button',
+        text: '测试',
+        handler: function() {
+            console.log('11');
+        }
+    }]
+>>>>>>> 201b642dc3fc73db186b7f07f0350aacfd94aee4
 });