ShowVmCopDetail.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.fa.arp.ShowVmCopDetail', {
  3. extend: 'Ext.app.Controller',
  4. BaseUtil: Ext.create('erp.util.BaseUtil'),
  5. views: ['core.trigger.DbfindTrigger', 'fa.arp.vmCopQuery.VmDetailGrid', 'fa.arp.vmCopQuery.ShowVmDetail', 'core.form.MonthDateField',
  6. 'core.form.ConMonthDateField', 'core.form.YearDateField'],
  7. init:function(){
  8. var me = this;
  9. this.control({
  10. 'vmdetailgrid':{
  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('vmcopdetailgrid');
  23. me.BaseUtil.exportGrid(grid, '应付总账明细'+'-'+yearmonth+'-'+vendname+'-'+currency+'_'+cop,' 公司:'+cop+' 供应商名称:'+vendname+' 币别:'+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: 'showapmsg',
  56. name: 'showapmsg',
  57. checked:true,
  58. columnWidth: .71,
  59. boxLabel: '显示应付发票信息'
  60. },{
  61. xtype: 'checkbox',
  62. id: 'showotapmsg',
  63. name: 'showotapmsg',
  64. checked:true,
  65. columnWidth: .71,
  66. boxLabel: '显示其它应付信息'
  67. },{
  68. xtype: 'checkbox',
  69. id: 'showpbmsg',
  70. name: 'showpbmsg',
  71. checked:true,
  72. columnWidth: .71,
  73. boxLabel: '显示付款单信息'
  74. },{
  75. xtype: 'checkbox',
  76. id: 'showprepaymsg',
  77. name: 'showprepaymsg',
  78. checked:true,
  79. columnWidth: .71,
  80. boxLabel: '显示预付账款信息'
  81. },{
  82. xtype: 'checkbox',
  83. id: 'showesmsg',
  84. name: 'showesmsg',
  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 showApDetailVal = Ext.getCmp('showdemsg').getValue();
  102. var grid = Ext.getCmp('vmcopdetailgrid');
  103. var fl = btn.ownerCt.ownerCt;
  104. var con = me.getConfig(fl);
  105. if(showApDetailVal){
  106. grid.columns = grid.detailColumns;
  107. me.getConditionDetail(con,'fa/arp/VmQueryController/getVmCopDetailByIdDetail.action');
  108. }else{
  109. grid.columns = grid.defaultColumns;
  110. me.getConditionDetail(con,'fa/arp/VmQueryController/getVmCopDetailById.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. 'vmid':vmid,
  147. 'yearmonth':yearmonth,
  148. 'currency':currency,
  149. 'vendcode':vendcode,
  150. 'cop':cop,
  151. 'chkumio':chkumio,
  152. 'config':{
  153. 'showapmsg':true,
  154. 'showotapmsg':true,
  155. 'showpbmsg':true,
  156. 'showesmsg':true,
  157. 'showprepaymsg':true
  158. }
  159. };
  160. me.query(cond);
  161. },
  162. query: function(cond) {
  163. var grid = Ext.getCmp('vmcopdetailgrid');
  164. grid.setLoading(true);
  165. Ext.Ajax.request({
  166. url: basePath + 'fa/arp/VmQueryController/getVmCopDetailById.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. 'vmid':vmid,
  184. 'yearmonth':yearmonth,
  185. 'currency':currency,
  186. 'cop':cop,
  187. 'vendcode':vendcode,
  188. 'chkumio':chkumio,
  189. 'config':config
  190. };
  191. me.queryDetail(cond,url);
  192. },
  193. queryDetail: function(cond,url) {
  194. var grid = Ext.getCmp('vmcopdetailgrid');
  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. // grid.store.loadData(res.data);
  205. var store = Ext.create('Ext.data.Store', {
  206. fields:[{
  207. name: 'tb_code',
  208. type: 'string'
  209. },{
  210. name: 'tb_kind',
  211. type: 'string'
  212. },{
  213. name: 'tb_remark',
  214. type: 'string'
  215. },{
  216. name: 'tb_date',
  217. type: 'string'
  218. },{
  219. name: 'tb_apamount',
  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_pbamount',
  241. type: 'string'
  242. },{
  243. name: 'tb_balance',
  244. type: 'string'
  245. },{
  246. name: 'tb_index',
  247. type: 'number'
  248. },{
  249. name: 'tb_id',
  250. type:'number'
  251. }],
  252. data: res.data
  253. });
  254. grid.reconfigure(store,grid.columns);
  255. }
  256. grid.setLoading(false);
  257. }
  258. });
  259. },
  260. onGridItemClick:function(selModel, record){
  261. var value = Number(record.data['tb_id']);
  262. var me = this;
  263. if(value>0){
  264. var url='';
  265. var keyField ='';
  266. var caller = '';
  267. var pfField = '';
  268. if(record.data['tb_kind']=='应付发票'){
  269. url ='jsps/fa/ars/apbill.jsp?whoami=APBill!CWIM';
  270. keyField = 'ab_id';
  271. pfField = 'abd_abid';
  272. caller = 'APBill!CWIM';
  273. }else if(record.data['tb_kind']=='付款单'){
  274. url ='jsps/fa/arp/paybalance.jsp?whoami=PayBalance';
  275. keyField = 'pb_id';
  276. pfField = 'pbd_pbid';
  277. caller = 'PayBalance';
  278. }else if(record.data['tb_kind']=='冲应付款'){
  279. url ='jsps/fa/arp/paybalance.jsp?whoami=PayBalance!CAID';
  280. keyField = 'pb_id';
  281. pfField = 'pbd_pbid';
  282. caller = 'PayBalance';
  283. }else if(record.data['tb_kind']=='其它应付单'){
  284. url ='jsps/fa/ars/apbill.jsp?whoami=APBill!OTDW';
  285. keyField = 'ab_id';
  286. pfField = 'abd_abid';
  287. caller = 'APBill!OTDW';
  288. }else if(record.data['tb_kind']=='应付暂估'){
  289. url ='jsps/fa/arp/estimate.jsp';
  290. keyField = 'es_id';
  291. pfField = 'esd_esid';
  292. caller = 'Estimate';
  293. }else if(record.data['tb_kind']=='采购验收单'){
  294. url ='jsps/scm/reserve/prodInOut.jsp?whoami=ProdInOut!PurcCheckin';
  295. keyField = 'pi_id';
  296. pfField = 'pd_piid';
  297. caller = 'ProdInOut!PurcCheckin';
  298. }else if(record.data['tb_kind']=='委外验收单'){
  299. url ='jsps/scm/reserve/prodInOut.jsp?whoami=ProdInOut!OutsideCheckIn';
  300. keyField = 'pi_id';
  301. pfField = 'pd_piid';
  302. caller = 'ProdInOut!OutsideCheckIn';
  303. }else if(record.data['tb_kind']=='采购验退单'){
  304. url ='jsps/scm/reserve/prodInOut.jsp?whoami=ProdInOut!PurcCheckout';
  305. keyField = 'pi_id';
  306. pfField = 'pd_piid';
  307. caller = 'ProdInOut!PurcCheckout';
  308. }else if(record.data['tb_kind']=='委外验退单'){
  309. url ='jsps/scm/reserve/prodInOut.jsp?whoami=ProdInOut!OutesideCheckReturn';
  310. keyField = 'pi_id';
  311. pfField = 'pd_piid';
  312. caller = 'ProdInOut!OutesideCheckReturn';
  313. }else if(record.data['tb_kind']=='预付款'){
  314. url ='jsps/fa/arp/prepay.jsp?whoami=PrePay!Arp!PAMT';
  315. keyField = 'pp_id';
  316. pfField = 'ppd_ppid';
  317. caller = 'PrePay!Arp!PAMT';
  318. }else if(record.data['tb_kind']=='预付冲应付'){
  319. url ='jsps/fa/arp/payBalancePRDetail.jsp?whoami=PayBalance!Arp!PADW';
  320. keyField = 'pb_id';
  321. pfField = 'pbd_pbid';
  322. caller = 'PayBalance!Arp!PADW';
  323. }
  324. var formCondition = keyField + "IS" + value ;
  325. var gridCondition = pfField + "IS" + value;
  326. var panelId = caller + keyField + "_" + value + gridCondition;
  327. var panel = Ext.getCmp(panelId);
  328. var main = parent.Ext.getCmp("content-panel");
  329. if(!main){
  330. main = parent.parent.Ext.getCmp("content-panel");
  331. }
  332. if(!panel){
  333. var title = "";
  334. if (value.toString().length>4) {
  335. title = value.toString().substring(value.toString().length-4);
  336. } else {
  337. title = value;
  338. }
  339. var myurl = '';
  340. if(me.BaseUtil.contains(url, '?', true)){
  341. myurl = url + '&formCondition='+formCondition+'&gridCondition='+gridCondition;
  342. } else {
  343. myurl = url + '?formCondition='+formCondition+'&gridCondition='+gridCondition;
  344. }
  345. myurl += "&datalistId=" + main.getActiveTab().id;
  346. panel = {
  347. title :record.data['tb_kind']+'('+title+')',
  348. tag : 'iframe',
  349. tabConfig:{tooltip:me.BaseUtil.getActiveTab().tabConfig.tooltip+'('+keyField + "=" + value+')'},
  350. frame : true,
  351. border : false,
  352. layout : 'fit',
  353. iconCls : 'x-tree-icon-query',
  354. html : '<iframe id="iframe_maindetail_'+caller+"_"+value+'" src="' + myurl + '" height="100%" width="100%" frameborder="0" style="border-width: 0px;padding: 0px;" scrolling="auto"></iframe>',
  355. closable : true,
  356. listeners : {
  357. close : function(){
  358. if(!main){
  359. main = parent.parent.Ext.getCmp("content-panel");
  360. }
  361. main.setActiveTab(main.getActiveTab().id);
  362. }
  363. }
  364. };
  365. this.openTab(panel, panelId);
  366. }else{
  367. main.setActiveTab(panel);
  368. }
  369. }
  370. },
  371. openTab : function (panel,id){
  372. var o = (typeof panel == "string" ? panel : id || panel.id);
  373. var main = parent.Ext.getCmp("content-panel");
  374. /*var tab = main.getComponent(o); */
  375. if(!main) {
  376. main =parent.parent.Ext.getCmp("content-panel");
  377. }
  378. var tab = main.getComponent(o);
  379. if (tab) {
  380. main.setActiveTab(tab);
  381. } else if(typeof panel!="string"){
  382. panel.id = o;
  383. var p = main.add(panel);
  384. main.setActiveTab(p);
  385. }
  386. }
  387. });