| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.fa.arp.PayPlease', {
- extend: 'Ext.app.Controller',
- FormUtil: Ext.create('erp.util.FormUtil'),
- GridUtil: Ext.create('erp.util.GridUtil'),
- BaseUtil: Ext.create('erp.util.BaseUtil'),
- ppdid:0,
- views:[
- 'core.form.Panel','fa.arp.PayPlease','fa.arp.payplease.PayPleaseDetailDetGrid','fa.arp.payplease.PayPleaseDetailGrid','core.button.Save','core.button.Add','core.button.Close','core.button.Delete','core.button.Update','core.button.DeleteDetail',
- 'core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger','core.form.YnField','core.button.ResAccounted','core.button.AssMain','core.button.Accounted','core.form.FileField',
- 'core.button.StrikeBalance','core.grid.AssPanel','core.window.AssWindow','core.trigger.CateTreeDbfindTrigger','core.trigger.HrOrgTreeDbfindTrigger',
- 'core.button.Post','core.button.ResPost','core.button.Print','core.button.Submit','core.button.ResAudit','core.button.Audit','core.button.ResSubmit',
- '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',
- 'erp.view.core.button.Down','erp.view.core.button.UpExcel','core.button.TurnPayBalance','core.button.TurnBankRegister','core.button.TurnBillAP','core.button.TurnBillARChange',
- 'core.trigger.MultiDbfindTrigger', 'core.form.SeparNumber','core.form.MultiField','core.button.GetSumAmount','core.button.End','core.button.ResEnd'
- ],
- init:function(){
- var me = this;
- me.gridLastSelected = null;
- this.control({
- 'textfield[name=pp_thispayamount]':{
- beforerender: function(field){
- field.readOnly=false;
- }
- },
- 'erpGetSumAmountButton':{
- click: function(btn){
- var grid1 = Ext.getCmp("paypleasedetailGrid"),grid2 = Ext.getCmp("paypleasedetaildetGrid"),items1 = grid1.store.data.items,items2 = grid2.store.data.items;
- var detailamount1 = 0;
- var detailamount2 = 0;
- Ext.each(items2,function(item,index){
- if(!me.GridUtil.isBlank(grid2,item.data)) {
- detailamount2 = detailamount2 + Number(item.data['ppdd_thisapplyamount']);
- }
- });
- me.gridLastSelected.set('ppd_applyamount',detailamount2);
- }
- },
- //第一个从表
- 'paypleasedetailGrid':{
- itemclick:me.onGridItemClick1,
- afterrender:function(grid){
- grid.plugins[0].on('afteredit',function(e){
- setTimeout(function(){
- var amount = 0;
- Ext.each(grid.store.data.items,function(item,index){
- amount=amount+Number(item.data['ppd_applyamount']);
- });
- Ext.getCmp('pp_total').setValue(Ext.util.Format.number(amount,'0.00'));
- },200);
- });
- }
- },
- //第二个从表
- 'paypleasedetaildetGrid':{
- itemclick:me.onGridItemClick2
- },
- //转付款单
- 'erpTurnPayBalanceButton':{
- click:function(btn){
- me.turnPayBalance();
- },
- afterrender: function(btn){
- var status = Ext.getCmp(me.getForm(btn).statuscodeField);
- if(status && status.value != 'AUDITED'){
- btn.hide();
- }
- }
- },
- //转银行登记
- 'erpTurnBankRegisterButton':{
- click:function(btn){
- me.turnBankRegister();
- },
- afterrender: function(btn){
- var status = Ext.getCmp(me.getForm(btn).statuscodeField);
- if(status && status.value != 'AUDITED'){
- btn.hide();
- }
- }
- },
- //应付票据付款
- 'erpTurnBillAPButton':{
- click:function(btn){
- me.turnBillAP();
- },
- afterrender: function(btn){
- var status = Ext.getCmp(me.getForm(btn).statuscodeField);
- if(status && status.value != 'AUDITED'){
- btn.hide();
- }
- }
- },
- //应付票据付款
- 'erpTurnBillARChangeButton':{
- click:function(btn){
- me.turnBillARChange();
- },
- afterrender: function(btn){
- var status = Ext.getCmp(me.getForm(btn).statuscodeField);
- if(status && status.value != 'AUDITED'){
- btn.hide();
- }
- }
- },
- 'erpSaveButton': {
- click: function(btn){
- var form = me.getForm(btn);
- if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
- me.BaseUtil.getRandomNumber();
- }
- //保存之前的一些前台的逻辑判定
- this.beforeSavePayPlease();
- }
- },
- 'erpEndButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('pp_statuscode');
- if(status && status.value == 'FINISH'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onEnd(Ext.getCmp('pp_id').value);
-
- }
- },
- 'erpResEndButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('pp_statuscode');
- if(status && status.value != 'FINISH'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onResEnd(Ext.getCmp('pp_id').value);
- }
- },
- 'erpDeleteButton' : {
- click: function(btn){
- me.FormUtil.onDelete(Ext.getCmp('pp_id').value);
- }
- },
- 'erpUpdateButton': {
- click: function(btn){
- this.beforeUpdatePayPlease();
- }
- },
- 'erpAddButton': {
- click: function(){
- me.FormUtil.onAdd('addPayBalance', '新增付款申请单', 'jsps/fa/arp/payplease.jsp?whoami='+caller);
- }
- },
- 'erpCloseButton': {
- click: function(btn){
- me.FormUtil.beforeClose(me);
- }
- },
- 'erpSubmitButton': {
- afterrender: function(btn){
- var status = Ext.getCmp(me.getForm(btn).statuscodeField);
- if(status && status.value != 'ENTERING'){
- btn.hide();
- }
- },
- click: function(btn){
- me.beforeSubmit(btn);
- }
- },
- 'erpResSubmitButton': {
- afterrender: function(btn){
- var status = Ext.getCmp(me.getForm(btn).statuscodeField);
- if(status && status.value != 'COMMITED'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onResSubmit(Ext.getCmp('pp_id').value);
- }
- },
- 'erpAuditButton': {
- afterrender: function(btn){
- var status = Ext.getCmp(me.getForm(btn).statuscodeField);
- if(status && status.value != 'COMMITED'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onAudit(Ext.getCmp('pp_id').value);
- }
- },
- 'erpResAuditButton': {
- afterrender: function(btn){
- var status = Ext.getCmp(me.getForm(btn).statuscodeField);
- if(status && status.value != 'AUDITED'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onResAudit(Ext.getCmp('pp_id').value);
- }
- },
- 'erpPrintButton': {
- click: function(btn){
- var reportName="APPay_app";
- var condition = '{PayPlease.pp_id}=' + Ext.getCmp('pp_id').value + '';
- var id = Ext.getCmp('pp_id').value;
- me.FormUtil.onwindowsPrint(id, reportName, condition);
- }
- },
- 'dbfindtrigger[name=ppdd_billcode]':{
- focus: function(t){
- t.setHideTrigger(false);
- t.setReadOnly(false);
- var record = Ext.getCmp('paypleasedetailGrid').selModel.selected.first();
- if(!record || !record.data['ppd_vendcode']) {
- showError("请先选择供应商!");
- t.setHideTrigger(true);
- t.setReadOnly(true);
- } else {
- var code = record.data['ppd_vendcode'];
- t.dbBaseCondition = " ab_vendcode = '" + code + "'";
- }
- }
- },
- 'dbfindtrigger[name=ppd_bankaccount]':{
- focus: function(t){
- var vecode = t.record.data['ppd_vendcode'];
- if(vecode != ''){
- t.dbBaseCondition = " vp_vecode='"+vecode+"' ";
- }
- }
- },
- 'multidbfindtrigger[name=ppdd_billcode]':{
- focus: function(t){
- t.setHideTrigger(false);
- t.setReadOnly(false);
- var record = Ext.getCmp('paypleasedetailGrid').selModel.selected.first();
- if(!record || !record.data['ppd_vendcode']) {
- showError("请先选择供应商!");
- t.setHideTrigger(true);
- t.setReadOnly(true);
- } else {
- var code = record.data['ppd_vendcode'];
- t.dbBaseCondition = " ab_vendcode = '" + code + "'";
- }
- }
- },
- //抓取发票信息
- 'button[name=catchab]':{
- click:function(btn){
- var grid2 = Ext.getCmp('paypleasedetaildetGrid');
- var form = Ext.getCmp('form');
- var lastselect = me.gridLastSelected;
- var params = new Object();
- console.log(btn.ownerCt.items);
- var startdate = btn.ownerCt.items.items[2].rawValue;
- var enddate = btn.ownerCt.items.items[4].rawValue;
- if(lastselect == null){
- //grid1 没有选择数据
- Ext.Msg.alert('警告','请先填写供应商信息!');
- }else{
- //grid1 选择了数据
- var array = new Array();
- Ext.each(grid2.store.data.items,function(item,index){
- var d = item.get('ppdd_id');
- if(d != null && Number(d) > 0){
- array.push(item);
- }
- });
- if(array.length>0){
- Ext.Msg.alert('警告','需要先清除明细行中的数据!');
- } else {
- params['ppd_id'] = lastselect.data['ppd_id'].toString();
- params['ppd_ppid'] = lastselect.data['ppd_ppid'].toString();
- params['startdate'] = startdate;
- params['enddate'] = enddate;
- //抓取
- Ext.Ajax.request({
- url : basePath + form.catchAPUrl,
- params : params,
- method : 'post',
- callback : function(options,success,response){
- me.FormUtil.getActiveTab().setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.success){
- catchSuccess(function(){
- var condition = 'ppdd_ppdid='+lastselect.data['ppd_id'].toString();
- grid2.getMyData(condition);
- });
- } else if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);
- } else{
- catchFailure();//@i18n/i18n.js
- }
- }
- });
- }
- }
- }
- },
- //清除发票信息
- 'button[name=cleanab]':{
- click:function(btn){
- var grid2 = Ext.getCmp('paypleasedetaildetGrid');
- warnMsg('确定清除所有明细行么?',function(t){
- if(t=='yes'){
- var lastselect = me.gridLastSelected;
- var form = Ext.getCmp('form');
- var params = new Object();
- if(lastselect == null){
- //grid1 没有选择数据
- Ext.Msg.alert('警告','请先从第一明细表中选择一行明细行!');
- }else{
- params['ppd_id'] = lastselect.data['ppd_id'].toString();
- params['ppd_ppid'] = lastselect.data['ppd_ppid'].toString();
- Ext.Ajax.request({
- url : basePath + form.cleanAPUrl,
- params : params,
- method : 'post',
- callback : function(options,success,response){
- me.FormUtil.getActiveTab().setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.success){
- cleanSuccess(function(){
- //add成功后刷新页面进入可编辑的页面
- var condition = 'ppdd_ppdid='+lastselect.data['ppd_id'].toString();
- grid2.getMyData(condition);
- });
- } else if(localJson.exceptionInfo){
-
- } else{
- cleanFailure();//@i18n/i18n.js
- }
- }
- });
- }
- }else{
- return;
- }
- });
- }
- },
- //发票明细
- 'button[name=detail]':{
- click:function(btn){
- var det = Ext.getCmp('paypleasedetaildetGrid');
- if(det.store.data.items.length == 0) {
- showError('请先选择申请单明细!');
- return;
- }
- var id = det.store.data.items[0].get('ppdd_ppdid');
- if(id == 0) {
- showError('请先选择申请单明细!');
- return;
- }
- var win = Ext.getCmp('bill-win');
- if(!win) {
- var url = basePath +'jsps/common/datalist.jsp?whoami=APBill!CWIM!Detail&_noc=1';
- url += '&urlcondition=ab_code in (select ppdd_billcode from paypleasedetaildet where ppdd_ppdid=' +
- id + ')';
- win = new Ext.window.Window({
- id : 'bill-win',
- title: '发票明细',
- height: '100%',
- width: '80%',
- maximizable : true,
- buttonAlign : 'center',
- closeAction: 'hide',
- layout : 'anchor',
- items: [{
- tag : 'iframe',
- frame : true,
- anchor : '100% 100%',
- layout : 'fit',
- html : '<iframe src="' + url + '" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
- }],
- buttons : [{
- text : '关 闭',
- iconCls: 'x-button-icon-close',
- cls: 'x-btn-gray',
- handler : function(){
- Ext.getCmp('bill-win').hide();
- }
- }]
- });
- }
- win.show();
- }
- }
- });
- },
-
- turnPayBalance: function(){
- var grid = Ext.getCmp('paypleasedetailGrid');
- var items = grid.selModel.getSelection();
- if(items.length==0){
- Ext.Msg.alert('警告','请勾选需要转付款单的明细行!');
- return;
- }
- Ext.each(items, function(item, index){
- if(this.data[grid.keyField] != null && this.data[grid.keyField] != ''
- && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0){
- grid.multiselected.push(item);
- }
- });
- var form = Ext.getCmp('form');
- var records = Ext.Array.unique(grid.multiselected);
- var r = form.getValues();
-
- if(records.length > 0){
- var params = new Object();
- params.caller = caller;
- var data = new Array();
- params.formStore = unescape(Ext.JSON.encode(r).replace(/\\/g,"%"));
- var bool = false;
- Ext.each(records, function(record, index){
- var f = form.fo_detailMainKeyField;
- if(((grid.keyField && this.data[grid.keyField] != null && this.data[grid.keyField] != ''
- && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0)
- ||(f && this.data[f] != null && this.data[f] != ''
- && this.data[f] != '0' && this.data[f] != 0))&&(record.data['ppd_statuscode']!='TURNPB')){
- bool = true;
- var o = new Object();
- if(grid.keyField){
- o[grid.keyField] = record.data[grid.keyField];
- } else {
- params.id[index] = record.data[form.fo_detailMainKeyField];
- }
- if(grid.toField){
- Ext.each(grid.toField, function(f, index){
- var v = Ext.getCmp(f).value;
- if(v != null && v.toString().trim() != '' && v.toString().trim() != 'null'){
- o[f] = v;
- }
- });
- }
- if(grid.necessaryFields){
- Ext.each(grid.necessaryFields, function(f, index){
- var v = record.data[f];
- if(Ext.isDate(v)){
- v = Ext.Date.toString(v);
- }
- o[f] = v;
- });
- }
- data.push(o);
- }
- });
- if(bool){
- params.data = Ext.encode(data);
- var main = parent.Ext.getCmp("content-panel");
- main.getActiveTab().setLoading(true);//loading...
- Ext.Ajax.request({
- url : basePath + 'fa/PayPleaseController/turnPayBalance.action',
- params: params,
- method : 'post',
- callback : function(options,success,response){
- main.getActiveTab().setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);
- return "";
- }
- if(localJson.success){
- if(localJson.log){
- showMessage("提示", localJson.log);
- }
- Ext.Msg.alert("提示", "处理成功!", function(){
- var me = this;
- //add成功后刷新页面进入可编辑的页面
- var value = r[form.keyField];
- var formCondition = form.keyField + "IS" + value ;
- if(me.contains(window.location.href, '?', true)){
- window.location.href = window.location.href + '&formCondition=' +
- formCondition;
- } else {
- window.location.href = window.location.href + '?formCondition=' +
- formCondition;
- }
-
- });
- }
- }
- });
- } else {
- showError("没有需要处理的数据!");
- }
- }
- },
- turnBankRegister: function(){
- var grid = Ext.getCmp('paypleasedetailGrid'), catecode = Ext.getCmp('pp_paymentcode').value;
- var items = grid.selModel.getSelection();
- var thisamount = Ext.getCmp('pp_thispayamount').value, amount = 0;
- var ppamount = Ext.getCmp('pp_total').value;
- Ext.each(grid.store.data.items,function(item,index){
- amount=amount+Number(item.data['ppd_account']);
- });
- if(thisamount-(ppamount-amount)>0.01){
- Ext.getCmp('pp_thispayamount').setValue(ppamount-amount);
- }
- if(items.length==0){
- Ext.Msg.alert('警告','请勾选需要转银行登记的明细行!');
- return;
- }
- if(catecode == null || catecode == ''){
- Ext.Msg.alert('警告','请填写需要转银行登记的付款方信息!');
- return;
- }
- if(thisamount == null || thisamount=='' || thisamount==0){
- Ext.getCmp('pp_thispayamount').setValue(ppamount-amount);
- }
- Ext.each(items, function(item, index){
- if(this.data[grid.keyField] != null && this.data[grid.keyField] != ''
- && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0){
- grid.multiselected.push(item);
- }
- });
- var form = Ext.getCmp('form');
- var records = Ext.Array.unique(grid.multiselected);
- var r = form.getValues();
-
- if(records.length > 0){
- var params = new Object();
- params.caller = caller;
- var data = new Array();
- params.formStore = unescape(Ext.JSON.encode(r).replace(/\\/g,"%"));
- var bool = false;
- Ext.each(records, function(record, index){
- var f = form.fo_detailMainKeyField;
- if(((grid.keyField && this.data[grid.keyField] != null && this.data[grid.keyField] != ''
- && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0)
- ||(f && this.data[f] != null && this.data[f] != ''
- && this.data[f] != '0' && this.data[f] != 0))&&(record.data['ppd_statuscode']!='TURNPB')){
- bool = true;
- var o = new Object();
- if(grid.keyField){
- o[grid.keyField] = record.data[grid.keyField];
- } else {
- params.id[index] = record.data[form.fo_detailMainKeyField];
- }
- if(grid.toField){
- Ext.each(grid.toField, function(f, index){
- var v = Ext.getCmp(f).value;
- if(v != null && v.toString().trim() != '' && v.toString().trim() != 'null'){
- o[f] = v;
- }
- });
- }
- if(grid.necessaryFields){
- Ext.each(grid.necessaryFields, function(f, index){
- var v = record.data[f];
- if(Ext.isDate(v)){
- v = Ext.Date.toString(v);
- }
- o[f] = v;
- });
- }
- data.push(o);
- }
- });
- if(bool){
- params.data = Ext.encode(data);
- var main = parent.Ext.getCmp("content-panel");
- main.getActiveTab().setLoading(true);//loading...
- Ext.Ajax.request({
- url : basePath + 'fa/PayPleaseController/turnBankRegister.action',
- params: params,
- method : 'post',
- callback : function(options,success,response){
- main.getActiveTab().setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);
- return "";
- }
- if(localJson.success){
- if(localJson.log){
- showMessage("提示", localJson.log);
- }
- Ext.Msg.alert("提示", "处理成功!", function(){
- var me = this;
- //add成功后刷新页面进入可编辑的页面
- var value = r[form.keyField];
- var formCondition = form.keyField + "IS" + value ;
- if(me.contains(window.location.href, '?', true)){
- window.location.href = window.location.href + '&formCondition=' +
- formCondition;
- } else {
- window.location.href = window.location.href + '?formCondition=' +
- formCondition;
- }
-
- });
- }
- }
- });
- } else {
- showError("没有需要处理的数据!");
- }
- }
- },
- turnBillAP: function(){
- var grid = Ext.getCmp('paypleasedetailGrid'), catecode = Ext.getCmp('pp_paymentcode').value;
- var items = grid.selModel.getSelection();
- var thisamount = Ext.getCmp('pp_thispayamount').value, amount = 0;
- var ppamount = Ext.getCmp('pp_total').value;
- Ext.each(grid.store.data.items,function(item,index){
- amount=amount+Number(item.data['ppd_account']);
- });
- if(thisamount-(ppamount-amount)>0.01){
- Ext.getCmp('pp_thispayamount').setValue(ppamount-amount);
- }
- if(items.length==0){
- Ext.Msg.alert('警告','请勾选需要转应付票据的明细行!');
- return;
- }
- if(catecode == null || catecode == ''){
- Ext.Msg.alert('警告','请填写需要转应付票据的付款方信息!');
- return;
- }
- if(thisamount == null || thisamount=='' || thisamount==0){
- Ext.getCmp('pp_thispayamount').setValue(ppamount-amount);
- }
- Ext.each(items, function(item, index){
- if(this.data[grid.keyField] != null && this.data[grid.keyField] != ''
- && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0){
- grid.multiselected.push(item);
- }
- });
- var form = Ext.getCmp('form');
- var records = Ext.Array.unique(grid.multiselected);
- var r = form.getValues();
-
- if(records.length > 0){
- var params = new Object();
- params.caller = caller;
- var data = new Array();
- params.formStore = unescape(Ext.JSON.encode(r).replace(/\\/g,"%"));
- var bool = false;
- Ext.each(records, function(record, index){
- var f = form.fo_detailMainKeyField;
- if(((grid.keyField && this.data[grid.keyField] != null && this.data[grid.keyField] != ''
- && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0)
- ||(f && this.data[f] != null && this.data[f] != ''
- && this.data[f] != '0' && this.data[f] != 0))&&(record.data['ppd_statuscode']!='TURNPB')){
- bool = true;
- var o = new Object();
- if(grid.keyField){
- o[grid.keyField] = record.data[grid.keyField];
- } else {
- params.id[index] = record.data[form.fo_detailMainKeyField];
- }
- if(grid.toField){
- Ext.each(grid.toField, function(f, index){
- var v = Ext.getCmp(f).value;
- if(v != null && v.toString().trim() != '' && v.toString().trim() != 'null'){
- o[f] = v;
- }
- });
- }
- if(grid.necessaryFields){
- Ext.each(grid.necessaryFields, function(f, index){
- var v = record.data[f];
- if(Ext.isDate(v)){
- v = Ext.Date.toString(v);
- }
- o[f] = v;
- });
- }
- data.push(o);
- }
- });
- if(bool){
- params.data = Ext.encode(data);
- var main = parent.Ext.getCmp("content-panel");
- main.getActiveTab().setLoading(true);//loading...
- Ext.Ajax.request({
- url : basePath + 'fa/PayPleaseController/turnBillAP.action',
- params: params,
- method : 'post',
- callback : function(options,success,response){
- main.getActiveTab().setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);
- return "";
- }
- if(localJson.success){
- if(localJson.log){
- showMessage("提示", localJson.log);
- }
- Ext.Msg.alert("提示", "处理成功!", function(){
- var me = this;
- //add成功后刷新页面进入可编辑的页面
- var value = r[form.keyField];
- var formCondition = form.keyField + "IS" + value ;
- if(me.contains(window.location.href, '?', true)){
- window.location.href = window.location.href + '&formCondition=' +
- formCondition;
- } else {
- window.location.href = window.location.href + '?formCondition=' +
- formCondition;
- }
-
- });
- }
- }
- });
- } else {
- showError("没有需要处理的数据!");
- }
- }
- },
- turnBillARChange: function(){
- var grid = Ext.getCmp('paypleasedetailGrid'), catecode = Ext.getCmp('pp_paymentcode').value;
- var items = grid.selModel.getSelection();
- var thisamount = Ext.getCmp('pp_thispayamount').value, amount = 0;
- var ppamount = Ext.getCmp('pp_total').value;
- Ext.each(grid.store.data.items,function(item,index){
- amount=amount+Number(item.data['ppd_account']);
- });
- if(thisamount-(ppamount-amount)>0.01){
- Ext.getCmp('pp_thispayamount').setValue(ppamount-amount);
- }
- if(items.length==0){
- Ext.Msg.alert('警告','请勾选需要转应付票据的明细行!');
- return;
- }
- if(catecode == null || catecode == ''){
- Ext.Msg.alert('警告','请填写需要转应付票据的付款方信息!');
- return;
- }
- if(thisamount == null || thisamount=='' || thisamount==0){
- Ext.getCmp('pp_thispayamount').setValue(ppamount-amount);
- }
- Ext.each(items, function(item, index){
- if(this.data[grid.keyField] != null && this.data[grid.keyField] != ''
- && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0){
- grid.multiselected.push(item);
- }
- });
- var form = Ext.getCmp('form');
- var records = Ext.Array.unique(grid.multiselected);
- var r = form.getValues();
-
- if(records.length > 0){
- var params = new Object();
- params.caller = caller;
- var data = new Array();
- params.formStore = unescape(Ext.JSON.encode(r).replace(/\\/g,"%"));
- var bool = false;
- Ext.each(records, function(record, index){
- var f = form.fo_detailMainKeyField;
- if(((grid.keyField && this.data[grid.keyField] != null && this.data[grid.keyField] != ''
- && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0)
- ||(f && this.data[f] != null && this.data[f] != ''
- && this.data[f] != '0' && this.data[f] != 0))&&(record.data['ppd_statuscode']!='TURNPB')){
- bool = true;
- var o = new Object();
- if(grid.keyField){
- o[grid.keyField] = record.data[grid.keyField];
- } else {
- params.id[index] = record.data[form.fo_detailMainKeyField];
- }
- if(grid.toField){
- Ext.each(grid.toField, function(f, index){
- var v = Ext.getCmp(f).value;
- if(v != null && v.toString().trim() != '' && v.toString().trim() != 'null'){
- o[f] = v;
- }
- });
- }
- if(grid.necessaryFields){
- Ext.each(grid.necessaryFields, function(f, index){
- var v = record.data[f];
- if(Ext.isDate(v)){
- v = Ext.Date.toString(v);
- }
- o[f] = v;
- });
- }
- data.push(o);
- }
- });
- if(bool){
- params.data = Ext.encode(data);
- var main = parent.Ext.getCmp("content-panel");
- main.getActiveTab().setLoading(true);//loading...
- Ext.Ajax.request({
- url : basePath + 'fa/PayPleaseController/turnBillARChange.action',
- params: params,
- method : 'post',
- callback : function(options,success,response){
- main.getActiveTab().setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);
- return "";
- }
- if(localJson.success){
- if(localJson.log){
- showMessage("提示", localJson.log);
- }
- Ext.Msg.alert("提示", "处理成功!", function(){
- var me = this;
- //add成功后刷新页面进入可编辑的页面
- var value = r[form.keyField];
- var formCondition = form.keyField + "IS" + value ;
- if(me.contains(window.location.href, '?', true)){
- window.location.href = window.location.href + '&formCondition=' +
- formCondition;
- } else {
- window.location.href = window.location.href + '?formCondition=' +
- formCondition;
- }
-
- });
- }
- }
- });
- } else {
- showError("没有需要处理的数据!");
- }
- }
- },
- //点击第一个grid
- onGridItemClick1: function(selModel,record){
- var me = this;
- me.gridLastSelected = record;
- var ppd_id = record.data['ppd_id'];
- this.ppdid = ppd_id;
- var grid = Ext.getCmp('paypleasedetailGrid');
- var ppddgrid = Ext.getCmp('paypleasedetaildetGrid');
-
- if(ppd_id > 0 && !me.GridUtil.isBlank(grid,record.data)){
- var condition = "ppdd_ppdid='"+ppd_id+"'";
- ppddgrid.getMyData(condition);
- }
- this.onGridItemClick(selModel,record,'paypleasedetailGrid');
-
- },
- //点击第二个GRID
- onGridItemClick2: function(selModel,record){
- this.onGridItemClick(selModel,record,'paypleasedetaildetGrid');
- },
- onGridItemClick: function(selModel, record,id){//grid行选择
- this.GridUtil.onGridItemClick(selModel, record,id);
- },
- getForm: function(btn){
- return btn.ownerCt.ownerCt;
- },
- beforeSavePayPlease: function(){
- this.beforeSave();
- },
- beforeUpdatePayPlease:function(){
- var s = ' ';
- var ppdgrid = Ext.getCmp('paypleasedetailGrid');
- var items = ppdgrid.store.data.items;
- var bool = true;
- var pptotal = Number(Ext.getCmp('pp_total').getValue());
- var amount = 0;
- Ext.each(items,function(item){
- var keys = Ext.Object.getKeys(item.modified);
- Ext.each(keys,function(key){
- if(key=='ppd_auditamount'||key=='ppd_ifpay'){
- item.set('ppd_editor',em_name);
- item.set('ppd_editorid',em_uu);
- }
- });
- var applyamount = item.data['ppd_applyamount'];
- var auditamount = item.data['ppd_auditamount'];
- if(applyamount<auditamount){
- s=s+(item.index+1)+' ';
- bool=false;
- }
- amount=amount+Number(applyamount);
- });
-
- if(bool){
- this.beforeUpdate();
- // if(amount != pptotal){
- // console.log('show error');
- // showError($I18N.common.grid.updatePayPleaseError1);
- // }else{
- // this.beforeUpdate();
- // }
- }else{
- showError($I18N.common.grid.auditApplyPayPlease1 + s + $I18N.common.grid.auditApplyPayPlease2);
- }
- },
-
- /**
- * 检查form未完善的字段
- */
- checkForm: function(){
- var s = '';
- var form = Ext.getCmp('form');
- form.getForm().getFields().each(function (item,index,length){
- if(!item.isValid()){
- if(s != ''){
- s = s + ',';
- }
- if(item.fieldLabel){
- s = s + item.fieldLabel.replace(/ /g,'');
- }
- }
- });
- if(s == ''){
- return true;
- }
- showError($I18N.common.form.necessaryInfo1 + '(<font color=green>'+s+'</font>)' + $I18N.common.form.necessaryInfo2);
- return false;
- },
- beforeUpdate: function(me){
- var mm = this;
- var form = Ext.getCmp('form');
- if(! this.checkForm()){
- return;
- }
- var grid = Ext.getCmp('paypleasedetailGrid');
- var date = Ext.getCmp('pp_date').getValue();
- grid.store.each(function(record){
- if(record.dirty && !mm.GridUtil.isBlank(grid, record.data)){
- if(Ext.isEmpty(record.get('ppd_startdate'))) {
- record.set('ppd_startdate', Ext.Date.getFirstDateOfMonth(date));
- }
- if(Ext.isEmpty(record.get('ppd_overdate'))) {
- record.set('ppd_overdate', Ext.Date.getLastDateOfMonth(date));
- }
- }
- });
- var gridsDet = Ext.getCmp('paypleasedetaildetGrid');
- var currency1 = '';
- if(this.gridLastSelected){
- if(this.gridLastSelected.data['ppd_id']){
- currency1 = this.gridLastSelected.data['ppd_currency'];
- mm.ppdid = this.gridLastSelected.data['ppd_id'];
- }
-
- }else{
- currency1 = grid.store.data.items[0].data['ppd_currency'];
- }
- var sameCurrency = true;
- Ext.each(gridsDet.store.data.items,function(item, index){
- if(item.dirty && !mm.GridUtil.isBlank(gridsDet, item.data)){
- var thisapplyamount = item.data['ppdd_thisapplyamount'];
- if(thisapplyamount == 0 || thisapplyamount == null){
- showError('明细表第' + item.data['ppdd_detno'] + '行本次申请金额不能为空!');return;
- return;
- }
- if(item.data['ppdd_currency'] != currency1){
- sameCurrency = false;
- }
- }
- });
- if(!sameCurrency){
- showError($I18N.common.msg.failure_update_currency);
- return;
- }
- if(mm.ppdid == 0 || mm.ppdid == null){
- if(grid){
- mm.ppdid = grid.store.data.items[0].data['ppd_id'];
- }else{
- mm.ppdid = 0;
- }
- }
- //如果ppdid == 0 则次页面为新建页面 活着以前也没有在grid1中添加数据
- //grid1 中的数据
- var param1 = mm.GridUtil.getGridStore(grid);
- //grid2中的数据
- var param2 = mm.getGridStoreDet(gridsDet);
- //ppdid==0的情况为 grid1第一条没有数据的情况 次情况只能保存grid1中的数据 grid2中的数据保存不上
- //如果ppdid!=0 则可能的情况为 1.点击grid1选择了一条数据 2.没有点击grid1 但是grid1中有数据 此时
- //grid2中的数据自动保存在grid1中第一条数据下
- if(mm.ppdid == 0){
- if(param2 == null || param2 == ''){
- //此时grid2数据为空 可以保存grid1的数据
- mm.onUpdate(param1);
- }else{
- warnMsg('不能保存从表二中的数据,是否只保存从表一?',function(btn){
- if(btn =='yes'){
- //保存从表一中的数据
- mm.onUpdate(param1);
- }else{
- //return
- return;
- }
- });
- }
- }else{
- if(param2 ==null||param2==''){
- mm.onUpdate(param1);
- }else{
- mm.onUpdate(param1,param2);
- }
- }
- },
- beforeSave: function(me){
- var mm = this;
- var form = Ext.getCmp('form');
- if(! this.checkForm()){
- return;
- }
- if(Ext.getCmp(form.keyField).value == null || Ext.getCmp(form.keyField).value == ''){
- mm.FormUtil.getSeqId(form);
- }
- var grid = Ext.getCmp('paypleasedetailGrid');
- var date = Ext.getCmp('pp_date').getValue();
- grid.store.each(function(record){
- if(record.dirty && !mm.GridUtil.isBlank(grid, record.data)){
- if(Ext.isEmpty(record.get('ppd_startdate'))) {
- record.set('ppd_startdate', Ext.Date.getFirstDateOfMonth(date));
- }
- if(Ext.isEmpty(record.get('ppd_overdate'))) {
- record.set('ppd_overdate', Ext.Date.getLastDateOfMonth(date));
- }
- }
- });
- var gridsDet = Ext.getCmp('paypleasedetaildetGrid');
- var currency1 = '';
- if(this.gridLastSelected){
- currency1 = this.gridLastSelected.data['ppd_currency'];
- mm.ppdid = this.gridLastSelected.data['ppd_id'];
- } else{
- currency1 = grid.store.first().data['ppd_currency'];
- }
- var sameCurrency = true;
- Ext.each(gridsDet.store.data.items,function(item, index){
- if(item.dirty && !mm.GridUtil.isBlank(gridsDet,item.data)){
- if(item.data['ppdd_currency'] != currency1){
- sameCurrency = false;
- }
- }
- });
- if(!sameCurrency){
- showError($I18N.common.msg.failure_save_currency);
- return;
- }
- if(mm.ppdid == 0 || mm.ppdid == null){
- if(grid){
- mm.ppdid = grid.store.data.items[0].data['ppd_id'];
- }else{
- mm.ppdid = 0;
- }
- }
- //如果ppdid == 0 则次页面为新建页面 活着以前也没有在grid1中添加数据
- //grid1 中的数据
- var param1 = mm.GridUtil.getGridStore(grid);
- //grid2中的数据
- var param2 = mm.getGridStoreDet(gridsDet);
- //ppdid==0的情况为 grid1第一条没有数据的情况 次情况只能保存grid1中的数据 grid2中的数据保存不上
- //如果ppdid!=0 则可能的情况为 1.点击grid1选择了一条数据 2.没有点击grid1 但是grid1中有数据 此时
- //grid2中的数据自动保存在grid1中第一条数据下
- if(mm.ppdid == 0){
- if(param2 == null || param2 == ''){
- //此时grid2数据为空 可以保存grid1的数据
- mm.onSave(param1);
- }else{
- warnMsg('不能保存从表二中的数据,是否只保存从表一?',function(btn){
- if(btn =='yes'){
- //保存从表一中的数据
- mm.onSave(param1);
- }else{
- //return
- return;
- }
- });
- }
- }else{
- if(param2 ==null||param2==''){
- mm.onSave(param1);
- }else{
- mm.onSave(param1,param2);
- }
- }
- },
- beforeSubmit: function(){
- var me = this;
- var grid1 = Ext.getCmp('paypleasedetailGrid'),items1=grid1.store.data.items;
- var grid2 = Ext.getCmp('paypleasedetaildetGrid'),items2=grid2.store.data.items;
- var applyamount = 0, nowamount=0,amount=0;
- var bool = true;
- Ext.each(items2,function(item,index){
- if(!me.GridUtil.isBlank(grid2, item.data)){
- nowamount = nowamount+Number(item.data['ppdd_thisapplyamount']);
- if(Math.abs(Number(item.data['ppdd_billamount']))<Math.abs(Number(item.data['ppdd_account']))){
- bool = false;
- showError('发票的已付金额大于发票金额,不能提交');return;
- }
- if(!Ext.isEmpty(item.get('ppdd_ordercode'))) {
- if(Math.abs(Number(item.data['ppdd_billamount'])-Number(item.data['ppdd_account'])) < Math.abs(Number(item.data['ppdd_thisapplyamount']))){
- bool = false;
- showError('本次申请金额大于发票未付的金额,不能提交');return;
- }
- }
- }
- });
- var pptotal = Number(Ext.getCmp('pp_total').getValue());
- var type=Ext.getCmp('pp_type').value;
- if(type=='应付款'){
- Ext.each(items1,function(item,index){
- if(item.data[grid1.necessaryField]!=''&&item.data[grid1.necessaryField]!=null){
- applyamount = Number(item.data['ppd_applyamount']);
- amount = amount+ applyamount;
- if(Math.abs(nowamount-applyamount)>0.001){
- //冲账金额与明细行本次结算总和不等
- //抛出异常
- bool = false;
- showError('申请金额与发票详情中本次申请金额不等,不能提交');return;
- }
- }
- });
-
- if(amount != pptotal){
- bool = false;
- showError($I18N.common.grid.submitPayPleaseError1);return;
- }
-
-
- if(bool)
- me.FormUtil.onSubmit(Ext.getCmp('pp_id').value);
- } else {
- if(bool)
- me.FormUtil.onSubmit(Ext.getCmp('pp_id').value);
- }
- },
- /**
- * 拿到grid里面要提交的数据
- */
- getGridStoreDet: function(grid){
- if(grid == null){
- grid = Ext.getCmp('grid');
- }
- var jsonGridData = new Array();
- var form = Ext.getCmp('form');
- var s = grid.getStore().data.items;//获取store里面的数据
- var dd;
- for(var i=0;i<s.length;i++){//将grid里面各行的数据获取并拼成jsonGridData
- var data = s[i].data;
- dd = new Object();
- if(s[i].dirty && !grid.GridUtil.isBlank(grid, data)){
- Ext.each(grid.columns, function(c){
- if(c.logic != 'ignore'){//只需显示,无需后台操作的字段,自动略去
- if(c.xtype == 'datecolumn'){
- if(Ext.isDate(data[c.dataIndex])){
- dd[c.dataIndex] = Ext.Date.toString(data[c.dataIndex]);//在这里把GMT日期转化成Y-m-d格式日期
- } else {
- dd[c.dataIndex] = Ext.Date.format(new Date(), 'Y-m-d');//如果用户没输入日期,或输入有误,就给个默认日期,
- //或干脆return;并且提示一下用户
- }
- } else if(c.xtype == 'datetimecolumn'){
- if(Ext.isDate(data[c.dataIndex])){
- dd[c.dataIndex] = Ext.Date.format(data[c.dataIndex], 'Y-m-d H:i:s');//在这里把GMT日期转化成Y-m-d H:i:s格式日期
- } else {
- dd[c.dataIndex] = Ext.Date.format(new Date(), 'Y-m-d H:i:s');//默认日期,
- }
- } else if(c.xtype == 'numbercolumn'){//赋个默认值0吧,不然不好保存
- if(data[c.dataIndex] == null || data[c.dataIndex] == ''){
- dd[c.dataIndex] = '0';//也可以从data里面去掉这些字段
- } else {
- dd[c.dataIndex] = String(s[i].data[c.dataIndex]);
- }
- } else {
- dd[c.dataIndex] = s[i].data[c.dataIndex];
- }
- }
- });
- if(grid.mainField){//例如,将pu_id的值赋给pd_puid
- dd[grid.mainField] = this.ppdid;
- }
- jsonGridData.push(Ext.JSON.encode(dd));
- }
- }
- return jsonGridData;
- },
- onUpdate:function(param1,param2){
- var me = this;
- var form =Ext.getCmp('form');
- param1 = param1 == null ? [] : "[" + param1.toString() + "]";
- param2 = param2 == null ? [] : "[" + param2.toString() + "]";
- if(form.getForm().isValid()){
- //form里面数据
- Ext.each(form.items.items, function(item){
- if(item.xtype == 'numberfield'){
- //number类型赋默认值,不然sql无法执行
- if(item.value == null || item.value == ''){
- item.setValue(0);
- }
- }
- });
- var r = form.getValues();
- if(!me.contains(form.updateUrl, '?caller=', true)){
- form.updateUrl = form.updateUrl + "?caller=" + caller;
- }
- me.update(r, param1,param2);
- }else{
- me.checkForm();
- }
- },
- onSave:function(param1,param2){
- var me = this;
- var form =Ext.getCmp('form');
- param1 = param1 == null ? [] : "[" + param1.toString() + "]";
- param2 = param2 == null ? [] : "[" + param2.toString() + "]";
- if(form.getForm().isValid()){
- //form里面数据
- Ext.each(form.items.items, function(item){
- if(item.xtype == 'numberfield'){
- //number类型赋默认值,不然sql无法执行
- if(item.value == null || item.value == ''){
- item.setValue(0);
- }
- }
- });
- var r = form.getValues();
- if(!me.contains(form.saveUrl, '?caller=', true)){
- form.saveUrl = form.saveUrl + "?caller=" + caller;
- }
- me.save(r, param1,param2);
- }else{
- me.checkForm();
- }
- },
- /*
- * 修改
- */
- update:function(){
- var params = new Object();
- var r = arguments[0];
- Ext.each(Ext.Object.getKeys(r), function(k){//去掉页面非表单定义字段
- if(contains(k, 'ext-', true)){
- delete r[k];
- }
- });
- params.formStore = unescape(Ext.JSON.encode(r).replace(/\\/g,"%"));
- params.param1 = unescape(arguments[1].toString().replace(/\\/g,"%"));
- for(var i=2; i<arguments.length; i++) { //兼容多参数
- params['param' + i] = unescape(arguments[i].toString().replace(/\\/g,"%"));
- }
- var me = this;
- var form = Ext.getCmp('form');
- me.getActiveTab().setLoading(true);//loading...
- Ext.Ajax.request({
- url : basePath + form.updateUrl,
- params : params,
- method : 'post',
- callback : function(options,success,response){
- me.getActiveTab().setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.success){
- saveSuccess(function(){
- //add成功后刷新页面进入可编辑的页面
- var value = r[form.keyField];
- var formCondition = form.keyField + "IS" + value ;
- if(me.contains(window.location.href, '?', true)){
- window.location.href = window.location.href + '&formCondition=' +
- formCondition;
- } else {
- window.location.href = window.location.href + '?formCondition=' +
- formCondition;
- }
- });
- } else if(localJson.exceptionInfo){
- var str = localJson.exceptionInfo;
- if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
- str = str.replace('AFTERSUCCESS', '');
- saveSuccess(function(){
- //add成功后刷新页面进入可编辑的页面
- var value = r[form.keyField];
- var formCondition = form.keyField + "IS" + value ;
- if(me.contains(window.location.href, '?', true)){
- window.location.href = window.location.href + '&formCondition=' +
- formCondition;
- } else {
- window.location.href = window.location.href + '?formCondition=' +
- formCondition;
- }
- });
- showError(str);
- } else {
- showError(str);
- return;
- }
- } else{
- saveFailure();//@i18n/i18n.js
- }
- }
- });
- },
- /**
- * 保存
- */
- save: function(){
- var params = new Object();
- var r = arguments[0];
- Ext.each(Ext.Object.getKeys(r), function(k){//去掉页面非表单定义字段
- if(contains(k, 'ext-', true)){
- delete r[k];
- }
- });
- params.formStore = unescape(Ext.JSON.encode(r).replace(/\\/g,"%"));
- params.param1 = unescape(arguments[1].toString().replace(/\\/g,"%"));
- for(var i=2; i<arguments.length; i++) { //兼容多参数
- params['param' + i] = unescape(arguments[i].toString().replace(/\\/g,"%"));
- }
- var me = this;
- var form = Ext.getCmp('form');
- me.getActiveTab().setLoading(true);//loading...
- Ext.Ajax.request({
- url : basePath + form.saveUrl,
- params : params,
- method : 'post',
- callback : function(options,success,response){
- me.getActiveTab().setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.success){
- saveSuccess(function(){
- //add成功后刷新页面进入可编辑的页面
- var value = r[form.keyField];
- var formCondition = form.keyField + "IS" + value ;
- if(me.contains(window.location.href, '?', true)){
- window.location.href = window.location.href + '&formCondition=' +
- formCondition;
- } else {
- window.location.href = window.location.href + '?formCondition=' +
- formCondition;
- }
- });
- } else if(localJson.exceptionInfo){
- var str = localJson.exceptionInfo;
- if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
- str = str.replace('AFTERSUCCESS', '');
- saveSuccess(function(){
- //add成功后刷新页面进入可编辑的页面
- var value = r[form.keyField];
- var formCondition = form.keyField + "IS" + value ;
- if(me.contains(window.location.href, '?', true)){
- window.location.href = window.location.href + '&formCondition=' +
- formCondition;
- } else {
- window.location.href = window.location.href + '?formCondition=' +
- formCondition;
- }
- });
- showError(str);
- } else {
- showError(str);
- return;
- }
- } else{
- saveFailure();//@i18n/i18n.js
- }
- }
-
- });
- },
- getActiveTab: function(){
- var tab = null;
- if(Ext.getCmp("content-panel")){
- tab = Ext.getCmp("content-panel").getActiveTab();
- }
- if(!tab && parent.Ext.getCmp("content-panel"))
- tab = parent.Ext.getCmp("content-panel").getActiveTab();
- if(!tab && parent.parent.Ext.getCmp("content-panel"))
- tab = parent.parent.Ext.getCmp("content-panel").getActiveTab();
- if(!tab){
- var win = parent.Ext.ComponentQuery.query('window');
- if(win.length > 0){
- tab = win[win.length-1];
- }
- }
- return tab;
- },
- /**
- * string:原始字符串
- * substr:子字符串
- * isIgnoreCase:忽略大小写
- */
- contains: function(string,substr,isIgnoreCase){
- if(isIgnoreCase){
- string=string.toLowerCase();
- substr=substr.toLowerCase();
- }
- var startChar=substr.substring(0,1);
- var strLen=substr.length;
- for(var j=0;j<string.length-strLen+1;j++){
- if(string.charAt(j)==startChar){//如果匹配起始字符,开始查找
- if(string.substring(j,j+strLen)==substr){//如果从j开始的字符与str匹配,那ok
- return true;
- }
- }
- }
- return false;
- }
- });
|