PreVendor.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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), kind =Ext.getCmp('ve_kind').value
  19. codeField = Ext.getCmp(form.codeField);
  20. if(codeField.value == null || codeField.value == ''){
  21. me.BaseUtil.getRandomNumber(caller);//自动添加编号
  22. var res = me.getCode(kind);
  23. if(res != null && res != ''){
  24. codeField.setValue(res);
  25. } else
  26. me.BaseUtil.getRandomNumber('Vendor',10,null);//自动添加编号
  27. }
  28. this.FormUtil.beforeSave(this);
  29. }
  30. },
  31. 'erpCloseButton': {
  32. click: function(btn){
  33. this.FormUtil.beforeClose(this);
  34. },
  35. afterrender:function(btn){
  36. var panel = parent.Ext.getCmp('tree-tab');
  37. if(panel && !panel.collapsed) {
  38. panel.toggleCollapse();
  39. }
  40. }
  41. },
  42. 'erpUpdateButton': {
  43. afterrender: function(btn){
  44. var status = Ext.getCmp('ve_auditstatuscode');
  45. if(status && status.value != 'ENTERING'){
  46. btn.hide();
  47. }
  48. },
  49. click: function(btn){
  50. this.FormUtil.onUpdate(this);
  51. }
  52. },
  53. 'erpDeleteButton': {
  54. click: function(btn){
  55. me.FormUtil.onDelete(Ext.getCmp('ve_id').value);
  56. }
  57. },
  58. 'erpAddButton': {
  59. click: function(){
  60. me.FormUtil.onAdd('addPreVendor', '新增供应商引进申请', 'jsps/scm/purchase/preVendor.jsp');
  61. }
  62. },
  63. 'erpSubmitButton': {
  64. afterrender: function(btn){
  65. var status = Ext.getCmp('ve_auditstatuscode');
  66. if(status && status.value != 'ENTERING'){
  67. btn.hide();
  68. }
  69. },
  70. click: function(btn){
  71. me.FormUtil.onSubmit(Ext.getCmp('ve_id').value);
  72. }
  73. },
  74. 'erpResSubmitButton': {
  75. afterrender: function(btn){
  76. var status = Ext.getCmp('ve_auditstatuscode');
  77. if(status && status.value != 'COMMITED'){
  78. btn.hide();
  79. }
  80. },
  81. click: function(btn){
  82. me.FormUtil.onResSubmit(Ext.getCmp('ve_id').value);
  83. }
  84. },
  85. 'erpAuditButton': {
  86. afterrender: function(btn){
  87. var status = Ext.getCmp('ve_auditstatuscode');
  88. if(status && status.value != 'COMMITED'){
  89. btn.hide();
  90. }
  91. },
  92. click: function(btn){
  93. me.FormUtil.onAudit(Ext.getCmp('ve_id').value);
  94. }
  95. },
  96. 'erpResAuditButton': {
  97. afterrender: function(btn){
  98. var status = Ext.getCmp('ve_auditstatuscode');
  99. if(status && status.value != 'AUDITED'){
  100. btn.hide();
  101. }
  102. },
  103. click: function(btn){
  104. me.FormUtil.onResAudit(Ext.getCmp('ve_id').value);
  105. }
  106. },
  107. 'erpTurnVendorButton': {
  108. afterrender: function(btn){
  109. var status = Ext.getCmp('ve_auditstatuscode');
  110. if(status && status.value != 'AUDITED'){
  111. btn.hide();
  112. }
  113. },
  114. /* base: function(btn){
  115. warnMsg("确定要转入供应商基本资料吗?", function(btn){
  116. if(btn == 'yes'){
  117. me.FormUtil.getActiveTab().setLoading(true);//loading...
  118. Ext.Ajax.request({
  119. url : basePath + 'scm/purchase/turnVendorBase.action',
  120. params: {
  121. id: Ext.getCmp('ve_id').value
  122. },
  123. method : 'post',
  124. callback : function(options,success,response){
  125. me.FormUtil.getActiveTab().setLoading(false);
  126. var localJson = new Ext.decode(response.responseText);
  127. if(localJson.exceptionInfo){
  128. showError(localJson.exceptionInfo);
  129. }
  130. if(localJson.success){
  131. turnSuccess(function(){
  132. var id = localJson.id;
  133. var url = "jsps/scm/purchase/vendor.jsp?formCondition=ve_id=" + id;
  134. me.FormUtil.onAdd('Vendor' + id, '供应商' + id, url);
  135. });
  136. }
  137. }
  138. });
  139. }
  140. });
  141. },*/
  142. click: function(btn){
  143. warnMsg("确定要转入正式供应商吗?", function(btn){
  144. if(btn == 'yes'){
  145. me.FormUtil.getActiveTab().setLoading(true);//loading...
  146. Ext.Ajax.request({
  147. url : basePath + 'scm/purchase/turnVendor.action',
  148. params: {
  149. id: Ext.getCmp('ve_id').value
  150. },
  151. method : 'post',
  152. callback : function(options,success,response){
  153. me.FormUtil.getActiveTab().setLoading(false);
  154. var localJson = new Ext.decode(response.responseText);
  155. if(localJson.exceptionInfo){
  156. showError(localJson.exceptionInfo);
  157. }
  158. if(localJson.success){
  159. turnSuccess(function(){
  160. var id = localJson.id;
  161. var url = "jsps/scm/purchase/vendor.jsp?formCondition=ve_id=" + id;
  162. me.FormUtil.onAdd('Vendor' + id, '供应商' + id, url);
  163. });
  164. }
  165. }
  166. });
  167. }
  168. });
  169. }
  170. }
  171. });
  172. },
  173. getForm: function(btn){
  174. return btn.ownerCt.ownerCt;
  175. },
  176. getLeadCode: function(type) {
  177. var result = null;
  178. Ext.Ajax.request({
  179. url : basePath + 'common/getFieldData.action',
  180. async: false,
  181. params: {
  182. caller: 'VendorKind',
  183. field: 'VK_EXCODE',
  184. condition: 'VK_KIND=\'' + type + '\''
  185. },
  186. method : 'post',
  187. callback : function(opt, s, res){
  188. var r = new Ext.decode(res.responseText);
  189. if(r.exceptionInfo){
  190. showError(r.exceptionInfo);return;
  191. } else if(r.success){
  192. result = r.data;
  193. }
  194. }
  195. });
  196. return result;
  197. },
  198. getCode: function(type) {
  199. var result = null;
  200. Ext.Ajax.request({
  201. url : basePath + 'scm/vendor/getVendorCodeNum.action',
  202. async: false,
  203. params: {
  204. ve_kind: type
  205. },
  206. method : 'post',
  207. callback : function(opt, s, res){
  208. var r = new Ext.decode(res.responseText);
  209. if(r.exceptionInfo){
  210. showError(r.exceptionInfo);return;
  211. } else if(r.success){
  212. result = r.number;
  213. }
  214. }
  215. });
  216. return result;
  217. }
  218. });