Ext.define('erp.view.ma.MultiForm',{ extend: 'Ext.Viewport', layout: 'anchor', hideBorders: true, initComponent : function(){ var me = this; Ext.apply(me, { items: [{ xtype: 'tabpanel', anchor: '100% 95%', id: 'mytab', items: [] },{ xtype: 'toolbar', anchor: '100% 5%', items: ['->',{ iconCls: 'x-button-icon-preview', name: 'FormBook', cls: 'x-btn-gray', text: $I18N.common.button.erpFormBookButton },'-',{ iconCls: 'x-button-icon-add', name: 'ReportFiles', cls: 'x-btn-gray', text: $I18N.common.button.erpReportFilesButton },'-',{ iconCls: 'x-button-icon-set', name: 'listSetting', cls: 'x-btn-gray', id:"listSetting", text: '列表设置' },'-',{ iconCls: 'tree-save', name: 'save', cls: 'x-btn-gray', text: $I18N.common.button.erpSaveButton },'-',{ xtype: 'erpSyncButton', style: { marginLeft: '0' } },'-',{ iconCls: 'tree-delete', name: 'delete', cls: 'x-btn-gray', text: $I18N.common.button.erpDeleteButton },'-',{ iconCls: 'tree-close', name: 'close', cls: 'x-btn-gray', text: $I18N.common.button.erpCloseButton },'->'] }] }); me.callParent(arguments); me.insertFormSet(); me.insertGridSet(); }, insertFormSet: function() { var me = this, whoami = getUrlParam('formParam'), cond = getUrlParam('formCondition'); if(typeof whoami !== 'undefined' || typeof cond !== 'undefined') { if(cond) { cond = cond.replace('IS','=');// 兼容原写法 whoami = cond.substr(cond.indexOf('=')+1); } var formParams = whoami.split(','), tab = me.down('#mytab'); Ext.Array.each(formParams, function(p, index){ tab.add({ title: '主表' + (formParams.length > 1 ? (index + 1) : ''), iconCls: 'formset-form', layout: 'anchor', items: [], dataId: p, listeners: { activate: function(panel) { me.getForm(panel); } } }); }); } }, insertGridSet: function() { var me = this, whoami = getUrlParam('gridParam'), cal = getUrlParam('whoami'); if(typeof whoami !== 'undefined') { cal && (whoami = cal); if(whoami && whoami != 'null') { var gridParams = whoami.split(','), tab = me.down('#mytab'); Ext.Array.each(gridParams, function(p, index){ tab.add({ title: '从表' + (gridParams.length > 1 ? (index + 1) : ''), iconCls: 'formset-grid', layout: 'anchor', items: [], whoami: p, listeners: { activate: function(panel) { // 第一次activate的时候才加载 me.getDetail(panel); } } }); }); } } }, getForm: function(panel) { if(!panel.firstReady) { panel.add([{ xtype: 'myform', deleteUrl: 'ma/deleteMultiForm.action', updateUrl: 'ma/updateMultiForm.action', keyField: 'fo_id', anchor: '100% 45%', dataId: panel.dataId },{ xtype: 'mygrid', anchor: '100% 55%', dataId: panel.dataId }]); panel.firstReady = true; } }, getDetail: function(panel) { if(!panel.firstReady) { panel.add({ xtype: 'mydetail', id: panel.id + '-grid', whoami: panel.whoami, anchor: '100% 100%', detno: 'dg_sequence', necessaryField: 'dg_field', keyField: 'dg_id', plugins: Ext.create('Ext.grid.plugin.CellEditing', { pluginId: panel.id + '-grid-editor', clicksToEdit: 1 }) }); panel.firstReady = true; } } });