feePleaseYZSYSQ.js 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.oa.fee.feePleaseYZSYSQ', {
  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 : ['oa.fee.feePleaseYZSYSQ', 'core.form.Panel', 'core.grid.Panel2',
  8. 'core.toolbar.Toolbar', 'core.button.Scan', 'core.form.FileField',
  9. 'core.button.Save', 'core.button.Add', 'core.button.Submit',
  10. 'core.button.Print', 'core.button.Upload', 'core.button.ResAudit',
  11. 'core.button.Audit', 'core.button.Close', 'core.button.Delete',
  12. 'core.button.Update', 'core.button.DeleteDetail',
  13. 'core.button.TurnFYBX', 'core.form.DateHourMinuteField',
  14. 'core.button.ResSubmit', 'core.button.End', 'core.button.ResEnd',
  15. 'core.button.Confirm', 'core.trigger.MultiDbfindTrigger',
  16. 'core.trigger.DbfindTrigger', 'core.trigger.TextAreaTrigger',
  17. 'core.grid.detailAttach', 'core.form.MultiField',
  18. 'erp.view.core.button.AddDetail',
  19. 'erp.view.core.button.DeleteDetail', 'erp.view.core.button.Copy',
  20. 'erp.view.core.button.Paste', 'erp.view.core.button.Up',
  21. 'erp.view.core.button.Down', 'erp.view.core.button.UpExcel',
  22. 'common.datalist.Toolbar', 'core.trigger.AutoCodeTrigger'],
  23. init : function() {
  24. var me = this;
  25. this.control({
  26. 'erpGridPanel2' : {
  27. itemclick : function(view, record) {
  28. this.onGridItemClick(view, record);
  29. }
  30. },
  31. 'dbfindtrigger[name=fp_vendcode]':{
  32. aftertrigger:function(trigger){
  33. var data = Ext.getCmp('grid').getStore().data;
  34. for(var i =0;i<data.getCount();i++){
  35. data.getAt(i).set('fpd_d6',Ext.getCmp('fp_vendname').value); }
  36. }},
  37. 'autocodetrigger' : {
  38. aftertrigger : function(trigger, val, path, item) {
  39. Ext.getCmp('FP_V13').setValue(null);
  40. Ext.getCmp('FP_V4').setValue(null);
  41. Ext.getCmp('FP_V5').setValue(null);
  42. Ext.getCmp('FP_V7').setValue(null);
  43. Ext.getCmp('FP_V8').setValue(null);
  44. if (path) {
  45. if (path[0]) {
  46. Ext.getCmp('FP_V4').setValue(path[0]);
  47. }
  48. if (path[1]) {
  49. Ext.getCmp('FP_V5').setValue(path[1]);
  50. }
  51. if (path[2]) {
  52. Ext.getCmp('FP_V7').setValue(path[2]);
  53. }
  54. if (path[3]) {
  55. Ext.getCmp('FP_V8').setValue(path[3]);
  56. }
  57. }
  58. if (val) {
  59. Ext.getCmp('FP_V13').setValue(val);
  60. Ext.getCmp('FP_V12').setValue(val.substr(0, val.length
  61. - (item.data['length'])));
  62. Ext.getCmp('FP_N2').setValue(item.data['length']);
  63. Ext.getCmp('FP_N1').setValue(val.substr(val.length
  64. - (item.data['length']), val.length));
  65. }
  66. }
  67. },
  68. 'erpSaveButton' : {
  69. click : function(btn) {
  70. var form = me.getForm(btn);
  71. if (Ext.getCmp(form.codeField).value == null
  72. || Ext.getCmp(form.codeField).value == '') {
  73. me.BaseUtil.getRandomNumber();// 自动添加编号
  74. }
  75. this.FormUtil.beforeSave(this);
  76. }
  77. },
  78. 'erpCloseButton' : {
  79. click : function(btn) {
  80. this.FormUtil.beforeClose(this);
  81. }
  82. },
  83. 'erpAddButton' : {
  84. click : function() {
  85. me.FormUtil
  86. .onAdd('addFeePleaseYZSYSQ', '新增印章申请单',
  87. 'jsps/oa/fee/feePleaseYZSYSQ.jsp?whoami=FeePlease!YZSYSQ');
  88. }
  89. },
  90. 'erpUpdateButton' : {
  91. click : function(btn) {
  92. this.FormUtil.onUpdate(this);
  93. }
  94. },
  95. 'erpDeleteButton' : {
  96. afterrender : function(btn) {
  97. var status = Ext.getCmp('fp_statuscode');
  98. if (status && status.value != 'ENTERING') {
  99. btn.hide();
  100. }
  101. },
  102. click : function(btn) {
  103. me.FormUtil.onDelete((Ext.getCmp('fp_id').value));
  104. }
  105. },
  106. 'erpAuditButton' : {
  107. afterrender : function(btn) {
  108. var status = Ext.getCmp('fp_statuscode');
  109. if (status && status.value != 'COMMITED') {
  110. btn.hide();
  111. }
  112. },
  113. click : function(btn) {
  114. this.FormUtil.onAudit(Ext.getCmp('fp_id').value);
  115. }
  116. },
  117. 'erpResAuditButton' : {
  118. afterrender : function(btn) {
  119. var status = Ext.getCmp('fp_statuscode');
  120. if (status && status.value != 'AUDITED') {
  121. btn.hide();
  122. }
  123. },
  124. click : function(btn) {
  125. this.FormUtil.onResAudit(Ext.getCmp('fp_id').value);
  126. }
  127. },
  128. 'erpSubmitButton' : {
  129. afterrender : function(btn) {
  130. var status = Ext.getCmp('fp_statuscode');
  131. if (status && status.value != 'ENTERING') {
  132. btn.hide();
  133. }
  134. },
  135. click : function(btn) {
  136. this.FormUtil.onSubmit(Ext.getCmp('fp_id').value);
  137. }
  138. },
  139. 'erpResSubmitButton' : {
  140. afterrender : function(btn) {
  141. var status = Ext.getCmp('fp_statuscode');
  142. if (status && status.value != 'COMMITED') {
  143. btn.hide();
  144. }
  145. },
  146. click : function(btn) {
  147. this.FormUtil.onResSubmit(Ext.getCmp('fp_id').value);
  148. }
  149. },
  150. 'erpPrintButton' : {
  151. click : function(btn) {
  152. var reportName = '';
  153. var kind = Ext.getCmp('fp_kind').value;
  154. if (kind == "印章申请单") {
  155. reportName = "AccountRegZW_yzsq";
  156. }
  157. var condition = '{FeePlease.fp_id}='
  158. + Ext.getCmp('fp_id').value + '';
  159. var id = Ext.getCmp('fp_id').value;
  160. me.FormUtil.onwindowsPrint(id, reportName, condition);
  161. }
  162. },
  163. 'erpEndButton' : {
  164. afterrender : function(btn) {
  165. var status = Ext.getCmp('fp_statuscode');
  166. if (status && status.value == 'FINISH') {
  167. btn.hide();
  168. }
  169. },
  170. click : function(btn) {
  171. this.FormUtil.onEnd(Ext.getCmp('fp_id').value);
  172. }
  173. },
  174. 'erpResEndButton' : {
  175. afterrender : function(btn) {
  176. var status = Ext.getCmp('fp_statuscode');
  177. if (status && status.value != 'FINISH') {
  178. btn.hide();
  179. }
  180. },
  181. click : function(btn) {
  182. this.FormUtil.onResEnd(Ext.getCmp('fp_id').value);
  183. }
  184. },
  185. 'erpConfirmButton' : {
  186. afterrender : function(btn) {
  187. var statu = Ext.getCmp('fp_statuscode');
  188. if (statu && statu.value != 'AUDITED') {
  189. btn.hide();
  190. }
  191. },
  192. click : function(btn) {
  193. me.onConfirm(Ext.getCmp('fp_id').value);
  194. }
  195. },
  196. 'erpDeleteDetailButton' : {
  197. afterrender : function(btn) {
  198. var status = Ext.getCmp('fp_statuscode');
  199. if (status && status.value != 'ENTERING') {
  200. btn.disabled = true;
  201. }
  202. }
  203. },
  204. 'erpTurnFYBXButton' : {
  205. afterrender : function(btn) {
  206. var statu = Ext.getCmp('fp_statuscode');
  207. if (statu && statu.value != 'AUDITED') {
  208. btn.hide();
  209. }
  210. },
  211. click : function(btn) {
  212. if (Ext.getCmp('sealTurnFYBXWin')) {
  213. Ext.getCmp('sealTurnFYBXWin').show();
  214. } else {
  215. Ext.create('Ext.window.Window', {
  216. id : 'sealTurnFYBXWin',
  217. title : '转费用报销',
  218. closeAction : 'hide',
  219. width : 300,
  220. height : 250,
  221. maximizable : true,
  222. buttonAlign : 'center',
  223. layout : 'anchor',
  224. buttons : [{
  225. text : $I18N.common.button.erpConfirmButton,
  226. height : 26,
  227. handler : function(b) {
  228. me.sealTurnFYBX(Ext
  229. .getCmp('thisturnamount').value);
  230. var w = b.ownerCt.ownerCt;
  231. w.close();
  232. }
  233. }, {
  234. text : $I18N.common.button.erpCancelButton,
  235. height : 26,
  236. handler : function(b) {
  237. var w = b.ownerCt.ownerCt;
  238. w.close();
  239. }
  240. }],
  241. items : [{
  242. fieldLabel : '申请金额',
  243. xtype : 'numberfield',
  244. readOnly : true,
  245. value : Ext.getCmp('fp_pleaseamount') ? Ext
  246. .getCmp('fp_pleaseamount').value : 0
  247. }, {
  248. fieldLabel : '批准总额',
  249. xtype : 'numberfield',
  250. readOnly : true,
  251. value : Ext.getCmp('fp_n3') ? Ext
  252. .getCmp('fp_n3').value : 0
  253. }, {
  254. fieldLabel : '已转金额',
  255. xtype : 'numberfield',
  256. readOnly : true,
  257. value : Ext.getCmp('fp_n4') ? Ext
  258. .getCmp('fp_n4').value : 0
  259. }, {
  260. id : 'thisturnamount',
  261. fieldLabel : '本次转金额',
  262. xtype : 'numberfield',
  263. allowBlank : false,
  264. value : (Ext.getCmp('fp_n3').value - Ext
  265. .getCmp('fp_n4').value).toFixed(3)
  266. }]
  267. }).show();
  268. }
  269. }
  270. }
  271. });
  272. },
  273. sealTurnFYBX : function(thisturnamount) {
  274. var me = this;
  275. if (me.BaseUtil.numberFormat(thisturnamount, 2)
  276. + me.BaseUtil.numberFormat(Ext.getCmp('fp_n4').value, 2) > me.BaseUtil
  277. .numberFormat(Ext.getCmp('fp_n3').value, 2)) {
  278. showMessage("警告", '本次转金额超出剩余金额!');
  279. return;
  280. }
  281. if (thisturnamount <= 0) {
  282. showMessage("警告", '本次转金额应大于0!');
  283. return;
  284. }
  285. //me.FormUtil.getActiveTab().setLoading(true);// loading...
  286. Ext.Ajax.request({
  287. url : basePath + 'oa/feeplease/sealTurnFYBX.action',
  288. params : {
  289. caller : caller,
  290. id : Ext.getCmp('fp_id').value,
  291. thisturnamount : thisturnamount
  292. },
  293. method : 'post',
  294. callback : function(options, success, response) {
  295. //me.FormUtil.getActiveTab().setLoading(false);
  296. window.location.reload();
  297. var localJson = new Ext.decode(response.responseText);
  298. if (localJson.exceptionInfo) {
  299. showError(localJson.exceptionInfo);
  300. }
  301. if (localJson.success) {
  302. if (localJson.log) {
  303. showMessage("提示", localJson.log);
  304. }
  305. }
  306. }
  307. });
  308. },
  309. onGridItemClick : function(selModel, record) {// grid行选择
  310. if (Ext.getCmp('fileform')) {
  311. Ext.getCmp('fileform').setDisabled(false);
  312. }
  313. this.GridUtil.onGridItemClick(selModel, record);
  314. },
  315. getForm : function(btn) {
  316. return btn.ownerCt.ownerCt;
  317. }
  318. });