OrgTreePanel.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. Ext.define('erp.view.oa.doc.OrgTreePanel', {
  2. extend: 'Ext.tree.Panel',
  3. xtype: 'erpOrgTreePanel',
  4. id:'orgtree',
  5. lines:true,
  6. rootVisible: false,
  7. containerScroll : true,
  8. autoScroll: false,
  9. useArrows: true,
  10. split:true,
  11. closeAction:'destroy',
  12. border : false,
  13. enableDD : false,
  14. FormUtil:Ext.create('erp.util.FormUtil'),
  15. store: Ext.create('Ext.data.TreeStore', {
  16. root : {
  17. text: 'root',
  18. id: 'root',
  19. expanded: true
  20. }
  21. }),
  22. initComponent : function(){
  23. this.callParent(arguments);
  24. this.getTreeRootNode(this);
  25. },
  26. listeners:{
  27. itemmousedown: function(selModel, record){
  28. var tree=selModel.ownerCt;
  29. if(! tree.itemselector) tree.itemselector=Ext.getCmp('itemselector-field');
  30. var data=new Array();
  31. data.push({
  32. text:'<font color="#D52B2B">[组织]</font>'+record.data.text,
  33. value:'org#'+record.data.id
  34. });
  35. Ext.Array.each(record.raw.otherInfo,function(item){
  36. data.push({
  37. text:'<font color="#C4C43C">[岗位]</font>'+item.jo_name,
  38. value:'job#'+item.jo_id
  39. })
  40. });
  41. Ext.Array.each(record.raw.data,function(item){
  42. data.push({
  43. text:'<font color="#4DB34D">[个人]</font>'+item.em_name,
  44. value:'employee#'+item.em_id
  45. })
  46. });
  47. tree.itemselector.fromField.store.loadData(data);
  48. }
  49. },
  50. getTreeRootNode: function(treepanel){
  51. treepanel.setLoading(true);
  52. treepanel.store.removeAll(true);
  53. Ext.Ajax.request({//拿到tree数据
  54. url : basePath + 'hr/employee/getHrOrgsTreeAndEmployees.action',
  55. callback : function(options,success,response){
  56. var res = new Ext.decode(response.responseText);
  57. treepanel.setLoading(false);
  58. if(res.tree){
  59. var tree = res.tree;
  60. treepanel.store.setRootNode({
  61. text: 'root',
  62. id: 'root',
  63. expanded: true,
  64. children: tree
  65. });
  66. } else if(res.exceptionInfo){
  67. showError(res.exceptionInfo);
  68. }
  69. }
  70. });
  71. },
  72. });