MultiForm.js 3.2 KB

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