AddrBook.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /**
  2. * 企业联系人tree
  3. */
  4. Ext.define('erp.view.core.tree.AddrBook',{
  5. extend: 'Ext.tree.Panel',
  6. alias: 'widget.addrbook',
  7. id: 'addrbook',
  8. margins : '0 0 -1 1',
  9. border : false,
  10. enableDD : false,
  11. split: true,
  12. width : '20%',
  13. region: 'east',
  14. title: "<font color=#a1a1a1; size=2>企业联系人</font>",
  15. toggleCollapse: function() {
  16. if (this.collapsed) {
  17. this.expand(this.animCollapse);
  18. } else {
  19. this.title = "企业联系人";
  20. this.collapse(this.collapseDirection, this.animCollapse);
  21. }
  22. return this;
  23. },
  24. rootVisible: false,
  25. singleExpand: true,
  26. containerScroll : true,
  27. collapsible : true,
  28. autoScroll: false,
  29. useArrows: true,
  30. bodyStyle:'background-color:#f1f1f1;',
  31. store: Ext.create('Ext.data.TreeStore', {
  32. remoteSort: true,
  33. root : {
  34. text: 'root',
  35. id: 'root',
  36. expanded: true
  37. }
  38. }),
  39. tools: [{
  40. id: 'gear',
  41. type: 'gear',
  42. tooltip: '修改联系人设置',
  43. handler: function(){
  44. }
  45. } , {
  46. id: 'refresh',
  47. type: 'refresh',
  48. tooltip: '刷新',
  49. handler: function(){
  50. }
  51. } , {
  52. id: 'search',
  53. type: 'search',
  54. tooltip: '查找',
  55. handler: function(){
  56. }
  57. }],
  58. initComponent : function(){
  59. this.getTreeRootNode();
  60. this.callParent(arguments);
  61. },
  62. getTreeRootNode: function(){
  63. var me = this;
  64. Ext.Ajax.request({//拿到tree数据
  65. url : basePath + 'common/addrbook.action',
  66. callback : function(options,success,response){
  67. var res = new Ext.decode(response.responseText);
  68. if(res.tree){
  69. var tree = res.tree;
  70. me.store.setRootNode({
  71. text: 'root',
  72. id: 'root',
  73. expanded: true,
  74. children: tree
  75. });
  76. } else if(res.exceptionInfo){
  77. showError(res.exceptionInfo);
  78. }
  79. }
  80. });
  81. },
  82. listeners: {//滚动条有时候没反应,添加此监听器
  83. scrollershow: function(scroller) {
  84. if (scroller && scroller.scrollEl) {
  85. scroller.clearManagedListeners();
  86. scroller.mon(scroller.scrollEl, 'scroll', scroller.onElScroll, scroller);
  87. }
  88. }
  89. }
  90. });