PreVendor.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.scm.purchase.PreVendor', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. views:[
  7. 'scm.purchase.PreVendor','core.form.Panel','core.form.FileField','core.form.MultiField',
  8. 'core.button.Add','core.button.Submit','core.button.Audit','core.button.Save','core.button.Close',
  9. 'core.button.ResSubmit','core.button.Upload','core.button.Update','core.button.Delete',
  10. 'core.button.ResAudit','core.button.TurnVendor','core.button.Flow','core.button.DownLoad','core.form.SplitTextField',
  11. 'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger','core.form.YnField','core.trigger.AutoCodeTrigger'
  12. ],
  13. init:function(){
  14. var me = this;
  15. this.control({
  16. 'erpSaveButton': {
  17. click: function(btn){
  18. var form = me.getForm(btn), codeField = Ext.getCmp(form.codeField);
  19. if(codeField.value == null || codeField.value == ''){
  20. me.BaseUtil.getRandomNumber(null,10,null);//自动添加编号
  21. var res = me.getLeadCode(Ext.getCmp('ve_kind').value);
  22. if(res != null && res != ''){
  23. codeField.setValue(res + codeField.getValue());
  24. }
  25. }
  26. this.FormUtil.beforeSave(this);
  27. }
  28. },
  29. 'erpCloseButton': {
  30. click: function(btn){
  31. this.FormUtil.beforeClose(this);
  32. },
  33. afterrender:function(btn){
  34. var panel = parent.Ext.getCmp('tree-tab');
  35. if(panel && !panel.collapsed) {
  36. panel.toggleCollapse();
  37. }
  38. }
  39. },
  40. 'erpUpdateButton': {
  41. afterrender: function(btn){
  42. var status = Ext.getCmp('ve_auditstatuscode');
  43. if(status && status.value != 'ENTERING'){
  44. btn.hide();
  45. }
  46. },
  47. click: function(btn){
  48. this.FormUtil.onUpdate(this);
  49. }
  50. },
  51. 'erpDeleteButton': {
  52. click: function(btn){
  53. me.FormUtil.onDelete(Ext.getCmp('ve_id').value);
  54. }
  55. },
  56. 'erpAddButton': {
  57. click: function(){
  58. me.FormUtil.onAdd('addPreVendor', '新增供应商引进申请', 'jsps/scm/purchase/preVendor.jsp');
  59. }
  60. },
  61. 'erpSubmitButton': {
  62. afterrender: function(btn){
  63. var status = Ext.getCmp('ve_auditstatuscode');
  64. if(status && status.value != 'ENTERING'){
  65. btn.hide();
  66. }
  67. },
  68. click: function(btn){
  69. me.FormUtil.onSubmit(Ext.getCmp('ve_id').value);
  70. }
  71. },
  72. 'erpResSubmitButton': {
  73. afterrender: function(btn){
  74. var status = Ext.getCmp('ve_auditstatuscode');
  75. if(status && status.value != 'COMMITED'){
  76. btn.hide();
  77. }
  78. },
  79. click: function(btn){
  80. me.FormUtil.onResSubmit(Ext.getCmp('ve_id').value);
  81. }
  82. },
  83. 'erpAuditButton': {
  84. afterrender: function(btn){
  85. var status = Ext.getCmp('ve_auditstatuscode');
  86. if(status && status.value != 'COMMITED'){
  87. btn.hide();
  88. }
  89. },
  90. click: function(btn){
  91. me.FormUtil.onAudit(Ext.getCmp('ve_id').value);
  92. }
  93. },
  94. 'erpResAuditButton': {
  95. afterrender: function(btn){
  96. var status = Ext.getCmp('ve_auditstatuscode');
  97. if(status && status.value != 'AUDITED'){
  98. btn.hide();
  99. }
  100. },
  101. click: function(btn){
  102. me.FormUtil.onResAudit(Ext.getCmp('ve_id').value);
  103. }
  104. },
  105. 'erpTurnVendorButton': {
  106. afterrender: function(btn){
  107. var status = Ext.getCmp('ve_auditstatuscode'),
  108. turnstatus = Ext.getCmp('ve_turnstatuscode');
  109. if(status && status.value != 'AUDITED'){
  110. btn.hide();
  111. }
  112. if(turnstatus && turnstatus.value == 'TURNFM'){
  113. btn.hide();
  114. }
  115. },
  116. base: function(btn){
  117. warnMsg("确定要转入供应商基本资料吗?", function(btn){
  118. if(btn == 'yes'){
  119. me.FormUtil.getActiveTab().setLoading(true);//loading...
  120. Ext.Ajax.request({
  121. url : basePath + 'scm/purchase/turnVendorBase.action',
  122. params: {
  123. id: Ext.getCmp('ve_id').value
  124. },
  125. method : 'post',
  126. callback : function(options,success,response){
  127. me.FormUtil.getActiveTab().setLoading(false);
  128. var localJson = new Ext.decode(response.responseText);
  129. console.log(localJson);
  130. if(localJson.exceptionInfo){
  131. showError(localJson.exceptionInfo);
  132. }
  133. if(localJson.success){
  134. turnSuccess(function(){
  135. var id = localJson.id;
  136. var url = "jsps/scm/purchase/vendor.jsp?formCondition=ve_id=" + id;
  137. me.FormUtil.onAdd('Vendor' + id, '供应商' + id, url);
  138. });
  139. }
  140. }
  141. });
  142. }
  143. });
  144. },
  145. formal: function(btn){
  146. warnMsg("确定要转入正式供应商吗?", function(btn){
  147. if(btn == 'yes'){
  148. me.FormUtil.getActiveTab().setLoading(true);//loading...
  149. Ext.Ajax.request({
  150. url : basePath + 'scm/purchase/turnVendor.action',
  151. params: {
  152. id: Ext.getCmp('ve_id').value
  153. },
  154. method : 'post',
  155. callback : function(options,success,response){
  156. me.FormUtil.getActiveTab().setLoading(false);
  157. var localJson = new Ext.decode(response.responseText);
  158. console.log(localJson);
  159. if(localJson.exceptionInfo){
  160. showError(localJson.exceptionInfo);
  161. }
  162. if(localJson.success){
  163. turnSuccess(function(){
  164. var id = localJson.id;
  165. var url = "jsps/scm/purchase/vendor.jsp?formCondition=ve_id=" + id;
  166. me.FormUtil.onAdd('Vendor' + id, '供应商' + id, url);
  167. });
  168. }
  169. }
  170. });
  171. }
  172. });
  173. }
  174. }
  175. });
  176. },
  177. getForm: function(btn){
  178. return btn.ownerCt.ownerCt;
  179. },
  180. getLeadCode: function(type) {
  181. var result = null;
  182. Ext.Ajax.request({
  183. url : basePath + 'common/getFieldData.action',
  184. async: false,
  185. params: {
  186. caller: 'VendorKind',
  187. field: 'vk_excode',
  188. condition: 'vk_kind=\'' + type + '\''
  189. },
  190. method : 'post',
  191. callback : function(opt, s, res){
  192. var r = new Ext.decode(res.responseText);
  193. if(r.exceptionInfo){
  194. showError(r.exceptionInfo);return;
  195. } else if(r.success){
  196. result = r.data;
  197. }
  198. }
  199. });
  200. return result;
  201. }
  202. });