AddrBook.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. root : {
  33. text: 'root',
  34. id: 'root',
  35. expanded: true
  36. }
  37. }),
  38. tools: [{
  39. id: 'gear',
  40. type: 'gear',
  41. tooltip: '修改联系人设置',
  42. handler: function(){
  43. }
  44. } , {
  45. id: 'refresh',
  46. type: 'refresh',
  47. tooltip: '刷新',
  48. handler: function(){
  49. }
  50. } , {
  51. id: 'search',
  52. type: 'search',
  53. tooltip: '查找',
  54. handler: function(){
  55. }
  56. }],
  57. initComponent : function(){
  58. this.getTreeRootNode();
  59. this.callParent(arguments);
  60. },
  61. getTreeRootNode: function(){
  62. Ext.Ajax.request({//拿到tree数据
  63. url : basePath + 'common/addrbook.action',
  64. callback : function(options,success,response){
  65. var res = new Ext.decode(response.responseText);
  66. if(res.tree){
  67. var tree = res.tree;
  68. Ext.getCmp('addrbook').store.setRootNode({
  69. text: 'root',
  70. id: 'root',
  71. expanded: true,
  72. children: tree
  73. });
  74. } else if(res.exceptionInfo){
  75. showError(res.exceptionInfo);
  76. }
  77. }
  78. });
  79. },
  80. listeners: {//滚动条有时候没反应,添加此监听器
  81. scrollershow: function(scroller) {
  82. if (scroller && scroller.scrollEl) {
  83. scroller.clearManagedListeners();
  84. scroller.mon(scroller.scrollEl, 'scroll', scroller.onElScroll, scroller);
  85. }
  86. }
  87. }
  88. });