MoreSubs.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.common.MoreSubs', {
  3. extend : 'Ext.app.Controller',
  4. requires : ['erp.util.BaseUtil', 'erp.util.FormUtil', 'erp.util.RenderUtil'],
  5. views : ['common.DeskTop.MoreSubs', 'common.datalist.GridPanel',
  6. 'common.datalist.Toolbar', 'core.grid.TfColumn',
  7. 'core.grid.YnColumn','core.grid.HeaderFilter','common.DeskTop.DeskTabPanel'],
  8. init : function() {
  9. var me = this;
  10. this.BaseUtil = Ext.create('erp.util.BaseUtil');
  11. this.FormUtil = Ext.create('erp.util.FormUtil');
  12. this.GridUtil = Ext.create('erp.util.GridUtil');
  13. this.control({
  14. 'erpDatalistGridPanel' : {
  15. itemclick: this.onGridItemClick
  16. }
  17. });
  18. },
  19. onGridItemClick: function(selModel, record){
  20. this.showWin(record.data.num_id_,record.data.instance_id_,record.data.id_,record.data.title_,'Subs');
  21. },
  22. showWin :function (numId,mainId,insId,title,id){
  23. var me=this;
  24. var url='common/charts/mobileCharts.action?numId='+numId+'&mainId='+mainId+'&insId='+insId+'&title='+title;
  25. if (Ext.getCmp('chwin')) {
  26. Ext.getCmp('chwin').setTitle(title);
  27. Ext.getCmp('chwin').insId=insId;
  28. Ext.getCmp('chwin').body.update('<iframe id="iframech" src="'+basePath+url+'" height="100%" width="100%" frameborder="0" scrolling="auto" ></iframe>');
  29. }
  30. else {
  31. var chwin = new Ext.window.Window({
  32. id : 'chwin',
  33. title: title,
  34. height: "100%",
  35. width: "80%",
  36. insId:insId,
  37. resizable:false,
  38. modal:true,
  39. buttonAlign : 'center',
  40. layout : 'anchor',
  41. items: [{
  42. tag : 'iframe',
  43. frame : true,
  44. anchor : '100% 100%',
  45. layout : 'fit',
  46. html : '<iframe id="iframech" src="'+basePath+url+'" height="100%" width="100%" frameborder="0" scrolling="auto" ></iframe>'
  47. }],
  48. buttons : [{
  49. text : '上一条',
  50. cls: 'x-btn-gray',
  51. handler : function(btn){
  52. me.prev(btn,id,btn.ownerCt.ownerCt.insId);
  53. }
  54. },{
  55. text : '下一条',
  56. cls: 'x-btn-gray',
  57. handler : function(btn){
  58. me.next(btn,id,btn.ownerCt.ownerCt.insId);
  59. }
  60. },{
  61. text : '关 闭',
  62. iconCls: 'x-button-icon-close',
  63. cls: 'x-btn-gray',
  64. handler : function(){
  65. Ext.getCmp('chwin').close();
  66. }
  67. }]
  68. });
  69. chwin.show();}},
  70. prev:function(btn,tabId,insId,index){
  71. //递归查找下一条,并取到数据
  72. var grid=Ext.getCmp(tabId);
  73. var record =index?grid.store.getAt(index):grid.store.findRecord('id_', insId, 0, false, false, true);
  74. var fIndex=index||record.index;
  75. if(fIndex-1 >=0){
  76. var d = grid.store.getAt(fIndex - 1);
  77. if(d){
  78. if(d.data['id_']==insId){
  79. this.prev(btn,tabId,insId,d.index);//过滤因合计数据重复显示的记录
  80. }
  81. else {this.showWin(d.data['num_id_'],d.data['instance_id_'],d.data['id_'],d.data['title_'],tabId);}
  82. }}
  83. else alert('暂无上一条数据');//btn.setDisabled(true);
  84. },
  85. next:function(btn,tabId,insId,index){
  86. //递归查找下一条,并取到数据
  87. var grid=Ext.getCmp(tabId);
  88. var record =index?grid.store.getAt(index):grid.store.findRecord('id_', insId, 0, false, false, true);
  89. var fIndex=index||record.index;
  90. if(fIndex+1 < grid.store.data.items.length){
  91. var d = grid.store.getAt(fIndex + 1);
  92. if(d){
  93. if(d.data['id_']==insId){
  94. this.next(btn,tabId,insId,d.index);
  95. }
  96. else {this.showWin(d.data['num_id_'],d.data['instance_id_'],d.data['id_'],d.data['title_'],tabId);}
  97. }}
  98. else alert('暂无下一条数据');//btn.setDisabled(true);
  99. }
  100. });