Application.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.plm.scm.Application', {
  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','plm.scm.Application','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','core.button.ResSubmit',
  11. 'core.button.TurnPurc','core.button.Flow',
  12. 'core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger','core.form.YnField'
  13. ],
  14. init:function(){
  15. var me = this;
  16. me.gridLastSelected = null;
  17. this.control({
  18. 'erpGridPanel2': {
  19. itemclick: this.onGridItemClick
  20. },
  21. 'erpSaveButton': {
  22. click: function(btn){
  23. var form = me.getForm(btn);
  24. if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
  25. me.BaseUtil.getRandomNumber();//自动添加编号
  26. }
  27. var bool = true;
  28. //数量不能为空或0
  29. //给从表赋值:vendcode、vendname
  30. var grid = Ext.getCmp('grid');
  31. var items = grid.store.data.items;
  32. Ext.each(items, function(item){
  33. if(item.dirty && item.data[grid.necessaryField] != null && item.data[grid.necessaryField] != ""){
  34. if(item.data['ad_qty'] == null || item.data['ad_qty'] == '' || item.data['ad_qty'] == '0'
  35. || item.data['pd_qty'] == 0){
  36. bool = false;
  37. showError('明细表第' + item.data['ad_detno'] + '行的数量为空');return;
  38. }
  39. }
  40. });
  41. if(bool){
  42. this.FormUtil.beforeSave(this);
  43. }
  44. }
  45. },
  46. 'field[name=ap_currency]': {
  47. beforetrigger: function(field) {
  48. var t = field.up('form').down('field[name=ap_date]'),
  49. value = t.getValue();
  50. if(value) {
  51. field.findConfig = 'cm_yearmonth=' + Ext.Date.format(value, 'Ym');
  52. }
  53. }
  54. },
  55. 'erpDeleteButton' : {
  56. click: function(btn){
  57. me.FormUtil.onDelete(Ext.getCmp('ap_id').value);
  58. }
  59. },
  60. 'erpUpdateButton': {
  61. click: function(btn){
  62. var bool = true;
  63. //数量不能为空或0
  64. //给从表赋值:vendcode、vendname
  65. var grid = Ext.getCmp('grid');
  66. var items = grid.store.data.items;
  67. Ext.each(items, function(item){
  68. if(item.dirty && item.data[grid.necessaryField] != null && item.data[grid.necessaryField] != ""){
  69. if(item.data['ad_qty'] == null || item.data['ad_qty'] == '' || item.data['ad_qty'] == '0'
  70. || item.data['pd_qty'] == 0){
  71. bool = false;
  72. showError('明细表第' + item.data['ad_detno'] + '行的数量为空');return;
  73. }
  74. }
  75. });
  76. if(bool){
  77. this.FormUtil.onUpdate(this);
  78. }
  79. }
  80. },
  81. 'erpAddButton': {
  82. click: function(){
  83. me.FormUtil.onAdd('addApplication', '新增研发请购单', 'jsps/plm/scm/application.jsp');
  84. }
  85. },
  86. 'erpCloseButton': {
  87. click: function(btn){
  88. me.FormUtil.beforeClose(me);
  89. }
  90. },
  91. 'erpSubmitButton': {
  92. afterrender: function(btn){
  93. var status = Ext.getCmp('ap_statuscode');
  94. if(status && status.value != 'ENTERING'){
  95. btn.hide();
  96. }
  97. },
  98. click: function(btn){
  99. me.FormUtil.onSubmit(Ext.getCmp('ap_id').value);
  100. }
  101. },
  102. 'erpResSubmitButton': {
  103. afterrender: function(btn){
  104. var status = Ext.getCmp('ap_statuscode');
  105. if(status && status.value != 'COMMITED'){
  106. btn.hide();
  107. }
  108. },
  109. click: function(btn){
  110. me.FormUtil.onResSubmit(Ext.getCmp('ap_id').value);
  111. }
  112. },
  113. 'erpAuditButton': {
  114. afterrender: function(btn){
  115. var status = Ext.getCmp('ap_statuscode');
  116. if(status && status.value != 'COMMITED'){
  117. btn.hide();
  118. }
  119. },
  120. click: function(btn){
  121. me.FormUtil.onAudit(Ext.getCmp('ap_id').value);
  122. }
  123. },
  124. 'erpResAuditButton': {
  125. afterrender: function(btn){
  126. var status = Ext.getCmp('ap_statuscode');
  127. if(status && status.value != 'AUDITED'){
  128. btn.hide();
  129. }
  130. },
  131. click: function(btn){
  132. me.FormUtil.onResAudit(Ext.getCmp('ap_id').value);
  133. }
  134. },
  135. 'erpPrintButton': {
  136. click: function(btn){
  137. me.FormUtil.onPrint(Ext.getCmp('ap_id').value);
  138. }
  139. },
  140. 'erp2PurcButton': {
  141. afterrender: function(btn){
  142. var status = Ext.getCmp('ap_statuscode');
  143. if(status && status.value != 'AUDITED'){
  144. btn.hide();
  145. }
  146. },
  147. click: function(btn){
  148. warnMsg("确定要转入采购单吗?", function(btn){
  149. if(btn == 'yes'){
  150. me.FormUtil.getActiveTab().setLoading(true);//loading...
  151. Ext.Ajax.request({
  152. url : basePath + 'scm/purchase/turnPurchase.action',
  153. params: {
  154. id: Ext.getCmp('ap_id').value
  155. },
  156. method : 'post',
  157. callback : function(options,success,response){
  158. me.FormUtil.getActiveTab().setLoading(false);
  159. var localJson = new Ext.decode(response.responseText);
  160. if(localJson.exceptionInfo){
  161. showError(localJson.exceptionInfo);
  162. }
  163. if(localJson.success){
  164. turnSuccess(function(){
  165. var id = localJson.id;
  166. var url = "jsps/scm/purchase/purchase.jsp?formCondition=pu_id=" + id + "&gridCondition=pd_puid=" + id;
  167. me.FormUtil.onAdd('Purchase' + id, '采购单' + id, url);
  168. });
  169. }
  170. }
  171. });
  172. }
  173. });
  174. }
  175. }
  176. });
  177. },
  178. onGridItemClick: function(selModel, record){//grid行选择
  179. this.GridUtil.onGridItemClick(selModel, record);
  180. },
  181. getForm: function(btn){
  182. return btn.ownerCt.ownerCt;
  183. }
  184. });