CustomerCreditApplication.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.scm.sale.CustomerCreditApplication', {
  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. 'scm.sale.CustomerCreditApplication','core.form.Panel','core.form.MultiField','core.grid.Panel2','core.form.FileField',
  9. 'core.button.Save','core.button.Add','core.button.Submit','core.button.Upload','core.button.ResAudit',
  10. 'core.button.Audit','core.button.Close','core.button.Delete','core.button.Update','core.button.ResSubmit',
  11. 'core.button.Sync','core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger','core.form.YnField'
  12. ],
  13. init:function(){
  14. var me = this;
  15. this.control({
  16. 'erpGridPanel2': {
  17. itemclick: this.onGridItemClick
  18. },
  19. 'erpSaveButton': {
  20. click: function(btn){
  21. var form = me.getForm(btn);
  22. /*if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
  23. me.BaseUtil.getRandomNumber();//自动添加编号
  24. }*/
  25. this.FormUtil.beforeSave(this);
  26. }
  27. },
  28. 'erpDeleteButton' : {
  29. click: function(btn){
  30. me.FormUtil.onDelete(Ext.getCmp('cca_id').value);
  31. }
  32. },
  33. 'erpUpdateButton': {
  34. afterrender: function(btn){
  35. var status = Ext.getCmp('cca_statuscode');
  36. if(status && status.value != 'ENTERING'){
  37. btn.hide();
  38. }
  39. },
  40. click: function(btn){
  41. me.beforeUpdate();
  42. }
  43. },
  44. 'erpAddButton': {
  45. click: function(){
  46. me.FormUtil.onAdd('addCustomerCreditApplication', '新增客户信用申请', 'jsps/scm/sale/CustomerCreditApplication.jsp');
  47. }
  48. },
  49. 'erpCloseButton': {
  50. click: function(btn){
  51. me.FormUtil.beforeClose(me);
  52. }
  53. },
  54. 'erpSubmitButton': {
  55. afterrender: function(btn){
  56. var status = Ext.getCmp('cca_statuscode');
  57. if(status && status.value != 'ENTERING'){
  58. btn.hide();
  59. }
  60. },
  61. click: function(btn){
  62. me.beforeSubmit(btn);
  63. }
  64. },
  65. 'erpResSubmitButton': {
  66. afterrender: function(btn){
  67. var status = Ext.getCmp('cca_statuscode');
  68. if(status && status.value != 'COMMITED'){
  69. btn.hide();
  70. }
  71. },
  72. click: function(btn){
  73. me.FormUtil.onResSubmit(Ext.getCmp('cca_id').value);
  74. }
  75. },
  76. 'erpAuditButton': {
  77. afterrender: function(btn){
  78. var status = Ext.getCmp('cca_statuscode');
  79. if(status && status.value != 'COMMITED'){
  80. btn.hide();
  81. }
  82. },
  83. click: function(btn){
  84. me.FormUtil.onAudit(Ext.getCmp('cca_id').value);
  85. }
  86. },
  87. 'erpResAuditButton': {
  88. afterrender: function(btn){
  89. var status = Ext.getCmp('cca_statuscode');
  90. if(status && status.value != 'AUDITED'){
  91. btn.hide();
  92. }
  93. },
  94. click: function(btn){
  95. me.FormUtil.onResAudit(Ext.getCmp('cca_id').value);
  96. }
  97. },
  98. 'field[name=cca_name]': {
  99. afterrender:function(f){
  100. f.setFieldStyle({
  101. 'color': 'blue'
  102. });
  103. f.focusCls = 'mail-attach';
  104. var c = Ext.Function.bind(me.openRelative, me);
  105. Ext.EventManager.on(f.inputEl, {
  106. mousedown : c,
  107. scope: f,
  108. buffer : 100
  109. });
  110. }
  111. }
  112. });
  113. },
  114. openRelative: function(e, el, obj) {
  115. var f = obj.scope;
  116. if(f.value) {
  117. this.FormUtil.onAdd('RiskAssessment', f.ownerCt.down('#cca_name').value,
  118. this.getRelativeUrl(f));
  119. }
  120. },
  121. getRelativeUrl: function(f) {
  122. var v = f.value, form = f.ownerCt,
  123. s = form.down('#cca_name'),
  124. cal = this.getRelativeCaller(s.value),
  125. u = '';
  126. if(!Ext.isEmpty(v)) {
  127. if(v.indexOf(',') > 0) {
  128. var _v = v.split(',');
  129. for(var i in _v) {
  130. _v[i] = "'" + _v[i] + "'";
  131. }
  132. var id = this.getRelativeId(s.value);
  133. u = 'jsps/common/datalist.jsp?whoami=' + cal + '&urlcondition=ra_id in(' + id + ')';
  134. } else {
  135. var id = this.getRelativeId(s.value);
  136. u = 'jsps/scm/sale/RiskAssessment.jsp?whoami=' + cal + '&formCondition=ra_idIS' +id;
  137. }
  138. }
  139. return u;
  140. },
  141. getRelativeId: function(s) {
  142. var id = 0;
  143. Ext.Ajax.request({
  144. url : basePath + 'common/getFieldData.action',
  145. async: false,
  146. params: {
  147. caller: 'RiskAssessment',
  148. field: 'wmsys.wm_concat(ra_id)',
  149. condition: 'ra_custname=\'' + s + '\''
  150. },
  151. method : 'post',
  152. callback : function(o, s, r){
  153. var rs = new Ext.decode(r.responseText);
  154. if(rs.exceptionInfo){
  155. showError(rs.exceptionInfo);return;
  156. }
  157. if(rs.success){
  158. if(rs.data != null){
  159. id = rs.data;
  160. }
  161. }
  162. }
  163. });
  164. return id;
  165. },
  166. getRelativeCaller: function(v) {
  167. var c = '';
  168. switch (v) {
  169. case '风险评估报告':
  170. c = 'RiskAssessment';break;
  171. }
  172. return c;
  173. },
  174. beforeSubmit:function(btn){
  175. var me = this;
  176. var grid = Ext.getCmp('grid'),items=grid.store.data.items;
  177. me.FormUtil.onSubmit(Ext.getCmp('cca_id').value);
  178. },
  179. beforeUpdate: function(){
  180. var bool = true;
  181. if(bool)
  182. this.FormUtil.onUpdate(this);
  183. },
  184. getForm: function(btn){
  185. return btn.ownerCt.ownerCt;
  186. },
  187. onGridItemClick: function(selModel, record){//grid行选择
  188. this.GridUtil.onGridItemClick(selModel, record);
  189. }
  190. });