Oapurchase.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.oa.appliance.Oapurchase', {
  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. 'oa.appliance.Oapurchase','core.form.Panel','core.grid.Panel2','core.toolbar.Toolbar','core.button.End',
  9. 'core.button.Add','core.button.Save','core.button.Close','core.button.DeleteDetail','core.button.ResEnd',
  10. 'core.button.Update','core.button.Delete','core.form.YnField','core.button.Submit',
  11. 'core.button.ResAudit','core.button.ResSubmit','core.button.Audit','core.button.TurnOaacceptance',
  12. 'core.trigger.TextAreaTrigger','core.button.Print','core.trigger.DbfindTrigger'
  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. 'erpCloseButton': {
  30. click: function(btn){
  31. this.FormUtil.beforeClose(this);
  32. }
  33. },
  34. 'erpUpdateButton': {
  35. click: function(btn){
  36. this.FormUtil.onUpdate(this);
  37. }
  38. },
  39. 'erpDeleteButton': {
  40. click: function(btn){
  41. me.FormUtil.onDelete(Ext.getCmp('op_id').value);
  42. }
  43. },
  44. 'erpPrintButton':{// 打印
  45. click: function(btn){
  46. var reportName = "OfficePurcList";
  47. var condition = '{Oapurchase.op_id}=' + Ext.getCmp('op_id').value + '';
  48. var id = Ext.getCmp('op_id').value;
  49. me.FormUtil.onwindowsPrint(id, reportName, condition);
  50. }
  51. },
  52. 'erpAddButton': {
  53. click: function(){
  54. me.FormUtil.onAdd('addOapurchase', '新增用品采购单', 'jsps/oa/appliance/oapurchase.jsp');
  55. }
  56. },'erpSubmitButton': {
  57. afterrender: function(btn){
  58. var status = Ext.getCmp('op_statuscode');
  59. if(status && status.value != 'ENTERING'){
  60. btn.hide();
  61. }
  62. },
  63. click: function(btn){
  64. me.FormUtil.onSubmit(Ext.getCmp('op_id').value);
  65. }
  66. },
  67. 'erpResSubmitButton': {
  68. afterrender: function(btn){
  69. var status = Ext.getCmp('op_statuscode');
  70. if(status && status.value != 'COMMITED'){
  71. btn.hide();
  72. }
  73. },
  74. click: function(btn){
  75. me.FormUtil.onResSubmit(Ext.getCmp('op_id').value);
  76. }
  77. },
  78. 'erpAuditButton': {
  79. afterrender: function(btn){
  80. var status = Ext.getCmp('op_statuscode');
  81. if(status && status.value != 'COMMITED'){
  82. btn.hide();
  83. }
  84. },
  85. click: function(btn){
  86. me.FormUtil.onAudit(Ext.getCmp('op_id').value);
  87. }
  88. },
  89. 'erpResAuditButton': {
  90. afterrender: function(btn){
  91. var status = Ext.getCmp('op_statuscode');
  92. if(status && status.value != 'AUDITED'){
  93. btn.hide();
  94. }
  95. },
  96. click: function(btn){
  97. me.FormUtil.onResAudit(Ext.getCmp('op_id').value);
  98. }
  99. },
  100. 'erpEndButton': {
  101. afterrender: function(btn) {
  102. var status = Ext.getCmp('op_statuscode');
  103. if (status && status.value != 'AUDITED') {
  104. btn.hide();
  105. }
  106. },
  107. click: function(btn) {
  108. me.FormUtil.onEnd(Ext.getCmp('op_id').value);
  109. }
  110. },
  111. 'erpResEndButton': {
  112. afterrender: function(btn) {
  113. var status = Ext.getCmp('op_statuscode');
  114. if (status && status.value != 'FINISH') {
  115. btn.hide();
  116. }
  117. },
  118. click: function(btn) {
  119. me.FormUtil.onResEnd(Ext.getCmp('op_id').value);
  120. }
  121. },
  122. 'erpTurnOaacceptanceButton':{
  123. afterrender: function(btn){
  124. var status = Ext.getCmp('op_statuscode');
  125. if(status && status.value != 'AUDITED'){
  126. btn.hide();
  127. }
  128. var isturn = Ext.getCmp('op_isturn');
  129. if(isturn && isturn.value != '0'){
  130. btn.hide();
  131. }
  132. },
  133. click: function(btn){
  134. warnMsg("确定要转入用品验收单吗?", function(btn){
  135. if(btn == 'yes'){
  136. var formdata = Ext.getCmp('form').getValues();
  137. var gridata = Ext.getCmp('grid').getStore().data.items;
  138. var jsonGridData = new Array();
  139. for(var i=0;i<gridata.length;i++){//将grid里面各行的数据获取并拼成jsonGridData
  140. var data = gridata[i].data;
  141. jsonGridData.push(Ext.JSON.encode(data));
  142. }
  143. }
  144. Ext.Ajax.request({
  145. url : basePath + 'oa/appliance/turnOaacceptance.action',
  146. params: {
  147. formdata : Ext.JSON.encode(formdata).toString(),
  148. griddata : "["+jsonGridData.toString()+"]"
  149. },
  150. method : 'post',
  151. callback : function(options,success,response){
  152. var localJson = new Ext.decode(response.responseText);
  153. if(localJson.exceptionInfo){
  154. showError(localJson.exceptionInfo);
  155. }
  156. if(localJson.success){
  157. Ext.Msg.alert('提示','转用采购品验收单成功!');
  158. }
  159. }
  160. });
  161. });
  162. }
  163. }
  164. });
  165. },
  166. onGridItemClick: function(selModel, record){//grid行选择
  167. this.GridUtil.onGridItemClick(selModel, record);
  168. },
  169. getForm: function(btn){
  170. return btn.ownerCt.ownerCt;
  171. }
  172. });