GridPanel.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. Ext.define('erp.view.data.GridPanel',{
  2. extend: 'Ext.grid.Panel',
  3. alias: 'widget.erpGridPanel',
  4. // id: 'grid',
  5. emptyText : '无数据',
  6. columnLines : true,
  7. autoScroll : true,
  8. FormUtil: Ext.create('erp.util.FormUtil'),
  9. GridUtil: Ext.create('erp.util.GridUtil'),
  10. plugins: [Ext.create('Ext.ux.grid.GridHeaderFilters')],
  11. BaseUtil: Ext.create('erp.util.BaseUtil'),
  12. store: Ext.create('Ext.data.Store', {
  13. fields: [{
  14. name:'table_name',
  15. type:'string'
  16. }]
  17. }),
  18. iconCls: 'icon-grid',
  19. frame: true,
  20. bodyStyle:'background-color:#f1f1f1;',
  21. features: [Ext.create('Ext.grid.feature.Grouping',{
  22. groupHeaderTpl: '{name} ({rows.length} 封)'
  23. })],
  24. selModel: Ext.create('Ext.selection.CheckboxModel',{
  25. }),
  26. // dockedItems: [{
  27. // id : 'paging',
  28. // xtype: 'erpMailPaging',
  29. // dock: 'bottom',
  30. // displayInfo: true
  31. // }],
  32. columns: [{
  33. text: '表名',
  34. width: 160,
  35. dataIndex: 'table_name'
  36. }],
  37. tbar: [{
  38. iconCls: 'x-button-icon-add',
  39. text: '添加数据字典',
  40. handler: function(btn){
  41. var me = btn.ownerCt.ownerCt;
  42. console.log(me);
  43. var selectItem = Ext.getCmp('grid1').selModel.selected.items;
  44. if (selectItem.length == 0 || selectItem.length > 3) {
  45. showError("请先选中要添加的表,并且每次不要打开过多(最多3个),想要同时处理更多请选择批量添加");return;
  46. } else {
  47. console.log(selectItem);
  48. Ext.each(selectItem, function(item, index){
  49. var tablename = item.data.table_name;
  50. var panel = Ext.getCmp("datadictionary_"+tablename);
  51. var main = parent.Ext.getCmp("content-panel");
  52. if(!panel){
  53. var title = "添加数据字典(" + tablename + ")";
  54. panel = {
  55. title : title,
  56. tag : 'iframe',
  57. tabConfig:{tooltip: title},
  58. frame : true,
  59. border : false,
  60. layout : 'fit',
  61. iconCls : 'x-tree-icon-tab-tab1',
  62. html : '<iframe id="iframe_' + tablename + '" src="' + basePath + 'jsps/ma/dataDictionary.jsp?tablename=' + tablename + '" height="100%" width="100%" frameborder="0" scrolling="yes"></iframe>',
  63. closable : true,
  64. listeners : {
  65. close : function(){
  66. main.setActiveTab(main.getActiveTab().id);
  67. }
  68. }
  69. };
  70. me.FormUtil.openTab(panel, "datadictionary_"+tablename);
  71. }else{
  72. main.setActiveTab(panel);
  73. }
  74. });
  75. }
  76. }
  77. },{
  78. iconCls: 'x-button-icon-add',
  79. text: '批量添加',
  80. id: 'print',
  81. handler: function(btn){
  82. }
  83. },{
  84. iconCls: 'x-button-icon-add',
  85. text: '刷新',
  86. id: 'refresh1',
  87. handler: function(btn){
  88. var me = btn.ownerCt.ownerCt;
  89. var url = "common/dataDD.action";
  90. me.FormUtil.getActiveTab().setLoading(true);
  91. Ext.Ajax.request({//拿到form的items
  92. url : basePath + url,
  93. params: {
  94. em_uu:em_uu
  95. },
  96. method : 'post',
  97. callback : function(options,success,response){
  98. me.FormUtil.getActiveTab().setLoading(false);
  99. var res = new Ext.decode(response.responseText);
  100. if(res.exceptionInfo != null){
  101. showError(res.exceptionInfo);return;
  102. }
  103. console.log(res);
  104. if(res.success){
  105. var grid = Ext.getCmp('grid1');
  106. grid.getStore().removeAll();
  107. if(res.list.length>0){//数据字典中缺省的表
  108. Ext.each(res.list,function(dc, index){
  109. grid.getStore().insert(index, {'table_name': dc.table_name});
  110. });
  111. console.log(grid.title);
  112. console.log(grid.title.split(' (')[0]);
  113. grid.setTitle(grid.title.split(' (')[0] + ' (' + res.list.length + ')');
  114. }
  115. }
  116. }
  117. });
  118. }
  119. }],
  120. initComponent : function(){
  121. this.callParent(arguments);
  122. },
  123. listeners: {//滚动条有时候没反应,添加此监听器
  124. scrollershow: function(scroller) {
  125. if (scroller && scroller.scrollEl) {
  126. scroller.clearManagedListeners();
  127. scroller.mon(scroller.scrollEl, 'scroll', scroller.onElScroll, scroller);
  128. }
  129. }
  130. }
  131. });