Vendor.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.scm.purchase.Vendor', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. views:[
  7. 'scm.purchase.Vendor','core.form.Panel','core.form.MultiField','core.form.FileField',
  8. 'core.button.Add','core.button.Submit','core.button.Audit','core.button.Save','core.button.Close','core.button.Print',
  9. 'core.button.Upload','core.button.Update','core.button.Delete','core.button.ResAudit','core.button.DownLoad','core.button.VendorLevel',
  10. 'core.button.ResSubmit','core.button.Banned','core.button.ResBanned','core.button.Flow','core.button.VendorUU',
  11. 'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger','core.form.YnField', 'core.button.Sync','core.button.UpdateInfo'
  12. ],
  13. init:function(){
  14. var me = this;
  15. this.control({
  16. 'field[name=ve_ifdeliveryonb2b]':{
  17. beforerender: function(field){
  18. field.readOnly=false;
  19. }
  20. },
  21. 'erpSaveButton': {
  22. click: function(btn){
  23. var form = me.getForm(btn), codeField = Ext.getCmp(form.codeField);
  24. if(codeField.value == null || codeField.value == ''){
  25. me.BaseUtil.getRandomNumber(null,10,null);//自动添加编号
  26. var res = me.getLeadCode(Ext.getCmp('ve_type').value);
  27. if(res != null && res != ''){
  28. codeField.setValue(res + codeField.getValue());
  29. }
  30. }
  31. //保存之前的一些前台的逻辑判定
  32. this.FormUtil.beforeSave(this);
  33. }
  34. },
  35. 'erpDeleteButton' : {
  36. click: function(btn){
  37. me.FormUtil.onDelete(Ext.getCmp('ve_id').value);
  38. }
  39. },
  40. 'erpUpdateButton': {
  41. click: function(btn){
  42. this.FormUtil.onUpdate(this);
  43. }
  44. },
  45. 'erpAddButton': {
  46. click: function(){
  47. me.FormUtil.onAdd('addVendor', '新增供应商基本资料', 'jsps/scm/purchase/vendor.jsp');
  48. }
  49. },
  50. 'erpCloseButton': {
  51. click: function(btn){
  52. me.FormUtil.beforeClose(me);
  53. }
  54. },
  55. 'erpSubmitButton': {
  56. afterrender: function(btn){
  57. var status = Ext.getCmp('ve_auditstatuscode');
  58. if(status && status.value != 'ENTERING'){
  59. btn.hide();
  60. }
  61. },
  62. click: function(btn){
  63. me.FormUtil.onSubmit(Ext.getCmp('ve_id').value);
  64. }
  65. },
  66. 'erpResSubmitButton': {
  67. afterrender: function(btn){
  68. var status = Ext.getCmp('ve_auditstatuscode');
  69. if(status && status.value != 'COMMITED'){
  70. btn.hide();
  71. }
  72. },
  73. click: function(btn){
  74. me.FormUtil.onResSubmit(Ext.getCmp('ve_id').value);
  75. }
  76. },
  77. 'erpAuditButton': {
  78. afterrender: function(btn){
  79. var status = Ext.getCmp('ve_auditstatuscode');
  80. if(status && status.value != 'COMMITED'){
  81. btn.hide();
  82. }
  83. },
  84. click: function(btn){
  85. me.FormUtil.onAudit(Ext.getCmp('ve_id').value);
  86. }
  87. },
  88. 'erpResAuditButton': {
  89. afterrender: function(btn){
  90. var status = Ext.getCmp('ve_auditstatuscode');
  91. if(status && status.value != 'AUDITED'){
  92. btn.hide();
  93. }
  94. },
  95. click: function(btn){
  96. me.FormUtil.onResAudit(Ext.getCmp('ve_id').value);
  97. }
  98. },
  99. 'erpPrintButton': {
  100. click: function(btn){
  101. me.FormUtil.onPrint(Ext.getCmp('ve_id').value);
  102. }
  103. },
  104. 'erpBannedButton': {
  105. afterrender: function(btn){
  106. var status = Ext.getCmp('ve_auditstatuscode');
  107. if(status && status.value == 'DISABLE'){
  108. btn.hide();
  109. }
  110. },
  111. click: function(btn){
  112. this.FormUtil.onBanned(Ext.getCmp('ve_id').value);
  113. }
  114. },
  115. 'erpResBannedButton': {
  116. afterrender: function(btn){
  117. var status = Ext.getCmp('ve_auditstatuscode');
  118. if(status && status.value != 'DISABLE'){
  119. btn.hide();
  120. }
  121. },
  122. click: function(btn){
  123. this.FormUtil.onResBanned(Ext.getCmp('ve_id').value);
  124. }
  125. },
  126. 'erpUpdateInfoButton':{
  127. click:function(){
  128. var text=Ext.getCmp('ve_ifdeliveryonb2b');
  129. me.updateInfo(text.value, Ext.getCmp('ve_id').value);
  130. }
  131. },
  132. });
  133. },
  134. updateInfo:function(text,id){
  135. Ext.Ajax.request({
  136. url : basePath + 'scm/purchase/vendor/updateInfo.action',
  137. params: {text:text,id:id},
  138. method : 'post',
  139. async:false,
  140. callback : function(options,success,response){
  141. var res = new Ext.decode(response.responseText);
  142. if(res.exceptionInfo != null){
  143. showError(res.exceptionInfo);return;
  144. }
  145. showMessage("提示", '更新成功!');
  146. window.location.reload();
  147. }
  148. });
  149. },
  150. getForm: function(btn){
  151. return btn.ownerCt.ownerCt;
  152. },
  153. getLeadCode: function(type) {
  154. var result = null;
  155. Ext.Ajax.request({
  156. url : basePath + 'common/getFieldData.action',
  157. async: false,
  158. params: {
  159. caller: 'VendorKind',
  160. field: 'vk_excode',
  161. condition: 'vk_kind=\'' + type + '\''
  162. },
  163. method : 'post',
  164. callback : function(opt, s, res){
  165. var r = new Ext.decode(res.responseText);
  166. if(r.exceptionInfo){
  167. showError(r.exceptionInfo);return;
  168. } else if(r.success){
  169. result = r.data;
  170. }
  171. }
  172. });
  173. return result;
  174. }
  175. });