JprocessClassify.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.common.JprocessClassify', {
  3. extend: 'Ext.app.Controller',
  4. views:[
  5. 'common.JProcessDeploy.JprocessClassify','core.grid.Panel2','core.grid.Panel2','core.grid.YnColumn','core.button.DeleteDetail'
  6. ],
  7. GridUtil: Ext.create('erp.util.GridUtil'),
  8. init:function(){
  9. var me = this;
  10. this.control({
  11. 'erpExportDetailButton':{
  12. afterrender:function(btn){
  13. btn.ownerCt.add({
  14. xtype:'combo',
  15. fieldLabel:'移动到',
  16. disabled:true,
  17. labelSeparator :'',
  18. labelAlign:'right',
  19. style:'margin-left:10px;margin-top:10px',
  20. fieldStyle:"background:#FFFAFA;color:#515151; height:20px",
  21. labelStyle:'font-size:14px',
  22. id:'moveto',
  23. queryMode :'local',
  24. displayField:'display',
  25. valueField :'value',
  26. listeners:{
  27. select :function(combo){
  28. var grid=Ext.getCmp('grid');
  29. var params=grid.getMultiSelected();
  30. params.id=combo.value;
  31. var main = parent.Ext.getCmp("content-panel");
  32. main.getActiveTab().setLoading(true);//loading...
  33. Ext.Ajax.request({
  34. url : basePath + 'common/removeToOtherClassify.action',
  35. params: params,
  36. method : 'post',
  37. callback : function(options,success,response){
  38. main.getActiveTab().setLoading(false);
  39. var localJson = new Ext.decode(response.responseText);
  40. if(localJson.exceptionInfo){
  41. showError(localJson.exceptionInfo);
  42. return "";
  43. }
  44. if(localJson.success){
  45. if(localJson.log){
  46. showMessage("提示", localJson.log);
  47. }
  48. Ext.getCmp('moveto').reset();
  49. Ext.getCmp('moveto').setDisabled(true);
  50. Ext.Msg.alert("提示", "移动成功!", function(){
  51. grid.multiselected = new Array();
  52. me.GridUtil.loadNewStore(grid,{caller:caller,condition:'1=1'});
  53. });
  54. }
  55. }
  56. });
  57. }
  58. },
  59. onTriggerClick:function(){
  60. var me = this;
  61. var data=new Array();
  62. var o=null;
  63. Ext.Ajax.request({
  64. url : basePath + 'common/getAllJProClassify.action',
  65. async: false,
  66. method : 'post',
  67. callback : function(options,success,response){
  68. var res = new Ext.decode(response.responseText);
  69. if(res.exceptionInfo){
  70. showError(res.exceptionInfo);return;
  71. }else {
  72. Ext.Array.each(res.data, function(tr) {
  73. if(tr){
  74. o=new Object();
  75. o.display=tr[1];
  76. o.value=tr[0];
  77. data.push(o);
  78. }
  79. });
  80. }
  81. }
  82. });
  83. this.getStore().loadData(data);
  84. Ext.create('Ext.data.Store', {
  85. fields: ['display', 'value'],
  86. data :data
  87. });
  88. if (!me.readOnly && !me.disabled) {
  89. if (me.isExpanded) {
  90. me.collapse();
  91. } else {
  92. me.expand();
  93. }
  94. me.inputEl.focus();
  95. }
  96. }
  97. });
  98. }
  99. }
  100. });
  101. },
  102. loadNode: function(selModel, record){
  103. var me = this;
  104. if (!record.get('leaf')) {
  105. if(record.isExpanded() && record.childNodes.length > 0){//是根节点,且已展开
  106. record.collapse(true,true);//收拢
  107. me.flag = true;
  108. } else {//未展开
  109. //看是否加载了其children
  110. if(record.childNodes.length == 0){
  111. //从后台加载
  112. var activeTab = me.getActiveTab();
  113. activeTab.setLoading(true);
  114. Ext.Ajax.request({//拿到tree数据
  115. url : basePath + 'common/getLazyJProcessDeploy.action',
  116. params: {
  117. parentId: record.data['id']
  118. },
  119. callback : function(options,success,response){
  120. activeTab.setLoading(false);
  121. var res = new Ext.decode(response.responseText);
  122. if(res.tree){
  123. var tree = res.tree;
  124. Ext.each(tree, function(t){
  125. t.jd_selfId = t.id;
  126. t.jd_parentId = t.parentId;
  127. t.jd_classifiedName = t.text;
  128. // t.sn_isleaf = t.leaf;
  129. t.jd_caller = t.creator;
  130. t.jd_formUrl = t.url;
  131. t.jd_processDefinitionId = t.qtitle;
  132. t.jd_enabled = t.using;
  133. t.jd_processDefinitionName = t.version;
  134. t.dirty = false;
  135. });
  136. record.appendChild(res.tree);
  137. record.expand(false,true);//展开
  138. Ext.each(record.childNodes, function(){
  139. this.dirty = false;
  140. });
  141. } else if(res.exceptionInfo){
  142. showError(res.exceptionInfo);
  143. }
  144. }
  145. });
  146. } else {
  147. record.expand(false,true);//展开
  148. }
  149. }
  150. }
  151. },
  152. getActiveTab: function(){
  153. var tab = null;
  154. if(Ext.getCmp("content-panel")){
  155. tab = Ext.getCmp("content-panel").getActiveTab();
  156. }
  157. if(!tab){
  158. var win = parent.Ext.ComponentQuery.query('window');
  159. if(win.length > 0){
  160. tab = win[win.length-1];
  161. }
  162. }
  163. if(!tab && parent.Ext.getCmp("content-panel"))
  164. tab = parent.Ext.getCmp("content-panel").getActiveTab();
  165. if(!tab && parent.parent.Ext.getCmp("content-panel"))
  166. tab = parent.parent.Ext.getCmp("content-panel").getActiveTab();
  167. return tab;
  168. }
  169. });