EmployeeTreePanel.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. Ext.define('erp.view.oa.attention.EmployeeTreePanel',{
  2. extend: 'Ext.tree.Panel',
  3. alias: 'widget.erpEmployeeTreePanel',
  4. BaseUtil: Ext.create('erp.util.BaseUtil'),
  5. id: 'EmployeeTree',
  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/getEmployee.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. Ext.Array.each(tree, function(tr) {
  52. tr.cls="x-tree-cls-node";
  53. tr.leaf=true;
  54. if(tr.id==0){
  55. tr.selected=true;
  56. }
  57. });
  58. me.store.setRootNode({
  59. text: 'root',
  60. id: 'root',
  61. expanded: true,
  62. children: tree
  63. });
  64. } else if(res.exceptionInfo){
  65. showError(res.exceptionInfo);
  66. }
  67. }
  68. });
  69. },
  70. listeners: {
  71. scrollershow: function(scroller) {
  72. if (scroller && scroller.scrollEl) {
  73. scroller.clearManagedListeners();
  74. scroller.mon(scroller.scrollEl, 'scroll', scroller.onElScroll, scroller);
  75. }
  76. }
  77. }
  78. });