WdTreePanel.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * 默认班次人员
  3. */
  4. Ext.define('erp.view.hr.attendance.WdTreePanel', {
  5. extend: 'Ext.tree.Panel',
  6. xtype: 'erpWdTreePanel',
  7. lines:true,
  8. rootVisible: false,
  9. containerScroll : true,
  10. autoScroll: false,
  11. useArrows: true,
  12. split:true,
  13. closeAction:'destroy',
  14. border : false,
  15. enableDD : false,
  16. FormUtil:Ext.create('erp.util.FormUtil'),
  17. store: Ext.create('Ext.data.TreeStore', {
  18. root : {
  19. text: 'root',
  20. id: 'root',
  21. expanded: true
  22. }
  23. }),
  24. initComponent : function(){
  25. this.callParent(arguments);
  26. this.getTreeRootNode(this);
  27. },
  28. listeners:{
  29. itemmousedown: function(selModel, record){
  30. var tree=selModel.ownerCt;
  31. if(! tree.itemselector) tree.itemselector=Ext.getCmp('itemselector-field');
  32. var data=new Array();
  33. Ext.Array.each(record.raw.data,function(item){
  34. data.push({
  35. text:item.em_name,
  36. value1:item.em_name,
  37. value:item.em_id+''
  38. })
  39. });
  40. tree.itemselector.fromField.store.loadData(data);
  41. }
  42. },
  43. getTreeRootNode: function(treepanel){
  44. treepanel.setLoading(true);
  45. treepanel.store.removeAll(true);
  46. Ext.Ajax.request({//拿到tree数据
  47. url : basePath + 'hr/attendance/getWdTreeAndEmployees.action',
  48. callback : function(options,success,response){
  49. var res = new Ext.decode(response.responseText);
  50. treepanel.setLoading(false);
  51. if(res.tree){
  52. var tree = res.tree;
  53. treepanel.store.setRootNode({
  54. text: 'root',
  55. id: 'root',
  56. expanded: true,
  57. children: tree
  58. });
  59. } else if(res.exceptionInfo){
  60. showError(res.exceptionInfo);
  61. }
  62. }
  63. });
  64. }
  65. });