JOffice中的自定义发文流程与运行模板设计

开发与设计公文流程在所有的政府oa项目上都少不了此需求,而能灵活定义一个在线的公文发文与收文流程尤其重要,J.Office通过过Velocity模板技术进行表单定义,同时结合WebOffice能非常容易实现在线公文的拟稿、保留修改痕迹、并且进行套红、套打功能。

在介绍本文之前,我们先看一下其中一个发文流程:

这是一个稍为复杂的发文流程,用jbpm工具发这个流程并不成问题,问题是这个流程设计好,其里面的每个任务如何跟公文系统的数据进行对应起来。

J.Office提供了流程的表单技术,通过Velocity,可以把表单里面对应的任务直接保存至公文系统,并且同时让流程跳转至下一步。

如其中一个任务表单的设计:

Java代码 复制代码  收藏代码
  1. FlowPanel=Ext.extend(Ext.form.FormPanel,{   
  2.     constructor:function(cfg){   
  3.         this.officePanel=new OfficePanel({   
  4.             height:490,   
  5.             filePath:'${doc_path}',   
  6.             showToolbar:true  
  7.         });   
  8.         FlowPanel.superclass.constructor.call(this,{   
  9.             bodyStyle:'padding:5px',   
  10.             title:'办公室主任审核',   
  11.             height:600,   
  12.             width:800,   
  13.             layout:'form',   
  14.             items:[   
  15.                 {   
  16.                     fieldLabel:'审核意见',   
  17.                     name:'zr_option',   
  18.                     xtype:'textarea',   
  19.                     width:400,   
  20.                     allowBlank:false,   
  21.                     anchor:'98%,98%'  
  22.                 },this.officePanel.panel   
  23.             ]   
  24.         });   
  25.     },   
  26.     save:function(){   
  27.             if(!this.getForm().isValid()) return;   
  28.             //TODO 保存我的流程表单至我的自定义表   
  29.             this.officePanel.saveDoc({   
  30.                 fileCat : 'archIssue',   
  31.                 docPath:this.officePanel.filePath   
  32.             });   
  33.             return true;   
  34.     }   
  35. })  
FlowPanel=Ext.extend(Ext.form.FormPanel,{
	constructor:function(cfg){
	    this.officePanel=new OfficePanel({
	    	height:490,
	    	filePath:'${doc_path}',
	    	showToolbar:true
	    });
		FlowPanel.superclass.constructor.call(this,{
			bodyStyle:'padding:5px',
			title:'办公室主任审核',
			height:600,
			width:800,
			layout:'form',
			items:[
				{
					fieldLabel:'审核意见',
					name:'zr_option',
					xtype:'textarea',
					width:400,
					allowBlank:false,
					anchor:'98%,98%'
				},this.officePanel.panel
			]
		});
	},
	save:function(){
			if(!this.getForm().isValid()) return;
			//TODO 保存我的流程表单至我的自定义表
			this.officePanel.saveDoc({
				fileCat : 'archIssue',
				docPath:this.officePanel.filePath
			});
			return true;
	}
})

  

对应的界面如下所示:

在以上可以比较容易在进行流程的跳转前,我们可以在这里处理我们的公文,如保存,套红,修改等操作,完成后再进行下一步的跳转处理。

注意,在VM模板中,我们也使用了${doc_path}这些变量,其值来自流程表单的提交,并且会在流程跳转过程中一直存在,以方便流程读取这些变量。

其他表单的设计也类似。

鉴于以前使用的WebOffice控件封装得不太好,现在附上一个封装较好的使用代码示例:

Java代码 复制代码  收藏代码
  1. OfficePanel=function(conf){   
  2.        
  3.     var officeObj = document.createElement('object');   
  4.     officeObj.width = "100%";   
  5.     officeObj.height = "100%";   
  6.     officeObj.classid= "clsid:E77E049B-23FC-4DB8-B756-60529A35FAD5";    
  7.     officeObj.codebase = __ctxPath+'/js/core/weboffice/weboffice_V6.0.4.6.cab#V6,0,4,6';   
  8.        
  9.     var panelConf={border:false,layout:'fit'};   
  10.        
  11.     if(conf.showToolbar){   
  12.         panelConf.tbar=new Ext.Toolbar({   
  13.             items:[   
  14.                 {   
  15.                     text : '保留修改痕迹',   
  16.                     iconCls : 'btn-archive-save-trace',   
  17.                     handler : function() {   
  18.                         officeObj.SetTrackRevisions(1);   
  19.                         officeObj.SetCurrUserName(curUserInfo.fullname);   
  20.                     }   
  21.                 }, '-', {   
  22.                     text : '取消保留痕迹',   
  23.                     iconCls : 'btn-archive-cancel-trace',   
  24.                     handler : function() {   
  25.                         officeObj.SetTrackRevisions(0);   
  26.                     }   
  27.                 }, '-',{   
  28.                     text : '清除痕迹',   
  29.                     iconCls : 'btn-archive-eraser',   
  30.                     handler : function() {   
  31.                         officeObj.SetTrackRevisions(4);   
  32.                     }   
  33.                 }, '-',{   
  34.                     text:'加入套红模板',   
  35.                     iconCls:'',   
  36.                     handler:function(){   
  37.                         new ArchTemplateSelector({   
  38.                                 callback : function(tempPath) {   
  39.                                     var filePath=conf.filePath?__fullPath+'/attachFiles/'+conf.filePath:'';   
  40.                                     officeObj.LoadOriginalFile(__fullPath+"/attachFiles/" + tempPath,'doc');   
  41.                                     officeObj.SetFieldValue("contents",filePath, "::FILE::");   
  42.                                     //officeObj.SetFieldValue("red_header","","::ADDMARK::");   
  43.                                     //officeObj.SetFieldValue("red_header",__fullPath+"/attachFiles/" + tempPath, "::FILE::");   
  44.                                 }   
  45.                             }   
  46.                         ).show();   
  47.                     }   
  48.                 }   
  49.             ]   
  50.         });   
  51.     }   
  52.        
  53.     Ext.applyIf(panelConf,conf);   
  54.   
  55.     var panel=new Ext.Panel(panelConf);   
  56.     panel.on('afterrender',function(){   
  57.             panel.body.appendChild(officeObj);   
  58.             panel.doLayout();   
  59.             var filePath=conf.filePath?__fullPath+'/attachFiles/'+conf.filePath:'';   
  60.             var docType=conf.docType?conf.docType:'doc';   
  61.             officeObj.LoadOriginalFile(filePath,docType);   
  62.             panel.doLayout();   
  63.                
  64.     });   
  65.     panel.on('destroy',function(){   
  66.         try {   
  67.                 officeObj.Close();   
  68.             } catch (ex) {}   
  69.     });   
  70.        
  71.     window.onunload=function(){   
  72.         try {   
  73.                 officeObj.Close();   
  74.             } catch (ex) {}   
  75.     };   
  76.        
  77.     //对外公共方法   
  78.     return {   
  79.         panel:panel,   
  80.         officeObj:officeObj,   
  81.         filePath:conf.filePath,   
  82.         openDoc:function(path,type){   
  83.             var vType='doc';   
  84.             if(type){   
  85.                 vType=type;   
  86.             }   
  87.             officeObj.LoadOriginalFile(path,type);   
  88.         },   
  89.         saveDoc:function(config){   
  90.                 config=config||{};   
  91.                 officeObj.HttpInit();   
  92.                 officeObj.HttpAddPostString('file_cat', config.fileCat);   
  93.                 //overwrite file path   
  94.                 if(config.docPath!=null && config.docPath!=''){   
  95.                     officeObj.HttpAddPostString('file_path', config.docPath);   
  96.                 }   
  97.                 officeObj.HttpAddPostCurrFile('AipFile','');       
  98.                 var url=config.url ? config.url: __fullPath + '/file-upload';   
  99.                 // 提交上传文件   
  100.                 returnValue = officeObj.HttpPost(url);   
  101.                 var obj;   
  102.                 eval('obj='+returnValue+";");   
  103.                 return obj;   
  104.         }   
  105.     };   
  106. };   
  107.   
  108. //Ext.reg('officepanel',OfficePanel);  
  109. 关于我
  110. 电话:13672461598
  111.     qq:1848175569

猜你喜欢

转载自nongyuxia.iteye.com/blog/1872502