Form.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. Ext.define('erp.view.common.batchDeal.Form',{
  2. extend: 'Ext.form.Panel',
  3. alias: 'widget.erpBatchDealFormPanel',
  4. id: 'dealform',
  5. region: 'north',
  6. frame : true,
  7. layout : 'column',
  8. autoScroll : true,
  9. defaultType : 'textfield',
  10. labelSeparator : ':',
  11. buttonAlign : 'center',
  12. fieldDefaults : {
  13. margin : '4 2 4 2',
  14. fieldStyle : "background:#FFFAFA;color:#515151;",
  15. labelAlign : "right",
  16. blankText : $I18N.common.form.blankText
  17. },
  18. FormUtil: Ext.create('erp.util.FormUtil'),
  19. tbar: [{
  20. name: 'query',
  21. id: 'query',
  22. text: $I18N.common.button.erpQueryButton,
  23. iconCls: 'x-button-icon-query',
  24. cls: 'x-btn-gray',
  25. handler: function(){
  26. Ext.getCmp('dealform').onQuery();
  27. }
  28. }, '->', {
  29. xtype: 'erpMakeOccurButton',
  30. id: 'erpMakeOccurButton',
  31. hidden: true
  32. },
  33. {
  34. xtype: 'erpSaleOccurButton',
  35. id: 'erpSaleOccurButton',
  36. hidden: true
  37. },
  38. {
  39. xtype: 'erpVastAnalyseButton',
  40. id: 'erpVastAnalyseButton',
  41. hidden: true
  42. },{
  43. xtype: 'erpVastPrintButton',
  44. id: 'erpVastPrintButton',
  45. hidden: true
  46. },{
  47. xtype: 'erpVastDealButton',
  48. id: 'erpVastDealButton',
  49. hidden: true
  50. },'-',{
  51. name: 'export',
  52. text: $I18N.common.button.erpExportButton,
  53. iconCls: 'x-button-icon-excel',
  54. cls: 'x-btn-gray',
  55. handler: function(){
  56. var grid = Ext.getCmp('batchDealGridPanel');
  57. grid.BaseUtil.exportexcel(grid);
  58. }
  59. },'-',{
  60. text: $I18N.common.button.erpCloseButton,
  61. iconCls: 'x-button-icon-close',
  62. cls: 'x-btn-gray',
  63. handler: function(){
  64. var main = parent.Ext.getCmp("content-panel");
  65. main.getActiveTab().close();
  66. }
  67. }],
  68. initComponent : function(){
  69. this.getItemsAndButtons();
  70. this.callParent(arguments);
  71. },
  72. getItemsAndButtons: function(){
  73. var me = this;
  74. me.FormUtil.getActiveTab().setLoading(true);
  75. Ext.Ajax.request({//拿到form的items
  76. url : basePath + 'common/singleFormItems.action',
  77. params: {
  78. caller: caller,
  79. condition: ''
  80. },
  81. method : 'post',
  82. callback : function(options,success,response){
  83. me.FormUtil.getActiveTab().setLoading(false);
  84. var res = new Ext.decode(response.responseText);
  85. if(res.exceptionInfo != null){
  86. showError(res.exceptionInfo);return;
  87. }
  88. me.fo_keyField = res.fo_keyField;
  89. me.tablename = res.tablename;
  90. if(res.keyField){
  91. me.keyField = res.keyField;
  92. }
  93. if(res.dealUrl){
  94. me.dealUrl = res.dealUrl;
  95. }
  96. me.fo_detailMainKeyField = res.fo_detailMainKeyField;
  97. Ext.each(res.items, function(item){
  98. if(screen.width >= 1280){//根据屏幕宽度,调整列显示宽度
  99. if(item.columnWidth > 0 && item.columnWidth <= 0.34){
  100. item.columnWidth = 0.25;
  101. } else if(item.columnWidth > 0.34 && item.columnWidth <= 0.67){
  102. item.columnWidth = 0.5;
  103. }
  104. }
  105. });
  106. me.add(res.items);
  107. //解析buttons字符串,并拼成json格式
  108. var buttonString = res.buttons;
  109. if(buttonString != null && buttonString != ''){
  110. if(contains(buttonString, '#', true)){
  111. Ext.each(buttonString.split('#'), function(b, index){
  112. if(!Ext.getCmp(b)){
  113. var btn = Ext.getCmp('erpVastDealButton');
  114. if(btn){
  115. btn.ownerCt.insert(2, {
  116. xtype: b
  117. });
  118. Ext.getCmp(b).show();
  119. }
  120. } else {
  121. Ext.getCmp(b).show();
  122. }
  123. });
  124. } else {
  125. if(Ext.getCmp(buttonString)){
  126. Ext.getCmp(buttonString).show();
  127. } else {
  128. var btn = Ext.getCmp('erpVastDealButton');//Ext.getCmp(buttonString);
  129. if(btn){
  130. btn.setText($I18N.common.button[buttonString]);
  131. btn.show();
  132. }
  133. }
  134. }
  135. }
  136. }
  137. });
  138. },
  139. onQuery: function(){
  140. var grid = Ext.getCmp('batchDealGridPanel');
  141. grid.multiselected = new Array();
  142. var form = this;
  143. var urlcondition=getUrlParam('urlcondition');
  144. var condition=urlcondition==''?'':urlcondition;
  145. Ext.each(form.items.items, function(f){
  146. if(condition==''){
  147. condition +=f.logic+" like '%"+f.value+"%'";
  148. }
  149. condition += ' AND (' + f.logic + "like '%" + f.value + "%')";
  150. });
  151. var gridParam = {caller: caller, condition: condition};
  152. grid.GridUtil.getGridColumnsAndStore(grid, 'common/singleGridPanel.action', gridParam, "");
  153. }
  154. });