RepQuery.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.fa.RepQuery', {
  3. extend: 'Ext.app.Controller',
  4. id: 'printcwform',
  5. FormUtil: Ext.create('erp.util.FormUtil'),
  6. GridUtil: Ext.create('erp.util.GridUtil'),
  7. BaseUtil: Ext.create('erp.util.BaseUtil'),
  8. views: ['fa.RepQuery', 'core.button.Query', 'core.button.Export', 'core.button.Print', 'core.button.Close',
  9. 'core.form.MonthDateField'],
  10. init:function(){
  11. var me = this;
  12. this.control({
  13. 'combo[name=fs_name]': {
  14. afterrender: function(f) {
  15. me.getRepCodes(f);
  16. },
  17. change: function(f) {
  18. if(!Ext.isEmpty(f.value)) {
  19. var d = f.lastSelection[0].data.data,
  20. form = f.ownerCt;
  21. form.down('textfield[name=fs_code]').setValue(d.FS_CODE);
  22. var grid = form.ownerCt.down('grid');
  23. me.resetGrid(grid, d);
  24. }
  25. }
  26. },
  27. 'monthdatefield': {
  28. afterrender: function(f) {
  29. this.getCurrentMonth(f);
  30. }
  31. },
  32. 'button[name=export]': {
  33. click: function(btn) {
  34. var grid = btn.ownerCt.ownerCt.ownerCt.down('gridpanel');
  35. this.BaseUtil.exportGrid(grid);
  36. }
  37. },
  38. 'erpQueryButton': {
  39. click: function(b) {
  40. var grid = b.ownerCt.ownerCt.ownerCt.down('gridpanel');
  41. this.getGridData(grid);
  42. }
  43. }
  44. ,
  45. 'erpPrintButton': {
  46. click: function(btn) {
  47. var form = Ext.getCmp('printcwform');
  48. // var title=form.title;
  49. if(Ext.getCmp('fs_code') && Ext.getCmp('fs_code').value =='P01'){
  50. var reportName="FAReportSY";
  51. }else{
  52. console.log(reportName);
  53. var reportName="FAReport";
  54. }
  55. var condition='{fareport.fr_fscode}='+ "'"+Ext.getCmp('fs_code').value+"'"+' and '+'{fareport.fr_yearmonth}='+Ext.getCmp('frd_yearmonth').value;
  56. //me.FormUtil.batchPrint(title,reportName,condition,'','','','','','','');
  57. //在这里传条件和报表名字
  58. //=======================================================
  59. var me = this;
  60. Ext.Ajax.request({
  61. url : basePath + 'common/enterprise/getprinturl.action?caller=' + caller,
  62. callback: function(opt, s, r) {
  63. var re = Ext.decode(r.responseText);
  64. thisreport=re.reportname;
  65. //===========================================
  66. var whichsystem = re.whichsystem;
  67. var urladdress = "";
  68. var rpname = re.reportName;
  69. if(Ext.isEmpty(rpname) || rpname == "null"){
  70. urladdress = re.printurl;
  71. } else if(rpname.indexOf(thisreport) > 0){
  72. urladdress = re.ErpPrintLargeData;
  73. } else{
  74. urladdress = re.printurl;
  75. }
  76. me.FormUtil.batchPrint('',reportName,condition,'','','','','',urladdress,whichsystem);
  77. //在这里传条件和报表名字
  78. }
  79. });
  80. }
  81. }
  82. });
  83. },
  84. getRepCodes: function(f) {
  85. Ext.Ajax.request({
  86. url : basePath + 'common/getFieldsDatas.action',
  87. params: {
  88. caller: 'FARepSet',
  89. fields: 'fs_code,fs_name,fs_title1,fs_title2,fs_righttitle1,fs_righttitle2,fs_head,fs_righthead',
  90. condition: '1=1'
  91. },
  92. method : 'post',
  93. callback : function(options,success,response){
  94. var rs = new Ext.decode(response.responseText);
  95. if(rs.exceptionInfo){
  96. showError(rs.exceptionInfo);return;
  97. }
  98. if(rs.success){
  99. var data = Ext.decode(rs.data), s = [];
  100. Ext.each(data, function(d){
  101. s.push({
  102. display: d.FS_NAME,
  103. value: d.FS_NAME,
  104. data: d
  105. });
  106. });
  107. f.store.loadData(s);
  108. if(s.length > 0) {
  109. f.setValue(s[0].value);
  110. }
  111. }
  112. }
  113. });
  114. },
  115. resetGrid: function(grid, d) {
  116. var columns = [{
  117. text: d.FS_HEAD,
  118. dataIndex: 'frd_name',
  119. cls: 'x-grid-header-1',
  120. flex: 1
  121. }, {
  122. text: '行次',
  123. dataIndex: 'frd_step',
  124. cls: 'x-grid-header-1',
  125. flex: 0.3
  126. }, {
  127. text: d.FS_TITLE1,
  128. dataIndex: 'frd_amount1',
  129. cls: 'x-grid-header-1',
  130. xtype: 'numbercolumn',
  131. format: '0,000.00',
  132. align: 'right',
  133. flex: 1,
  134. renderer: function(v, m, r) {
  135. if (v == 0) {
  136. m.style = 'text-align: center;color:red;';
  137. return '-';
  138. }
  139. return Ext.util.Format.number(v, '0,000.00');
  140. }
  141. }, {
  142. text: d.FS_TITLE2,
  143. dataIndex: 'frd_amount2',
  144. cls: 'x-grid-header-1',
  145. xtype: 'numbercolumn',
  146. format: '0,000.00',
  147. align: 'right',
  148. flex: 1,
  149. renderer: function(v, m, r) {
  150. if (v == 0) {
  151. m.style = 'text-align: center;color:red;';
  152. return '-';
  153. }
  154. return Ext.util.Format.number(v, '0,000.00');
  155. }
  156. },{
  157. text: d.FS_RIGHTHEAD,
  158. dataIndex: 'frd_rightname',
  159. cls: 'x-grid-header-1',
  160. flex: 1
  161. }, {
  162. text: '行次',
  163. dataIndex: 'frd_rightstep',
  164. cls: 'x-grid-header-1',
  165. flex: 0.3
  166. }, {
  167. text: d.FS_RIGHTTITLE1,
  168. dataIndex: 'frd_rightamount1',
  169. cls: 'x-grid-header-1',
  170. xtype: 'numbercolumn',
  171. format: '0,000.00',
  172. align: 'right',
  173. flex: 1,
  174. renderer: function(v, m, r) {
  175. if (v == 0) {
  176. m.style = 'text-align: center;color:red;';
  177. return '-';
  178. }
  179. return Ext.util.Format.number(v, '0,000.00');
  180. }
  181. }, {
  182. text: d.FS_RIGHTTITLE2,
  183. dataIndex: 'frd_rightamount2',
  184. cls: 'x-grid-header-1',
  185. xtype: 'numbercolumn',
  186. format: '0,000.00',
  187. align: 'right',
  188. flex: 1,
  189. renderer: function(v, m, r) {
  190. if (v == 0) {
  191. m.style = 'text-align: center;color:red;';
  192. return '-';
  193. }
  194. return Ext.util.Format.number(v, '0,000.00');
  195. }
  196. }];
  197. var store = new Ext.data.Store({
  198. fields: ['frd_name', 'frd_step', 'frd_amount1', 'frd_amount2', 'frd_rightname', 'frd_rightstep',
  199. 'frd_rightamount1', 'frd_rightamount2'],
  200. data: [{frd_step: 1},{frd_step: 2},{frd_step: 3},{frd_step: 4},{frd_step: 5}]
  201. });
  202. grid.reconfigure(store, columns);
  203. this.getGridData(grid);
  204. },
  205. getCurrentMonth: function(f) {
  206. Ext.Ajax.request({
  207. url: basePath + 'fa/getMonth.action',
  208. params: {
  209. type: 'MONTH-A'
  210. },
  211. callback: function(opt, s, r) {
  212. var rs = Ext.decode(r.responseText);
  213. if(rs.data) {
  214. f.setValue(rs.data.PD_DETNO);
  215. }
  216. }
  217. });
  218. },
  219. getGridData: function(grid) {
  220. var code = Ext.getCmp('fs_code').value,
  221. ym = Ext.getCmp('frd_yearmonth').value,
  222. cond = '';
  223. if(!Ext.isEmpty(code)) {
  224. cond = "frd_fscode='" + code + "'";
  225. }
  226. if(!Ext.isEmpty(ym)) {
  227. if(cond.length > 0)
  228. cond += ' AND frd_yearmonth=' + ym;
  229. else
  230. cond = 'frd_yearmonth=' + ym;
  231. }
  232. if(cond.length == 0) {
  233. cond = '1=1';
  234. }
  235. cond += ' order by to_number(frd_step)';
  236. Ext.Ajax.request({
  237. url : basePath + 'common/getFieldsDatas.action',
  238. params: {
  239. caller: 'FAReportDetail',
  240. 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',
  241. condition: cond
  242. },
  243. method : 'post',
  244. callback : function(options,success,response){
  245. var rs = new Ext.decode(response.responseText);
  246. if(rs.exceptionInfo){
  247. showError(rs.exceptionInfo);return;
  248. }
  249. if(rs.success){
  250. var data = Ext.decode(rs.data), s = [];
  251. Ext.each(data, function(d){
  252. s.push({
  253. frd_name: d.FRD_NAME,
  254. frd_step: d.FRD_STEP,
  255. frd_amount1: d.FRD_AMOUNT1,
  256. frd_amount2: d.FRD_AMOUNT2,
  257. frd_rightname: d.FRD_RIGHTNAME,
  258. frd_rightstep: d.FRD_RIGHTSTEP,
  259. frd_rightamount1: d.FRD_RIGHTAMOUNT1,
  260. frd_rightamount2: d.FRD_RIGHTAMOUNT2
  261. });
  262. });
  263. grid.store.loadData(s);
  264. }
  265. }
  266. });
  267. }
  268. });