activiti工作流在线表单设计功能(activiti + ueditor + Ueditor Web Form Design扩展 )

之前实现了activiti工作流的动态表单功能,接下来准备实现activiti的外置表单功能,并且外置表单可以在线编辑。

activiti工作流在线表单设计功能实现可以分为2个部分:

1.在线表单设计功能。

2.表单与activiti工作流关联起来。

 

第一部分,在线表单设计功能可以使用ueditor 的插件WEB表单设计器实现。

第二部分,可以使用activiti工作流的外置表单 原理关联 WEB表单设计器 设计的表单。

 

主要难点在实现第一部分,具体效果图如下:

activiti工作流在线表单设计功能(activiti + ueditor + Ueditor Web Form Design扩展 )_第1张图片

 

相关所有实现代码:

list.jsp

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>



	在线表单列表
<%@include file="/common/base.jsp" %>





	
表单名称 描述 设计者 日期 是否启用 操作
设计者:    查询    新增


add.jsp

 

 

 

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%> 
<%@page import="org.springframework.context.ApplicationContext" %>    
<%@page import="com.jy.service.onlineform.OnlineFormService" %> 
<%
  ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(getServletContext());    
  OnlineFormService onlineFormService = (OnlineFormService)ctx.getBean("onlineFormService"); 
  String bizId = request.getParameter("bizId");
  if(bizId != null && !bizId.equals("")){
  	request.setAttribute("of", onlineFormService.getEntityById(bizId));
  }
%>



	新增文档
<%@include file="/common/base.jsp" %>






    
保存    取消


design.jsp

 

 

 

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%> 
<%@page import="org.springframework.context.ApplicationContext" %>    
<%@page import="com.jy.service.onlineform.OnlineFormService" %> 
<%
  ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(getServletContext());    
  OnlineFormService onlineFormService = (OnlineFormService)ctx.getBean("onlineFormService"); 
  String bizId = request.getParameter("bizId");
  if(bizId != null && !bizId.equals("")){
  	request.setAttribute("of", onlineFormService.getEntityById(bizId));
  }
%>



	设计表单
<%@include file="/common/base.jsp" %>






		
表单设计(表单名称:${of.key})
提醒:单选框和复选框,如:{|-选项-|}两边边界是防止误删除控件,程序会把它们替换为空,请不要手动删除!


preview.jsp

 

 

 

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page   import= "com.jy.common.utils.UeditorTools "%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>



	新增文档
	<%@include file="/common/base.jsp" %>
	




  
<%= UeditorTools.formatStr(request.getParameter("html"))%>

 

 

OnlineFormController.java

 

package com.jy.controller.onlineform;


import java.util.List;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jy.common.ajax.AjaxRes;
import com.jy.common.utils.base.Const;
import com.jy.common.utils.base.Tools;
import com.jy.common.utils.security.AccountShiroUtil;
import com.jy.controller.base.BaseController;
import com.jy.entity.onlineform.OnlineForm;
import com.jy.service.onlineform.OnlineFormService;

@Controller
@RequestMapping("/OnlineFormController/")
public class OnlineFormController extends BaseController{
	@Autowired
	private OnlineFormService onlineFormService;
	
	@RequestMapping(value="list")	
	@ResponseBody
	public List list(Model model,OnlineForm obj){
		List list = onlineFormService.list(obj);
		return list;
	}
	
	/**
	 * 保存表单
	 * @param obj
	 * @return
	 */
	@RequestMapping(value="save")
	@ResponseBody
	public AjaxRes save(Model model,OnlineForm obj){
		AjaxRes ar=getAjaxRes();
		if (Tools.isEmpty(obj.getId())) {
			obj.setId(get32UUID());
			obj.setAddUserId(AccountShiroUtil.getCurrentUser().getAccountId());
			onlineFormService.insert(obj);
		}else{
			obj.setModUserId(AccountShiroUtil.getCurrentUser().getAccountId());
			onlineFormService.update(obj);
		}
		ar.setObj("");
		ar.setSucceedMsg(Const.SAVE_SUCCEED);
//		System.out.println(JsonUtil.toJson(content));
		return ar;
	}
	/**
	 * 设计表单
	 * @param obj
	 * @return
	 */
	@RequestMapping(value="design")
	@ResponseBody
	public AjaxRes design(Model model,OnlineForm obj){
		AjaxRes ar=getAjaxRes();
		obj.setModUserId(AccountShiroUtil.getCurrentUser().getAccountId());
		onlineFormService.design(obj);
		ar.setObj("");
		ar.setSucceedMsg(Const.SAVE_SUCCEED);
//		System.out.println(JsonUtil.toJson(content));
		return ar;
	}
	
	/**
	 * 删除记录
	 * @param obj
	 * @return
	 */
	@RequestMapping(value="delete")
	@ResponseBody
	public AjaxRes delete(Model model,OnlineForm obj){
		AjaxRes ar=getAjaxRes();
		onlineFormService.delete(obj);
		ar.setObj("");
		ar.setSucceedMsg(Const.DEL_SUCCEED);
//		System.out.println(JsonUtil.toJson(content));
		return ar;
	}
}
 
  

 

OnlineFormMapper.xml

 

 




    
      
      
      
      
      
      
      
      
      
         
         
     
    
	
    	
	    insert into online_form(id,key,descr,enabled,addUserId,addtime) 
	    values(#{id},#{key},#{descr},#{enabled},#{addUserId},sysdate)
	
		
		update online_form set key=#{key},descr=#{descr},enabled=#{enabled}
			,modUserId=#{modUserId},modtime=sysdate
	    where id=#{id}
	
		
		update online_form set html=#{html,jdbcType=CLOB}
			,modUserId=#{modUserId},modtime=sysdate
	    where id=#{id}
	
		
		delete from online_form where id=#{id}
	

看到一直有人问UeditorTools这个类。其实挺简单的,我找了下,下面贴出来了。

com.jy.common.utils.UeditorTools

package com.jy.common.utils;

public class UeditorTools {
	/**
	 * 去掉分界符 {|- 和  -|}
	 * @param str
	 * @return
	 */
	public static String formatStr(String str){
		str = replaceAll(str,"{|-","");
		str = replaceAll(str,"-|}","");
		return str;
	}
	public static String replaceAll(String strAll,String oldStr,String newStr){
		return strAll.replaceAll(escapeExprSpecialWord(oldStr), "");
	}
	/** 
	 * 转义正则特殊字符 ($()*+.[]?\^{},|) 
	 * @param keyword 
	 * @return 
	 */  
	public static String escapeExprSpecialWord(String keyword) {  
	    if (keyword != null && !keyword.equals("")) {  
	        String[] fbsArr = { "\\", "$", "(", ")", "*", "+", ".", "[", "]", "?", "^", "{", "}", "|" };  
	        for (String key : fbsArr) {  
	            if (keyword.contains(key)) {  
	                keyword = keyword.replace(key, "\\" + key);  
	            }  
	        }  
	    }  
	    return keyword;  
	}  
}

 

 

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(Activiti)