ShowCmCopDetail.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.fa.ars.ShowCmCopDetail', {
  3. extend: 'Ext.app.Controller',
  4. BaseUtil: Ext.create('erp.util.BaseUtil'),
  5. views: ['core.trigger.DbfindTrigger', 'fa.ars.cmCopQuery.CmDetailGrid', 'fa.ars.cmCopQuery.ShowCmDetail', 'core.form.MonthDateField',
  6. 'core.form.ConMonthDateField', 'core.form.YearDateField'],
  7. init:function(){
  8. var me = this;
  9. this.control({
  10. 'cmdetailgrid':{
  11. itemclick:this.onGridItemClick
  12. },
  13. 'button[id=close]': {
  14. afterrender: function() {
  15. setTimeout(function(){
  16. me.getCondition();
  17. },200);
  18. }
  19. },
  20. 'button[name=export]': {
  21. click: function() {
  22. var grid = Ext.getCmp('cmcopdetailgrid');
  23. me.BaseUtil.exportGrid(grid, '应收总账明细'+'-'+yearmonth+'-'+custname+'-'+currency+'_'+cop,' 公司:'+cop+' 客户名称:'+custname+' 币别:'+currency+' 期间:'+yearmonth);
  24. }
  25. },
  26. 'button[name=query]':{
  27. click:function(btn){
  28. var me = this;
  29. if(Ext.getCmp(btn.getId() + '-filter')){
  30. Ext.getCmp(btn.getId() + '-filter').show();
  31. }else{
  32. var filter = me.createFilterPanel(btn);
  33. filter.show();
  34. }
  35. }
  36. }
  37. });
  38. },
  39. //弹出筛选框
  40. createFilterPanel:function(btn){
  41. var me = this;
  42. var filter = Ext.create('Ext.Window', {
  43. id: btn.getId() + '-filter',
  44. style: 'background:#f1f1f1',
  45. title: '筛选条件',
  46. width: 300,
  47. modal:true,
  48. height: 250,
  49. layout: 'column',
  50. defaults: {
  51. margin: '2 2 2 10'
  52. },
  53. items: [{
  54. xtype: 'checkbox',
  55. id: 'showarmsg',
  56. name: 'showarmsg',
  57. checked:true,
  58. columnWidth: .71,
  59. boxLabel: '显示应收发票信息'
  60. },{
  61. xtype: 'checkbox',
  62. id: 'showotarmsg',
  63. name: 'showotarmsg',
  64. checked:true,
  65. columnWidth: .71,
  66. boxLabel: '显示其它应收信息'
  67. },{
  68. xtype: 'checkbox',
  69. id: 'showrbmsg',
  70. name: 'showrbmsg',
  71. checked:true,
  72. columnWidth: .71,
  73. boxLabel: '显示收款单信息'
  74. },{
  75. xtype: 'checkbox',
  76. id: 'showprerecmsg',
  77. name: 'showprerecmsg',
  78. checked:true,
  79. columnWidth: .71,
  80. boxLabel: '显示预收账款信息'
  81. },{
  82. xtype: 'checkbox',
  83. id: 'showgsmsg',
  84. name: 'showgsmsg',
  85. checked:true,
  86. columnWidth: .71,
  87. boxLabel: '显示发出商品信息'
  88. },{
  89. xtype: 'checkbox',
  90. id: 'showdemsg',
  91. name: 'showdemsg',
  92. columnWidth: .71,
  93. boxLabel: '显示销售发票明细'
  94. }],
  95. buttonAlign: 'center',
  96. buttons: [{
  97. text: '确定',
  98. width: 60,
  99. cls: 'x-btn-blue',
  100. handler: function(btn) {
  101. var showArDetailVal = Ext.getCmp('showdemsg').getValue();
  102. var grid = Ext.getCmp('cmcopdetailgrid');
  103. var fl = btn.ownerCt.ownerCt;
  104. var con = me.getConfig(fl);
  105. if(showArDetailVal){
  106. grid.columns = grid.detailColumns;
  107. me.getConditionDetail(con,'fa/ars/CmQueryController/getCmCopDetailByIdDetail.action');
  108. }else{
  109. grid.columns = grid.defaultColumns;
  110. me.getConditionDetail(con,'fa/ars/CmQueryController/getCmCopDetailById.action');
  111. }
  112. //隐藏筛选框
  113. fl.hide();
  114. }
  115. },{
  116. text: '关闭',
  117. width: 60,
  118. cls: 'x-btn-blue',
  119. handler: function(btn) {
  120. var fl = btn.ownerCt.ownerCt;
  121. fl.hide();
  122. }
  123. }]
  124. });
  125. return filter;
  126. },
  127. getConfig: function(pl) {
  128. var r = new Object(),v;
  129. Ext.each(pl.items.items, function(item){
  130. if(item.getValue !== undefined) {
  131. v = item.getValue();
  132. if(!Ext.isEmpty(v)) {
  133. r[item.id] = v;
  134. }
  135. }
  136. });
  137. var tb = Ext.getCmp('gl_info_ym');
  138. if(tb)
  139. tb.updateInfo(r);
  140. return r;
  141. },
  142. //得到界面上够选框选择条件 并执行查找 没有勾选显示明细的情况
  143. getCondition:function(){
  144. var me = this;
  145. var cond = {
  146. 'cmid':cmid,
  147. 'yearmonth':yearmonth,
  148. 'currency':currency,
  149. 'custcode':custcode,
  150. 'chkumio':chkumio,
  151. 'cop':cop,
  152. 'config':{
  153. 'showarmsg':true,
  154. 'showotarmsg':true,
  155. 'showrbmsg':true,
  156. 'showgsmsg':true,
  157. 'showprerecmsg':true
  158. }
  159. };
  160. me.query(cond);
  161. },
  162. query: function(cond) {
  163. var grid = Ext.getCmp('cmcopdetailgrid');
  164. grid.setLoading(true);
  165. Ext.Ajax.request({
  166. url: basePath + 'fa/ars/CmQueryController/getCmCopDetailById.action',
  167. params: {
  168. condition: Ext.encode(cond)
  169. },
  170. callback: function(opt, s, r) {
  171. var res = Ext.decode(r.responseText);
  172. if(grid && res.data) {
  173. grid.store.loadData(res.data);
  174. }
  175. grid.setLoading(false);
  176. }
  177. });
  178. },
  179. //得到界面上够选框选择条件 并执行查找 勾选显示明细的情况
  180. getConditionDetail:function(config,url){
  181. var me = this;
  182. var cond = {
  183. 'cmid':cmid,
  184. 'yearmonth':yearmonth,
  185. 'cop':cop,
  186. 'currency':currency,
  187. 'custcode':custcode,
  188. 'chkumio':chkumio,
  189. 'config':config
  190. };
  191. me.queryDetail(cond,url);
  192. },
  193. queryDetail: function(cond,url) {
  194. var grid = Ext.getCmp('cmcopdetailgrid');
  195. grid.setLoading(true);
  196. Ext.Ajax.request({
  197. url: basePath + url,
  198. params: {
  199. condition: Ext.encode(cond)
  200. },
  201. callback: function(opt, s, r) {
  202. var res = Ext.decode(r.responseText);
  203. if(grid && res.data) {
  204. var store = Ext.create('Ext.data.Store', {
  205. fields:[{
  206. name: 'tb_code',
  207. type: 'string'
  208. },{
  209. name: 'tb_kind',
  210. type: 'string'
  211. },{
  212. name: 'tb_remark',
  213. type: 'string'
  214. },{
  215. name: 'tb_vouc',
  216. type: 'string'
  217. },{
  218. name: 'tb_date',
  219. type: 'string'
  220. },{
  221. name: 'tb_aramount',
  222. type: 'string'
  223. },{
  224. name: 'tb_inoutno',
  225. type: 'string'
  226. },{
  227. name: 'tb_pdno',
  228. type: 'string'
  229. },{
  230. name: 'tb_ordercode',
  231. type: 'string'
  232. },{
  233. name: 'tb_prodcode',
  234. type: 'string'
  235. },{
  236. name: 'tb_qty',
  237. type: 'string'
  238. },{
  239. name: 'tb_price',
  240. type: 'string'
  241. },{
  242. name: 'tb_rbamount',
  243. type: 'string'
  244. },{
  245. name: 'tb_aramounts',
  246. type: 'string'
  247. },{
  248. name: 'tb_rbamounts',
  249. type: 'string'
  250. },{
  251. name: 'tb_balance',
  252. type: 'string'
  253. },{
  254. name: 'tb_index',
  255. type: 'number'
  256. },{
  257. name: 'tb_id',
  258. type:'number'
  259. }],
  260. data: res.data
  261. });
  262. grid.reconfigure(store,grid.columns);
  263. }
  264. grid.setLoading(false);
  265. }
  266. });
  267. },
  268. onGridItemClick:function(selModel, record){
  269. var value = Number(record.data['tb_id']);
  270. var me = this;
  271. if(value>0){
  272. var url='', k = record.get('tb_kind');
  273. var keyField ='';
  274. var caller = '';
  275. var pfField = '';
  276. if(k == '应收发票'){
  277. url ='jsps/fa/ars/arbill.jsp?whoami=ARBill!IRMA';
  278. keyField = 'ab_id';
  279. pfField = 'abd_abid';
  280. caller = 'ARBill!IRMA';
  281. }else if(k=='收款单'){
  282. url ='jsps/fa/ars/recBalance.jsp?whoami=RecBalance!PBIL';
  283. keyField = 'rb_id';
  284. pfField = 'rbd_rbid';
  285. caller = 'RecBalance!PBIL';
  286. }else if(k=='其它应收单'){
  287. url ='jsps/fa/ars/arbill.jsp?whoami=ARBill!OTRS';
  288. keyField = 'ab_id';
  289. pfField = 'abd_abid';
  290. caller = 'ARBill!OTRS';
  291. }else if(k=='发出商品'){
  292. url ='jsps/fa/ars/goodsSend.jsp';
  293. keyField = 'gs_id';
  294. pfField = 'gsd_gsid';
  295. caller = 'GoodsSendGs';
  296. }else if(k=='出货单'){
  297. url ='jsps/scm/reserve/prodInOut.jsp?whoami=ProdInOut!Sale';
  298. keyField = 'pi_id';
  299. pfField = 'pd_piid';
  300. caller = 'ProdInOut!Sale';
  301. }else if(k=='销售退货单'){
  302. url ='jsps/scm/reserve/prodInOut.jsp?whoami=ProdInOut!SaleReturn';
  303. keyField = 'pi_id';
  304. pfField = 'pd_piid';
  305. caller = 'ProdInOut!SaleReturn';
  306. }else if(k=='预收款'){
  307. url ='jsps/fa/ars/preRec.jsp?whoami=PreRec!Ars!DERE';
  308. keyField = 'pr_id';
  309. pfField = 'prd_prid';
  310. caller = 'PreRec!Ars!DERE';
  311. }else if(k=='预收冲应收'){
  312. url ='jsps/fa/ars/recBalancePRDetail.jsp?whoami=RecBalance!PTAR';
  313. keyField = 'rb_id';
  314. pfField = 'rbd_rbid';
  315. caller = 'RecBalance!PTAR';
  316. }else if(k=='冲应收款'){
  317. url ='jsps/fa/ars/recBalance.jsp?whoami=RecBalance!IMRE';
  318. keyField = 'rb_id';
  319. pfField = 'rbd_rbid';
  320. caller = 'RecBalance!IMRE';
  321. }
  322. var formCondition = keyField + "IS" + value ;
  323. var gridCondition = pfField + "IS" + value;
  324. var panelId = caller + keyField + "_" + value + gridCondition;
  325. var panel = Ext.getCmp(panelId);
  326. var main = parent.Ext.getCmp("content-panel");
  327. if(!main){
  328. main = parent.parent.Ext.getCmp("content-panel");
  329. }
  330. if(!panel){
  331. var title = "";
  332. if (value.toString().length>4) {
  333. title = value.toString().substring(value.toString().length-4);
  334. } else {
  335. title = value;
  336. }
  337. var myurl = '';
  338. if(me.BaseUtil.contains(url, '?', true)){
  339. myurl = url + '&formCondition='+formCondition+'&gridCondition='+gridCondition;
  340. } else {
  341. myurl = url + '?formCondition='+formCondition+'&gridCondition='+gridCondition;
  342. }
  343. myurl += "&datalistId=" + main.getActiveTab().id;
  344. panel = {
  345. title :record.data['tb_kind']+'('+title+')',
  346. tag : 'iframe',
  347. tabConfig:{tooltip:me.BaseUtil.getActiveTab().tabConfig.tooltip+'('+keyField + "=" + value+')'},
  348. frame : true,
  349. border : false,
  350. layout : 'fit',
  351. iconCls : 'x-tree-icon-query',
  352. html : '<iframe id="iframe_maindetail_'+caller+"_"+value+'" src="' + myurl + '" height="100%" width="100%" frameborder="0" style="border-width: 0px;padding: 0px;" scrolling="auto"></iframe>',
  353. closable : true,
  354. listeners : {
  355. close : function(){
  356. if(!main){
  357. main = parent.parent.Ext.getCmp("content-panel");
  358. }
  359. main.setActiveTab(main.getActiveTab().id);
  360. }
  361. }
  362. };
  363. this.openTab(panel, panelId);
  364. }else{
  365. main.setActiveTab(panel);
  366. }
  367. }
  368. },
  369. openTab : function (panel,id){
  370. var o = (typeof panel == "string" ? panel : id || panel.id);
  371. var main = parent.Ext.getCmp("content-panel");
  372. /*var tab = main.getComponent(o); */
  373. if(!main) {
  374. main =parent.parent.Ext.getCmp("content-panel");
  375. }
  376. var tab = main.getComponent(o);
  377. if (tab) {
  378. main.setActiveTab(tab);
  379. } else if(typeof panel!="string"){
  380. panel.id = o;
  381. var p = main.add(panel);
  382. main.setActiveTab(p);
  383. }
  384. }
  385. // getCurrentStore: function(value){
  386. // var grid = Ext.getCmp('cmdetailgrid');
  387. // var items = grid.store.data.items;
  388. // var array = new Array();
  389. // var o = null;
  390. // Ext.each(items, function(item, index){
  391. // o = new Object();
  392. // o.selected = false;
  393. // if(index == 0){
  394. // o.prev = null;
  395. // } else {
  396. // o.prev = items[index-1].data[keyField];
  397. // }
  398. // if(index == items.length - 1){
  399. // o.next = null;
  400. // } else {
  401. // o.next = items[index+1].data[keyField];
  402. // }
  403. // var v = item.data[keyField];
  404. // o.value = v;
  405. // if(v == value)
  406. // o.selected = true;
  407. // array.push(o);
  408. // });
  409. // return array;
  410. // }
  411. });