MouldFeePlease.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.pm.mould.MouldFeePlease', {
  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. 'core.form.Panel','pm.mould.MouldFeePlease','core.grid.Panel2','core.toolbar.Toolbar','core.form.MultiField', 'core.form.SeparNumber',
  9. 'core.button.Save','core.button.Add','core.button.Submit','core.button.Print','core.button.ResAudit',
  10. 'core.button.Audit','core.button.Close','core.button.Delete','core.button.Update','core.button.DeleteDetail','core.button.ResSubmit',
  11. 'core.button.TurnPurcProdIO','core.form.FileField','core.button.UpdatePayStatus',
  12. 'core.button.TurnBankRegister','core.button.TurnBillAP','core.button.TurnBillARChange',
  13. 'core.button.End', 'core.button.ResEnd',
  14. 'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger','core.trigger.MultiDbfindTrigger','core.form.YnField'
  15. ],
  16. init:function(){
  17. var me = this;
  18. this.control({
  19. 'textfield[name=mp_thispayamount]':{
  20. beforerender: function(field){
  21. field.readOnly=false;
  22. }
  23. },
  24. 'field[name=mp_thispaydate]':{
  25. beforerender: function(field){
  26. field.readOnly=false;
  27. }
  28. },
  29. 'field[name=mp_bankcode]':{
  30. beforerender: function(field){
  31. field.readOnly=false;
  32. }
  33. },
  34. 'erpGridPanel2': {
  35. afterrender: function(grid){
  36. var status = Ext.getCmp('mp_statuscode');
  37. if(status && status.value != 'ENTERING' && status.value != 'COMMITED'){
  38. Ext.each(grid.columns, function(c){
  39. c.setEditor(null);
  40. });
  41. }
  42. },
  43. itemclick: this.onGridItemClick
  44. },
  45. 'erpSaveButton': {
  46. click: function(btn){
  47. var form = me.getForm(btn);
  48. if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
  49. me.BaseUtil.getRandomNumber();//自动添加编号
  50. }
  51. this.FormUtil.beforeSave(this);
  52. }
  53. },
  54. 'erpDeleteButton' : {
  55. click: function(btn){
  56. me.FormUtil.onDelete(Ext.getCmp('mp_id').value);
  57. }
  58. },
  59. 'erpPrintButton': {
  60. click: function(btn){
  61. var condition = '{MOULDFEEPLEASE.mp_id}=' + Ext.getCmp('mp_id').value;
  62. var reportName="AccountRegZW_zw";
  63. var id = Ext.getCmp('mp_id').value;
  64. me.FormUtil.onwindowsPrint(id, reportName, condition);
  65. }
  66. },
  67. 'erpUpdateButton': {
  68. afterrender: function(btn){
  69. var status = Ext.getCmp('mp_statuscode');
  70. if(status && status.value != 'ENTERING'){
  71. btn.hide();
  72. }
  73. },
  74. click: function(btn){
  75. this.FormUtil.onUpdate(this);
  76. }
  77. },
  78. 'erpAddButton': {
  79. click: function(){
  80. me.FormUtil.onAdd('addPurMould', '新增模具付款申请单', 'jsps/pm/mould/mouldFeePlease.jsp');
  81. }
  82. },
  83. 'erpCloseButton': {
  84. click: function(btn){
  85. me.FormUtil.beforeClose(me);
  86. }
  87. },
  88. 'erpSubmitButton': {
  89. afterrender: function(btn){
  90. var status = Ext.getCmp('mp_statuscode');
  91. if(status && status.value != 'ENTERING'){
  92. btn.hide();
  93. }
  94. },
  95. click: function(btn){
  96. me.FormUtil.onSubmit(Ext.getCmp('mp_id').value);
  97. }
  98. },
  99. 'erpResSubmitButton': {
  100. afterrender: function(btn){
  101. var status = Ext.getCmp('mp_statuscode');
  102. if(status && status.value != 'COMMITED'){
  103. btn.hide();
  104. }
  105. },
  106. click: function(btn){
  107. me.FormUtil.onResSubmit(Ext.getCmp('mp_id').value);
  108. }
  109. },
  110. 'erpAuditButton': {
  111. afterrender: function(btn){
  112. var status = Ext.getCmp('mp_statuscode');
  113. if(status && status.value != 'COMMITED'){
  114. btn.hide();
  115. }
  116. },
  117. click: function(btn){
  118. me.FormUtil.onAudit(Ext.getCmp('mp_id').value);
  119. }
  120. },
  121. 'erpResAuditButton': {
  122. afterrender: function(btn){
  123. var status = Ext.getCmp('mp_statuscode'),
  124. paystatus = Ext.getCmp('mp_paystatus'),
  125. turnstatus = Ext.getCmp('mp_turnstatuscode');
  126. if(status && status.value != 'AUDITED'){
  127. btn.hide();
  128. }
  129. if(paystatus && paystatus.value != '未付款'){
  130. btn.hide();
  131. }
  132. if(turnstatus && turnstatus.value){
  133. btn.hide();
  134. }
  135. },
  136. click: function(btn){
  137. me.FormUtil.onResAudit(Ext.getCmp('mp_id').value);
  138. }
  139. },
  140. 'erpEndButton': {
  141. afterrender: function(btn) {
  142. var status = Ext.getCmp('mp_statuscode');
  143. if (status && status.value != 'AUDITED') {
  144. btn.hide();
  145. }
  146. },
  147. click: function(btn) {
  148. me.FormUtil.onEnd(Ext.getCmp('mp_id').value);
  149. }
  150. },
  151. 'erpResEndButton': {
  152. afterrender: function(btn) {
  153. var status = Ext.getCmp('mp_statuscode');
  154. if (status && status.value != 'FINISH') {
  155. btn.hide();
  156. }
  157. },
  158. click: function(btn) {
  159. me.FormUtil.onResEnd(Ext.getCmp('mp_id').value);
  160. }
  161. },
  162. //转银行登记
  163. 'erpTurnBankRegisterButton':{
  164. click:function(btn){
  165. me.turnBankRegister();
  166. },
  167. afterrender: function(btn){
  168. var status = Ext.getCmp(me.getForm(btn).statuscodeField);
  169. if(status && status.value != 'AUDITED'){
  170. btn.hide();
  171. }
  172. }
  173. },
  174. //应付票据付款
  175. 'erpTurnBillAPButton':{
  176. click:function(btn){
  177. me.turnBillAP();
  178. },
  179. afterrender: function(btn){
  180. var status = Ext.getCmp(me.getForm(btn).statuscodeField);
  181. if(status && status.value != 'AUDITED'){
  182. btn.hide();
  183. }
  184. }
  185. },
  186. //应付票据付款
  187. 'erpTurnBillARChangeButton':{
  188. click:function(btn){
  189. me.turnBillARChange();
  190. },
  191. afterrender: function(btn){
  192. var status = Ext.getCmp(me.getForm(btn).statuscodeField);
  193. if(status && status.value != 'AUDITED'){
  194. btn.hide();
  195. }
  196. }
  197. },
  198. 'field[name=mfd_purccode]': {
  199. focus: function(t){
  200. t.setHideTrigger(false);
  201. t.setReadOnly(false);
  202. if(Ext.getCmp('mp_vendcode')){
  203. var code = Ext.getCmp('mp_vendcode').value;
  204. if(code == null || code == ''){
  205. showError("请先选择供应商!");
  206. t.setHideTrigger(true);
  207. t.setReadOnly(true);
  208. } else {
  209. var obj = me.getBaseCondition();
  210. if(obj.vendor){
  211. t.dbBaseCondition = "pm_vendcode='" + code + "'";
  212. }
  213. }
  214. }
  215. }
  216. }
  217. });
  218. },
  219. onGridItemClick: function(selModel, record){//grid行选择
  220. this.GridUtil.onGridItemClick(selModel, record);
  221. },
  222. getForm: function(btn){
  223. return btn.ownerCt.ownerCt;
  224. },
  225. turnBankRegister: function(){
  226. var me = this;
  227. var grid = Ext.getCmp('grid'), catecode = Ext.getCmp('mp_bankcode').value;
  228. var thisamount = Ext.getCmp('mp_thispayamount').value, amount = Ext.getCmp('mp_payamount').value;
  229. var ppamount = Ext.getCmp('mp_total').value;
  230. var thispaydate = Ext.getCmp('mp_thispaydate').value;
  231. if(Ext.isEmpty(thispaydate)){
  232. Ext.Msg.alert('警告','请填写本次付款日期!');
  233. return;
  234. }
  235. if(thisamount-(ppamount-amount)>0.01){
  236. Ext.Msg.alert('警告','本次付款金额超过剩余未转金额!未转金额:'+ (ppamount-amount));
  237. return;
  238. }
  239. if(catecode == null || catecode == ''){
  240. Ext.Msg.alert('警告','请填写需要转银行登记的付款方信息!');
  241. return;
  242. }
  243. if(thisamount == null || thisamount=='' || thisamount==0){
  244. Ext.Msg.alert('警告','本次付款金额未填写!');
  245. return;
  246. }
  247. me.FormUtil.getActiveTab().setLoading(true);//loading...
  248. Ext.Ajax.request({
  249. url : basePath + 'pm/mould/turnAccountRegister.action',
  250. params: {
  251. id: Ext.getCmp('mp_id').value,
  252. thisamount: thisamount,
  253. catecode : catecode,
  254. thisdate : thispaydate,
  255. caller : caller
  256. },
  257. method : 'post',
  258. callback : function(options,success,response){
  259. me.FormUtil.getActiveTab().setLoading(false);
  260. var localJson = new Ext.decode(response.responseText);
  261. if(localJson.exceptionInfo){
  262. showError(localJson.exceptionInfo);
  263. }
  264. if(localJson.success){
  265. turnSuccess(function(){
  266. var id = localJson.id;
  267. var url = "jsps/fa/gs/accountRegister.jsp?whoami=AccountRegister!Bank&formCondition=ar_id=" + id + "&gridCondition=ard_arid=" + id;
  268. me.FormUtil.onAdd('AccountRegister' + id, '银行登记' + id, url);
  269. });
  270. }
  271. }
  272. });
  273. },
  274. turnBillAP: function(){
  275. var me = this;
  276. var grid = Ext.getCmp('grid'), catecode = Ext.getCmp('mp_bankcode').value;
  277. var thisamount = Ext.getCmp('mp_thispayamount').value, amount = Ext.getCmp('mp_payamount').value;
  278. var ppamount = Ext.getCmp('mp_total').value;
  279. var thispaydate = Ext.getCmp('mp_thispaydate').value;
  280. if(Ext.isEmpty(thispaydate)){
  281. Ext.Msg.alert('警告','请填写本次付款日期!');
  282. return;
  283. }
  284. if(thisamount-(ppamount-amount)>0.01){
  285. Ext.Msg.alert('警告','本次付款金额超过剩余未转金额!未转金额:'+ (ppamount-amount));
  286. return;
  287. }
  288. if(catecode == null || catecode == ''){
  289. Ext.Msg.alert('警告','请填写需要转银行登记的付款方信息!');
  290. return;
  291. }
  292. if(thisamount == null || thisamount=='' || thisamount==0){
  293. Ext.Msg.alert('警告','本次付款金额未填写!');
  294. return;
  295. }
  296. me.FormUtil.getActiveTab().setLoading(true);//loading...
  297. Ext.Ajax.request({
  298. url : basePath + 'pm/mould/turnBillAP.action',
  299. params: {
  300. id: Ext.getCmp('mp_id').value,
  301. thisamount: thisamount,
  302. catecode : catecode,
  303. thisdate : thispaydate,
  304. caller : caller
  305. },
  306. method : 'post',
  307. callback : function(options,success,response){
  308. me.FormUtil.getActiveTab().setLoading(false);
  309. var localJson = new Ext.decode(response.responseText);
  310. if(localJson.exceptionInfo){
  311. showError(localJson.exceptionInfo);
  312. }
  313. if(localJson.success){
  314. turnSuccess(function(){
  315. var id = localJson.id;
  316. var url = "jsps/fa/gs/billAP.jsp?formCondition=bap_id=" + id;
  317. me.FormUtil.onAdd('BillAP' + id, '应付票据' + id, url);
  318. });
  319. }
  320. }
  321. });
  322. },
  323. turnBillARChange: function(){
  324. var me = this;
  325. var grid = Ext.getCmp('grid'), catecode = Ext.getCmp('mp_bankcode').value;
  326. var thisamount = Ext.getCmp('mp_thispayamount').value, amount = Ext.getCmp('mp_payamount').value;
  327. var ppamount = Ext.getCmp('mp_total').value;
  328. var thispaydate = Ext.getCmp('mp_thispaydate').value;
  329. if(Ext.isEmpty(thispaydate)){
  330. Ext.Msg.alert('警告','请填写本次付款日期!');
  331. return;
  332. }
  333. if(thisamount-(ppamount-amount)>0.01){
  334. Ext.Msg.alert('警告','本次付款金额超过剩余未转金额!未转金额:'+ (ppamount-amount));
  335. return;
  336. }
  337. if(catecode == null || catecode == ''){
  338. Ext.Msg.alert('警告','请填写需要转银行登记的付款方信息!');
  339. return;
  340. }
  341. if(thisamount == null || thisamount=='' || thisamount==0){
  342. Ext.Msg.alert('警告','本次付款金额未填写!');
  343. return;
  344. }
  345. me.FormUtil.getActiveTab().setLoading(true);//loading...
  346. Ext.Ajax.request({
  347. url : basePath + 'pm/mould/turnBillARChange.action',
  348. params: {
  349. id: Ext.getCmp('mp_id').value,
  350. thisamount: thisamount,
  351. catecode : catecode,
  352. thisdate : thispaydate,
  353. caller : caller
  354. },
  355. method : 'post',
  356. callback : function(options,success,response){
  357. me.FormUtil.getActiveTab().setLoading(false);
  358. var localJson = new Ext.decode(response.responseText);
  359. if(localJson.exceptionInfo){
  360. showError(localJson.exceptionInfo);
  361. }
  362. if(localJson.success){
  363. turnSuccess(function(){
  364. var id = localJson.id;
  365. var url = "jsps/fa/gs/billARChange.jsp?formCondition=brc_id=" + id + "&gridCondition=brd_brcid=" + id;
  366. me.FormUtil.onAdd('BillARChange' + id, '应收票据异动' + id, url);
  367. });
  368. }
  369. }
  370. });
  371. }
  372. });