| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.fa.arp.PayPlease2', {
- 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.PayPlease2','fa.arp.payplease.PayPleaseDetailDetGrid2','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.trigger.MultiDbfindTrigger', 'core.form.SeparNumber','core.form.MultiField','core.button.GetSumAmount'
- ],
- 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("paypleasedetaildetGrid2"),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);
- });
- }
- },
- //第二个从表
- 'paypleasedetaildetGrid2':{
- afterrender: function(g) {
- g.plugins[0].on('beforeedit', function(args) {
- var bool = true;
- if (args.field == "ppdd_pucode") {
- if (!Ext.isEmpty(args.record.get('ppdd_makecode'))){
- bool = false;
- }
- return bool;
- }
- if (args.field == "ppdd_makecode") {
- if (!Ext.isEmpty(args.record.get('ppdd_pucode'))){
- bool = false;
- }
- return bool;
- }
- });
- },
- 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();
- }
- }
- },
- '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();
- }
- },
- 'erpDeleteButton' : {
- click: function(btn){
- me.FormUtil.onDelete(Ext.getCmp('pp_id').value);
- }
- },
- 'erpUpdateButton': {
- click: function(btn){
- this.beforeUpdatePayPlease();
- }
- },
- 'erpAddButton': {
- click: function(){
- me.FormUtil.onAdd('addPayPlease', '新增预付款申请单', 'jsps/fa/arp/payplease2.jsp');
- }
- },
- '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_app2";
- 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_pucode]':{
- 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 = " pu_vendcode = '" + code + "'";
- }
- }
- },
- 'multidbfindtrigger[name=ppdd_pucode]':{
- 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 = " pu_vendcode = '" + code + "'";
- }
- }
- },
- 'dbfindtrigger[name=ppdd_makecode]':{
- 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 = " ma_vendcode = '" + code + "'";
- }
- }
- },
- 'multidbfindtrigger[name=ppdd_makecode]':{
- 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 = " ma_vendcode = '" + code + "'";
- }
- }
- }
- });
- },
-
- 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']!='TURNPP')){
- 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("没有需要处理的数据!");
- }
- }
- },
- //点击第一个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('paypleasedetaildetGrid2');
-
- 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,'paypleasedetaildetGrid2');
- },
- 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 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();
- }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;
- if(! this.checkForm()){
- return;
- }
- var grids = Ext.ComponentQuery.query('paypleasedetailGrid');
- var gridsDet = Ext.ComponentQuery.query('paypleasedetaildetGrid2');
- 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 = grids[0].store.data.items[0].data['ppd_currency'];
- }
- var sameCurrency = true;
- Ext.each(gridsDet[0].store.data.items,function(item, index){
- if(item.dirty && !mm.GridUtil.isBlank(gridsDet[0], 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(grids[0]){
- mm.ppdid = grids[0].store.data.items[0].data['ppd_id'];
- }else{
- mm.ppdid = 0;
- }
- }
- //如果ppdid == 0 则次页面为新建页面 活着以前也没有在grid1中添加数据
- //grid1 中的数据
- var param1 = mm.GridUtil.getGridStore(grids[0]);
- //grid2中的数据
- var param2 = mm.getGridStoreDet(gridsDet[0]);
- //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 grids = Ext.getCmp('paypleasedetailGrid');
- var gridsDet = Ext.getCmp('paypleasedetaildetGrid2');
- var currency1 = '';
- if(this.gridLastSelected){
- currency1 = this.gridLastSelected.data['ppd_currency'];
- mm.ppdid = this.gridLastSelected.data['ppd_id'];
- } else{
- currency1 = grids.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(mm.ppdid == 0 || mm.ppdid == null){
- if(grids[0]){
- mm.ppdid = grids[0].store.data.items[0].data['ppd_id'];
- }else{
- mm.ppdid = 0;
- }
- }
- //如果ppdid == 0 则次页面为新建页面 活着以前也没有在grid1中添加数据
- //grid1 中的数据
- var param1 = mm.GridUtil.getGridStore(grids);
- //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 grid2 = Ext.getCmp('paypleasedetaildetGrid2'),items2=grid2.store.data.items;
- var bool = true;
- Ext.each(items2,function(item,index){
- if(!me.GridUtil.isBlank(grid2, item.data)){
- 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;
- }
- }
- }
- });
- 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 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;
- },
- 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("没有需要处理的数据!");
- }
- }
- }
- });
|