DocumentTreePanel.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. Ext.define('erp.view.oa.doc.DocumentTreePanel', {
  2. extend: 'Ext.tree.Panel',
  3. xtype: 'erpDocumentTreePanel',
  4. /* title: '文档管理',*/
  5. cls: 'doclist',
  6. id:'doctree',
  7. lines:false,
  8. rootVisible: false,
  9. containerScroll : true,
  10. //collapsible : true,
  11. autoScroll: false,
  12. useArrows: true,
  13. store: Ext.create('Ext.data.TreeStore', {
  14. root: {
  15. expanded: true,
  16. children: [{
  17. text: '公共文档',
  18. expanded: false,
  19. iconCls:'x-tree-icon-topFolder',
  20. url:"/公共文档",
  21. id:0
  22. },
  23. {
  24. text: '我的文档',
  25. url:"/我的文档",
  26. expanded: false,
  27. iconCls:'x-tree-icon-myFolder',
  28. id:1
  29. },
  30. {
  31. text: '我的常用文档',
  32. url:"/我的常用文档",
  33. expanded: false,
  34. leaf:true,
  35. iconCls:'x-tree-icon-myfav',
  36. id:2
  37. },
  38. {
  39. text: '借给我的文档',
  40. url:"/借给我的文档",
  41. expanded: false,
  42. leaf:true,
  43. iconCls:'x-tree-icon-mylendings',
  44. id:3
  45. },
  46. {
  47. text: '我借出的文档',
  48. url:"/我借出的文档",
  49. expanded: false,
  50. leaf:true,
  51. iconCls:'x-tree-icon-mylends' ,
  52. id:4
  53. },{
  54. text: '回收站',
  55. url:"/回收站",
  56. expanded: false,
  57. leaf:true,
  58. iconCls:'x-tree-icon-trash',
  59. id:5
  60. }
  61. ]
  62. }
  63. }),
  64. refreshNodeByParentId:function (parentId,tree){
  65. var condition = tree.baseCondition;
  66. var record=tree.getSelectionModel().getSelection()[0];
  67. record.removeAll(true);
  68. var me = this;
  69. Ext.Ajax.request({//拿到tree数据
  70. url : basePath + 'oa/documetlist/loadDir.action',
  71. params: {
  72. parentId: parentId,
  73. condition: condition
  74. },
  75. callback : function(options,success,response){
  76. tree.setLoading(false);
  77. var res = new Ext.decode(response.responseText);
  78. if(res.tree){
  79. if(!record.get('level')) {
  80. record.set('level', 0);
  81. }
  82. Ext.each(res.tree, function(n){
  83. if(n.showMode == 2){//openBlank
  84. n.text = "<a href='" + basePath + me.parseUrl(n.url) + "' target='_blank'>" + n.text + "</a>";
  85. }
  86. if(!n.leaf) {
  87. n.level = record.get('level') + 1;
  88. n.iconCls = 'x-tree-icon-level-' + n.level;
  89. }
  90. });
  91. record.appendChild(res.tree);
  92. record.expand(false,true);//展开
  93. me.flag = true;
  94. } else if(res.exceptionInfo){
  95. showError(res.exceptionInfo);
  96. me.flag = true;
  97. }
  98. }
  99. });
  100. },
  101. reset: function(parentId){
  102. Ext.getCmp('doctree').setRootNode({
  103. expanded: true,
  104. children: [{
  105. text: '公共文档',
  106. expanded: false,
  107. iconCls:'x-tree-icon-topFolder',
  108. url:"/公共文档",
  109. id:0
  110. },
  111. {
  112. text: '我的文档',
  113. url:"/我的文档",
  114. expanded: false,
  115. iconCls:'x-tree-icon-myFolder',
  116. id:1
  117. },
  118. {
  119. text: '我的常用文档',
  120. url:"/我的常用文档",
  121. expanded: false,
  122. leaf:true,
  123. iconCls:'x-tree-icon-myfav',
  124. id:2
  125. },
  126. {
  127. text: '借给我的文档',
  128. url:"/借给我的文档",
  129. expanded: false,
  130. leaf:true,
  131. iconCls:'x-tree-icon-mylendings',
  132. id:3
  133. },
  134. {
  135. text: '我借出的文档',
  136. url:"/我借出的文档",
  137. expanded: false,
  138. leaf:true,
  139. iconCls:'x-tree-icon-mylends' ,
  140. id:4
  141. },{
  142. text: '回收站',
  143. url:"/回收站",
  144. expanded: false,
  145. leaf:true,
  146. iconCls:'x-tree-icon-trash',
  147. id:5
  148. }
  149. ]
  150. });
  151. }
  152. });