| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.fa.RepQuery', {
- extend: 'Ext.app.Controller',
- id: 'printcwform',
- FormUtil: Ext.create('erp.util.FormUtil'),
- GridUtil: Ext.create('erp.util.GridUtil'),
- BaseUtil: Ext.create('erp.util.BaseUtil'),
- views: ['fa.RepQuery', 'core.button.Query', 'core.button.Export', 'core.button.Print', 'core.button.Close',
- 'core.form.MonthDateField'],
- init:function(){
- var me = this;
- this.control({
- 'combo[name=fs_name]': {
- afterrender: function(f) {
- me.getRepCodes(f);
- },
- change: function(f) {
- if(!Ext.isEmpty(f.value)) {
- var d = f.lastSelection[0].data.data,
- form = f.ownerCt;
- form.down('textfield[name=fs_code]').setValue(d.FS_CODE);
- var grid = form.ownerCt.down('grid');
- me.resetGrid(grid, d);
- }
- }
- },
- 'monthdatefield': {
- afterrender: function(f) {
- this.getCurrentMonth(f);
- }
- },
- 'button[name=export]': {
- click: function(btn) {
- var grid = btn.ownerCt.ownerCt.ownerCt.down('gridpanel');
- this.BaseUtil.exportGrid(grid);
- }
- },
- 'erpQueryButton': {
- click: function(b) {
- var grid = b.ownerCt.ownerCt.ownerCt.down('gridpanel');
- this.getGridData(grid);
- }
- }
- ,
- 'erpPrintButton': {
- click: function(btn) {
- var form = Ext.getCmp('printcwform');
- // var title=form.title;
- if(Ext.getCmp('fs_code') && Ext.getCmp('fs_code').value =='P01'){
- var reportName="FAReportSY";
- }else{
- console.log(reportName);
- var reportName="FAReport";
- }
- var condition='{fareport.fr_fscode}='+ "'"+Ext.getCmp('fs_code').value+"'"+' and '+'{fareport.fr_yearmonth}='+Ext.getCmp('frd_yearmonth').value;
-
- //me.FormUtil.batchPrint(title,reportName,condition,'','','','','','','');
- //在这里传条件和报表名字
-
- //=======================================================
- var me = this;
- Ext.Ajax.request({
- url : basePath + 'common/enterprise/getprinturl.action?caller=' + caller,
- callback: function(opt, s, r) {
- var re = Ext.decode(r.responseText);
- thisreport=re.reportname;
- //===========================================
- var whichsystem = re.whichsystem;
- var urladdress = "";
- var rpname = re.reportName;
- if(Ext.isEmpty(rpname) || rpname == "null"){
- urladdress = re.printurl;
- } else if(rpname.indexOf(thisreport) > 0){
- urladdress = re.ErpPrintLargeData;
- } else{
- urladdress = re.printurl;
- }
- me.FormUtil.batchPrint('',reportName,condition,'','','','','',urladdress,whichsystem);
- //在这里传条件和报表名字
- }
- });
-
- }
- }
- });
- },
- getRepCodes: function(f) {
- Ext.Ajax.request({
- url : basePath + 'common/getFieldsDatas.action',
- params: {
- caller: 'FARepSet',
- fields: 'fs_code,fs_name,fs_title1,fs_title2,fs_righttitle1,fs_righttitle2,fs_head,fs_righthead',
- condition: '1=1'
- },
- method : 'post',
- callback : function(options,success,response){
- var rs = new Ext.decode(response.responseText);
- if(rs.exceptionInfo){
- showError(rs.exceptionInfo);return;
- }
- if(rs.success){
- var data = Ext.decode(rs.data), s = [];
- Ext.each(data, function(d){
- s.push({
- display: d.FS_NAME,
- value: d.FS_NAME,
- data: d
- });
- });
- f.store.loadData(s);
- if(s.length > 0) {
- f.setValue(s[0].value);
- }
- }
- }
- });
- },
- resetGrid: function(grid, d) {
- var columns = [{
- text: d.FS_HEAD,
- dataIndex: 'frd_name',
- cls: 'x-grid-header-1',
- flex: 1
- }, {
- text: '行次',
- dataIndex: 'frd_step',
- cls: 'x-grid-header-1',
- flex: 0.3
- }, {
- text: d.FS_TITLE1,
- dataIndex: 'frd_amount1',
- cls: 'x-grid-header-1',
- xtype: 'numbercolumn',
- format: '0,000.00',
- align: 'right',
- flex: 1,
- renderer: function(v, m, r) {
- if (v == 0) {
- m.style = 'text-align: center;color:red;';
- return '-';
- }
- return Ext.util.Format.number(v, '0,000.00');
- }
- }, {
- text: d.FS_TITLE2,
- dataIndex: 'frd_amount2',
- cls: 'x-grid-header-1',
- xtype: 'numbercolumn',
- format: '0,000.00',
- align: 'right',
- flex: 1,
- renderer: function(v, m, r) {
- if (v == 0) {
- m.style = 'text-align: center;color:red;';
- return '-';
- }
- return Ext.util.Format.number(v, '0,000.00');
- }
- },{
- text: d.FS_RIGHTHEAD,
- dataIndex: 'frd_rightname',
- cls: 'x-grid-header-1',
- flex: 1
- }, {
- text: '行次',
- dataIndex: 'frd_rightstep',
- cls: 'x-grid-header-1',
- flex: 0.3
- }, {
- text: d.FS_RIGHTTITLE1,
- dataIndex: 'frd_rightamount1',
- cls: 'x-grid-header-1',
- xtype: 'numbercolumn',
- format: '0,000.00',
- align: 'right',
- flex: 1,
- renderer: function(v, m, r) {
- if (v == 0) {
- m.style = 'text-align: center;color:red;';
- return '-';
- }
- return Ext.util.Format.number(v, '0,000.00');
- }
- }, {
- text: d.FS_RIGHTTITLE2,
- dataIndex: 'frd_rightamount2',
- cls: 'x-grid-header-1',
- xtype: 'numbercolumn',
- format: '0,000.00',
- align: 'right',
- flex: 1,
- renderer: function(v, m, r) {
- if (v == 0) {
- m.style = 'text-align: center;color:red;';
- return '-';
- }
- return Ext.util.Format.number(v, '0,000.00');
- }
- }];
- var store = new Ext.data.Store({
- fields: ['frd_name', 'frd_step', 'frd_amount1', 'frd_amount2', 'frd_rightname', 'frd_rightstep',
- 'frd_rightamount1', 'frd_rightamount2'],
- data: [{frd_step: 1},{frd_step: 2},{frd_step: 3},{frd_step: 4},{frd_step: 5}]
- });
- grid.reconfigure(store, columns);
- this.getGridData(grid);
- },
- getCurrentMonth: function(f) {
- Ext.Ajax.request({
- url: basePath + 'fa/getMonth.action',
- params: {
- type: 'MONTH-A'
- },
- callback: function(opt, s, r) {
- var rs = Ext.decode(r.responseText);
- if(rs.data) {
- f.setValue(rs.data.PD_DETNO);
- }
- }
- });
- },
- getGridData: function(grid) {
- var code = Ext.getCmp('fs_code').value,
- ym = Ext.getCmp('frd_yearmonth').value,
- cond = '';
- if(!Ext.isEmpty(code)) {
- cond = "frd_fscode='" + code + "'";
- }
- if(!Ext.isEmpty(ym)) {
- if(cond.length > 0)
- cond += ' AND frd_yearmonth=' + ym;
- else
- cond = 'frd_yearmonth=' + ym;
- }
- if(cond.length == 0) {
- cond = '1=1';
- }
- cond += ' order by to_number(frd_step)';
- Ext.Ajax.request({
- url : basePath + 'common/getFieldsDatas.action',
- params: {
- caller: 'FAReportDetail',
- fields: 'distinct frd_name, frd_step, frd_rate*frd_amount1 frd_amount1, frd_rate*frd_amount2 frd_amount2, frd_rightname, frd_rightstep, frd_rightrate*frd_rightamount1 frd_rightamount1, frd_rightrate*frd_rightamount2 frd_rightamount2',
- condition: cond
- },
- method : 'post',
- callback : function(options,success,response){
- var rs = new Ext.decode(response.responseText);
- if(rs.exceptionInfo){
- showError(rs.exceptionInfo);return;
- }
- if(rs.success){
- var data = Ext.decode(rs.data), s = [];
- Ext.each(data, function(d){
- s.push({
- frd_name: d.FRD_NAME,
- frd_step: d.FRD_STEP,
- frd_amount1: d.FRD_AMOUNT1,
- frd_amount2: d.FRD_AMOUNT2,
- frd_rightname: d.FRD_RIGHTNAME,
- frd_rightstep: d.FRD_RIGHTSTEP,
- frd_rightamount1: d.FRD_RIGHTAMOUNT1,
- frd_rightamount2: d.FRD_RIGHTAMOUNT2
- });
- });
- grid.store.loadData(s);
- }
- }
- });
- }
- });
|