MultiForm.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. Ext.define('erp.view.ma.MultiForm',{
  2. extend: 'Ext.Viewport',
  3. layout: 'anchor',
  4. hideBorders: true,
  5. initComponent : function(){
  6. var me = this;
  7. Ext.apply(me, {
  8. items: [{
  9. xtype: 'tabpanel',
  10. anchor: '100% 95%',
  11. id: 'mytab',
  12. items: []
  13. },{
  14. xtype: 'toolbar',
  15. anchor: '100% 5%',
  16. items: ['->',{
  17. iconCls: 'x-button-icon-preview',
  18. name: 'FormBook',
  19. cls: 'x-btn-gray',
  20. text: $I18N.common.button.erpFormBookButton
  21. },'-',{
  22. iconCls: 'x-button-icon-add',
  23. name: 'ReportFiles',
  24. cls: 'x-btn-gray',
  25. text: $I18N.common.button.erpReportFilesButton
  26. },'-',{
  27. iconCls: 'x-button-icon-set',
  28. name: 'listSetting',
  29. cls: 'x-btn-gray',
  30. id:"listSetting",
  31. text: '列表设置'
  32. },'-',{
  33. iconCls: 'tree-save',
  34. name: 'save',
  35. cls: 'x-btn-gray',
  36. text: $I18N.common.button.erpSaveButton
  37. },'-',{
  38. xtype: 'erpSyncButton',
  39. style: {
  40. marginLeft: '0'
  41. }
  42. },'-',{
  43. iconCls: 'tree-delete',
  44. name: 'delete',
  45. cls: 'x-btn-gray',
  46. text: $I18N.common.button.erpDeleteButton
  47. },'-',{
  48. iconCls: 'tree-close',
  49. name: 'close',
  50. cls: 'x-btn-gray',
  51. text: $I18N.common.button.erpCloseButton
  52. },'->']
  53. }]
  54. });
  55. me.callParent(arguments);
  56. me.insertFormSet();
  57. me.insertGridSet();
  58. },
  59. insertFormSet: function() {
  60. var me = this, whoami = getUrlParam('formParam'), cond = getUrlParam('formCondition');
  61. if(typeof whoami !== 'undefined' || typeof cond !== 'undefined') {
  62. if(cond) {
  63. cond = cond.replace('IS','=');// 兼容原写法
  64. whoami = cond.substr(cond.indexOf('=')+1);
  65. }
  66. var formParams = whoami.split(','), tab = me.down('#mytab');
  67. Ext.Array.each(formParams, function(p, index){
  68. tab.add({
  69. title: '主表' + (formParams.length > 1 ? (index + 1) : ''),
  70. iconCls: 'formset-form',
  71. layout: 'anchor',
  72. items: [],
  73. dataId: p,
  74. listeners: {
  75. activate: function(panel) {
  76. me.getForm(panel);
  77. }
  78. }
  79. });
  80. });
  81. }
  82. },
  83. insertGridSet: function() {
  84. var me = this, whoami = getUrlParam('gridParam'), cal = getUrlParam('whoami');
  85. if(typeof whoami !== 'undefined') {
  86. cal && (whoami = cal);
  87. if(whoami && whoami != 'null') {
  88. var gridParams = whoami.split(','), tab = me.down('#mytab');
  89. Ext.Array.each(gridParams, function(p, index){
  90. tab.add({
  91. title: '从表' + (gridParams.length > 1 ? (index + 1) : ''),
  92. iconCls: 'formset-grid',
  93. layout: 'anchor',
  94. items: [],
  95. whoami: p,
  96. listeners: {
  97. activate: function(panel) {
  98. // 第一次activate的时候才加载
  99. me.getDetail(panel);
  100. }
  101. }
  102. });
  103. });
  104. }
  105. }
  106. },
  107. getForm: function(panel) {
  108. if(!panel.firstReady) {
  109. panel.add([{
  110. xtype: 'myform',
  111. deleteUrl: 'ma/deleteMultiForm.action',
  112. updateUrl: 'ma/updateMultiForm.action',
  113. keyField: 'fo_id',
  114. anchor: '100% 45%',
  115. dataId: panel.dataId
  116. },{
  117. xtype: 'mygrid',
  118. anchor: '100% 55%',
  119. dataId: panel.dataId
  120. }]);
  121. panel.firstReady = true;
  122. }
  123. },
  124. getDetail: function(panel) {
  125. if(!panel.firstReady) {
  126. panel.add({
  127. xtype: 'mydetail',
  128. id: panel.id + '-grid',
  129. whoami: panel.whoami,
  130. anchor: '100% 100%',
  131. detno: 'dg_sequence',
  132. necessaryField: 'dg_field',
  133. keyField: 'dg_id',
  134. plugins: Ext.create('Ext.grid.plugin.CellEditing', {
  135. pluginId: panel.id + '-grid-editor',
  136. clicksToEdit: 1
  137. })
  138. });
  139. panel.firstReady = true;
  140. }
  141. }
  142. });