feePlease2.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.oa.fee.feePlease2', {
  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. 'oa.fee.feePlease2','core.form.Panel','core.grid.Panel2','core.toolbar.Toolbar','core.button.Scan',
  9. 'core.button.Save','core.button.Add','core.button.Submit','core.button.Print','core.button.Upload','core.button.ResAudit',
  10. 'core.button.Audit','core.button.Close','core.button.Delete','core.button.Update','core.button.DeleteDetail',
  11. 'core.button.ResSubmit','core.button.TurnCLFBX','core.button.TurnFYBX','core.button.TurnYHFKSQ',
  12. 'core.button.TurnYWZDBX','core.button.End','core.button.ResEnd','core.form.FileField',
  13. 'core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger','core.form.YnField',
  14. ],
  15. init:function(){
  16. var me = this;
  17. this.control({
  18. 'erpGridPanel2': {
  19. itemclick: this.onGridItemClick
  20. },
  21. 'erpSaveButton': {
  22. click: function(btn){
  23. var form = me.getForm(btn),
  24. c = form.ownerCt.down('container[itemId=item2]');
  25. if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
  26. me.BaseUtil.getRandomNumber();//自动添加编号
  27. }
  28. this.getamount();
  29. if(form.keyField){
  30. if(Ext.getCmp(form.keyField).value == null || Ext.getCmp(form.keyField).value == ''){
  31. this.FormUtil.getSeqId(form);
  32. }
  33. }
  34. var f = this.GridUtil.getGridStore(c.down('grid'));
  35. this.FormUtil.onSave(f);
  36. }
  37. },
  38. 'combo[name=fp_type]': {
  39. delay: 200,
  40. afterrender : function(m) {
  41. this.resetViewport(m.ownerCt, m, m.getValue());
  42. },
  43. change: function(m){
  44. this.resetViewport(m.ownerCt, m, m.getValue());
  45. }
  46. },
  47. 'erpCloseButton': {
  48. click: function(btn){
  49. this.FormUtil.beforeClose(this);
  50. }
  51. },
  52. 'erpAddButton': {
  53. click: function(btn){
  54. me.FormUtil.onAdd('add' + caller, '新增费用申请', "jsps/oa/fee/feePlease2.jsp?whoami=" + caller);
  55. }
  56. },
  57. 'erpUpdateButton': {
  58. click: function(btn){
  59. var form = me.getForm(btn),
  60. c = form.ownerCt.down('container[itemId=item2]'),
  61. f = this.GridUtil.getGridStore(c.down('grid'));
  62. this.getamount();
  63. this.FormUtil.update(form.getValues(), f);
  64. }
  65. },
  66. 'erpDeleteButton': {
  67. afterrender: function(btn){
  68. var status = Ext.getCmp('fp_statuscode');
  69. if(status && status.value != 'ENTERING'){
  70. btn.hide();
  71. }
  72. },
  73. click: function(btn){
  74. me.FormUtil.onDelete((Ext.getCmp('fp_id').value));
  75. }
  76. },
  77. 'erpAuditButton': {
  78. afterrender: function(btn){
  79. var status = Ext.getCmp('fp_statuscode');
  80. if(status && status.value != 'COMMITED'){
  81. btn.hide();
  82. }
  83. },
  84. click: function(btn){
  85. this.FormUtil.onAudit(Ext.getCmp('fp_id').value);
  86. }
  87. },
  88. 'erpResAuditButton': {
  89. afterrender: function(btn){
  90. var status = Ext.getCmp('fp_statuscode');
  91. if(status && status.value != 'AUDITED'){
  92. btn.hide();
  93. }
  94. },
  95. click: function(btn){
  96. this.FormUtil.onResAudit(Ext.getCmp('fp_id').value);
  97. }
  98. },
  99. 'erpSubmitButton': {
  100. afterrender: function(btn){
  101. var status = Ext.getCmp('fp_statuscode');
  102. if(status && status.value != 'ENTERING'){
  103. btn.hide();
  104. }
  105. },
  106. click: function(btn){
  107. this.FormUtil.onSubmit(Ext.getCmp('fp_id').value);
  108. }
  109. },
  110. 'erpPrintButton': {
  111. click:function(btn){
  112. var kind=Ext.getCmp('fp_kind').value;
  113. var reportName='';
  114. if (kind=="借款申请单"){
  115. var kindtype=Ext.getCmp('fp_type').value;
  116. if(kindtype=="应酬费"){reportName="FeePleaseQt1";}
  117. if(kindtype=="差旅费"){reportName="FeePleaseQt2";}
  118. if(kindtype=="培训费"){reportName="FeePleaseQt3";}
  119. if(kindtype=="其它"){reportName="FeePleaseQt";}
  120. }else if(kind="费用报销单"){
  121. reportName="FeeClaimQt";
  122. }
  123. var condition='{FeePlease.fp_id}='+Ext.getCmp('fp_id').value+'';
  124. var id=Ext.getCmp('fp_id').value;
  125. me.FormUtil.onwindowsPrint(id,reportName,condition);
  126. }
  127. },
  128. 'erpResSubmitButton': {
  129. afterrender: function(btn){
  130. var status = Ext.getCmp('fp_statuscode');
  131. if(status && status.value != 'COMMITED'){
  132. btn.hide();
  133. }
  134. },
  135. click: function(btn){
  136. this.FormUtil.onResSubmit(Ext.getCmp('fp_id').value);
  137. }
  138. },
  139. 'erpEndButton': {
  140. afterrender: function(btn){
  141. var status = Ext.getCmp('fp_statuscode');
  142. if(status && status.value == 'FINISH'){
  143. btn.hide();
  144. }
  145. },
  146. click: function(btn){
  147. this.FormUtil.onEnd(Ext.getCmp('fp_id').value);
  148. }
  149. },
  150. 'erpResEndButton': {
  151. afterrender: function(btn){
  152. var status = Ext.getCmp('fp_statuscode');
  153. if(status && status.value != 'FINISH'){
  154. btn.hide();
  155. }
  156. },
  157. click: function(btn){
  158. this.FormUtil.onResEnd(Ext.getCmp('fp_id').value);
  159. }
  160. },
  161. 'erpTurnCLFBXButton':{
  162. afterrender: function(btn){
  163. var status = Ext.getCmp('fp_statuscode');
  164. if(status && status.value != 'AUDITED'){
  165. btn.hide();
  166. }
  167. },
  168. click: function(btn){
  169. warnMsg("确定要转入差旅费报销单吗?", function(btn){
  170. if(btn == 'yes'){
  171. me.FormUtil.getActiveTab().setLoading(true);//loading...
  172. Ext.Ajax.request({
  173. url : basePath + 'oa/feeplease/turnCLFBX.action',
  174. params: {
  175. caller: caller,
  176. id: Ext.getCmp('fp_id').value
  177. },
  178. method : 'post',
  179. callback : function(options,success,response){
  180. me.FormUtil.getActiveTab().setLoading(false);
  181. var localJson = new Ext.decode(response.responseText);
  182. if(localJson.exceptionInfo){
  183. showError(localJson.exceptionInfo);
  184. }
  185. if(localJson.success){
  186. turnSuccess(function(){
  187. var id = localJson.id;
  188. var url = "jsps/oa/fee/feePlease.jsp?whoami=FeePlease!CLFBX&formCondition=fp_id=" + id + "&gridCondition=fpd_fpid=" + id;
  189. me.FormUtil.onAdd('FeePlease' + id, '差旅费报销单' + id, url);
  190. });
  191. }
  192. }
  193. });
  194. }
  195. });
  196. }
  197. },
  198. 'erpTurnFYBXButton':{
  199. afterrender: function(btn){
  200. var status = Ext.getCmp('fp_statuscode');
  201. if(status && status.value != 'AUDITED'){
  202. btn.hide();
  203. }
  204. },
  205. click: function(btn){
  206. var url = null;
  207. if(caller=='FeePlease!JKSQ'){
  208. url = 'oa/feeplease/jksqturnFYBX.action';
  209. }
  210. warnMsg("确定要转入费用报销单吗?", function(btn){
  211. if(btn == 'yes'){
  212. me.FormUtil.getActiveTab().setLoading(true);//loading...
  213. Ext.Ajax.request({
  214. url : basePath + url,
  215. params: {
  216. caller: caller,
  217. id: Ext.getCmp('fp_id').value
  218. },
  219. method : 'post',
  220. callback : function(options,success,response){
  221. me.FormUtil.getActiveTab().setLoading(false);
  222. var localJson = new Ext.decode(response.responseText);
  223. if(localJson.exceptionInfo){
  224. showError(localJson.exceptionInfo);
  225. }
  226. if(localJson.success){
  227. turnSuccess(function(){
  228. var id = localJson.id;
  229. var url = "jsps/oa/fee/feePlease2.jsp?whoami=FeePlease!FYBX&formCondition=fp_id=" + id + "&gridCondition=fpd_fpid=" + id;
  230. me.FormUtil.onAdd('FeePlease' + id, '费用报销单' + id, url);
  231. });
  232. }
  233. }
  234. });
  235. }
  236. });
  237. }
  238. }
  239. });
  240. },
  241. getamount: function(){
  242. var grid = Ext.getCmp('grid');
  243. var items = grid.store.data.items;
  244. var amount = 0;
  245. Ext.each(items,function(item,index){
  246. if(item.data['fpd_date1']!=null&&item.data['fpd_date1']!=""){
  247. amount= amount + Number(item.data['fpd_total']);
  248. }
  249. });
  250. Ext.getCmp('fp_pleaseamount').setValue(amount);
  251. Ext.getCmp('fp_n2').setValue(amount);
  252. },
  253. onGridItemClick: function(selModel, record){//grid行选择
  254. this.GridUtil.onGridItemClick(selModel, record);
  255. },
  256. getForm: function(btn){
  257. return btn.ownerCt.ownerCt;
  258. },
  259. resetViewport : function(form, cm, val) {
  260. var vp = form.ownerCt.down('container[itemId=item2]');
  261. var c = null, a = null, b = null;
  262. if(caller == 'FeePlease!FYBX'){
  263. c = this.getCallerByType2(val),
  264. a = c.form, b = c.grid;
  265. } else {
  266. c = this.getCallerByType(val),
  267. a = c.form, b = c.grid;
  268. }
  269. vp.removeAll(true);
  270. if (a) {
  271. vp.add(Ext.create('erp.view.core.form.Panel', {
  272. id : 'form-oth',
  273. anchor: '100% 30%',
  274. caller: a,
  275. _noc: 1,
  276. enableTools: false
  277. }));
  278. }
  279. if (b) {
  280. var c = this.BaseUtil.getUrlParam('gridCondition');
  281. if (c) {
  282. c = c.replace(/IS/g, "=");
  283. }
  284. vp.add(Ext.create('erp.view.core.grid.Panel2', {
  285. caller: b,
  286. width: '100%',
  287. anchor: '100% ' + (a == null ? '100%' : '70%'),
  288. detno: 'fpd_detno',
  289. keyField: 'fpd_id',
  290. mainField: 'fpd_fpid',
  291. condition: c,
  292. listeners : {
  293. afterrender : function(grid) {
  294. // grid.getView().getEl().setWidth(1000);
  295. }
  296. }
  297. }));
  298. }
  299. },
  300. //借款申请单
  301. getCallerByType : function(t) {
  302. var a = null, b = null;
  303. switch (t) {
  304. case '应酬费':
  305. a = 'FeePlease!JKSQ!YC';
  306. b = 'FeePlease!JKSQ';
  307. break;
  308. case '差旅费':
  309. a = 'FeePlease!JKSQ!CL';
  310. b = 'FeePlease!JKSQ!CL';
  311. break;
  312. case '培训费':
  313. a = 'FeePlease!JKSQ!PX';
  314. b = 'FeePlease!JKSQ!PX';
  315. break;
  316. case '其它':
  317. b = 'FeePlease!JKSQ!QT';
  318. break;
  319. }
  320. return {form : a, grid : b};
  321. },
  322. //费用报销单
  323. getCallerByType2 : function(t) {
  324. var a = null, b = null;
  325. switch (t) {
  326. case '应酬费':
  327. a = 'FeePlease!JKSQ!YC';
  328. b = 'FeePlease!FYBX';
  329. break;
  330. case '差旅费':
  331. a = 'FeePlease!JKSQ!CL';
  332. b = 'FeePlease!FYBX!CL';
  333. break;
  334. case '培训费':
  335. a = 'FeePlease!JKSQ!PX';
  336. b = 'FeePlease!FYBX!PX';
  337. break;
  338. case '其它':
  339. b = 'FeePlease!FYBX!QT';
  340. break;
  341. }
  342. return {form : a, grid : b};
  343. }
  344. });