| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.fa.ars.Voucher', {
- extend: 'Ext.app.Controller',
- FormUtil: Ext.create('erp.util.FormUtil'),
- BaseUtil: Ext.create('erp.util.BaseUtil'),
- GridUtil: Ext.create('erp.util.GridUtil'),
- views:[
- 'fa.ars.Voucher','core.form.Panel','core.grid.Panel2','core.toolbar.Toolbar',
- 'fa.ars.VoucherFlowGrid','fa.ars.DetailAssGrid', 'core.button.CreateTemplate',
- 'core.button.Add','core.button.Save','core.button.Close','core.button.Source','core.button.ExportTemplate',
- 'core.button.Submit','core.button.ResSubmit','core.button.Audit','core.button.ResAudit',
- 'core.button.Update','core.button.Delete','core.form.YnField','core.button.DeleteDetail',
- 'core.button.VoucherFlow', 'core.button.CopyAll','core.button.ExportExcelButton','core.button.Print',
- 'core.trigger.DbfindTrigger','core.grid.YnColumn','core.form.YnField', 'core.trigger.CateTreeDbfindTrigger'
- ],
- init:function(){
- var me = this;
- this.control({
- 'erpFormPanel': {
-
- afterload: function(form) {
- Ext.defer(function(){// 非手工做的、有来源的凭证,不能改凭证字
- var lead = Ext.getCmp('vo_lead'), sr = Ext.getCmp('vo_source'),
- sc = Ext.getCmp('vo_sourcecode');
- if(lead && ((sr && !Ext.isEmpty(sr.getValue())) ||
- (sc && !Ext.isEmpty(sc.getValue()))))
- lead.setReadOnly(true);
- }, 200);
- }
- },
- '#vo_id': {
- afterrender: function(f) {
- Ext.defer(function(){
- var id = f.getValue();
- me.getMonth(function(data){
- if (Ext.isEmpty(id) || id == 0) {
- Ext.getCmp('vo_yearmonth').setValue(data.PD_DETNO);
- Ext.getCmp('vo_date').setValue(new Date(data.PD_ENDDATE));
- } else {
- var ym = Ext.getCmp('vo_yearmonth').getValue() || Ext.Date.format(new Date(), 'Ym');
- if(ym < data.PD_DETNO) {
- form.readOnly = true;
- Ext.getCmp('grid').readOnly = true;
- }
- }
- });
- }, 20);
- },
- change: function(f){
- var grid = Ext.getCmp('flowgrid');
- if(grid) {
- if(!Ext.isEmpty(f.value) && f.value != 0){
- grid.getMyData(f.value);
- } else {
- if(grid.columns && grid.columns.length > 2){
- grid.GridUtil.add10EmptyItems(grid);
- } else {
- grid.getMyData(-1);
- }
- }
- }
- var ff = Ext.getCmp('form_disable');
- ff.FormUtil.loadNewStore(ff, {caller: ff.caller, condition: "vo_id=" + f.value});
- }
- },
- 'erpSaveButton': {
- click: function(btn){
- var form = me.getForm(btn);
- if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
- me.BaseUtil.getRandomNumber();//自动添加编号
- }
- //保存之前的一些前台的逻辑判定
- var grid = Ext.getCmp('grid'), items = grid.store.data.items;
- Ext.each(items,function(item,index){
- if(!Ext.isEmpty(item.data['vd_catecode']) || !Ext.isEmpty(item.data['vd_explanation'])){
- if((Ext.isEmpty(item.data['vd_debit']) || item.data['vd_debit'] == 0) && (Ext.isEmpty(item.data['vd_credit']) || item.data['vd_credit'] == 0)){
- showError('明细表第' + item.data['vd_detno'] + '行借、贷方金额均未填写!');
- }
- }
- });
- this.beforeSave();
- }
- },
- //查看来源
- 'erpSourceButton': {
- afterender: function(btn){
- Ext.defer(function(){
- var v = Ext.getCmp('vo_source').value;
- if(v == null || v == ''){
- btn.hide();
- }
- }, 200);
- },
- click: function(){
- var id = Ext.getCmp('vo_id').value;
- if(id != null && id > 0) {
- me.getSource(id);
- }
- }
- },
- 'erpExportExcelButton':{
- afterrender:function(btn){
- //btn.exportCaller="Voucher!DetailAss!Export";
- btn.exportCaller="Voucher!DetailandAss!Export";
- var status = Ext.getCmp('vo_statuscode').value;
- if(status&&status!='ENTERING'){
- btn.hide();
- }
- }
- },
- 'filefield[id=excelfile]':{
- change: function(field){
- warnMsg('确认要重新导入吗?', function(btn){
- if(btn == 'yes'){
- if(contains(field.value, "\\", true)){
- filename = field.value.substring(field.value.lastIndexOf('\\') + 1);
- } else {
- filename = field.value.substring(field.value.lastIndexOf('/') + 1);
- }
- field.ownerCt.getForm().submit({
- url: basePath + 'common/upload.action?em_code=' + em_code,
- waitMsg: "正在解析文件信息",
- success: function(fp,o){
- if(o.result.error){
- showError(o.result.error);
- } else {
- var filePath=o.result.filepath;
- var keyValue=Ext.getCmp('vo_id').getValue();
- Ext.Ajax.request({//拿到form的items
- url : basePath + 'fa/ars/ImportExcel.action',
- params:{
- id:keyValue,
- fileId:filePath
- },
- method : 'post',
- callback : function(options,success,response){
- var result=Ext.decode(response.responseText);
- if(result.success){
- Ext.Msg.alert('提示','导入成功!');
- window.location.reload();
- }else{
- var err = result.exceptionInfo || result.error;
- if(err != null){
- showError(err);
- }
- }
- }
- });
- }
- }
- });
- }
- });
- }
- },
- 'erpVoucherFlowButton': {
- click: function(){
- this.showVoucherFlow();
- }
- },
- 'erpCloseButton': {
- click: function(btn){
- this.FormUtil.beforeClose(this);
- }
- },
- 'erpCopyButton': {
- click: function(btn) {
- this.copy();
- }
- },
- 'erpUpdateButton': {
- click: function(btn){
- var grid = Ext.getCmp('grid'), items = grid.store.data.items;
- Ext.each(items,function(item,index){
- if(!Ext.isEmpty(item.data['vd_catecode']) || !Ext.isEmpty(item.data['vd_explanation'])){
- if((Ext.isEmpty(item.data['vd_debit']) || item.data['vd_debit'] == 0) && (Ext.isEmpty(item.data['vd_credit']) || item.data['vd_credit'] == 0)){
- showError('明细表第' + item.data['vd_detno'] + '行借、贷方金额均未填写!');
- }
- }
- });
- this.beforeUpdate();
- }
- },
- 'erpPrintButton': {
- click: function(btn) {
- var reportName = '';
- reportName = "vouclist_rmb";
- var condition = '{Voucher.vo_id}=' + Ext.getCmp('vo_id').value + '';
- var id = Ext.getCmp('vo_id').value;
- me.FormUtil.onwindowsPrint(id, reportName, condition);
- }
- },
- 'erpDeleteButton': {
- afterrender: function(btn){
- Ext.defer(function(){
- var source = Ext.getCmp('vo_source'),
- sourceCode = Ext.getCmp('vo_sourcecode');
- if((source && source.value) || (sourceCode && sourceCode.value)){
- btn.hide();
- }
- }, 200);
- },
- click: function(btn){
- me.FormUtil.onDelete(Ext.getCmp('vo_id').value);
- }
- },
- 'erpAddButton': {
- click: function(){
- var tab = me.FormUtil.getActiveTab();
- me.FormUtil.onAdd(null, '新增凭证资料', 'jsps/fa/ars/voucher.jsp');
- setTimeout(function(){
- if(tab) {
- tab.close();
- }
- }, 200);
- }
- },
- 'erpSubmitButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('vo_statuscode');
- if(status && status.value != 'ENTERING'){
- btn.hide();
- }
- },
- click: function(btn){
- var grid = Ext.getCmp('grid'), items = grid.store.data.items;
- Ext.each(items,function(item,index){
- if(!Ext.isEmpty(item.data['vd_catecode']) || !Ext.isEmpty(item.data['vd_explanation'])){
- if((Ext.isEmpty(item.data['vd_debit']) || item.data['vd_debit'] == 0) && (Ext.isEmpty(item.data['vd_credit']) || item.data['vd_credit'] == 0)){
- showError('明细表第' + item.data['vd_detno'] + '行借、贷方金额均未填写!');
- return;
- }
- }
- });
- me.FormUtil.onSubmit(Ext.getCmp('vo_id').value);
- }
- },
- 'erpResSubmitButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('vo_statuscode');
- if(status && status.value != 'COMMITED'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onResSubmit(Ext.getCmp('vo_id').value);
- }
- },
- 'erpAuditButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('vo_statuscode');
- if(status && status.value != 'COMMITED'){
- btn.hide();
- }
- },
- click: function(btn){
- var grid = Ext.getCmp('grid'), items = grid.store.data.items;
- Ext.each(items,function(item,index){
- if(!Ext.isEmpty(item.data['vd_catecode']) || !Ext.isEmpty(item.data['vd_explanation'])){
- if((Ext.isEmpty(item.data['vd_debit']) || item.data['vd_debit'] == 0) && (Ext.isEmpty(item.data['vd_credit']) || item.data['vd_credit'] == 0)){
- showError('明细表第' + item.data['vd_detno'] + '行借、贷方金额均未填写!');
- return;
- }
- }
- });
- me.FormUtil.onAudit(Ext.getCmp('vo_id').value);
- }
- },
- 'erpResAuditButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('vo_statuscode');
- if(status && status.value != 'AUDITED'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onResAudit(Ext.getCmp('vo_id').value);
- }
- },
- 'field[name=vo_errstring]': {
- afterrender: function(f){
- if(f.value != null && f.value != ''){
- f.inputEl.setStyle({color: 'OrangeRed'});
- } else {
- f.setValue('正常');
- f.inputEl.setStyle({color: '#B6E2FF'});
- f.originalValue = f.value;
- }
- },
- change: function(f){
- if(f.value != null && f.value != ''){
- f.inputEl.setStyle({color: 'OrangeRed'});
- } else {
- f.setValue('正常');
- f.inputEl.setStyle({color: '#B6E2FF'});
- f.originalValue = f.value;
- }
- }
- },
- 'field[name=vo_date]': {
- change: function(f){
- if(f.value == null){
- f.setValue(new Date());
- }
- }
- },
- 'field[name=vo_yearmonth]': {
- afterrender: function(f){
- if(f.value == null || f.value == 0){
- f.setValue(Ext.Date.format(new Date(), 'Ym'));
- }
- }
- },
- 'erpDeleteDetailButton': {
- afterrender: function(btn){
- //将当前行的 借方/贷方 以及外币借方/外币贷方 互换
- btn.ownerCt.add({
- text: '借贷调换',
- width: 85,
- disabled: true,
- cls: 'x-btn-gray',
- id: 'replace'
- });
- //当前行的借方 = 其它行的贷方总额-其它行的借方总额
- btn.ownerCt.add({
- text: '找平',
- width: 65,
- disabled: true,
- cls: 'x-btn-gray',
- id: 'level'
- });
- },
- afterdelete: function(d, r, btn){
- //更新凭证状态
- Ext.Ajax.request({
- url: basePath + 'fa/ars/validVoucher.action',
- params: {
- id: d.vd_void
- },
- callback: function(opt, s, r){
- var res = Ext.decode(r.responseText);
- if(res.success) {
- var f = Ext.getCmp('vo_errstring');
- f.setValue((res.errstring || ''));
- f.dirty = false;
- f.originalValue = f.value;
- }
- }
- });
- }
- },
- 'ExportExcelButton':{
- afterrender:function(btn){
- btn.caller='Voucher!DetailAss!Export';
- }
-
- },
- 'erpGridPanel2': {
- afterrender: function(grid){
- grid.plugins[0].on('beforeedit', function(args) {
- var iscashflow = Ext.getCmp('vo_iscashflow');
- if(iscashflow && iscashflow.value != 0){
- if (args.field == "vd_flowcode") {
- var bool = false;
- if (args.record.get('ca_cashflow') == 0){
- bool = true;
- }
- }
- return bool;
- } else {
- if (args.field == "vd_flowcode") {
- return false;
- }
- }
- if (args.field == "vd_debit") {
- var bool = true;
- if (args.record.get('vd_credit') != null && args.record.get('vd_credit') > 0){
- bool = false;
- }
- if (args.record.get('vd_doublecredit') != null && args.record.get('vd_doublecredit') > 0){
- bool = false;
- }
- return bool;
- }
- if (args.field == "vd_credit") {
- var bool = true;
- if (args.record.get('vd_debit') != null && args.record.get('vd_debit') > 0){
- bool = false;
- }
- if (args.record.get('vd_doubledebit') != null && args.record.get('vd_doubledebit') > 0){
- bool = false;
- }
- return bool;
- }
- if (args.field == "vd_doubledebit") {
- var bool = true;
- if (args.record.get('vd_doublecredit') != null && args.record.get('vd_doublecredit') > 0){
- bool = false;
- }
- if (args.record.get('vd_credit') != null && args.record.get('vd_credit') > 0){
- bool = false;
- }
- return bool;
- }
- if (args.field == "vd_doublecredit") {
- var bool = true;
- if (args.record.get('vd_doubledebit') != null && args.record.get('vd_doubledebit') > 0){
- bool = false;
- }
- if (args.record.get('vd_debit') != null && args.record.get('vd_debit') > 0){
- bool = false;
- }
- return bool;
- }
- });
- var f = Ext.getCmp('vo_currencytype');
- if(f) {
- Ext.defer( function(){
- me.changeCurrencyType(f);
- },200);
- }
- Ext.defer(function(){
- Ext.EventManager.addListener(document.body, 'keydown', function(e){
- if(e.getKey() == 187 && ['vd_debit', 'vd_credit'].indexOf(e.target.name) > -1) {
- me.levelOut(e.target);
- }
- });
- }, 200);
- },
- /*storeloaded: function(grid){
- var f = Ext.getCmp('vo_currencytype');
- if(f) {
- me.changeCurrencyType(f);
- }
- },*/
- itemclick: function(selModel, record){
- var grid = selModel.ownerCt;
- if(!grid.readOnly) {
- this.GridUtil.onGridItemClick(selModel, record);
- var btn = Ext.getCmp('replace');
- btn.setDisabled(false);
- btn = Ext.getCmp('level');
- btn.setDisabled(false);
- }
- }
- },
- 'voucherflowgrid': {
- itemclick: function(selModel, record){
- var grid = Ext.getCmp('flowgrid');
- var index = record.data[grid.detno];
- if(index == grid.store.data.items[grid.store.data.items.length-1].index + 1){
- me.GridUtil.add10EmptyItems(grid);
- }
- }
- },
- 'field[name=vo_currencytype]': {
- change: function(c){
- me.changeCurrencyType(c);
- }
- },
- /**
- * 借调互换
- */
- 'button[id=replace]': {
- click: function(btn){
- var grid = btn.ownerCt.ownerCt;
- var record = grid.selModel.lastSelected;
- if(record){
- var v1 = record.data['vd_debit'];//借方
- var v2 = record.data['vd_credit'];//贷方
- var v3 = record.data['vd_doubledebit'];//原币借方
- var v4 = record.data['vd_doublecredit'];//原币贷方
- record.set('vd_debit', v2);
- record.set('vd_credit', v1);
- record.set('vd_doubledebit', v4);
- record.set('vd_doublecredit', v3);
- }
- }
- },
- /**
- * 找平
- */
- 'button[id=level]': {
- click: me.levelOut
- },
- 'field[name=vd_doubledebit]': {//原币借方
- focus : function(f) {
- var grid = Ext.getCmp('grid'),
- record = grid.selModel.lastSelected,
- val = record.get('vd_doublecredit');
- if( val != 0 ) {
- f.setReadOnly(true);
- } else {
- f.setReadOnly(false);
- }
- },
- change: function(f){
- if(!f.ownerCt && f.value != null && f.value != 0 ){
- var grid = Ext.getCmp('grid');
- var record = grid.selModel.lastSelected,
- rate = record.data['vd_rate'];
- if(rate != null && rate > 0){
- var val = me.BaseUtil.numberFormat(me.BaseUtil.multiply(f.value, rate), 2);
- if(record.data['vd_debit'] != val) {
- record.set('vd_debit', val);//本币
- }
- }
- }
- }
- },
- 'field[name=vd_doublecredit]': {//原币贷方
- focus : function(f) {
- var grid = Ext.getCmp('grid'),
- record = grid.selModel.lastSelected,
- val = record.get('vd_doubledebit');
- if( val != 0 ) {
- f.setReadOnly(true);
- } else {
- f.setReadOnly(false);
- }
- },
- change: function(f){
- if(!f.ownerCt && f.value != null && f.value != 0 ){
- var record = Ext.getCmp('grid').selModel.lastSelected,
- rate = record.data['vd_rate'];
- if(rate != null && rate > 0){
- var val = me.BaseUtil.numberFormat(me.BaseUtil.multiply(f.value, rate), 2);
- if(record.data['vd_credit'] != val) {
- record.set('vd_credit', val);//本币
- }
- }
- }
- }
- },
- 'field[name=vd_currency]': {
- afterrender: function(f){
- f.mappingKey = 'cm_yearmonth';
- f.dbKey = 'vo_yearmonth';
- },
- aftertrigger: function(f){
- if(f.value != null && f.value != '' ){
- var record = Ext.getCmp('grid').selModel.lastSelected;
- if(record.data['vd_rate'] != null && record.data['vd_rate'] > 0){
- if(record.data['vd_doubledebit'] != null){
- record.set('vd_debit',
- me.BaseUtil.numberFormat(me.BaseUtil.multiply(record.get('vd_doubledebit'), record.get('vd_rate')), 2));//原币计算本币
- }
- if(record.data['vd_doublecredit'] != null){
- record.set('vd_credit',
- me.BaseUtil.numberFormat(me.BaseUtil.multiply(record.get('vd_doublecredit'), record.get('vd_rate')), 2));//原币计算本币
- }
- }
- }
- }
- },
- 'field[name=vd_explanation]': {
- specialkey: function(f, e){//按ENTER自动把摘要复制到下一行
- if (e.getKey() == e.ENTER) {
- if(f.value != null && f.value != '' ){
- var grid = Ext.getCmp('grid'),
- record = grid.selModel.lastSelected,
- idx = grid.store.indexOf(record),
- next = grid.store.getAt(idx + 1);
- if(next) {
- var v = next.get('vd_explanation');
- if(Ext.isEmpty(v))
- next.set('vd_explanation', f.value);
- }
- }
- }
- },
- change: function(f) {
- if(f.value == '=') {
- var grid = Ext.getCmp('grid'),
- record = grid.selModel.lastSelected,
- idx = grid.store.indexOf(record),
- prev = grid.store.getAt(idx - 1);
- if(prev) {
- var v = prev.get('vd_explanation');
- if(!Ext.isEmpty(v))
- f.setValue(v);
- }
- }
- }
- },
- 'field[name=vd_debit]': {
- focus : function(f) {
- var grid = Ext.getCmp('grid'),
- record = grid.selModel.lastSelected,
- val = record.get('vd_credit');
- if( val != 0 ) {
- f.setReadOnly(true);
- } else {
- f.setReadOnly(false);
- }
- },
- specialkey: function(f, e){//按ENTER自动把摘要复制到下一行
- if (e.getKey() == e.ENTER) {
- var grid = Ext.getCmp('grid'),
- record = grid.selModel.lastSelected,
- val = record.get('vd_explanation'),
- idx = grid.store.indexOf(record),
- next = grid.store.getAt(idx + 1);
- if(!Ext.isEmpty(val)) {
- if(next) {
- var v = next.get('vd_explanation');
- if(Ext.isEmpty(v))
- next.set('vd_explanation', val);
- }
- }
- }
- }
- },
- 'field[name=vd_credit]': {
- focus : function(f) {
- var grid = Ext.getCmp('grid'),
- record = grid.selModel.lastSelected,
- val = record.get('vd_debit');
- if( val != 0 ) {
- f.setReadOnly(true);
- } else {
- f.setReadOnly(false);
- }
- },
- specialkey: function(f, e){//按ENTER自动把摘要复制到下一行
- console.log(e);
- if (e.getKey() == e.ENTER) {
- var grid = Ext.getCmp('grid'),
- record = grid.selModel.lastSelected,
- val = record.get('vd_explanation'),
- idx = grid.store.indexOf(record),
- next = grid.store.getAt(idx + 1);
- if(!Ext.isEmpty(val)) {
- if(next) {
- var v = next.get('vd_explanation');
- if(Ext.isEmpty(v))
- next.set('vd_explanation', val);
- }
- }
- }
- }
- },
- 'dbfindtrigger[name=vd_catecode]': {
- aftertrigger: function(f){
- var grid = Ext.getCmp('grid'),
- record = grid.selModel.lastSelected;
- var type = record.get('ca_assname'), ass = record.get('ass') || [];
- if(!Ext.isEmpty(type)){
- var oldType = Ext.Array.concate(ass, '#', 'vds_asstype');
- if(type != oldType) {
- var idx = me.getRecordIndex(grid, record), dd = [];
- Ext.Array.each(type.split('#'), function(t){
- dd.push({
- vds_vdid: idx,
- vds_asstype: t
- });
- });
- record.set('ass', dd);
- var view = grid.view, idx = grid.store.indexOf(record), rowNode = view.getNode(idx),
- expander = grid.plugins[2], row = Ext.fly(rowNode, '_rowExpander'),
- isCollapsed = row.hasCls(expander.rowCollapsedCls);
- if(isCollapsed)
- expander.toggleRow(idx, record);
- }
- } else
- record.set('ass', null);
- }
- },
- 'cateTreeDbfindTrigger[name=vd_catecode]': {
- aftertrigger: function(f, d){
- var grid = Ext.getCmp('grid'),
- record = grid.selModel.lastSelected;
- var type = record.get('ca_assname'), ass = record.get('ass') || [];
- if(!Ext.isEmpty(type)){
- var oldType = Ext.Array.concate(ass, '#', 'vds_asstype');
- if(type != oldType) {
- var idx = me.getRecordIndex(grid, record), dd = [];
- Ext.Array.each(type.split('#'), function(t){
- dd.push({
- vds_vdid: idx,
- vds_asstype: t
- });
- });
- record.set('ass', dd);
- }
- } else
- record.set('ass', null);
- },
- afterrender: function(f){
- f.onTriggerClick = function(){
- me.showCateTree(f);
- };
- }
- },
- /**
- * 导入凭证模板
- */
- 'erpExportTemplateButton': {
- click: function() {
- me.showTp();
- }
- },
- /**
- * 添加到模板
- */
- 'erpCreateTemplateButton': {
- click: function() {
- me.createTp();
- }
- }
- });
- },
- getForm: function(btn){
- return btn.ownerCt.ownerCt;
- },
- getRecordIndex: function(grid, record) {
- var me = this, id = record.get(grid.keyField);
- if(!id || id == 0) {
- me.rowCounter = me.rowCounter || 0;
- id = --me.rowCounter;
- record.set(grid.keyField, id);
- }
- return id;
- },
- changeCurrencyType: function(c){
- var grid = Ext.getCmp('grid');
- if(grid) {
- var cols = grid.headerCt.getGridColumns();
- if(c.checked){
- Ext.each(cols, function(cn){
- if(cn.dataIndex == 'vd_doubledebit' || cn.dataIndex == 'vd_doublecredit'){
- cn.width = 110;
- cn.setVisible(true);
- }
- if(cn.dataIndex == 'vd_currency' || cn.dataIndex == 'vd_rate'){
- cn.width = 60;
- cn.setVisible(true);
- }
- if(cn.dataIndex == 'vd_debit'){
- cn.setText('本币借方');
- }
- if(cn.dataIndex == 'vd_credit'){
- cn.setText('本币贷方');
- }
- });
- } else {
- Ext.each(cols, function(cn){
- if(cn.dataIndex == 'vd_currency' || cn.dataIndex == 'vd_rate'
- || cn.dataIndex == 'vd_doubledebit' || cn.dataIndex == 'vd_doublecredit'){
- cn.setVisible(false);
- }
- if(cn.dataIndex == 'vd_debit'){
- cn.setText('借方');
- }
- if(cn.dataIndex == 'vd_credit'){
- cn.setText('贷方');
- }
- });
- }
- }
- },
- beforeSave: function(){
- var me = this;
- var form = Ext.getCmp('form'), id = Ext.getCmp(form.keyField).value;
- if(! me.FormUtil.checkForm()){
- return;
- }
- if(Ext.isEmpty(id) || id == 0 || id == '0'){
- me.FormUtil.getSeqId(form);
- }
- var detail = Ext.getCmp('grid');
- var flow = Ext.getCmp('flowgrid');
- var ass = [];
- detail.store.each(function(record){
- if(record.get('ca_assname')) {
- var s = record.get('ass') || [];
- Ext.Array.each(s, function(t, i){
- t.vds_id = t.vds_id || 0;
- t.vds_detno = i + 1;
- t.vds_vdid = String(t.vds_vdid);
- ass.push(t);
- });
- }
- });
- var param2 = new Array();
- if(flow) {
- param2 = me.GridUtil.getGridStore(flow);
- }
- var param3 = Ext.encode(ass);
- Ext.each(detail.store.data.items, function(item, idx){
- if(item.data.vd_id == null || item.data.vd_id == 0){
- item.data.vd_id = -idx;
- }
- });
- var param1 = me.GridUtil.getGridStore(detail);
- if(detail.necessaryField.length > 0 && (param1.length == 0)){
- showError($I18N.common.grid.emptyDetail);
- return;
- }
- var ex = new Array(),d;
- Ext.each(param1, function(){//摘要未填写
- d = Ext.decode(this);
- if(Ext.isEmpty(d.vd_explanation)) {
- ex.push(d.vd_detno);
- }
- });
- if(ex.length > 0) {
- warnMsg("摘要未填写,序号:" + ex.join(',') + " 是否继续保存?", function(btn){
- if(btn == 'yes') {
- me.onSave(form, param1, param2, param3);;
- }
- });
- } else {
- me.onSave(form, param1, param2, param3);
- }
- },
- onSave: function(form, param1, param2, param3) {
- var me = this;
- param1 = param1 == null ? [] : "[" + param1.toString().replace(/\\/g,"%") + "]";
- param2 = param2 == null ? [] : "[" + param2.toString().replace(/\\/g,"%") + "]";
- param3 = param3 == null ? [] : param3.toString().replace(/\\/g,"%");
- if(form.getForm().isValid()){
- Ext.each(form.items.items, function(item){
- if(item.xtype == 'numberfield'){
- if(item.value == null || item.value == ''){
- item.setValue(0);
- }
- }
- });
- var r = form.getValues();
- r.vo_currencytype = Ext.getCmp('vo_currencytype').value ? -1 : 0;
- r.vo_errstring = r.vo_errstring == '正常' ? '' : r.vo_errstring;
- me.FormUtil.save(r, param1, param2, param3);
- }else{
- me.FormUtil.checkForm();
- }
- },
- beforeUpdate: function(){
- var me = this;
- var form = Ext.getCmp('form');
- if(! me.FormUtil.checkForm()){
- return;
- }
- if(Ext.getCmp(form.keyField).value == null || Ext.getCmp(form.keyField).value == ''){
- me.FormUtil.getSeqId(form);
- }
- var detail = Ext.getCmp('grid');
- var flow = Ext.getCmp('flowgrid');
- var param1 = me.GridUtil.getGridStore(detail);
- var param2 = new Array();
- if(flow) {
- param2 = me.GridUtil.getGridStore(flow);
- }
- var ass = [];
- detail.store.each(function(record){
- if(record.get('ca_assname')) {
- var s = record.get('ass') || [];
- Ext.Array.each(s, function(t, i){
- t.vds_id = t.vds_id || 0;
- t.vds_detno = i + 1;
- t.vds_vdid = String(t.vds_vdid);
- ass.push(t);
- });
- }
- });
- var param3 = Ext.encode(ass);
- if(me.FormUtil.checkFormDirty(form) == '' && detail.necessaryField.length > 0 && (param1.length == 0) &&
- (!flow || (flow.necessaryField.length > 0 && (param2.length == 0)))
- && (param3.length <= 2)){
- showError($I18N.common.grid.emptyDetail);
- return;
- }
- // 摘要未填写判断
- var ex = new Array(),d;
- Ext.each(param1, function(){
- d = Ext.decode(this);
- if(Ext.isEmpty(d.vd_explanation)) {
- ex.push(d.vd_detno);
- }
- });
- if(ex.length > 0) {
- warnMsg("摘要未填写,序号:" + ex.join(',') + " 是否继续保存?", function(btn){
- if(btn == 'yes') {
- me.onUpdate(form, param1, param2, param3);;
- }
- });
- } else {
- me.onUpdate(form, param1, param2, param3);
- }
- },
- onUpdate: function(form, param1, param2, param3) {
- var me = this;
- param1 = param1 == null ? [] : "[" + param1.toString().replace(/\\/g,"%") + "]";
- param2 = param2 == null ? [] : "[" + param2.toString().replace(/\\/g,"%") + "]";
- param3 = param3 == null ? [] : param3.toString().replace(/\\/g,"%");
- if(form.getForm().isValid()){
- Ext.each(form.items.items, function(item){
- if(item.xtype == 'numberfield'){
- if(item.value == null || item.value == ''){
- item.setValue(0);
- }
- }
- });
- var r = form.getValues();
- r.vo_currencytype = Ext.getCmp('vo_currencytype').value ? -1 : 0;
- r.vo_errstring = r.vo_errstring == '正常' ? '' : r.vo_errstring;
- me.FormUtil.update(r, param1, param2, param3);
- }else{
- me.FormUtil.checkForm();
- }
- },
- showVoucherFlow: function(){
- var win = Ext.getCmp('flow_win');
- var voucherid = Ext.getCmp('vo_id').value;
- if(!win) {
- Ext.create('Ext.Window', {
- id: 'flow_win',
- height: "100%",
- width: "80%",
- iconCls: 'x-button-icon-set',
- closeAction: 'hide',
- autoShow: true,
- title: '现金流',
- maximizable : true,
- layout : 'anchor',
- items: [{
- anchor: '100% 100%',
- xtype: 'voucherflowgrid',
- listeners: {
- afterrender: function(grid){
- if(formCondition == null || formCondition.toString().trim() == ''){
- grid.getMyData(-1);
- } else {
- grid.getMyData(voucherid);
- }
- }
- }
- }],
- buttonAlign: 'center',
- buttons: [{
- text: $I18N.common.button.erpConfirmButton,
- iconCls: 'x-button-icon-save',
- cls: 'x-btn-gray',
- handler: function(btn){
- btn.ownerCt.ownerCt.close();
- }
- }]
- });
- } else {
- win.show();
- }
- },
- /**
- * 复制凭证
- */
- copy: function(){
- var form = Ext.getCmp('form');
- var v = form.down('#vo_id').value;
- if(v > 0) {
- form.setLoading(true);
- Ext.Ajax.request({
- url: basePath + 'fa/ars/copyVoucher.action',
- params: {
- id: v
- },
- callback: function(opt, s, r){
- form.setLoading(false);
- var res = Ext.decode(r.responseText);
- if(res.voucher) {
- showMessage('提示', '复制成功!<a href="javascript:openUrl(\'jsps/fa/ars/voucher.jsp?formCondition=vo_idIS' +
- + res.voucher.vo_id + '&gridCondition=vd_voidIS' + res.voucher.vo_id +
- '\')">\n凭证号:<' + res.voucher.vo_number +
- '>\n流水号:<' + res.voucher.vo_code + '></a>');
- } else {
- showError(res.exceptionInfo);
- }
- }
- });
- }
- },
- getSource: function(id) {
- var me = this;
- Ext.Ajax.request({
- url : basePath + 'common/getFieldsData.action',
- params: {
- caller: 'VoucherBill',
- fields: 'vb_billcode,vb_vscode',
- condition: 'vb_void=' + id
- },
- method : 'post',
- callback : function(options,success,response){
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);
- } else if(localJson.success){
- if(localJson.data != null && localJson.data.vb_vscode != null){
- me.showSourceList(localJson.data.vb_vscode, localJson.data.vb_billcode);
- } else {
- showMessage('提示', '当前凭证没有来源信息!');
- }
- }
- }
- });
- },
- showSourceList: function(vscode, pri) {
- var me = this, cls = Ext.getCmp('vo_source').value,
- cfg = me.getSourceConfig(vscode, cls),
- merge = pri.indexOf(',') > 0 || /SELECT.*FROM.*/.test(pri.toUpperCase());
- Ext.Ajax.request({
- url : basePath + 'common/getFieldsData.action',
- params: {
- caller: 'VoucherStyle',
- fields: 'vs_datalist,vs_prikey1,vs_pritable,vs_classfield',
- condition: 'vs_code=\'' + vscode + '\''
- },
- method : 'post',
- callback : function(opt, s, res){
- var r = new Ext.decode(res.responseText);
- if (r.exceptionInfo) {
- showError(r.exceptionInfo);
- } else if(r.success) {
- if (r.data != null) {
- if (merge || !cfg.url) {
- if(r.data.vs_datalist)
- me.showSourceGrid(vscode, r.data.vs_datalist, r.data.vs_prikey1,
- r.data.vs_pritable, r.data.vs_classfield, cls, pri, cfg);
- else
- showError('凭证公式未配置列表参数,无法显示来源!');
- } else
- me.linkSource(vscode, r.data.vs_prikey1, r.data.vs_pritable,
- r.data.vs_classfield, cls, pri, cfg);
- } else {
- showMessage('提示', '当前凭证没有来源信息!', 3000);
- }
- }
- }
- });
- },
- linkSource : function(vscode, key, tab, clsfield, cls, pri, cfg) {
- var me = this, url = cfg.url, k = cfg.keyfield, m = cfg.mainfield;
- if (url) {
- Ext.Ajax.request({
- url : basePath + 'common/getFieldData.action',
- async: false,
- params: {
- caller: tab,
- field: k,
- condition: key + '=' + pri + (clsfield ? (' and ' + clsfield + '=\'' + cls + '\'') : '')
- },
- method : 'post',
- callback : function(opt, s, res){
- var r = new Ext.decode(res.responseText);
- if(r.exceptionInfo){
- showError(r.exceptionInfo);
- } else if(r.success && r.data){
- url += url.indexOf('?') > 0 ? '&' : '?';
- me.FormUtil.onAdd(null, '来源', url + 'formCondition=' + k + 'IS' +
- r.data + '&gridCondition=' + m + 'IS' + r.data);
- }
- }
- });
- }
- },
- showSourceGrid : function(vscode, cal, key, tab, clsfield, cls, pri, cfg) {
- var me = this,
- condition = key + ' in (' + pri + ')';
- if('PRODINOUT' == vscode) {
- condition += ' and pi_class=\'' + cls + '\'';
- }
- var w = Ext.isIE ? 800 : '80%',
- h = Ext.isIE ? 500 : '100%';
- var win = Ext.create('Ext.Window', {
- width: w,
- height: h,
- title: '凭证来源',
- layout: 'anchor',
- items: [],
- buttonAlign: 'center',
- buttons: [{
- text: $I18N.common.button.erpExportButton,
- cls: 'x-btn-gray',
- iconCls: 'x-button-icon-ecel',
- handler: function(btn) {
- me.BaseUtil.exportGrid(btn.ownerCt.ownerCt.down('grid'));
- btn.ownerCt.ownerCt.close();
- }
- },{
- text: $I18N.common.button.erpCloseButton,
- cls: 'x-btn-gray',
- iconCls: 'x-button-icon-close',
- handler: function(btn) {
- btn.ownerCt.ownerCt.close();
- }
- }]
- }).show();
- var grid = Ext.create('Ext.grid.Panel', {
- anchor: '100% 100%',
- columnLines: true,
- columns: [],
- store: []
- });
- win.add(grid);
- me.GridUtil.getGridColumnsAndStore(grid, 'common/singleGridPanel.action', {caller: cal, condition: condition});
- grid.on('itemclick', function(s, r){
- me.linkSource(vscode, key, tab, clsfield, cls, "\'" + r.get(key) + "\'", cfg);
- });
- },
- getSourceConfig : function(vscode, vdclass) {
- var url = null, keyfield = null, mainfield = null;
- if(vscode == 'RecBalance') {
- keyfield = 'rb_id';
- mainfield = 'rbd_rbid';
- switch (vdclass) {
- case '应收冲应付':
- url = 'jsps/fa/ars/recBalanceAP.jsp?whoami=RecBalance!RRCW';
- break;
- case '收款单':
- url = 'jsps/fa/ars/recBalance.jsp?whoami=RecBalance!PBIL';
- break;
- case '冲应收款':
- url = 'jsps/fa/ars/recBalance.jsp?whoami=RecBalance!IMRE';
- break;
- case '预收冲应收':
- url = 'jsps/fa/ars/recBalancePRDetail.jsp?whoami=RecBalance!PTAR';
- break;
- case '应收票据':
- url = 'jsps/fa/gs/billAR.jsp';
- break;
- case '应收款转销':
- url = 'jsps/fa/ars/recBalance.jsp?whoami=RecBalance!ARRM';
- break;
- case '应收退款单':
- url = 'jsps/fa/ars/recBalanceTK.jsp?whoami=RecBalance!TK';
- break;
- }
- } else if(vscode == 'PreRec') {
- keyfield = 'pr_id';
- mainfield = 'prd_prid';
- switch (vdclass) {
- case '预收款':
- url = 'jsps/fa/ars/preRec.jsp?whoami=PreRec!Ars!DERE';
- break;
- case '预收退款':
- url = 'jsps/fa/ars/preRec.jsp?whoami=PreRec!Ars!DEPR';
- break;
- case '预收退款单':
- url = 'jsps/fa/ars/preRec.jsp?whoami=PreRec!Ars!DEPR';
- break;
- }
- } else if(vscode == 'PrePay') {
- keyfield = 'pp_id';
- mainfield = 'ppd_ppid';
- switch (vdclass) {
- case '预付款':
- url = 'jsps/fa/arp/prepay.jsp?whoami=PrePay!Arp!PAMT';
- break;
- case '预付退款':
- url = 'jsps/fa/arp/prepay.jsp?whoami=PrePay!Arp!PAPR';
- break;
- case '预付退款单':
- url = 'jsps/fa/arp/prepay.jsp?whoami=PrePay!Arp!PAPR';
- break;
- }
- } else if(vscode == 'PrePaid') {
- keyfield = 'pp_id';
- mainfield = 'pd_ppid';
- switch (vdclass) {
- case '摊销':
- url = 'jsps/fa/gla/prePaid.jsp';
- break;
- }
- } else if(vscode == 'PurcFee') {
- keyfield = 'pi_id';
- mainfield = 'pd_piid';
- switch (vdclass) {
- case '采购验收单':
- url = 'jsps/scm/reserve/prodinout.jsp?whoami=ProdInOut!PurcCheckin';
- break;
- case '采购验退单':
- url = 'jsps/scm/reserve/prodinout.jsp?whoami=ProdInOut!PurcCheckout';
- break;
- }
- } else if(vscode == 'PayBalance') {
- keyfield = 'pb_id';
- mainfield = 'pbd_pbid';
- switch (vdclass) {
- case '冲应付款':
- url = 'jsps/fa/arp/paybalance.jsp?whoami=PayBalance!CAID';
- break;
- case '应付款转销':
- url = 'jsps/fa/arp/paybalance.jsp?whoami=PayBalance!APRM';
- break;
- case '预付冲应付':
- url = 'jsps/fa/arp/payBalancePRDetail.jsp?whoami=PayBalance!Arp!PADW';
- break;
- case '付款单':
- url = 'jsps/fa/arp/paybalance.jsp?whoami=PayBalance';
- break;
- case '应付冲应收':
- url = 'jsps/fa/arp/paybalance.jsp?whoami=PayBalance!DWRC';
- break;
- case '应付退款单':
- url = 'jsps/fa/arp/paybalanceTK.jsp?whoami=PayBalance!TK';
- break;
- }
- } else if(vscode == 'AccountRegiste') {
- keyfield = 'ar_id';
- mainfield = 'ard_arid';
- url = 'jsps/fa/gs/accountRegister.jsp?whoami=AccountRegister!Bank';
- } else if(vscode == 'Estimate') {
- keyfield = 'es_id';
- mainfield = 'esd_esid';
- url = 'jsps/fa/arp/estimate.jsp?whoami=Estimate';
- } else if(vscode == 'GoodsSend') {
- keyfield = 'gs_id';
- mainfield = 'gsd_gsid';
- url = 'jsps/fa/ars/goodsSend.jsp?whoami=GoodsSendGs';
- } else if(vscode == 'ARBill') {
- keyfield = 'ab_id';
- mainfield = 'abd_abid';
- switch (vdclass) {
- case '其它应收单':
- url = 'jsps/fa/ars/arbill.jsp?whoami=ARBill!OTRS';
- break;
- case '应收发票':
- url = 'jsps/fa/ars/arbill.jsp?whoami=ARBill!IRMA';
- break;
- }
- } else if(vscode == 'APBill') {
- keyfield = 'ab_id';
- mainfield = 'abd_abid';
- switch (vdclass) {
- case '其它应付单':
- url = 'jsps/fa/ars/apbill.jsp?whoami=APBill!OTDW';
- break;
- case '应付发票':
- url = 'jsps/fa/ars/apbill.jsp?whoami=APBill!CWIM';
- break;
- }
- } else if(vscode == 'BillOut') {
- keyfield = 'bi_id';
- mainfield = 'ard_biid';
- url = 'jsps/fa/ars/billOut.jsp';
- } else if(vscode == 'BillOutAP') {
- keyfield = 'bi_id';
- mainfield = 'ard_biid';
- url = 'jsps/fa/arp/billOutAP.jsp';
- } else if(vscode == 'AssetsCard') {
- keyfield = 'ac_id';
- url = 'jsps/fa/fix/assetsCard.jsp';
- } else if(vscode == 'Depreciation') {
- keyfield = 'de_id';
- mainfield = 'dd_deid';
- switch (vdclass) {
- case '折旧单':
- url = 'jsps/fa/fix/assetsDepreciation.jsp?whoami=AssetsDepreciation';
- break;
- case '资产增加单':
- url = 'jsps/fa/fix/assetsDepreciation.jsp?whoami=AssetsDepreciation!Add';
- break;
- case '资产减少单':
- url = 'jsps/fa/fix/assetsDepreciation.jsp?whoami=AssetsDepreciation!Reduce';
- break;
- }
- } else if(vscode == 'PRODINOUT') {
- keyfield = 'pi_id';
- mainfield = 'pd_piid';
- url = 'jsps/scm/reserve/prodInOut.jsp';
- var call;
- switch (vdclass) {
- case '采购验收单':
- call = 'ProdInOut!PurcCheckin';
- break;
- case '采购验退单':
- call = 'ProdInOut!PurcCheckout';
- break;
- case '出货单':
- call = 'ProdInOut!Sale';
- break;
- case '拨入单':
- call = 'ProdInOut!AppropriationIn';
- break;
- case '销售拨出单':
- call = 'ProdInOut!SaleAppropriationOut';
- break;
- case '销售退货单':
- call = 'ProdInOut!SaleReturn';
- break;
- case '拨出单':
- call = 'ProdInOut!AppropriationOut';
- break;
- case '不良品入库单':
- call = 'ProdInOut!DefectIn';
- break;
- case '不良品出库单':
- call = 'ProdInOut!DefectOut';
- break;
- case '委外领料单':
- call = 'ProdInOut!OutsidePicking';
- break;
- case '委外退料单':
- call = 'ProdInOut!OutsideReturn';
- break;
- case '委外验收单':
- call = 'ProdInOut!OutsideCheckIn';
- break;
- case '委外验退单':
- call = 'ProdInOut!OutesideCheckReturn';
- break;
- case '借货归还单':
- call = 'ProdInOut!OutReturn';
- break;
- case '研发采购验收单':
- call = 'ProdInOut!PurcCheckin!PLM';
- break;
- case '研发采购验退单':
- call = 'ProdInOut!PurcCheckout!PLM';
- break;
- case '换货入库单':
- call = 'ProdInOut!ExchangeIn';
- break;
- case '换货出库单':
- call = 'ProdInOut!ExchangeOut';
- break;
- case '生产补料单':
- call = 'ProdInOut!Make!Give';
- break;
- case '完工入库单':
- call = 'ProdInOut!Make!In';
- break;
- case '生产退料单':
- call = 'ProdInOut!Make!Return';
- break;
- case '生产报废单':
- call = 'ProdInOut!Make!Useless';
- break;
- case '无订单出货单':
- call = 'ProdInOut!NoSale';
- break;
- case '委外补料单':
- call = 'ProdInOut!OSMake!Give';
- break;
- case '其它入库单':
- call = 'ProdInOut!OtherIn';
- break;
- case '其它出库单':
- call = 'ProdInOut!OtherOut';
- break;
- case '其它采购入库单':
- call = 'ProdInOut!OtherPurcIn';
- break;
- case '其它采购出库单':
- call = 'ProdInOut!OtherPurcOut';
- break;
- case '拆件入库单':
- call = 'ProdInOut!PartitionStockIn';
- break;
- case '生产领料单':
- call = 'ProdInOut!Picking';
- break;
- case '库存初始化':
- call = 'ProdInOut!ReserveInitialize';
- break;
- case '借货出货单':
- call = 'ProdInOut!SaleBorrow';
- break;
- case '销售拨入单':
- call = 'ProdInOut!SaleAppropriationIn';
- break;
- case '盘亏调整单':
- call = 'ProdInOut!StockLoss';
- break;
- case '盘盈调整单':
- call = 'ProdInOut!StockProfit';
- break;
- case '报废单':
- call = 'ProdInOut!StockScrap';
- break;
- case '研发退料单':
- call = 'ProdInOut!YFIN';
- break;
- case '研发领料单':
- call = 'ProdInOut!YFOUT';
- break;
- case '成本调整单':
- call = 'ProdInOut!CostChange';
- break;
- }
- call && (url += '?whoami=' + call);
- } else if(vscode == 'BillAR') {
- url = 'jsps/fa/gs/billAR.jsp';
- keyfield = 'bar_id';
- } else if(vscode == 'BillAP') {
- url = 'jsps/fa/gs/billAP.jsp';
- keyfield = 'bap_id';
- } else if(vscode == 'BillARChange') {
- url = 'jsps/fa/gs/billARChange.jsp';
- keyfield = 'brc_id';
- mainfield = 'brd_brcid';
- } else if(vscode == 'BillAPChange') {
- url = 'jsps/fa/gs/billAPChange.jsp';
- keyfield = 'bpc_id';
- mainfield = 'bpd_bpcid';
- }
- return {url : url, keyfield : keyfield, mainfield : mainfield};
- },
- levelOut:function (target){
- var grid = Ext.getCmp('grid'), me = this;
- var record = grid.selModel.lastSelected;
- if(record){
- var f = Ext.getCmp('vo_currencytype');
- var debit = 0;
- var credit = 0;
- var rate = record.get('vd_rate');
- rate = rate == 0 ? 1 : rate;
- grid.getStore().each(function(item){
- if(item.id != record.id){
- debit += item.get('vd_debit');
- credit += item.get('vd_credit');
- }
- });
- var targetName = target.name;
- if(record.get('vd_debit') != 0)
- targetName = 'vd_debit';
- else if(record.get('vd_credit') != 0)
- targetName = 'vd_credit';
- if(targetName && typeof targetName == 'string') {
- if(targetName == 'vd_debit') {
- debit = credit - debit;
- record.set('vd_debit', me.BaseUtil.numberFormat(debit, 4));
- if(f.checked) {
- record.set('vd_doubledebit', me.BaseUtil.numberFormat(debit/rate, 4));
- }
- } else if(targetName == 'vd_credit'){
- credit = debit - credit;
- record.set('vd_credit', me.BaseUtil.numberFormat(credit, 4));
- if(f.checked) {
- record.set('vd_doublecredit', me.BaseUtil.numberFormat(credit/rate, 4));
- }
- }
- if(target.name == targetName)
- target.value = record.get(targetName);
- } else {
- if(credit > debit) {
- record.set('vd_debit', credit - debit);
- if(f.checked) {
- record.set('vd_doubledebit', me.BaseUtil.numberFormat((credit - debit)/rate, 4));
- }
- } else {
- record.set('vd_credit', debit - credit);
- if(f.checked) {
- record.set('vd_doublecredit', me.BaseUtil.numberFormat((debit - credit)/rate, 4));
- }
- }
- }
- }
- },
- showCateTree: function(f) {
- var cawin = Ext.getCmp('cawin');
- if(!cawin) {
- cawin = new Ext.window.Window({
- id : 'cawin',
- title: '科目查找',
- height: "100%",
- width: "80%",
- maximizable : true,
- buttonAlign : 'center',
- layout : 'anchor',
- modal:true,
- items: [{
- tag : 'iframe',
- frame : true,
- anchor : '100% 100%',
- layout : 'fit',
- html : '<iframe id="iframe_dbfind_'+caller+"_"+f.name+"="+f.value+'" src="'+basePath+'jsps/common/catetreepaneldbfind.jsp?key='+f.name+"&dbfind=&caller1="+caller+"&keyValue="+f.value+"&trigger="+f.id+'" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
- }],
- buttons : [{
- text : '确 认',
- iconCls: 'x-button-icon-save',
- cls: 'x-btn-gray',
- handler : function(btn){
- var contentwindow = Ext.getCmp('cawin').body.dom.getElementsByTagName('iframe')[0].contentWindow;
- var tree = contentwindow.Ext.getCmp('tree-panel');
- var data = tree.getChecked(), record = Ext.getCmp('grid').selModel.lastSelected;
- var dbfinds = Ext.getCmp('grid').dbfinds;
- if(dbfinds != null && record){
- Ext.each(dbfinds, function(dbfind,index){
- record.set(dbfind.field, data[0].raw.data[dbfind.dbGridField]);
- });
- }
- f.fireEvent('aftertrigger', f, data);
- btn.ownerCt.ownerCt.hide();
- }
- },{
- text : '关 闭',
- iconCls: 'x-button-icon-close',
- cls: 'x-btn-gray',
- handler : function(btn){
- btn.ownerCt.ownerCt.hide();
- }
- }]
- });
- }
- cawin.show();
- },
- getMonth: function(callback) {
- Ext.Ajax.request({
- url: basePath + 'fa/getMonth.action',
- params: {
- votype: 'GL'
- },
- callback: function(opt, s, r) {
- var rs = Ext.decode(r.responseText);
- if(rs.data) {
- callback.call(null, rs.data);
- }
- }
- });
- },
- /**
- * 显示模板
- */
- showTp: function() {
- var me = this, win = me.tpWin;
- if(!win) {
- win = me.tpWin = new Ext.window.Window({
- id: 'tp-win',
- width: '84%',
- height: '100%',
- title: '选择模板',
- layout: 'anchor',
- closeAction: 'hide',
- items: [{
- xtype: 'container',
- anchor: '100% 100%',
- html: '<iframe src="' + basePath + 'jsps/common/datalist.jsp?whoami=Voucher!TP&&parentDoc=tp-win" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
- }],
- listeners: {
- 'itemselect': function(scope, data) {
- me.loadTp(data.vo_id);
- scope.hide();
- },
- 'close': function(scope) {
- scope.hide();
- }
- }
- });
- }
- win.show();
- },
- /**
- * 加载模板
- */
- loadTp: function(id) {
- Ext.Ajax.request({
- url: basePath + 'fa/gla/getvotp.action',
- params: {
- id: id
- },
- callback: function(opt, s, r) {
- var rs = Ext.decode(r.responseText);
- if(rs.data) {
- var form = Ext.getCmp('form'), grid = Ext.getCmp('grid');
- form.getForm().setValues(rs.data.voucher);
- grid.store.loadData(rs.data.voucherdetail);
- var store = grid.store, i = 0, exp = grid.plugins[2];
- grid.store.each(function(record){
- exp.toggleRow(i++);
- record.dirty = true;
- });
- } else {
- showError(rs.exceptionInfo);
- }
- }
- });
- },
- /**
- * 添加到凭证模板
- */
- createTp: function(){
- var form = Ext.getCmp('form');
- var v = form.down('#vo_id').value;
- if(v > 0) {
- form.setLoading(true);
- Ext.Ajax.request({
- url: basePath + 'fa/gla/copyvotp.action',
- params: {
- id: v
- },
- callback: function(opt, s, r){
- form.setLoading(false);
- var res = Ext.decode(r.responseText);
- if(res.data) {
- showMessage('提示', '添加成功!<a href="javascript:openUrl(\'jsps/fa/gla/vouchertp.jsp?formCondition=vo_idIS' +
- + res.data.vo_id + '&gridCondition=vd_voidIS' + res.data.vo_id +
- '\')"> \n流水号:<' + res.data.vo_code + '></a>');
- } else {
- showError(res.exceptionInfo);
- }
- }
- });
- }
- }
- });
|