فهرست منبع

formutil调整

zhuth 7 سال پیش
والد
کامیت
020e077963
2فایلهای تغییر یافته به همراه31 افزوده شده و 36 حذف شده
  1. 1 9
      frontend/saas-web/app/util/FormUtil.js
  2. 30 27
      frontend/saas-web/app/view/core/form/FormPanel.js

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

@@ -25,15 +25,7 @@ Ext.define('saas.util.FormUtil', {
                 var config = res.data, items = [];
                 if(config) {
                     items = config.items,
-                    bindFields = items.filter(function(item) {
-                        return !!item.bind;
-                    }).map(function(item) {
-                        return item.bind.replace(/[{ | }]/g, '');
-                    }),
-                    viewModel = form.getViewModel();
-    
-                    form.bindFields = bindFields;
-                    form.add(items);
+                    form.addItems(items);
                 }
 
                 form.fireEvent('afterSetItems', form, items);

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

@@ -20,41 +20,44 @@ 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;
+        var me = this;
+        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);
     }
     
 });