ATPMain.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.pm.atp.ATPMain', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. GridUtil: Ext.create('erp.util.GridUtil'),
  6. BaseUtil: Ext.create('erp.util.BaseUtil'),
  7. views:[
  8. 'core.form.Panel','pm.atp.ATPMain','core.grid.Panel2','core.toolbar.Toolbar','core.form.MultiField',
  9. 'core.button.Save','core.button.Add','core.button.Submit','core.button.Print','core.button.ResAudit',
  10. 'core.button.Audit','core.button.Close','core.button.Delete','core.button.Update','core.button.DeleteDetail',
  11. 'core.button.ResSubmit','core.button.Flow','core.trigger.MultiDbfindTrigger','core.button.Post','core.button.ResPost',
  12. 'core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger','core.form.YnField','core.button.ExecuteOperation','core.button.SupplyScan'
  13. ],
  14. init:function(){
  15. var me = this;
  16. this.control({
  17. 'erpGridPanel2': {
  18. itemclick: this.onGridItemClick
  19. },
  20. 'erpSaveButton': {
  21. click: function(btn){
  22. var form = me.getForm(btn);
  23. if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
  24. me.BaseUtil.getRandomNumber();//自动添加编号
  25. }
  26. this.FormUtil.beforeSave(this);
  27. }
  28. },
  29. 'erpDeleteButton' : {
  30. click: function(btn){
  31. me.FormUtil.onDelete(Ext.getCmp('am_id').value);
  32. }
  33. },
  34. 'erpUpdateButton': {
  35. click: function(btn){
  36. this.FormUtil.onUpdate(this);
  37. }
  38. },
  39. 'erpAddButton': {
  40. click: function(){
  41. me.FormUtil.onAdd('addATPMain', '新增应付开票记录', 'jsps/pm/atp/ATPMain.jsp');
  42. }
  43. },
  44. 'erpCloseButton': {
  45. click: function(btn){
  46. me.FormUtil.beforeClose(me);
  47. }
  48. },
  49. 'erpSubmitButton': {
  50. afterrender: function(btn){
  51. var status = Ext.getCmp('am_statuscode');
  52. if(status && status.value != 'ENTERING'){
  53. btn.hide();
  54. }
  55. },
  56. click: function(btn){
  57. me.FormUtil.onSubmit(Ext.getCmp('am_id').value);
  58. }
  59. },
  60. 'erpResSubmitButton': {
  61. afterrender: function(btn){
  62. var status = Ext.getCmp('am_statuscode');
  63. if(status && status.value != 'COMMITED'){
  64. btn.hide();
  65. }
  66. },
  67. click: function(btn){
  68. me.FormUtil.onResSubmit(Ext.getCmp('am_id').value);
  69. }
  70. },
  71. 'erpAuditButton': {
  72. afterrender: function(btn){
  73. var status = Ext.getCmp('am_statuscode');
  74. if(status && status.value != 'COMMITED'){
  75. btn.hide();
  76. }
  77. },
  78. click: function(btn){
  79. me.FormUtil.onAudit(Ext.getCmp('am_id').value);
  80. }
  81. },
  82. 'erpResAuditButton': {
  83. afterrender: function(btn){
  84. var status = Ext.getCmp('am_statuscode');
  85. if(status && status.value != 'AUDITED'){
  86. btn.hide();
  87. }
  88. },
  89. click: function(btn){
  90. me.FormUtil.onResAudit(Ext.getCmp('am_id').value);
  91. }
  92. },
  93. 'erpPrintButton': {
  94. click: function(btn){
  95. me.FormUtil.onPrint(Ext.getCmp('am_id').value);
  96. }
  97. },
  98. 'erpExecuteOperationButton':{
  99. click: function(btn){
  100. me.FormUtil.setLoading(true);//loading...
  101. Ext.Ajax.request({
  102. url : basePath + 'pm/atp/executeOperation.action',
  103. params: {
  104. id: Ext.getCmp('am_id').value
  105. },
  106. method : 'post',
  107. timeout: 600000,
  108. callback : function(options,success,response){
  109. me.FormUtil.setLoading(false);
  110. var localJson = new Ext.decode(response.responseText);
  111. if(localJson.exceptionInfo){
  112. showError(localJson.exceptionInfo);
  113. }
  114. if(localJson.success){
  115. //resAudit成功后刷新页面进入可编辑的页面
  116. showMessage('提示', '执行运算成功!', 2000);
  117. window.location.reload();
  118. }
  119. }
  120. });
  121. }
  122. },
  123. 'erpSupplyScanButton':{
  124. click: function(btn){
  125. var form=Ext.getCmp('form');
  126. var keyField=form.keyField;
  127. var KeyValue=Ext.getCmp(keyField).value;
  128. if(KeyValue==null||KeyValue==''){
  129. showError('请先保存记录');
  130. }
  131. var me = this;
  132. var url=basePath+"jsps/common/queryDetail.jsp";
  133. var panel = Ext.getCmp("lackResultid=" +KeyValue);
  134. var main = parent.Ext.getCmp("content-panel");
  135. var urlCondition='ad_atpid='+KeyValue;
  136. main.getActiveTab().currentGrid = Ext.getCmp('grid');
  137. if(!panel){
  138. var title = "";
  139. if (KeyValue.toString().length>4) {
  140. title = KeyValue.toString().substring(KeyValue.toString().length-4);
  141. } else {
  142. title = KeyValue;
  143. }
  144. panel = {
  145. title:'供需查询('+KeyValue+')',
  146. tag : 'iframe',
  147. tabConfig:{tooltip:'供需查询('+title+')'},
  148. frame : true,
  149. border : false,
  150. layout : 'fit',
  151. iconCls : 'x-tree-icon-tab-tab',
  152. html : '<iframe id="iframe_maindetail_'+caller+"_"+KeyValue+'" src="'+url+'?whoami=ATPDATA&_noc=1&urlcondition='+urlCondition+'" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>',
  153. closable : true,
  154. listeners : {
  155. close : function(){
  156. main.setActiveTab(main.getActiveTab().id);
  157. }
  158. }
  159. };
  160. me.FormUtil.openTab(panel,"lackResultid=" + KeyValue);
  161. }else{
  162. main.setActiveTab(panel);
  163. }
  164. }
  165. }
  166. });
  167. },
  168. beforeSubmit:function(btn){
  169. var me = this;
  170. var grid = Ext.getCmp('grid'),items=grid.store.data.items;
  171. me.FormUtil.onSubmit(Ext.getCmp('am_id').value);
  172. },
  173. onGridItemClick: function(selModel, record){//grid行选择
  174. this.GridUtil.onGridItemClick(selModel, record);
  175. },
  176. getForm: function(btn){
  177. return btn.ownerCt.ownerCt;
  178. }
  179. });