Portlet.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. Ext.define('erp.view.common.DeskTop.Portlet', {
  2. extend: 'Ext.panel.Panel',
  3. alias: 'widget.portlet',
  4. layout: 'fit',
  5. anchor: '100%',
  6. frame: true,
  7. animCollapse: true,
  8. draggable: true,
  9. maxCount:50,
  10. cls: 'x-portlet',
  11. defaults:{
  12. cls:'custom-framed'
  13. },
  14. initComponent : function(){
  15. this.callParent(arguments);
  16. if(this.enableTools) {
  17. this.getTools();
  18. }
  19. },
  20. getTools:function(){
  21. var me=this;
  22. this.tools=[{
  23. type:'set',
  24. cls : 'set-tool',
  25. tooltip: '设置',
  26. listeners : {
  27. click : function(t) {
  28. Ext.MessageBox.show({
  29. title: t.ownerCt.title,
  30. msg: '请输入记录数:',
  31. width:200,
  32. buttons: Ext.MessageBox.OKCANCEL,
  33. prompt: true,
  34. value:t.ownerCt.ownerCt.pageCount,
  35. animateTarget:t.getId(),
  36. fn:me.setPageCount,
  37. updateXtype:t.ownerCt.ownerCt.xtype,
  38. sourcePortal:t.ownerCt.ownerCt
  39. });
  40. }
  41. }
  42. },{
  43. type:'more',
  44. cls : 'more-tool',
  45. tooltip: '更多',
  46. listeners : {
  47. click : function(t) {
  48. me.getMore();
  49. }
  50. }
  51. }];
  52. },
  53. setPageCount:function(type,c,o){
  54. if(type=='ok'){
  55. if(Ext.isNumeric(c)){
  56. var portal=o.sourcePortal,itemPortal=portal.items.items[0];
  57. if(portal && portal.maxCount>0 && (c>portal.maxCount || c<1 )){
  58. alert('记录数超出限制'); return;
  59. }else {
  60. Ext.Ajax.request({
  61. url:basePath+'/common/desktop/setTotalCount.action',
  62. method:'POST',
  63. params:{
  64. type:o.updateXtype,
  65. count:c
  66. },
  67. callback : function(options, success, response){
  68. var res = response.responseText;
  69. if(res=='success'){
  70. //更新成功
  71. portal.pageCount=c;
  72. if(itemPortal.xtype=='tabpanel'){
  73. var store=itemPortal.getActiveTab().getStore();
  74. var params=store.proxy.extraParams;
  75. Ext.apply(params,{
  76. count: c,
  77. pageSize:c
  78. });
  79. store.load();
  80. }else{
  81. var store=itemPortal.getStore();
  82. var params=store.proxy.extraParams;
  83. Ext.apply(params,{
  84. count: c,
  85. pageSize:c
  86. });
  87. store.load();
  88. }
  89. }
  90. }
  91. });
  92. }
  93. }else alert('请输入正确的数字!');
  94. }
  95. },
  96. getMore:function(){}
  97. });