feePlease.js 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.oa.fee.feePlease', {
  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.feePlease','core.form.Panel','core.grid.Panel2','core.toolbar.Toolbar','core.button.Scan','core.form.FileField','core.form.SeparNumber',
  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','core.form.DateHourMinuteField',
  11. 'core.button.ResSubmit','core.button.TurnCLFBX','core.button.TurnFYBX','core.button.TurnYHFKSQ','core.button.VoCreate',
  12. 'core.button.TurnYWZDBX','core.button.End','core.button.ResEnd','core.button.Confirm','core.trigger.MultiDbfindTrigger',
  13. 'core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger','core.button.TurnBankRegister','core.form.MultiField','oa.fee.FeeBackGrid',
  14. 'erp.view.core.button.AddDetail','erp.view.core.button.DeleteDetail','erp.view.core.button.Copy','erp.view.core.button.Paste','erp.view.core.button.Up',
  15. 'erp.view.core.button.Down','erp.view.core.button.UpExcel','common.datalist.Toolbar','oa.fee.feePleaseFYBX','core.form.ConDateHourMinuteField','core.form.CheckBoxGroup'
  16. ],
  17. init:function(){
  18. var me = this;
  19. this.control({
  20. 'erpGridPanel2': {
  21. itemclick: function(selModel, record){
  22. if(record.data.fpd_id != 0 && record.data.fpd_id != null && record.data.fpd_id != ''){
  23. var btn = Ext.getCmp('factdays');
  24. btn && btn.setDisabled(false);
  25. }
  26. this.onGridItemClick(selModel, record);
  27. }
  28. },
  29. 'mfilefield':{
  30. beforerender:function(f){
  31. if(caller=='FeePlease!ZWSQ'){
  32. f.readOnly=false;
  33. }
  34. }
  35. },
  36. 'FeeBackGrid': {
  37. itemclick: this.onGridItemClick2
  38. },
  39. 'erpFormPanel' : {
  40. afterload : function(form) {
  41. this.hidecolumns(true);
  42. }
  43. },
  44. 'field[name=fp_v11]':{
  45. beforerender: function(field){
  46. field.readOnly=false;
  47. }
  48. },
  49. 'dbfindtrigger[name=fp_v1]': {
  50. afterrender:function(trigger){
  51. if(caller=='FeePlease!JKSQ'){
  52. trigger.dbKey='fp_department';
  53. trigger.mappingKey='fcs_departmentname';
  54. trigger.dbMessage='请先选择申请部门';}
  55. }
  56. },
  57. 'dbfindtrigger[name=fpd_d1]': {
  58. afterrender:function(trigger){
  59. trigger.dbKey='fp_department';
  60. trigger.mappingKey='fcs_departmentname';
  61. trigger.dbMessage='请先选择报销部门';
  62. }
  63. },
  64. 'dbfindtrigger[name=fp_pleaseman]':{
  65. aftertrigger:function(trigger,record){
  66. Ext.Ajax.request({
  67. url:basePath+'oa/fee/getFeeAccount.action',
  68. method:'POST',
  69. params:{
  70. emcode:trigger.value
  71. },
  72. async:false,
  73. callback:function(opts,success,res){
  74. var r = new Ext.decode(res.responseText);
  75. trigger.up('form').getForm().setValues(r.info);
  76. }
  77. });
  78. }
  79. },
  80. 'erpSaveButton': {
  81. click: function(btn){
  82. var form = me.getForm(btn);
  83. if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
  84. if(caller=='FeePlease!CLFBX'){
  85. me.BaseUtil.getRandomNumber('FeePlease!FYBX');//差旅费报销取费用报销同样的caller取编号
  86. }else{
  87. me.BaseUtil.getRandomNumber(caller);//自动添加编号
  88. }
  89. }
  90. if(caller == 'FeePlease!CZCFSQ'|| caller == 'FeePlease!FYBX'){
  91. this.getamount();
  92. }
  93. if(caller == 'FeePlease!CCSQ'){
  94. this.getTotal();
  95. if(Ext.getCmp('fp_prestartdate')!=null && Ext.getCmp('fp_preenddate')!=null){
  96. var start=new Date(Ext.getCmp('fp_prestartdate').items.items[5].value);
  97. var end=new Date(Ext.getCmp('fp_preenddate').value);
  98. if(start-end>0){
  99. showError('预计时间跨度输入有误,请确认后重新输入');
  100. }
  101. else{
  102. this.beforeSave();
  103. }
  104. }else{
  105. this.beforeSave();
  106. }
  107. }else if(caller == 'FeePlease!JKSQ'){
  108. if(Ext.getCmp('fp_startdate')!=null && Ext.getCmp('fp_enddate')!=null){
  109. var start=new Date(Ext.getCmp('fp_startdate').value);
  110. var end=new Date(Ext.getCmp('fp_enddate').value);
  111. if(start-end>0){
  112. showError('借款日期不能早于还款日期,请确认后重新输入');
  113. }else{
  114. this.beforeSave();
  115. }
  116. }
  117. else{
  118. this.beforeSave();
  119. }
  120. }else{
  121. this.beforeSave();
  122. }
  123. }
  124. },
  125. 'erpCloseButton': {
  126. click: function(btn){
  127. this.FormUtil.beforeClose(this);
  128. }
  129. },
  130. 'erpAddButton': {
  131. click: function(btn){
  132. if(caller!='FeePlease!FYBX'){
  133. me.FormUtil.onAdd('add' + caller, '新增单据', "jsps/oa/fee/feePlease.jsp?whoami=" + caller);
  134. }else{
  135. me.FormUtil.onAdd('add' + caller, '新增费用申请', "jsps/oa/fee/feePleaseFYBX.jsp?whoami=" + caller);
  136. }
  137. }
  138. },
  139. 'erpUpdateButton': {
  140. click: function(btn){
  141. if(caller == 'FeePlease!CZCFSQ'){
  142. this.getamount();
  143. }
  144. if(caller == 'FeePlease!CCSQ'){
  145. this.getTotal();
  146. if(Ext.getCmp('fp_prestartdate')!=null && Ext.getCmp('fp_preenddate')!=null){
  147. var start=new Date(Ext.getCmp('fp_prestartdate').items.items[5].value);
  148. var end=new Date(Ext.getCmp('fp_preenddate').value);
  149. if(start-end>0){
  150. showError('预计时间跨度输入有误,请确认后重新输入');
  151. }else{
  152. this.beforeUpdate();
  153. }
  154. }else{
  155. this.beforeUpdate();
  156. }
  157. }else if(caller == 'FeePlease!JKSQ'){
  158. if(Ext.getCmp('fp_startdate')!=null && Ext.getCmp('fp_enddate')!=null){
  159. var start=new Date(Ext.getCmp('fp_startdate').value);
  160. var end=new Date(Ext.getCmp('fp_enddate').value);
  161. if(start-end>0){
  162. showError('借款日期不能早于还款日期,请确认后重新输入');
  163. }else{
  164. this.beforeUpdate();
  165. }
  166. }else{
  167. this.beforeUpdate();
  168. }
  169. }else{
  170. this.beforeUpdate();
  171. }
  172. }
  173. },
  174. 'erpDeleteButton': {
  175. afterrender: function(btn){
  176. var status = Ext.getCmp('fp_statuscode');
  177. if(status && status.value != 'ENTERING'){
  178. btn.hide();
  179. }
  180. },
  181. click: function(btn){
  182. me.FormUtil.onDelete((Ext.getCmp('fp_id').value));
  183. }
  184. },
  185. 'erpAuditButton': {
  186. afterrender: function(btn){
  187. var status = Ext.getCmp('fp_statuscode');
  188. if(status && status.value != 'COMMITED'){
  189. btn.hide();
  190. }
  191. },
  192. click: function(btn){
  193. this.FormUtil.onAudit(Ext.getCmp('fp_id').value);
  194. }
  195. },
  196. 'erpResAuditButton': {
  197. afterrender: function(btn){
  198. var status = Ext.getCmp('fp_statuscode');
  199. if(status && status.value != 'AUDITED'){
  200. btn.hide();
  201. }
  202. },
  203. click: function(btn){
  204. this.FormUtil.onResAudit(Ext.getCmp('fp_id').value);
  205. }
  206. },
  207. 'erpSubmitButton': {
  208. afterrender: function(btn){
  209. var status = Ext.getCmp('fp_statuscode');
  210. if(status && status.value != 'ENTERING'){
  211. btn.hide();
  212. }
  213. },
  214. click: function(btn){
  215. if(caller == 'FeePlease!CCSQ'){
  216. this.getTotal();
  217. }
  218. if(caller == 'FeePlease!JKSQ'){
  219. if(Ext.getCmp('fp_startdate')!=null && Ext.getCmp('fp_enddate')!=null){
  220. var start=new Date(Ext.getCmp('fp_startdate').value);
  221. var end=new Date(Ext.getCmp('fp_enddate').value);
  222. if(start-end>0){
  223. showError('借款日期不能早于还款日期,请确认后重新输入');
  224. }else{
  225. this.FormUtil.onSubmit(Ext.getCmp('fp_id').value);
  226. }
  227. }else{
  228. this.FormUtil.onSubmit(Ext.getCmp('fp_id').value);
  229. }
  230. }else{
  231. this.FormUtil.onSubmit(Ext.getCmp('fp_id').value);
  232. }
  233. }
  234. },
  235. 'erpResSubmitButton': {
  236. afterrender: function(btn){
  237. var status = Ext.getCmp('fp_statuscode');
  238. if(status && status.value != 'COMMITED'){
  239. btn.hide();
  240. }
  241. },
  242. click: function(btn){
  243. this.FormUtil.onResSubmit(Ext.getCmp('fp_id').value);
  244. }
  245. },
  246. 'erpPrintButton': {
  247. click:function(btn){
  248. var reportName='';
  249. var kind=Ext.getCmp('fp_kind').value;
  250. if(kind=="借款申请单"){
  251. reportName="AccountRegZW2";
  252. }else if(kind=="费用报销单"){
  253. reportName="AccountRegZW_fybx";
  254. }else if(kind=="差旅费报销单"){
  255. reportName="AccountRegZW_clfbx";
  256. }else if(kind=="还款申请单"){
  257. reportName="AccountRegZW_hksq";
  258. }else{
  259. reportName="AccountRegZW";
  260. }
  261. var condition='{FeePlease.fp_id}='+Ext.getCmp('fp_id').value+'';
  262. var id=Ext.getCmp('fp_id').value;
  263. me.FormUtil.onwindowsPrint(id,reportName,condition);
  264. }
  265. },
  266. 'field[name=fp_n3]': {
  267. change:function(f){
  268. if(caller=='FeePlease!ZWSQ'){
  269. Ext.getCmp('fp_pleaseamount').setValue((Ext.getCmp('fp_n3').value-0)+(Ext.getCmp('fp_n4').value-0));;
  270. }
  271. }
  272. },
  273. 'field[name=fp_n4]': {
  274. change:function(f){
  275. if(caller=='FeePlease!ZWSQ'){
  276. Ext.getCmp('fp_pleaseamount').setValue((Ext.getCmp('fp_n3').value-0)+(Ext.getCmp('fp_n4').value-0));;
  277. }
  278. }
  279. },
  280. 'erpEndButton': {
  281. afterrender: function(btn){
  282. var status = Ext.getCmp('fp_statuscode');
  283. if(status && status.value == 'FINISH'){
  284. btn.hide();
  285. }
  286. },
  287. click: function(btn){
  288. var endreason = Ext.getCmp('fp_endreason')
  289. if(endreason && endreason !=null){
  290. me.FormUtil.onUpdate(Ext.getCmp('fp_id').value);
  291. }
  292. this.FormUtil.onEnd(Ext.getCmp('fp_id').value);
  293. }
  294. },
  295. 'combo[name=fp_object]': {
  296. delay: 200,
  297. change: function(m){
  298. this.hidecolumns(false);
  299. }
  300. },
  301. 'erpResEndButton': {
  302. afterrender: function(btn){
  303. var status = Ext.getCmp('fp_statuscode');
  304. if(status && status.value != 'FINISH'){
  305. btn.hide();
  306. }
  307. },
  308. click: function(btn){
  309. this.FormUtil.onResEnd(Ext.getCmp('fp_id').value);
  310. }
  311. },
  312. 'erpConfirmButton': {afterrender: function(btn){
  313. var statu = Ext.getCmp('fp_statuscode');
  314. if(statu && statu.value != 'AUDITED'){
  315. btn.hide();
  316. }
  317. },
  318. click: function(btn){
  319. me.onConfirm(Ext.getCmp('fp_id').value);
  320. }
  321. } ,
  322. 'erpVoCreateButton':{//业务招待费转费用报销
  323. beforerender:function(btn){
  324. btn.setWidth(100);
  325. btn.setText("转费用报销");
  326. },
  327. afterrender: function(btn){
  328. var status = Ext.getCmp('fp_statuscode');
  329. var turnStatus=Ext.getCmp('fp_v11');
  330. if(status && status.value != 'AUDITED'&&turnStatus||turnStatus.value!='未转费用申请'){
  331. btn.hide();
  332. }
  333. },
  334. click:function(){
  335. this.turnFYBX(me);
  336. }
  337. },
  338. //转银行登记
  339. 'erpTurnBankRegisterButton':{
  340. click:function(btn){
  341. me.turnBankRegister();
  342. },
  343. afterrender: function(btn){
  344. var status = Ext.getCmp('fp_statuscode');
  345. if(status && status.value != 'AUDITED'){
  346. btn.hide();
  347. }
  348. }
  349. },
  350. /**
  351. * 更改实际天数
  352. */
  353. '#factdays': {
  354. click: function(btn) {
  355. var record=btn.ownerCt.ownerCt.getSelectionModel().getLastSelected();
  356. me.UpdateFactdays(record);
  357. }
  358. },
  359. 'field[name=fp_v11]':{
  360. beforerender:function(field){
  361. var status = Ext.getCmp('fp_statuscode');
  362. if(status && status.value == 'AUDITED'){
  363. field.readOnly=false;
  364. }
  365. }
  366. },
  367. 'field[name=fp_endreason]':{
  368. beforerender:function(field){
  369. var status = Ext.getCmp('fp_statuscode');
  370. if(status && status.value == 'AUDITED'){
  371. field.readOnly=false;
  372. }
  373. }
  374. },
  375. 'field[name=fp_n2]':{
  376. beforerender:function(field){
  377. if(caller!='FeePlease!CCSQ'){
  378. var status = Ext.getCmp('fp_statuscode');
  379. if(status && status.value == 'AUDITED'){
  380. field.readOnly=false;
  381. var back=0;
  382. if(Ext.getCmp('fp_n6')&&Ext.getCmp('fp_n6').value!=''){
  383. back=Ext.getCmp('fp_n6').value;
  384. }
  385. field.setValue((Ext.getCmp('fp_pleaseamount').value-back-Ext.getCmp('fp_n1').value).toFixed(3));
  386. }
  387. }
  388. }
  389. },
  390. 'dbfindtrigger[name=fp_kind]': {
  391. afterrender:function(trigger){
  392. if(caller == 'FeePlease!JKSQ'){
  393. trigger.dbKey='fp_department';
  394. trigger.mappingKey='fcs_departmentname';
  395. trigger.dbMessage='请先选择申请部门!';
  396. }
  397. }
  398. },
  399. 'field[name=fp_sourcecode]': {
  400. afterrender:function(f){
  401. if(caller=='FeePlease!CLFBX'|| caller=='FeePlease!FYBX'||caller=='FeePlease!HKSQ'){
  402. if(Ext.getCmp('fp_sourcecode').value!=""){
  403. f.setFieldStyle({
  404. 'color': 'blue'
  405. });
  406. f.focusCls = 'mail-attach';
  407. var c = Ext.Function.bind(me.openRelative, me);
  408. Ext.EventManager.on(f.inputEl, {
  409. mousedown : c,
  410. scope: f,
  411. buffer : 100
  412. });
  413. }
  414. }
  415. }
  416. },
  417. 'erpTurnCLFBXButton':{
  418. afterrender: function(btn){
  419. var status = Ext.getCmp('fp_statuscode');
  420. if(status && status.value != 'AUDITED'){
  421. btn.hide();
  422. }
  423. },
  424. click: function(btn){
  425. warnMsg("确定要转入差旅费报销单吗?", function(btn){
  426. if(btn == 'yes'){
  427. me.FormUtil.getActiveTab().setLoading(true);//loading...
  428. Ext.Ajax.request({
  429. url : basePath + 'oa/feeplease/turnCLFBX.action',
  430. params: {
  431. caller: caller,
  432. id: Ext.getCmp('fp_id').value
  433. },
  434. method : 'post',
  435. callback : function(options,success,response){
  436. me.FormUtil.getActiveTab().setLoading(false);
  437. var localJson = new Ext.decode(response.responseText);
  438. if(localJson.exceptionInfo){
  439. showError(localJson.exceptionInfo);
  440. }
  441. if(localJson.success){
  442. turnSuccess(function(){
  443. var id = localJson.id;
  444. var url = "jsps/oa/fee/feePlease.jsp?whoami=FeePlease!CLFBX&formCondition=fp_id=" + id + "&gridCondition=fpd_fpid=" + id;
  445. me.FormUtil.onAdd('FeePlease' + id, '差旅费报销单' + id, url);
  446. });
  447. }
  448. }
  449. });
  450. }
  451. });
  452. }
  453. },
  454. 'erpTurnFYBXButton':{
  455. afterrender: function(btn){
  456. var status = Ext.getCmp('fp_statuscode');
  457. if(status && status.value != 'AUDITED'){
  458. btn.hide();
  459. }
  460. },
  461. click: function(btn){
  462. warnMsg("确定要转入费用报销单吗?", function(btn){
  463. if(btn == 'yes'){
  464. me.FormUtil.getActiveTab().setLoading(true);//loading...
  465. Ext.Ajax.request({
  466. url : basePath + 'oa/feeplease/turnFYBX.action',
  467. params: {
  468. caller: caller,
  469. id: Ext.getCmp('fp_id').value
  470. },
  471. method : 'post',
  472. callback : function(options,success,response){
  473. me.FormUtil.getActiveTab().setLoading(false);
  474. var localJson = new Ext.decode(response.responseText);
  475. if(localJson.exceptionInfo){
  476. showError(localJson.exceptionInfo);
  477. }
  478. if(localJson.success){
  479. turnSuccess(function(){
  480. var id = localJson.id;
  481. var url = "jsps/oa/fee/feePlease.jsp?whoami=FeePlease!FYBX&formCondition=fp_id=" + id + "&gridCondition=fpd_fpid=" + id;
  482. me.FormUtil.onAdd('FeePlease' + id, '费用报销单' + id, url);
  483. });
  484. }
  485. }
  486. });
  487. }
  488. });
  489. }
  490. },
  491. 'erpTurnYHFKSQButton':{
  492. afterrender: function(btn){
  493. var status = Ext.getCmp('fp_statuscode');
  494. if(status && status.value != 'AUDITED'){
  495. btn.hide();
  496. }
  497. },
  498. click: function(btn){
  499. warnMsg("确定要转入银行付款申请单吗?", function(btn){
  500. if(btn == 'yes'){
  501. me.FormUtil.getActiveTab().setLoading(true);//loading...
  502. Ext.Ajax.request({
  503. url : basePath + 'oa/feeplease/turnYHFKSQ.action',
  504. params: {
  505. caller: caller,
  506. id: Ext.getCmp('fp_id').value
  507. },
  508. method : 'post',
  509. callback : function(options,success,response){
  510. me.FormUtil.getActiveTab().setLoading(false);
  511. var localJson = new Ext.decode(response.responseText);
  512. if(localJson.exceptionInfo){
  513. showError(localJson.exceptionInfo);
  514. }
  515. if(localJson.success){
  516. turnSuccess(function(){
  517. var id = localJson.id;
  518. var url = "jsps/oa/fee/feePlease.jsp?whoami=FeePlease!YHFKSQ&formCondition=fp_id=" + id + "&gridCondition=fpd_fpid=" + id;
  519. me.FormUtil.onAdd('FeePlease' + id, '银行付款申请单' + id, url);
  520. });
  521. }
  522. }
  523. });
  524. }
  525. });
  526. }
  527. },
  528. 'erpTurnYWZDBXButton':{
  529. afterrender: function(btn){
  530. var status = Ext.getCmp('fp_statuscode');
  531. if(status && status.value != 'AUDITED'){
  532. btn.hide();
  533. }
  534. },
  535. click: function(btn){
  536. warnMsg("确定要转入业务招待费报销单吗?", function(btn){
  537. if(btn == 'yes'){
  538. me.FormUtil.getActiveTab().setLoading(true);//loading...
  539. Ext.Ajax.request({
  540. url : basePath + 'oa/feeplease/turnYWZDBX.action',
  541. params: {
  542. caller: caller,
  543. id: Ext.getCmp('fp_id').value
  544. },
  545. method : 'post',
  546. callback : function(options,success,response){
  547. me.FormUtil.getActiveTab().setLoading(false);
  548. var localJson = new Ext.decode(response.responseText);
  549. if(localJson.exceptionInfo){
  550. showError(localJson.exceptionInfo);
  551. }
  552. if(localJson.success){
  553. turnSuccess(function(){
  554. var id = localJson.id;
  555. var url = "jsps/oa/fee/feePlease.jsp?whoami=FeePlease!YWZDBX&formCondition=fp_id=" + id + "&gridCondition=fpd_fpid=" + id;
  556. me.FormUtil.onAdd('FeePlease' + id, '业务招待费报销单' + id, url);
  557. });
  558. }
  559. }
  560. });
  561. }
  562. });
  563. }
  564. }
  565. });
  566. },
  567. getTotal:function(){
  568. var carfare=Ext.getCmp('fp_n2')!=null?(Ext.getCmp('fp_n2').value=="" ? 0 : Ext.getCmp('fp_n2').value-0):0;//交通费
  569. var accommodation=Ext.getCmp('fp_n3')!=null?(Ext.getCmp('fp_n3').value=="" ? 0 : Ext.getCmp('fp_n3').value-0):0;//住宿费
  570. var prfee=Ext.getCmp('fp_n4')!=null?(Ext.getCmp('fp_n4').value=="" ? 0 : Ext.getCmp('fp_n4').value-0):0;//公关费
  571. if(Ext.getCmp('fp_pleaseamount')!=null)
  572. Ext.getCmp('fp_pleaseamount').setValue(carfare+accommodation+prfee);
  573. },
  574. getamount: function(){
  575. var grid = Ext.getCmp('grid');
  576. var items = grid.store.data.items;
  577. var amount = 0;
  578. Ext.each(items,function(item,index){
  579. if(item.data['fpd_date1']!=null&&item.data['fpd_date1']!=""){
  580. amount= amount + Number(item.data['fpd_total']);
  581. }
  582. });
  583. Ext.getCmp('fp_pleaseamount').setValue(amount);
  584. },
  585. onGridItemClick: function(selModel, record){//grid行选择
  586. this.GridUtil.onGridItemClick(selModel, record);
  587. },
  588. getForm: function(btn){
  589. return btn.ownerCt.ownerCt;
  590. },
  591. onConfirm: function(id){
  592. var form = Ext.getCmp('form');
  593. Ext.Ajax.request({
  594. url : basePath + form.confirmUrl,
  595. params: {
  596. id: id,
  597. caller:caller
  598. },
  599. method : 'post',
  600. callback : function(options,success,response){
  601. //me.setLoading(false);
  602. var localJson = new Ext.decode(response.responseText);
  603. if(localJson.success){
  604. //audit成功后刷新页面进入可编辑的页面
  605. //auditSuccess(function(){
  606. window.location.reload();
  607. //});
  608. } else {
  609. if(localJson.exceptionInfo){
  610. var str = localJson.exceptionInfo;
  611. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  612. str = str.replace('AFTERSUCCESS', '');
  613. showMessage("提示", '确认成功');
  614. //auditSuccess(function(){
  615. window.location.reload();
  616. //});
  617. } else {
  618. showError(str);return;
  619. }
  620. }
  621. }
  622. }
  623. });
  624. },
  625. openRelative:function(e, el, obj){
  626. var f = obj.scope;
  627. var name='';
  628. var cal='';
  629. var field=''
  630. var conField=''
  631. var type=Ext.getCmp('fp_sourcekind').value;
  632. if(type=='客户拜访记录'){
  633. name='VisitRecord';
  634. cal='visitrecord';
  635. field='vr_id';
  636. conField='vr_class=\'OfficeClerk\' and vr_code';
  637. }else if(type=='原厂拜访记录'){
  638. name='VisitRecord';
  639. cal='visitrecord';
  640. field='vr_id';
  641. conField='vr_class=\'VisitRecord!Vender\' and vr_code';
  642. }else if(type=='业务招待费申请单'){
  643. name='FeePlease';
  644. cal='FeePlease';
  645. field='fp_id';
  646. conField='fp_kind=\'业务招待费申请单\' and fp_code';
  647. }else if(type=='出差申请单'){
  648. name='FeePlease';
  649. cal='FeePlease';
  650. field='fp_id';
  651. conField='fp_kind=\'出差申请单\' and fp_code';
  652. }else if(type=='资源开发记录'){
  653. name='VisitRecord';
  654. cal='visitrecord';
  655. field='vr_id';
  656. conField='vr_class=\'VisitRecord!Resource\' and vr_code';
  657. }else if(type=='借款申请单'){
  658. name='FeePlease';
  659. cal='FeePlease';
  660. field='fp_id';
  661. conField='fp_kind=\'借款申请单\' and fp_code';
  662. }
  663. else if(type=='费用申请'){
  664. name='PreFeePlease';
  665. cal='PreFeePlease';
  666. field='fp_id';
  667. conField=' fp_code';
  668. }else if(type=='资产维修'){
  669. name='Propertyrepair';
  670. cal='Propertyrepair';
  671. field='pr_id';
  672. conField=' pr_code';
  673. }else if(type=='车辆维修'){
  674. name='vehiclearchivesdetail';
  675. cal='vehiclearchivesdetail';
  676. field='vd_id';
  677. conField=' vd_code';
  678. }
  679. if(type=='市场调研立项'||type=='客户拜访记录' || type=='原厂拜访记录' || type=='业务招待费申请单'||type=='出差申请单'||type=='资源开发记录'||type=='借款申请单'||type=='费用申请'||type=='资产维修'||type=='车辆维修') {
  680. var code = Ext.getCmp('fp_sourcecode').value;
  681. if(code.indexOf('(')>-1){//来自其他的单据
  682. this.turnOtherSob(code,field,conField,cal);
  683. }else{
  684. var url=this.getRelativeUrl(code,field,conField,cal);
  685. this.FormUtil.onAdd(name, Ext.getCmp('fp_sourcekind').value,
  686. url);
  687. }
  688. }
  689. },
  690. getRelativeUrl:function(code,field,conField,cal){
  691. var id = 0;
  692. Ext.Ajax.request({
  693. url : basePath + 'common/getFieldData.action',
  694. async: false,
  695. params: {
  696. caller: cal,
  697. field: field,
  698. condition: conField+'=\'' + code + '\''
  699. },
  700. method : 'post',
  701. callback : function(o, s, r){
  702. var rs = new Ext.decode(r.responseText);
  703. if(rs.exceptionInfo){
  704. showError(rs.exceptionInfo);return;
  705. }
  706. if(rs.success){
  707. if(rs.data != null){
  708. id = rs.data;
  709. }
  710. }
  711. }
  712. });
  713. var url='#';
  714. var type=Ext.getCmp('fp_sourcekind').value;
  715. if(type=='客户拜访记录'){
  716. url='jsps/crm/customermgr/customervisit/visitRecord.jsp?formCondition=vr_idIS'+id+'&gridCondition=vrd_vridIS'+id;
  717. }else if(type=='原厂拜访记录'){
  718. url='jsps/crm/customermgr/customervisit/visitRecord3.jsp?formCondition=vr_idIS'+id+'&gridCondition=vrd_vridIS'+id;
  719. }else if(type=='业务招待费申请单'){
  720. url='jsps/oa/fee/feePlease.jsp?whoami=FeePlease!YWZDSQ&formCondition=fp_idIS'+id+'&gridCondition=fpd_fpidIS'+id;
  721. }else if(type=='出差申请单'){
  722. url='jsps/oa/fee/feePlease.jsp?whoami=FeePlease!CCSQ&formCondition=fp_idIS'+id+'&gridCondition=fpd_fpidIS'+id;
  723. }else if(type=='资源开发记录'){
  724. url='jsps/crm/customermgr/customervisit/visitRecord4.jsp?formCondition=vr_idIS'+id+'&gridCondition=vrd_vridIS'+id;
  725. }else if(type=='借款申请单'){
  726. url='jsps/oa/fee/feePlease.jsp?whoami=FeePlease!JKSQ&formCondition=fp_idIS'+id+'&gridCondition=fpd_fpidIS'+id;
  727. }else if(type=='费用申请'){
  728. url='jsps/oa/fee/preFeePlease.jsp?formCondition=fp_idIS'+id+'&gridCondition=fpd_fpidIS'+id;
  729. }else if(type=='资产维修'){
  730. url='jsps/oa/storage/propertyrepair.jsp?formCondition=pr_idIS'+id+'&gridCondition=prd_pridIS'+id;
  731. }else if(type=='车辆维修'){
  732. url='jsps/oa/vehicle/vehiclemaintain.jsp?formCondition=vd_idIS'+id;
  733. }
  734. return url;
  735. },
  736. turnOtherSob:function(code,field,conField,cal){
  737. var newSob=null;//code形如:2015040052(资料中心) 2016010052((华商龙)资料中心)
  738. Ext.Ajax.request({//去资料中心寻找括号内的帐套
  739. url : basePath + 'common/getFieldData.action',
  740. async: false,
  741. params: {
  742. caller: 'N_DataCenter.MASTER',
  743. field: 'ma_user',
  744. condition: 'ma_function=\'' + code.substring(code.lastIndexOf('('),code.lastIndexOf(')')) + '\''
  745. },
  746. method : 'post',
  747. callback : function(o, s, r){
  748. var rs = new Ext.decode(r.responseText);
  749. if(rs.exceptionInfo){
  750. showError(rs.exceptionInfo);return;
  751. }
  752. if(rs.success){
  753. if(rs.data != null){
  754. newSob = rs.data;
  755. }
  756. }
  757. }
  758. });
  759. if(newSob==null){
  760. showError('没有找到要转的帐套!');
  761. return;
  762. }else{
  763. var url=this.getRelativeUrl(code.split('(')[0],field,conField,newSob+'.'+cal);
  764. var currentMaster = parent.sob?parent.sob:parent.parent.sob;
  765. url=parent.location.href.split('jsps')[0]+url;//防止因为父页面url的改变,而找不到页面
  766. Ext.Ajax.request({
  767. url: basePath + 'common/changeMaster.action',
  768. params: {
  769. to: newSob
  770. },
  771. callback: function(opt, s, r) {
  772. if (s) {
  773. var win = parent.Ext.create('Ext.Window', {
  774. width: '100%',
  775. height: '100%',
  776. draggable: false,
  777. closable: false,
  778. modal: true,
  779. id:'modalwindow',
  780. historyMaster:currentMaster,
  781. title: '创建到帐套' + code.substring(code.lastIndexOf('('),code.lastIndexOf(')')) + '的临时会话',
  782. html : '<iframe src="' + url + '" height="100%" width="100%" frameborder="0" style="border-width: 0px;padding: 0px;" scrolling="auto"></iframe>',
  783. buttonAlign: 'center',
  784. buttons: [{
  785. text: $I18N.common.button.erpCloseButton,
  786. cls: 'x-btn-blue',
  787. id: 'close',
  788. handler: function(b) {
  789. Ext.Ajax.request({
  790. url: basePath + 'common/changeMaster.action',
  791. params: {
  792. to: currentMaster
  793. },
  794. callback: function(opt, s, r) {
  795. if (s) {
  796. b.up('window').close();
  797. } else {
  798. alert('切换到原帐套失败!');
  799. }
  800. }
  801. });
  802. }
  803. }]
  804. });
  805. win.show();
  806. } else {
  807. alert('无法创建到帐套' + code.substring(code.lastIndexOf('('),code.lastIndexOf(')')) + '的临时会话!');
  808. }
  809. }
  810. });
  811. }
  812. },
  813. turnFYBX:function(me){
  814. warnMsg("确定要转入费用报销单吗?", function(btn){
  815. if(btn == 'yes'){
  816. me.FormUtil.getActiveTab().setLoading(true);//loading...
  817. Ext.Ajax.request({
  818. url : basePath + 'oa/feeplease/turnFYBX2.action',
  819. params: {
  820. caller: caller,
  821. id: Ext.getCmp('fp_id').value
  822. },
  823. method : 'post',
  824. callback : function(options,success,response){
  825. me.FormUtil.getActiveTab().setLoading(false);
  826. var localJson = new Ext.decode(response.responseText);
  827. if(localJson.exceptionInfo){
  828. showError(localJson.exceptionInfo);
  829. }
  830. if(localJson.success){
  831. //turnSuccess(function(){
  832. showMessage("提示", '转入成功');
  833. window.location.reload();
  834. var id = localJson.id;
  835. var url = "jsps/oa/fee/feePlease.jsp?whoami=FeePlease!FYBX&formCondition=fp_id=" + id + "&gridCondition=fpd_fpid=" + id;
  836. me.FormUtil.onAdd('FeePlease' + id, '费用报销单' + id, url);
  837. //});
  838. }
  839. }
  840. });
  841. }
  842. });
  843. },
  844. turnBankRegister:function(){
  845. var form = Ext.getCmp('form');
  846. var catecode = Ext.getCmp('fp_v11').value;
  847. if(catecode == null || catecode == ''){
  848. showMessage("警告", '请填写需要转银行登记的付款方信息!');
  849. return;
  850. }
  851. var thispayamount=form.BaseUtil.numberFormat(Ext.getCmp('fp_n2').value,2);
  852. var back=0;//还款金额
  853. if(Ext.getCmp('fp_n6')&&Ext.getCmp('fp_n6').value!=null&&Ext.getCmp('fp_n6').value!=''){
  854. back=form.BaseUtil.numberFormat(Ext.getCmp('fp_n6').value,2);
  855. }
  856. if(form.BaseUtil.numberFormat(Ext.getCmp('fp_n1').value+thispayamount,2) > form.BaseUtil.numberFormat(Ext.getCmp('fp_pleaseamount').value-back,2)){
  857. showMessage("警告", '本次转金额超出剩余金额!');
  858. return;
  859. }
  860. var main = parent.Ext.getCmp("content-panel");
  861. main.getActiveTab().setLoading(true);//loading...
  862. Ext.Ajax.request({
  863. url : basePath + 'oa/fee/turnBankRegister.action',
  864. params: {
  865. id:Ext.getCmp("fp_id").value,
  866. paymentcode:Ext.getCmp('fp_v11').value,
  867. payment:Ext.getCmp('fp_v10').value,
  868. thispayamount:Ext.getCmp('fp_n2').value,
  869. caller:caller
  870. },
  871. method : 'post',
  872. callback : function(options,success,response){
  873. main.getActiveTab().setLoading(false);
  874. var localJson = new Ext.decode(response.responseText);
  875. if(localJson.exceptionInfo){
  876. showError(localJson.exceptionInfo);
  877. return "";
  878. }
  879. if(localJson.success){
  880. if(localJson.log){
  881. showMessage("提示", localJson.log);
  882. window.location.reload();
  883. }
  884. }
  885. }
  886. });
  887. },
  888. UpdateFactdays:function(record){
  889. var win = this.factdayswindow;
  890. if (!win) {
  891. win = this.getFactdaysWindow();
  892. }
  893. win.show();
  894. },
  895. getFactdaysWindow : function() {
  896. var me = this;
  897. return Ext.create('Ext.window.Window',{
  898. width: 330,
  899. height: 180,
  900. closeAction: 'hide',
  901. cls: 'custom-blue',
  902. title:'<h1>更改实际天数</h1>',
  903. layout: {
  904. type: 'vbox'
  905. },
  906. items:[{
  907. margin: '5 0 0 5',
  908. xtype:'numberfield',
  909. fieldLabel:'实际天数',
  910. name:'factdays',
  911. id:'factdays'
  912. },{
  913. margin: '5 0 0 5',
  914. xtype: 'fieldcontainer',
  915. fieldLabel: '全部更新',
  916. combineErrors: false,
  917. defaults: {
  918. hideLabel: true
  919. },
  920. layout: {
  921. type: 'column',
  922. defaultMargins: {top: 0, right: 5, bottom: 0, left: 0}
  923. },
  924. items: [{
  925. xtype:'checkbox',
  926. columnidth: 0.4,
  927. fieldLabel:'全部更新',
  928. name:'allupdate',
  929. id:'allupdate'
  930. },{
  931. xtype:'displayfield',
  932. fieldStyle:'color:red',
  933. columnidth: 0.6,
  934. value:' *更改当前所有明细'
  935. }]
  936. }],
  937. buttonAlign:'center',
  938. buttons:[{
  939. xtype:'button',
  940. text:'保存',
  941. width:60,
  942. iconCls: 'x-button-icon-save',
  943. handler:function(btn){
  944. var w = btn.up('window');
  945. me.saveFactdays(w);
  946. w.hide();
  947. }
  948. },{
  949. xtype:'button',
  950. columnWidth:0.1,
  951. text:'关闭',
  952. width:60,
  953. iconCls: 'x-button-icon-close',
  954. margin:'0 0 0 10',
  955. handler:function(btn){
  956. btn.up('window').hide();
  957. }
  958. }]
  959. });
  960. },
  961. saveFactdays: function(w) {
  962. var factdays = w.down('field[name=factdays]').getValue(),
  963. grid = Ext.getCmp('grid'),
  964. record = grid.getSelectionModel().getLastSelected();
  965. if(!factdays) {
  966. showError('请先设置预计天数.') ;
  967. return;
  968. } else {
  969. var allupdate = w.down('field[name=allupdate]').getValue();
  970. var dd = {
  971. fpd_id : record.data.fpd_id,
  972. fpd_fpid : record.data.fpd_fpid,
  973. factdays : factdays? factdays : record.data.fpd_n5,
  974. allupdate : allupdate ? 1 : 0
  975. };
  976. Ext.Ajax.request({
  977. url : basePath +'oa/fee/updatefactdays.action',
  978. params : {
  979. data: unescape(Ext.JSON.encode(dd))
  980. },
  981. method : 'post',
  982. callback : function(opt, s, res){
  983. var r = new Ext.decode(res.responseText);
  984. if(r.success){
  985. grid.GridUtil.loadNewStore(grid,{
  986. caller:'FeePlease!CCSQ',
  987. condition: 'fpd_fpid=' + record.data.fpd_fpid
  988. });
  989. } else if(r.exceptionInfo){
  990. showError(r.exceptionInfo);
  991. } else{
  992. saveFailure();
  993. }
  994. }
  995. });
  996. }
  997. },
  998. beforeSave: function(){
  999. var me = this;
  1000. var form = Ext.getCmp('form');
  1001. if(! me.FormUtil.checkForm()){
  1002. return;
  1003. }
  1004. if(caller=='FeePlease!FYBX'&&Ext.getCmp('fp_object')){
  1005. var obj = Ext.getCmp("fp_object").value;
  1006. if(obj == '供应商' && (Ext.getCmp('fp_vendcode').value==null||Ext.getCmp('fp_vendcode').value=='')){
  1007. showError('供应商不能为空!');//对象为供应商时,供应商编号不能为空
  1008. return;
  1009. }
  1010. if(obj == '客户' && (Ext.getCmp('fp_cucode').value==null||Ext.getCmp('fp_cucode').value=='')){
  1011. showError('供应商不能为空!');//对象为客户时,客户编号不能为空
  1012. return;
  1013. }
  1014. }
  1015. if(Ext.getCmp(form.keyField).value == null || Ext.getCmp(form.keyField).value == ''){
  1016. me.FormUtil.getSeqId(form);
  1017. }
  1018. var detail = Ext.getCmp('grid');
  1019. var detail2 = Ext.getCmp('FeeBackGrid');
  1020. Ext.each(detail.store.data.items, function(item){
  1021. if(item.data.vd_id == null || item.data.vd_id == 0){
  1022. item.data.vd_id = -item.index;
  1023. }
  1024. });
  1025. var param1 = me.GridUtil.getGridStore(detail);
  1026. var param2 = new Array();
  1027. if(detail2) {
  1028. param2 = me.GridUtil.getGridStore(detail2);
  1029. }
  1030. param1 = param1 == null ? [] : "[" + param1.toString().replace(/\\/g,"%") + "]";
  1031. param2 = param2 == null ? [] : "[" + param2.toString().replace(/\\/g,"%") + "]";
  1032. if(form.getForm().isValid()){
  1033. Ext.each(form.items.items, function(item){
  1034. if(item.xtype == 'numberfield'){
  1035. if(item.value == null || item.value == ''){
  1036. item.setValue(0);
  1037. }
  1038. }
  1039. });
  1040. var r = form.getValues();
  1041. me.save(r, param1, param2);
  1042. }else{
  1043. me.FormUtil.checkForm();
  1044. }
  1045. },
  1046. save: function(){
  1047. var form=Ext.getCmp('form');
  1048. var params = new Object();
  1049. var r = arguments[0];
  1050. Ext.each(Ext.Object.getKeys(r), function(k){//去掉页面非表单定义字段
  1051. if(contains(k, 'ext-', true)){
  1052. delete r[k];
  1053. }
  1054. });
  1055. //去除ignore字段
  1056. var keys = Ext.Object.getKeys(r), f;
  1057. var reg = /[!@#$%^&*()'":,\/?]/;
  1058. Ext.each(keys, function(k){
  1059. f = form.down('#' + k);
  1060. if(f && f.logic == 'ignore') {
  1061. delete r[k];
  1062. }
  1063. //codeField值强制大写,自动过滤特殊字符
  1064. if(k == form.codeField && !Ext.isEmpty(r[k])) {
  1065. r[k] = r[k].trim().toUpperCase().replace(reg, '');
  1066. }
  1067. });
  1068. params.formStore = unescape(Ext.JSON.encode(r).replace(/\\/g,"%"));
  1069. params.param = unescape(arguments[1].toString().replace(/\\/g,"%"));
  1070. params.param2 = unescape(arguments[2].toString().replace(/\\/g,"%"));
  1071. params.caller=caller;
  1072. /*for(var i=2; i<arguments.length; i++) { //兼容多参数
  1073. params['param' + i] = unescape(arguments[i].toString().replace(/\\/g,"%"));
  1074. }*/
  1075. var me = this;
  1076. var form = Ext.getCmp('form');
  1077. //me.getActiveTab().setLoading(true);//loading...
  1078. Ext.Ajax.request({
  1079. url : basePath + form.saveUrl,
  1080. params : params,
  1081. method : 'post',
  1082. callback : function(options,success,response){
  1083. var localJson = new Ext.decode(response.responseText);
  1084. if(localJson.success){
  1085. saveSuccess(function(){
  1086. //add成功后刷新页面进入可编辑的页面
  1087. var value = r[form.keyField];
  1088. var formCondition = form.keyField + "IS" + value ;
  1089. if(me.contains(window.location.href, '?', true)){
  1090. window.location.href = window.location.href + '&formCondition=' +
  1091. formCondition+'&gridCondition=fpd_fpidIS'+value;
  1092. } else {
  1093. window.location.href = window.location.href + '?formCondition=' +
  1094. formCondition+'&gridCondition=fpd_fpidIS'+value;
  1095. }
  1096. });
  1097. } else if(localJson.exceptionInfo){
  1098. var str = localJson.exceptionInfo;
  1099. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  1100. str = str.replace('AFTERSUCCESS', '');
  1101. saveSuccess(function(){
  1102. //add成功后刷新页面进入可编辑的页面
  1103. var value = r[form.keyField];
  1104. var formCondition = form.keyField + "IS" + value ;
  1105. if(me.contains(window.location.href, '?', true)){
  1106. window.location.href = window.location.href + '&formCondition=' +
  1107. formCondition+'&gridCondition=fpd_fpidIS'+value;
  1108. } else {
  1109. window.location.href = window.location.href + '?formCondition=' +
  1110. formCondition+'&gridCondition=fpd_fpidIS'+value;
  1111. }
  1112. });
  1113. showError(str);
  1114. } else {
  1115. showError(str);
  1116. return;
  1117. }
  1118. } else{
  1119. saveFailure();//@i18n/i18n.js
  1120. }
  1121. }
  1122. });
  1123. },
  1124. beforeUpdate: function(){
  1125. var me = this;
  1126. var form = Ext.getCmp('form');
  1127. if(! me.FormUtil.checkForm()){
  1128. return;
  1129. }
  1130. if(caller=='FeePlease!FYBX'&&Ext.getCmp('fp_object')){
  1131. var obj = Ext.getCmp("fp_object").value;
  1132. if(obj == '供应商' && (Ext.getCmp('fp_vendcode').value==null||Ext.getCmp('fp_vendcode').value=='')){
  1133. showError('供应商不能为空!');//对象为供应商时,供应商编号不能为空
  1134. return;
  1135. }
  1136. if(obj == '客户' && (Ext.getCmp('fp_cucode').value==null||Ext.getCmp('fp_cucode').value=='')){
  1137. showError('客户不能为空!');//对象为客户时,客户编号不能为空
  1138. return;
  1139. }
  1140. }
  1141. if(Ext.getCmp(form.keyField).value == null || Ext.getCmp(form.keyField).value == ''){
  1142. me.FormUtil.getSeqId(form);
  1143. }
  1144. var detail = Ext.getCmp('grid');
  1145. var detail2 = Ext.getCmp('FeeBackGrid');
  1146. Ext.each(detail.store.data.items, function(item){
  1147. if(item.data.vd_id == null || item.data.vd_id == 0){
  1148. item.data.vd_id = -item.index;
  1149. }
  1150. });
  1151. var param1 = me.GridUtil.getGridStore(detail);
  1152. var param2 = new Array();
  1153. if(detail2) {
  1154. param2 = me.GridUtil.getGridStore(detail2);
  1155. }
  1156. param1 = param1 == null ? [] : "[" + param1.toString().replace(/\\/g,"%") + "]";
  1157. param2 = param2 == null ? [] : "[" + param2.toString().replace(/\\/g,"%") + "]";
  1158. if(form.getForm().isValid()){
  1159. Ext.each(form.items.items, function(item){
  1160. if(item.xtype == 'numberfield'){
  1161. if(item.value == null || item.value == ''){
  1162. item.setValue(0);
  1163. }
  1164. }
  1165. });
  1166. var r = form.getValues();
  1167. me.update(r, param1, param2);
  1168. }else{
  1169. me.FormUtil.checkForm();
  1170. }
  1171. },
  1172. update:function(){
  1173. var form=Ext.getCmp('form');
  1174. var params = new Object();
  1175. var r = arguments[0];
  1176. Ext.each(Ext.Object.getKeys(r), function(k){//去掉页面非表单定义字段
  1177. if(contains(k, 'ext-', true)){
  1178. delete r[k];
  1179. }
  1180. });
  1181. //去除ignore字段
  1182. var keys = Ext.Object.getKeys(r), f;
  1183. var reg = /[!@#$%^&*()'":,\/?]/;
  1184. Ext.each(keys, function(k){
  1185. f = form.down('#' + k);
  1186. if(f && f.logic == 'ignore') {
  1187. delete r[k];
  1188. }
  1189. //codeField值强制大写,自动过滤特殊字符
  1190. if(k == form.codeField && !Ext.isEmpty(r[k])) {
  1191. r[k] = r[k].trim().toUpperCase().replace(reg, '');
  1192. }
  1193. });
  1194. params.formStore = unescape(Ext.JSON.encode(r).replace(/\\/g,"%"));
  1195. params.param = unescape(arguments[1].toString().replace(/\\/g,"%"));
  1196. params.param2 = unescape(arguments[2].toString().replace(/\\/g,"%"));
  1197. params.caller=caller;
  1198. var me = this;
  1199. var form = Ext.getCmp('form');
  1200. //me.getActiveTab().setLoading(true);//loading...
  1201. Ext.Ajax.request({
  1202. url : basePath + form.updateUrl,
  1203. params : params,
  1204. method : 'post',
  1205. callback : function(options,success,response){
  1206. //me.getActiveTab().setLoading(false);
  1207. var localJson = new Ext.decode(response.responseText);
  1208. if(localJson.success){
  1209. saveSuccess(function(){
  1210. //add成功后刷新页面进入可编辑的页面
  1211. var value = r[form.keyField];
  1212. var formCondition = form.keyField + "IS" + value ;
  1213. if(me.contains(window.location.href, '?', true)){
  1214. window.location.href = window.location.href + '&formCondition=' +
  1215. formCondition;
  1216. } else {
  1217. window.location.href = window.location.href + '?formCondition=' +
  1218. formCondition;
  1219. }
  1220. });
  1221. } else if(localJson.exceptionInfo){
  1222. var str = localJson.exceptionInfo;
  1223. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  1224. str = str.replace('AFTERSUCCESS', '');
  1225. saveSuccess(function(){
  1226. //add成功后刷新页面进入可编辑的页面
  1227. var value = r[form.keyField];
  1228. var formCondition = form.keyField + "IS" + value ;
  1229. if(me.contains(window.location.href, '?', true)){
  1230. window.location.href = window.location.href + '&formCondition=' +
  1231. formCondition;
  1232. } else {
  1233. window.location.href = window.location.href + '?formCondition=' +
  1234. formCondition;
  1235. }
  1236. });
  1237. showError(str);
  1238. } else {
  1239. showError(str);
  1240. return;
  1241. }
  1242. } else{
  1243. saveFailure();//@i18n/i18n.js
  1244. }
  1245. }
  1246. });
  1247. },
  1248. contains: function(string,substr,isIgnoreCase){
  1249. if(isIgnoreCase){
  1250. string=string.toLowerCase();
  1251. substr=substr.toLowerCase();
  1252. }
  1253. var startChar=substr.substring(0,1);
  1254. var strLen=substr.length;
  1255. for(var j=0;j<string.length-strLen+1;j++){
  1256. if(string.charAt(j)==startChar){//如果匹配起始字符,开始查找
  1257. if(string.substring(j,j+strLen)==substr){//如果从j开始的字符与str匹配,那ok
  1258. return true;
  1259. }
  1260. }
  1261. }
  1262. return false;
  1263. },
  1264. onGridItemClick: function(selModel, record){//grid行选择
  1265. this.GridUtil.onGridItemClick(selModel, record);
  1266. },
  1267. onGridItemClick2: function(selModel,record){
  1268. this.onGridItemClick(selModel,record,'FeeBackGrid');
  1269. },
  1270. hidecolumns: function(isNoClean){
  1271. if(caller=='FeePlease!CLFBX'){
  1272. var source = Ext.getCmp('fp_sourcekind').value;
  1273. var form = Ext.getCmp('fp_sourcekind').ownerCt;
  1274. if(source == '原厂拜访记录'){
  1275. if(Ext.getCmp('fp_cucode')){
  1276. form.down('#fp_cucode').hide();
  1277. }
  1278. if(Ext.getCmp('fp_cuname')){
  1279. form.down('#fp_cuname').hide();
  1280. }
  1281. }else if(source == '客户拜访记录'){
  1282. if(Ext.getCmp('fp_vendcode')){
  1283. form.down('#fp_vendcode').hide();
  1284. }
  1285. if(Ext.getCmp('fp_vendname')){
  1286. form.down('#fp_vendname').hide();
  1287. }
  1288. }else{
  1289. if(Ext.getCmp('fp_vendcode')){
  1290. form.down('#fp_vendcode').hide();
  1291. }
  1292. if(Ext.getCmp('fp_vendname')){
  1293. form.down('#fp_vendname').hide();
  1294. }
  1295. if(Ext.getCmp('fp_cucode')){
  1296. form.down('#fp_cucode').hide();
  1297. }
  1298. if(Ext.getCmp('fp_cuname')){
  1299. form.down('#fp_cuname').hide();
  1300. }
  1301. }
  1302. }
  1303. if(caller=='FeePlease!FYBX'&&Ext.getCmp('fp_object')){
  1304. var obj=Ext.getCmp('fp_object').value;
  1305. var form = Ext.getCmp('fp_object').ownerCt;
  1306. if(obj=='供应商'){
  1307. form.down('#fp_cucode').hide();
  1308. form.down('#fp_cuname').hide();
  1309. form.down('#fp_vendcode').show();
  1310. form.down('#fp_vendname').show();
  1311. if(!isNoClean){
  1312. form.down('#fp_cucode').setValue('');
  1313. form.down('#fp_cuname').setValue('');
  1314. form.down('#fp_vendcode').setValue('');
  1315. form.down('#fp_vendname').setValue('');
  1316. }
  1317. }else if(obj=='客户'){
  1318. form.down('#fp_cucode').show();
  1319. form.down('#fp_cuname').show();
  1320. form.down('#fp_vendcode').hide();
  1321. form.down('#fp_vendname').hide();
  1322. if(!isNoClean){
  1323. form.down('#fp_cucode').setValue('');
  1324. form.down('#fp_cuname').setValue('');
  1325. form.down('#fp_vendcode').setValue('');
  1326. form.down('#fp_vendname').setValue('');
  1327. }
  1328. }else{
  1329. form.down('#fp_cucode').hide();
  1330. form.down('#fp_cuname').hide();
  1331. form.down('#fp_vendcode').hide();
  1332. form.down('#fp_vendname').hide();
  1333. if(!isNoClean){
  1334. form.down('#fp_cucode').setValue('');
  1335. form.down('#fp_cuname').setValue('');
  1336. form.down('#fp_vendcode').setValue('');
  1337. form.down('#fp_vendname').setValue('');
  1338. }
  1339. }
  1340. }
  1341. }
  1342. });