LaunchContainer.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. Ext.define('erp.view.common.JProcess.LaunchContainer',{
  2. extend: 'Ext.panel.Panel',
  3. hideBorders: true,
  4. layout:'fit',
  5. alias: 'widget.erpLaunchContainer',
  6. BaseUtil:Ext.create('erp.util.BaseUtil'),
  7. FormUtil:Ext.create('erp.util.FormUtil'),
  8. initComponent : function(){
  9. this.items=this.getItems();
  10. this.callParent(arguments);
  11. },
  12. getItems:function(){
  13. var items=new Array();
  14. var me=this;
  15. this.BaseUtil.getActiveTab().setLoading(true);
  16. Ext.Ajax.request({
  17. url : basePath + "common/getAllProcessInfo.action",
  18. params:{},
  19. method : 'post',
  20. async:false,
  21. callback : function(options,success,response){
  22. Ext.create('erp.util.BaseUtil').getActiveTab().setLoading(false);
  23. var localJson = new Ext.decode(response.responseText);
  24. if(localJson.exceptionInfo){
  25. showError(localJson.exceptionInfo);return;
  26. }
  27. if(localJson.success){
  28. var classify=localJson.classify;
  29. var deploy=localJson.deploy;
  30. if(deploy['0']){
  31. items.push({
  32. xtype:'grid',
  33. title:'未分类流程',
  34. iconCls: 'main-msg',
  35. id:'grid0',
  36. tools: me.getTools(),
  37. height:300,
  38. layout:'fit',
  39. columns:me.getColumns(),
  40. requires: ['erp.view.core.grid.HeaderFilter'],
  41. plugins : [Ext.create('erp.view.core.grid.HeaderFilter')],
  42. store:Ext.create('Ext.data.Store', {
  43. fields :[{name:'jd_id',type:'int'},{name:'jd_processdefinitionname',type:'string'},{name:'js_formurl',type:'string'},{name:'jd_caller',type:'string'},{name:'jd_selfid',type:'int'}],
  44. data:deploy['0']
  45. })
  46. });
  47. }
  48. Ext.Array.each(classify,function(item){
  49. var data=deploy[item.JC_ID]?deploy[item.JC_ID]:[];
  50. if(data.length>0){
  51. items.push({
  52. xtype:'grid',
  53. iconCls: 'main-msg',
  54. title:'<div style="color:green;">'+item.JC_NAME+'</div>',
  55. id:'grid'+item.JC_ID,
  56. tools: me.getTools(),
  57. height:300,
  58. layout:'fit',
  59. columns:me.getColumns(),
  60. requires: ['erp.view.core.grid.HeaderFilter'],
  61. plugins : [Ext.create('erp.view.core.grid.HeaderFilter')],
  62. store:Ext.create('Ext.data.Store', {
  63. fields :[{name:'jd_id',type:'int'},{name:'jd_processdefinitionname',type:'string'},{name:'js_formurl',type:'string'},{name:'jd_caller',type:'string'}],
  64. data:data
  65. })
  66. });
  67. }
  68. });
  69. } else {
  70. delFailure();
  71. }
  72. }
  73. });
  74. return items;
  75. },
  76. getTools: function(){
  77. var me=this;
  78. return [{xtype:'button',
  79. tooltip:'添加流程',
  80. height:15.3,
  81. width:15.3,
  82. hidden:canAdd==1,
  83. menu: [{
  84. iconCls: 'main-msg',
  85. text: '单表',
  86. handler: function(){
  87. if(Ext.getCmp('mainwin')){
  88. Ext.getCmp('mainwin').close();
  89. }
  90. var gridCondition="fd_foid=0";
  91. var win = parent.Ext.create('Ext.window.Window',
  92. {
  93. id : 'singlewin',
  94. height : '90%',
  95. width : '90%',
  96. maximizable : true,
  97. buttonAlign : 'center',
  98. layout : 'anchor',
  99. title:'添加流程',
  100. items : [{
  101. frame : true,
  102. anchor : '100% 100%',
  103. layout : 'fit',
  104. html : '<iframe id="iframe_form" src="'+basePath+'jsps/oa/custom/customform.jsp?_noc=1'+'" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>'
  105. }]
  106. });
  107. win.show();
  108. }
  109. },{
  110. iconCls: 'main-msg',
  111. text: '主从表',
  112. handler:function(){
  113. if(Ext.getCmp('singlewin')){
  114. Ext.getCmp('singlewin').close();
  115. }
  116. var gridCondition="fd_foid=0";
  117. var win = parent.Ext.create('Ext.window.Window',
  118. {
  119. id : 'mainwin',
  120. height : '90%',
  121. width : '90%',
  122. maximizable : true,
  123. buttonAlign : 'center',
  124. layout : 'anchor',
  125. title:'添加流程',
  126. items : [{
  127. //tag : 'iframe',
  128. frame : true,
  129. anchor : '100% 100%',
  130. layout : 'fit',
  131. // html : '<iframe id="iframe_form" src="'+basePath+'jsps/ma/form.jsp?_noc=1&gridCondition='+gridCondition+'&formCondition='+formCondition+'" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>'
  132. html:'<iframe id="iframe_form" src="'+basePath+'jsps/oa/custom/multiform.jsp?_noc=1'+'" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>'
  133. }]
  134. });
  135. win.show();
  136. }
  137. }],
  138. /*handler:function(e,target,panelHeader,tool){
  139. var win = parent.Ext.create('Ext.window.Window',
  140. {
  141. id : 'win',
  142. height : 600,
  143. width : 800,
  144. maximizable : true,
  145. buttonAlign : 'center',
  146. layout : 'anchor',
  147. items : [ {
  148. //tag : 'iframe',
  149. frame : true,
  150. anchor : '100% 100%',
  151. layout : 'fit',
  152. // html : '<iframe id="iframe_form" src="'+basePath+'jsps/ma/form.jsp?_noc=1&gridCondition='+gridCondition+'&formCondition='+formCondition+'" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>'
  153. html:'<iframe id="iframe_form" src="'+basePath+'jsps/ma/form.jsp?_noc=1'+'" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>'
  154. } ]
  155. });
  156. win.show();
  157. //Ext.create('erp.util.FormUtil').onAdd('添加流程','Form',basePath+'jsps/ma/form.jsp');
  158. }**/
  159. },/*{
  160. xtype:'tool',
  161. type:'up',
  162. handler:function(e,target,panelHeader,tool){
  163. if(tool.type=='up'){
  164. tool.setType('down');
  165. panelHeader.ownerCt.collapse(Ext.Component.DIRECTION_TOP,true);
  166. }else {
  167. tool.setType('up');
  168. panelHeader.ownerCt.expand();
  169. }
  170. },
  171. },*/{
  172. xtype: 'tool',
  173. type: 'collapse',
  174. tooltip:'已发起流程',
  175. hidden:canAdd==1,
  176. handler: function(e, target, panelHeader, tool){
  177. var portlet = panelHeader.ownerCt;
  178. var select=portlet.getSelectionModel().getLastSelected();
  179. if(!select){
  180. showError('请先选择需要查看的流程!');
  181. }else {
  182. openTable(select.data.jd_processdefinitionname,"jsps/common/datalist.jsp?whoami=JProcess&urlcondition=jp_flag=1 and jp_caller='"+select.data.jd_caller+"'",select.data.jd_caller);
  183. }
  184. }
  185. },{
  186. xtype: 'tool',
  187. type: 'gear',
  188. tooltip:'流程排序',
  189. hidden:canAdd==1,
  190. handler: function(e, target, panelHeader, tool){
  191. var portlet = panelHeader.ownerCt;
  192. var jcid=portlet.id.substring(portlet.id.indexOf('grid')+4,portlet.id.length);
  193. var condition="jd_selfid="+jcid;
  194. var win = Ext.create('Ext.window.Window',
  195. {
  196. title:'流程排序',
  197. id : 'orderwin',
  198. height : '60%',
  199. width : '45%',
  200. maximizable : true,
  201. buttonAlign : 'center',
  202. layout : 'anchor',
  203. items : [{
  204. //tag : 'iframe',
  205. frame : true,
  206. anchor : '100% 100%',
  207. layout : 'fit',
  208. // html : '<iframe id="iframe_form" src="'+basePath+'jsps/ma/form.jsp?_noc=1&gridCondition='+gridCondition+'&formCondition='+formCondition+'" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>'
  209. html:'<iframe id="iframe_form" src="'+basePath+'jsps/common/editorColumn.jsp?caller=JprocessDeploy&condition='+condition+'&_noc=1'+'" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>'
  210. }],
  211. buttonAlign:'center',
  212. buttons:[{
  213. xtype:'erpSaveButton',
  214. handler:function(){
  215. var grid = Ext.getCmp('orderwin').items.items[0].body.dom.getElementsByTagName('iframe')[0].contentWindow.Ext.getCmp("editorColumnGridPanel");
  216. var data = grid.getEffectData();
  217. if(data != null){
  218. grid.setLoading(true);
  219. Ext.Ajax.request({
  220. url : basePath + 'custom/orderByJprocess.action',
  221. params: {
  222. data: Ext.encode(data)
  223. },
  224. method : 'post',
  225. callback : function(options,success,response){
  226. grid.setLoading(false);
  227. var localJson = new Ext.decode(response.responseText);
  228. if(localJson.exceptionInfo){
  229. showError(localJson.exceptionInfo);
  230. return "";
  231. }
  232. if(localJson.success){
  233. if(localJson.log){
  234. showMessage("提示", localJson.log);
  235. }
  236. Ext.Msg.alert("提示", "处理成功!", function(){
  237. win.close();
  238. me.loadNewStore(portlet,condition);
  239. });
  240. }
  241. }
  242. });
  243. }
  244. }
  245. },{
  246. xtype:'erpCloseButton',
  247. handler:function(){
  248. win.close();
  249. }
  250. }]
  251. });
  252. win.show();
  253. }
  254. },{
  255. xtype:'tool',
  256. type:'close',
  257. tooltip:'删除流程',
  258. hidden:canAdd==1,
  259. handler:function(e, target, panelHeader, tool){
  260. //me.onPortletClose(panelHeader.ownerCt);
  261. //panelHeader.ownerCt.close();
  262. var portlet = panelHeader.ownerCt;
  263. var select=portlet.getSelectionModel().getLastSelected();
  264. if(!select){
  265. showError('请先选择需要查看的流程!');
  266. }else {
  267. warnMsg('确认要删除该流程吗', function(btn){
  268. if(btn == 'yes'){
  269. me.BaseUtil.getActiveTab().setLoading(true);//loading...
  270. Ext.Ajax.request({
  271. url:basePath+'common/deleteProcessDeploy.action',
  272. params:{
  273. id:select.data.jd_id
  274. },
  275. method:'post',
  276. callback : function(options,success,response){
  277. me.BaseUtil.getActiveTab().setLoading(false);
  278. var localJson = new Ext.decode(response.responseText);
  279. if(localJson.exceptionInfo){
  280. showError(localJson.exceptionInfo);return;
  281. }
  282. if(localJson.success){
  283. delSuccess(function(){
  284. me.loadNewStore(portlet,"jd_selfid="+select.data.jd_selfid);
  285. });//@i18n/i18n.js
  286. } else {
  287. delFailure();
  288. }
  289. }
  290. });
  291. }
  292. });
  293. }
  294. }
  295. }];
  296. },
  297. onPortletClose: function(portlet) {
  298. this.showMsg('"' + portlet.title + '" 已关闭!');
  299. },
  300. showMsg: function(msg) {
  301. var el = Ext.get('app-msg'),
  302. msgId = Ext.id();
  303. this.msgId = msgId;
  304. el.update(msg).show();
  305. Ext.defer(this.clearMsg, 3000, this, [msgId]);
  306. },
  307. clearMsg: function(msgId) {
  308. if (msgId === this.msgId) {
  309. Ext.get('app-msg').hide();
  310. }
  311. },
  312. loadNewStore:function(grid,condition){
  313. var me = this;
  314. grid.setLoading(true);//loading...
  315. Ext.Ajax.request({//拿到grid的columns
  316. url : basePath + "common/getProcessInfoByCondition.action",
  317. params: {
  318. condition:condition
  319. },
  320. method : 'post',
  321. callback : function(options,success,response){
  322. grid.setLoading(false);
  323. var res = new Ext.decode(response.responseText);
  324. if(res.exceptionInfo){
  325. showError(res.exceptionInfo);return;
  326. }
  327. var data = res.data;
  328. if(!data || data.length == 0){
  329. grid.store.removeAll();
  330. me.add10EmptyItems(grid);
  331. } else {
  332. grid.store.loadData(data);
  333. }
  334. //自定义event
  335. grid.addEvents({
  336. storeloaded: true
  337. });
  338. grid.fireEvent('storeloaded', grid, data);
  339. }
  340. });
  341. },
  342. getColumns:function(){
  343. var me=this;
  344. if(canAdd!=1){
  345. return [
  346. {dataIndex:'jd_id',width:0,fixed:true},
  347. {dataIndex:'jd_processdefinitionname',renderer:open,header:'流程名称',width:150,flex:1,filter: {xtype: 'textfield', filterName: 'jd_processdefinitionname'},fixed:true},
  348. {xtype:'actioncolumn',width:50,fixed:true,items:[{
  349. icon: basePath+'/resource/images/icon/detail.png', // Use a URL in the icon config
  350. tooltip: '查看列表',
  351. style: {
  352. marginLeft: '2px'
  353. },
  354. handler: function(grid, rowIndex, colIndex) {
  355. var rec = grid.getStore().getAt(rowIndex);
  356. //根据caller查找列表的配置
  357. Ext.Ajax.request({
  358. url:basePath+'/custom/IfDatalist.action',
  359. params:{
  360. caller:rec.data.jd_caller
  361. },
  362. method:'post',
  363. callback : function(options,success,response){
  364. var rs = new Ext.decode(response.responseText);
  365. if(rs.exceptionInfo){
  366. warnMsg('该单据未配置相关列表,是否配置列表?', function(btn){
  367. if(btn == 'yes'){
  368. me.BaseUtil.getActiveTab().setLoading(true);//loading...
  369. var type=me.FormUtil.contains(rec.data.js_formurl,'single',true)?'single':'multi';
  370. Ext.Ajax.request({
  371. url:basePath+'/custom/ToDatalistByForm.action',
  372. params:{
  373. caller:rec.data.jd_caller,
  374. type:type
  375. },
  376. method:'post',
  377. callback : function(options,success,response){
  378. me.BaseUtil.getActiveTab().setLoading(false);
  379. var localJson = new Ext.decode(response.responseText);
  380. if(localJson.exceptionInfo){
  381. showError(localJson.exceptionInfo);return;
  382. }
  383. if(localJson.success){
  384. Ext.Msg.alert('提示','配置成功!',function(){
  385. openTable(rec.data.jd_processdefinitionname,"jsps/common/datalist.jsp?whoami="+rec.data.jd_caller,rec.data.jd_caller);
  386. });
  387. } else {
  388. delFailure();
  389. }
  390. }
  391. });
  392. }
  393. });
  394. }
  395. if(rs.success){
  396. openTable(rec.data.jd_processdefinitionname,"jsps/common/datalist.jsp?whoami="+rec.data.jd_caller,rec.data.jd_caller);
  397. }
  398. }
  399. });
  400. }
  401. },{
  402. icon: basePath+'/resource/images/icon/execute.png',
  403. tooltip: '查看流程',
  404. style: {
  405. marginLeft: '2px',
  406. width:0,
  407. },
  408. handler: function(grid, rowIndex, colIndex) {
  409. var select= grid.getStore().getAt(rowIndex);;
  410. var formCondition="jd_idIS"+select.data.jd_id;
  411. openTable(select.data.jd_processdefinitionname,"jsps/common/jprocessDeploy.jsp?formCondition="+formCondition,select.data.jd_caller);
  412. // window.open();
  413. }
  414. },{
  415. icon: basePath+'/resource/images/icon/trash.png',
  416. tooltip: '删除流程',
  417. style: {
  418. marginLeft: '2px'
  419. },
  420. handler: function(grid, rowIndex, colIndex) {
  421. var select= grid.getStore().getAt(rowIndex);;
  422. warnMsg('确认要删除该流程吗', function(btn){
  423. if(btn == 'yes'){
  424. me.BaseUtil.getActiveTab().setLoading(true);//loading...
  425. Ext.Ajax.request({
  426. url:basePath+'common/deleteProcessDeploy.action',
  427. params:{
  428. id:select.data.jd_id
  429. },
  430. method:'post',
  431. callback : function(options,success,response){
  432. me.BaseUtil.getActiveTab().setLoading(false);
  433. var localJson = new Ext.decode(response.responseText);
  434. if(localJson.exceptionInfo){
  435. showError(localJson.exceptionInfo);return;
  436. }
  437. if(localJson.success){
  438. delSuccess(function(){
  439. me.loadNewStore(grid,"jd_selfid="+select.data.jd_selfid);
  440. });//@i18n/i18n.js
  441. } else {
  442. delFailure();
  443. }
  444. }
  445. });
  446. }
  447. });
  448. }
  449. }]},{dataIndex:'js_formurl',width:0,fixed:true},{dataIndex:'jd_caller',width:0,fixed:true},{dataIndex:'jd_selfid',width:0,fixed:true}];
  450. }else {
  451. return [{dataIndex:'jd_id',width:0,fixed:true},{dataIndex:'jd_processdefinitionname',renderer:open,header:'流程名称',width:150,flex:1,filter: {xtype: 'textfield', filterName: 'jd_processdefinitionname'},fixed:true},{xtype:'actioncolumn',width:50,fixed:true,items:[{
  452. icon: basePath+'/resource/images/icon/detail.png', // Use a URL in the icon config
  453. tooltip: '查看列表',
  454. style: {
  455. marginLeft: '2px'
  456. },
  457. handler: function(grid, rowIndex, colIndex) {
  458. var rec = grid.getStore().getAt(rowIndex);
  459. //根据caller查找列表的配置
  460. Ext.Ajax.request({
  461. url:basePath+'/custom/IfDatalist.action',
  462. params:{
  463. caller:rec.data.jd_caller
  464. },
  465. method:'post',
  466. callback : function(options,success,response){
  467. var rs = new Ext.decode(response.responseText);
  468. if(rs.exceptionInfo){
  469. warnMsg('该单据未配置相关列表,是否配置列表?', function(btn){
  470. if(btn == 'yes'){
  471. me.BaseUtil.getActiveTab().setLoading(true);//loading...
  472. var type=me.FormUtil.contains(rec.data.js_formurl,'single',true)?'single':'multi';
  473. Ext.Ajax.request({
  474. url:basePath+'/custom/ToDatalistByForm.action',
  475. params:{
  476. caller:rec.data.jd_caller,
  477. type:type
  478. },
  479. method:'post',
  480. callback : function(options,success,response){
  481. me.BaseUtil.getActiveTab().setLoading(false);
  482. var localJson = new Ext.decode(response.responseText);
  483. if(localJson.exceptionInfo){
  484. showError(localJson.exceptionInfo);return;
  485. }
  486. if(localJson.success){
  487. Ext.Msg.alert('提示','配置成功!',function(){
  488. openTable(rec.data.jd_processdefinitionname,"jsps/common/datalist.jsp?whoami="+rec.data.jd_caller,rec.data.jd_caller);
  489. });
  490. } else {
  491. delFailure();
  492. }
  493. }
  494. });
  495. }
  496. });
  497. }
  498. if(rs.success){
  499. openTable(rec.data.jd_processdefinitionname,"jsps/common/datalist.jsp?whoami="+rec.data.jd_caller,rec.data.jd_caller);
  500. }
  501. }
  502. });
  503. }
  504. }]},{dataIndex:'js_formurl',width:0,fixed:true},{dataIndex:'jd_caller',width:0,fixed:true},{dataIndex:'jd_selfid',width:0,fixed:true}];
  505. }
  506. }
  507. });