FlowPanel.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. Ext.define('erp.view.common.main.FlowPanel',{
  2. extend: 'Ext.panel.Panel',
  3. alias: 'widget.erpFlowPanel',
  4. defaults: {
  5. autoScroll:true,
  6. /*bodyPadding: 5,*/
  7. cls: 'my-panel'
  8. },
  9. animCollapse: false,
  10. constrainHeader: true,
  11. bodyBorder: true,
  12. layout: 'accordion',
  13. border: false,
  14. autoShow: true,
  15. collapsible : true,
  16. plain: true,
  17. initComponent : function(){
  18. this.callParent(arguments);
  19. },
  20. listeners:{
  21. activate:function (tab){
  22. var items=tab.getItems(tab);
  23. if(items.length==0){
  24. var title="设置个人流程";
  25. var url="jsps/common/PersonalProcessSet.jsp";
  26. items.push({
  27. title:'查看流程',
  28. frame:true,
  29. html:'<h2>你还没有设置个人导航流程或系统没有定义相应的导航图</br><a style="text-decoration:none;" href="javascript:openTable('+'\''+title+'\',\''+url+'\''+ ');">快去看看吧!</a></h2>'
  30. });
  31. }
  32. if(tab.items.length==0){
  33. tab.add(items);
  34. }else {
  35. tab.removeAll();
  36. tab.add(items);
  37. }
  38. }
  39. },
  40. getItems:function(panel){
  41. var items=new Array();
  42. Ext.Ajax.request({//拿到form的items
  43. url : basePath + 'common/PersonalProcess.action',
  44. method : 'post',
  45. async:false,
  46. callback : function(options, success, response){
  47. var res = new Ext.decode(response.responseText);
  48. if(res.exceptionInfo != null){
  49. showError(res.exceptionInfo);return;
  50. }
  51. var bool=res.data.length>5?true:false;
  52. var arr= [{
  53. type: 'search',
  54. tooltip:'添加导航图',
  55. handler:function(){
  56. Ext.create('erp.util.BaseUtil').onAdd('PersonalProcessSet','个人流程设置','jsps/common/PersonalProcessSet.jsp');
  57. }
  58. },{
  59. type:'refresh',
  60. tooltip: '刷新导航图',
  61. handler:function(){
  62. panel.fireEvent('activate',panel);
  63. }
  64. }];
  65. if(bool){
  66. arr.push({
  67. type:'expand',
  68. tooltip: '更多导航图',
  69. handler:function(){
  70. if(!Ext.getCmp('moreflow-win')){
  71. Ext.create('Ext.window.Window', {
  72. id: 'moreflow-win',
  73. title: '更多导航图',
  74. height: screen.height*0.8,
  75. width: screen.width*0.2,
  76. renderTo: Ext.getBody(),
  77. animCollapse: false,
  78. constrainHeader: true,
  79. bodyBorder: true,
  80. layout: 'accordion',
  81. border: false,
  82. autoShow: true,
  83. collapsible : true,
  84. x: 0,
  85. items:panel.getMoreItems(res.data)
  86. });
  87. } else {
  88. Ext.getCmp('moreflow-win').show();
  89. }
  90. }
  91. });
  92. }
  93. Ext.Array.each(res.data,function(item,index){
  94. if(index>4) return;
  95. var url='workfloweditor/flownavigationonlyeditor.jsp?jdId='+item.id;
  96. var tag=new Object();
  97. if(index==0){
  98. tag={
  99. xtype:'panel',
  100. title : item.name,
  101. border : false,
  102. tools:arr,
  103. html : '<iframe id="iframe_jprocess_' + item.id + '" src="' + basePath + url + '" height="100%" width="100%" frameborder="0" style="border-width: 0px;padding: 0px;" scrolling="auto"></iframe>',
  104. listeners:{
  105. expand:function(p,opts){
  106. if(p.body.dom.firstChild==null){
  107. p.body.insertHtml('afterBegin','<iframe id="iframe_jprocess_' + item.id + '" src="' + basePath + url + '" height="100%" width="100%" frameborder="0" style="border-width: 0px;padding: 0px;" scrolling="auto"></iframe>',false ) ;
  108. }
  109. }
  110. }
  111. };
  112. }else {
  113. tag={
  114. xtype:'panel',
  115. title : item.name,
  116. listeners:{
  117. expand:function(p,opts){
  118. if(p.body.dom.firstChild==null){
  119. p.body.insertHtml('afterBegin','<iframe id="iframe_jprocess_' + item.id + '" src="' + basePath + url + '" height="100%" width="100%" frameborder="0" style="border-width: 0px;padding: 0px;" scrolling="auto"></iframe>',false ) ;
  120. }
  121. }
  122. }
  123. };
  124. }
  125. items.push(tag);
  126. });
  127. }
  128. });
  129. return items;
  130. },
  131. getMoreItems:function(items){
  132. var moreitems=new Array();
  133. Ext.Array.each(items,function(item,index){
  134. var tag=new Object();
  135. var url='workfloweditor/flownavigationonlyeditor.jsp?jdId='+item.id;
  136. if(index>4){
  137. if(index==5){
  138. tag={
  139. xtype:'panel',
  140. title : item.name,
  141. border : false,
  142. html : '<iframe id="iframe_jprocess_' + item.id + '" src="' + basePath + url + '" height="100%" width="100%" frameborder="0" style="border-width: 0px;padding: 0px;" scrolling="auto"></iframe>',
  143. listeners:{
  144. expand:function(p,opts){
  145. if(p.body.dom.firstChild==null){
  146. p.body.insertHtml('afterBegin','<iframe id="iframe_jprocess_' + item.id + '" src="' + basePath + url + '" height="100%" width="100%" frameborder="0" style="border-width: 0px;padding: 0px;" scrolling="auto"></iframe>',false ) ;
  147. }
  148. }
  149. }
  150. };
  151. }else if(index>5){
  152. tag={
  153. xtype:'panel',
  154. title : item.name,
  155. listeners:{
  156. expand:function(p,opts){
  157. if(p.body.dom.firstChild==null){
  158. p.body.insertHtml('afterBegin','<iframe id="iframe_jprocess_' + item.id + '" src="' + basePath + url + '" height="100%" width="100%" frameborder="0" style="border-width: 0px;padding: 0px;" scrolling="auto"></iframe>',false ) ;
  159. }
  160. }
  161. }
  162. };
  163. }
  164. moreitems.push(tag);
  165. }
  166. });
  167. return moreitems;
  168. }
  169. });