PersonalAddressTreePanel.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. Ext.define('erp.view.oa.attention.PersonalAddressTreePanel',{
  2. extend: 'Ext.tree.Panel',
  3. alias: 'widget.erpPersonalAddressTreePanel',
  4. BaseUtil: Ext.create('erp.util.BaseUtil'),
  5. id: 'PersonalAddressTree',
  6. margins : '0 0 -1 1',
  7. border : false,
  8. enableDD : false,
  9. split: true,
  10. width : '20%',
  11. region: 'east',
  12. title: "<font color=#a1a1a1; size=3;weight= bold;>个人通讯录</font>",
  13. toggleCollapse: function() {
  14. if (this.collapsed) {
  15. this.title=title;
  16. this.expand(this.animCollapse);
  17. } else{
  18. this.title='个人通讯录';
  19. this.collapse(this.collapseDirection, this.animCollapse);
  20. }
  21. return this;
  22. },
  23. rootVisible: false,
  24. singleExpand: false,
  25. containerScroll : true,
  26. collapsible : true,
  27. autoScroll: false,
  28. useArrows: true,
  29. select:null,
  30. bodyStyle:'background-color:#f0f0f0;',
  31. store: Ext.create('Ext.data.TreeStore', {
  32. root : {
  33. text: 'root',
  34. id: 'root',
  35. expanded: true,
  36. }
  37. }),
  38. initComponent : function(){
  39. this.getTreeRootNode(this);
  40. this.callParent(arguments);
  41. },
  42. getTreeRootNode: function(treepanel){
  43. var me=treepanel;
  44. Ext.Ajax.request({
  45. url : basePath + 'oa/addressbook/getAddressBookGroup.action',
  46. async: false,
  47. callback : function(options,success,response){
  48. var res = new Ext.decode(response.responseText);
  49. if(res.tree){
  50. var tree = res.tree;
  51. if(tree.length<2){
  52. var item=new Object();
  53. item.text='没有添加分组';
  54. item.leaf=true;
  55. item.id=-1;
  56. tree.push(item);
  57. }
  58. Ext.Array.each(tree, function(tr) {
  59. tr.cls="x-tree-cls-node";
  60. });
  61. me.store.setRootNode({
  62. text: 'root',
  63. id: 'root',
  64. expanded: true,
  65. children: tree
  66. });
  67. } else if(res.exceptionInfo){
  68. showError(res.exceptionInfo);
  69. }
  70. }
  71. });
  72. },
  73. listeners: {
  74. scrollershow: function(scroller) {
  75. if (scroller && scroller.scrollEl) {
  76. scroller.clearManagedListeners();
  77. scroller.mon(scroller.scrollEl, 'scroll', scroller.onElScroll, scroller);
  78. }
  79. }
  80. }
  81. });