ShowCmDetail.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.fa.ars.ShowCmDetail', {
  3. extend: 'Ext.app.Controller',
  4. BaseUtil: Ext.create('erp.util.BaseUtil'),
  5. views: ['core.trigger.DbfindTrigger', 'fa.ars.cmQuery.CmDetailGrid', 'fa.ars.cmQuery.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('cmdetailgrid');
  23. me.BaseUtil.exportGrid(grid, '应收总账明细'+'-'+yearmonth+'-'+custname+'-'+currency+'_',' 客户名称:'+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('cmdetailgrid');
  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/getCmDetailByIdDetail.action');
  108. }else{
  109. grid.columns = grid.defaultColumns;
  110. me.getConditionDetail(con,'fa/ars/CmQueryController/getCmDetailById.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. 'config':{
  152. 'showarmsg':true,
  153. 'showotarmsg':true,
  154. 'showrbmsg':true,
  155. 'showgsmsg':true,
  156. 'showprerecmsg':true
  157. }
  158. };
  159. me.query(cond);
  160. },
  161. query: function(cond) {
  162. var grid = Ext.getCmp('cmdetailgrid');
  163. grid.setLoading(true);
  164. Ext.Ajax.request({
  165. url: basePath + 'fa/ars/CmQueryController/getCmDetailById.action',
  166. params: {
  167. condition: Ext.encode(cond)
  168. },
  169. callback: function(opt, s, r) {
  170. var res = Ext.decode(r.responseText);
  171. if(grid && res.data) {
  172. grid.store.loadData(res.data);
  173. }
  174. grid.setLoading(false);
  175. }
  176. });
  177. },
  178. //得到界面上够选框选择条件 并执行查找 勾选显示明细的情况
  179. getConditionDetail:function(config,url){
  180. var me = this;
  181. var cond = {
  182. 'cmid':cmid,
  183. 'yearmonth':yearmonth,
  184. 'currency':currency,
  185. 'custcode':custcode,
  186. 'chkumio':chkumio,
  187. 'config':config
  188. };
  189. me.queryDetail(cond,url);
  190. },
  191. queryDetail: function(cond,url) {
  192. var grid = Ext.getCmp('cmdetailgrid');
  193. grid.setLoading(true);
  194. Ext.Ajax.request({
  195. url: basePath + url,
  196. params: {
  197. condition: Ext.encode(cond)
  198. },
  199. callback: function(opt, s, r) {
  200. var res = Ext.decode(r.responseText);
  201. if(grid && res.data) {
  202. var store = Ext.create('Ext.data.Store', {
  203. fields:[{
  204. name: 'tb_code',
  205. type: 'string'
  206. },{
  207. name: 'tb_kind',
  208. type: 'string'
  209. },{
  210. name: 'tb_remark',
  211. type: 'string'
  212. },{
  213. name: 'tb_vouc',
  214. type: 'string'
  215. },{
  216. name: 'tb_date',
  217. type: 'string'
  218. },{
  219. name: 'tb_aramount',
  220. type: 'string'
  221. },{
  222. name: 'tb_inoutno',
  223. type: 'string'
  224. },{
  225. name: 'tb_pdno',
  226. type: 'string'
  227. },{
  228. name: 'tb_ordercode',
  229. type: 'string'
  230. },{
  231. name: 'tb_prodcode',
  232. type: 'string'
  233. },{
  234. name: 'tb_qty',
  235. type: 'string'
  236. },{
  237. name: 'tb_price',
  238. type: 'string'
  239. },{
  240. name: 'tb_rbamount',
  241. type: 'string'
  242. },{
  243. name: 'tb_aramounts',
  244. type: 'string'
  245. },{
  246. name: 'tb_rbamounts',
  247. type: 'string'
  248. },{
  249. name: 'tb_balance',
  250. type: 'string'
  251. },{
  252. name: 'tb_index',
  253. type: 'number'
  254. },{
  255. name: 'tb_id',
  256. type:'number'
  257. }],
  258. data: res.data
  259. });
  260. grid.reconfigure(store,grid.columns);
  261. }
  262. grid.setLoading(false);
  263. }
  264. });
  265. },
  266. onGridItemClick:function(selModel, record){
  267. var value = Number(record.data['tb_id']);
  268. var me = this;
  269. if(value>0){
  270. var url='', k = record.get('tb_kind');
  271. var keyField ='';
  272. var caller = '';
  273. var pfField = '';
  274. if(k == '应收发票'){
  275. url ='jsps/fa/ars/arbill.jsp?whoami=ARBill!IRMA';
  276. keyField = 'ab_id';
  277. pfField = 'abd_abid';
  278. caller = 'ARBill!IRMA';
  279. }else if(k=='收款单'){
  280. url ='jsps/fa/ars/recBalance.jsp?whoami=RecBalance!PBIL';
  281. keyField = 'rb_id';
  282. pfField = 'rbd_rbid';
  283. caller = 'RecBalance!PBIL';
  284. }else if(k=='其它应收单'){
  285. url ='jsps/fa/ars/arbill.jsp?whoami=ARBill!OTRS';
  286. keyField = 'ab_id';
  287. pfField = 'abd_abid';
  288. caller = 'ARBill!OTRS';
  289. }else if(k=='发出商品'){
  290. url ='jsps/fa/ars/goodsSend.jsp';
  291. keyField = 'gs_id';
  292. pfField = 'gsd_gsid';
  293. caller = 'GoodsSendGs';
  294. }else if(k=='出货单'){
  295. url ='jsps/scm/reserve/prodInOut.jsp?whoami=ProdInOut!Sale';
  296. keyField = 'pi_id';
  297. pfField = 'pd_piid';
  298. caller = 'ProdInOut!Sale';
  299. }else if(k=='销售退货单'){
  300. url ='jsps/scm/reserve/prodInOut.jsp?whoami=ProdInOut!SaleReturn';
  301. keyField = 'pi_id';
  302. pfField = 'pd_piid';
  303. caller = 'ProdInOut!SaleReturn';
  304. }else if(k=='预收款'){
  305. url ='jsps/fa/ars/preRec.jsp?whoami=PreRec!Ars!DERE';
  306. keyField = 'pr_id';
  307. pfField = 'prd_prid';
  308. caller = 'PreRec!Ars!DERE';
  309. }else if(k=='预收冲应收'){
  310. url ='jsps/fa/ars/recBalancePRDetail.jsp?whoami=RecBalance!PTAR';
  311. keyField = 'rb_id';
  312. pfField = 'rbd_rbid';
  313. caller = 'RecBalance!PTAR';
  314. }else if(k=='冲应收款'){
  315. url ='jsps/fa/ars/recBalance.jsp?whoami=RecBalance!IMRE';
  316. keyField = 'rb_id';
  317. pfField = 'rbd_rbid';
  318. caller = 'RecBalance!IMRE';
  319. }
  320. var formCondition = keyField + "IS" + value ;
  321. var gridCondition = pfField + "IS" + value;
  322. var panelId = caller + keyField + "_" + value + gridCondition;
  323. var panel = Ext.getCmp(panelId);
  324. var main = parent.Ext.getCmp("content-panel");
  325. if(!main){
  326. main = parent.parent.Ext.getCmp("content-panel");
  327. }
  328. if(!panel){
  329. var title = "";
  330. if (value.toString().length>4) {
  331. title = value.toString().substring(value.toString().length-4);
  332. } else {
  333. title = value;
  334. }
  335. var myurl = '';
  336. if(me.BaseUtil.contains(url, '?', true)){
  337. myurl = url + '&formCondition='+formCondition+'&gridCondition='+gridCondition;
  338. } else {
  339. myurl = url + '?formCondition='+formCondition+'&gridCondition='+gridCondition;
  340. }
  341. myurl += "&datalistId=" + main.getActiveTab().id;
  342. panel = {
  343. title :record.data['tb_kind']+'('+title+')',
  344. tag : 'iframe',
  345. tabConfig:{tooltip:me.BaseUtil.getActiveTab().tabConfig.tooltip+'('+keyField + "=" + value+')'},
  346. frame : true,
  347. border : false,
  348. layout : 'fit',
  349. iconCls : 'x-tree-icon-query',
  350. html : '<iframe id="iframe_maindetail_'+caller+"_"+value+'" src="' + myurl + '" height="100%" width="100%" frameborder="0" style="border-width: 0px;padding: 0px;" scrolling="auto"></iframe>',
  351. closable : true,
  352. listeners : {
  353. close : function(){
  354. if(!main){
  355. main = parent.parent.Ext.getCmp("content-panel");
  356. }
  357. main.setActiveTab(main.getActiveTab().id);
  358. }
  359. }
  360. };
  361. this.openTab(panel, panelId);
  362. }else{
  363. main.setActiveTab(panel);
  364. }
  365. }
  366. },
  367. openTab : function (panel,id){
  368. var o = (typeof panel == "string" ? panel : id || panel.id);
  369. var main = parent.Ext.getCmp("content-panel");
  370. /*var tab = main.getComponent(o); */
  371. if(!main) {
  372. main =parent.parent.Ext.getCmp("content-panel");
  373. }
  374. var tab = main.getComponent(o);
  375. if (tab) {
  376. main.setActiveTab(tab);
  377. } else if(typeof panel!="string"){
  378. panel.id = o;
  379. var p = main.add(panel);
  380. main.setActiveTab(p);
  381. }
  382. }
  383. // getCurrentStore: function(value){
  384. // var grid = Ext.getCmp('cmdetailgrid');
  385. // var items = grid.store.data.items;
  386. // var array = new Array();
  387. // var o = null;
  388. // Ext.each(items, function(item, index){
  389. // o = new Object();
  390. // o.selected = false;
  391. // if(index == 0){
  392. // o.prev = null;
  393. // } else {
  394. // o.prev = items[index-1].data[keyField];
  395. // }
  396. // if(index == items.length - 1){
  397. // o.next = null;
  398. // } else {
  399. // o.next = items[index+1].data[keyField];
  400. // }
  401. // var v = item.data[keyField];
  402. // o.value = v;
  403. // if(v == value)
  404. // o.selected = true;
  405. // array.push(o);
  406. // });
  407. // return array;
  408. // }
  409. });