Commit 60b0953d by Java-曹文达

页面优化 流程图导入导出

parent 203bd8aa
......@@ -2,18 +2,33 @@ package com.bbd.bpm.controller.user;
import com.bbd.bpm.base.PageBean;
import com.bbd.bpm.domain.User;
import com.bbd.bpm.dto.SysCode;
import com.bbd.bpm.dto.response.BpmResponse;
import com.bbd.bpm.result.RespCode;
import com.bbd.bpm.result.Result;
import com.bbd.bpm.result.ResultUtil;
import com.bbd.bpm.service.UserInfoService;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.activiti.bpmn.converter.BpmnXMLConverter;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.editor.constants.ModelDataJsonConstants;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Model;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import java.io.*;
/**
* 用户功能模块接口
* @Author:cwd
......@@ -28,6 +43,8 @@ public class UserApiController {
@Autowired
private UserInfoService userInfoService;
@Autowired
private RepositoryService repositoryService;
/**
......@@ -237,6 +254,92 @@ public class UserApiController {
}
@ApiOperation(value = "导出流程列表")
@GetMapping("/exportDeployMent")
@ResponseBody
public BpmResponse exportDeployMent(String modelId, HttpServletResponse response) {
BufferedOutputStream bos = null;
BpmResponse resp = new BpmResponse();
try {
try {
Model modelData = repositoryService.getModel(modelId);
byte[] bpmnBytes = repositoryService
.getModelEditorSource(modelData.getId());
// 封装输出流
bos = new BufferedOutputStream(response.getOutputStream());
// 写入流
bos.write(bpmnBytes);
String filename = modelData.getName() + ".json";
response.setContentType("application/x-msdownload");
response.setHeader("Content-Disposition",
"attachment; filename=" + new String(filename.getBytes(),"iso-8859-1"));
response.flushBuffer();
resp.setSuccess(true);
resp.setMessage("导出成功");
resp.setCode(SysCode.SUCCESS_CODE);
return resp;
} finally {
bos.flush();
bos.close();
}
} catch (Exception e) {
System.out.println("导出失败");
e.printStackTrace();
return resp;
}
}
@ApiOperation(value = "导入流程列表")
@PostMapping("/improtDeployMent")
@ResponseBody
public BpmResponse improtDeployMent(String file,String name,String content) {
file="D:/年金管理.json";
String s="";
BpmResponse resp = new BpmResponse();
try {
StringBuffer strbuffer = new StringBuffer();
FileInputStream fis = new FileInputStream(file);
InputStreamReader inputStreamReader = new InputStreamReader(fis, "UTF-8");
BufferedReader in = new BufferedReader(inputStreamReader);
String str;
while ((str = in.readLine()) != null) {
strbuffer.append(str);
}
s = strbuffer.toString();
byte[] bytes = s.getBytes();
ObjectMapper objectMapper = new ObjectMapper();
ObjectNode modelObjectNode = objectMapper.createObjectNode();
Model modelData = repositoryService.newModel();
modelObjectNode.put(ModelDataJsonConstants.MODEL_NAME, name);
modelObjectNode.put(ModelDataJsonConstants.MODEL_REVISION, 1);
modelObjectNode.put(ModelDataJsonConstants.MODEL_DESCRIPTION, content);
modelData.setMetaInfo(modelObjectNode.toString());
modelData.setName(name);
repositoryService.saveModel(modelData);
repositoryService.addModelEditorSource(modelData.getId(),bytes);
resp.setSuccess(true);
resp.setMessage("导入成功");
resp.setCode(SysCode.SUCCESS_CODE);
in.close();
return resp;
}
catch (IOException e) {
resp.setSuccess(false);
resp.setMessage("导入成功");
resp.setCode(SysCode.SYS_ERROR);
e.getStackTrace();
return resp;
}
}
......
......@@ -90,6 +90,17 @@ public class UserWebController {
return "user/addUser";
}
/**
* @Author:cwd
* @Description:进入添加人员功能
* @Date: 2019/04/04
* @Param:
* @return
**/
@GetMapping(value = "/imports")
public String imports(){
return "deployment/importDeployment";
}
......
......@@ -82,7 +82,7 @@
<!--end 头部-->
<!--左边导航-->
<div class="main_wrap clearfix" >
<ul id="aside_nav" class="navBox" style='width:140px;min-height: 680px;'>
<ul id="aside_nav" class="navBox" style='width:140px; position: absolute;'>
<li class="s_menu_item"><a target="main_frame" href="/web/bpm/user/toDeployment"><span class="nav-icon"><i class="fa fa-qrcode bg-gradient-red text-white"></i></span>查看流程</a></li>
<li class="s_menu_item"><a target="main_frame" href="/model/createNew"><span class="nav-icon"><i class="fa fa-heart bg-gradient-orange text-white"></i></span>创建流程</a></li>
<li class="s_menu_item"><a target="main_frame" href="/web/bpm/user/toOrganization"><span class="nav-icon"><i class="fa fa-table bg-gradient-green text-white"></i></span>组织结构</a></li>
......
......@@ -7,6 +7,8 @@
<link rel="stylesheet" th:href="@{/css/common/page_new.css}" />
<link rel="stylesheet" th:href="@{/js/plugins/bootstrapselect/css/product_list.css}" />
<link rel="stylesheet" th:href="@{/css/layui.css}" media="all">
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
</head>
<style type="text/css">
.box .search_pro .cx input{
......@@ -29,6 +31,7 @@
text-align: center;
}
</style>
<body>
<div class="box">
<h2><span></span>流程列表<button onclick="location.reload()">刷新</button></h2>
......@@ -40,7 +43,12 @@
<span class="cx">
<button style="margin-left: 16px;" class="layui-btn" onclick="getBargainProduct()">查询</button>
</span>
<button id="addMe" class="layui-btn layui-btn-radius" style="margin-left: 565px" onclick="goImport()">上传文件</button></span>
</p>
</div>
<div class="content">
<p class="title list_ti"><span>流程列表</span></p>
......@@ -59,6 +67,7 @@
</html>
<script src="/js/plugins/jquery.min.js"></script>
<script src="/js/plugins/layer/layer.js"></script>
<script src="/js/layui.js"></script>
<script type="text/javascript" src="/js/plugins/page_new.js"></script>
<script type="text/javascript">
$(function(){
......@@ -91,6 +100,8 @@
'json'
);
flushHtml();
});
function flushHtml(current) {
var pageNum = 1;
......@@ -127,7 +138,8 @@
content += '<td class="product_num">'+data[i].metaInfo+'</td><td class="product_num">'+data[i].version+'</td>';
content += '<td class="cao_zuo"><span onclick="toActivityDetail('+data[i].id+')">查看</span></span><span onclick="deploymentModel('+data[i].id+',\''+data[i].name+'\',\''+data[i].deploymentId+'\')">部署流程</span><span onclick="deleteDeployMent('+data[i].id+',\''+data[i].name+'\')">删除</span></td></tr></tbody>';
content += '<td class="cao_zuo"><span style="width: 15%" onclick="toActivityDetail('+data[i].id+')">查看</span></span><span onclick="deploymentModel('+data[i].id+',\''+data[i].name+'\',\''+data[i].deploymentId+'\')">部署流程</span>' +
'<span style="width: 15%" onclick="deleteDeployMent('+data[i].id+',\''+data[i].name+'\')">删除</span><span style="width: 15%" onclick="exportDeployMent('+data[i].id+')">导出</span></td></tr></tbody>';
}
$('#pages').text(pages);
$('#total').text(total);
......@@ -183,7 +195,7 @@
area:['300px', '165px'],
content: '<div style="margin-top: 22px;margin-left: 8px;">您确定部署'+name+"流程吗?</div>"
,
btn:['保存','取消'],
btn:['确定','取消'],
btn1: function (index,layero) {
layer.msg('文件部署中', {
icon: 16,
......@@ -218,7 +230,7 @@
area:['300px', '165px'],
content: '<div style="margin-top: 22px;margin-left: 8px;">您确定再次部署'+name+"流程吗?</div>"
,
btn:['保存','取消'],
btn:['确定','取消'],
btn1: function (index,layero) {
layer.msg('文件部署中', {
icon: 16,
......@@ -248,8 +260,6 @@
}
......@@ -263,7 +273,7 @@
area:['300px', '165px'],
content: '<div style="margin-top: 22px;margin-left: 8px;">您确定删除'+name+"流程吗?</div>"
,
btn:['保存','取消'],
btn:['确定','取消'],
btn1: function (index,layero) {
$.post("/api/bpm/model/deleteModel",
{
......@@ -285,4 +295,62 @@
}
});
}
</script>
\ No newline at end of file
/*导出流程 */
function exportDeployMent(id) {
location.href="/bpm/user/exportDeployMent?modelId="+id
}
function getPath(obj) {
if (obj) {
if (window.navigator.userAgent.indexOf("MSIE") >= 1) {
obj.select();
return document.selection.createRange().text;
} else if (window.navigator.userAgent.indexOf("Firefox") >= 1) {
if (obj.files) {
return obj.files.item(0).getAsDataURL();
}
return obj.value;
}
return obj.value;
}
}
/*上传流程 */
function getPath(obj) {
if (obj) {
if (window.navigator.userAgent.indexOf("MSIE") >= 1) {
obj.select(); return document.selection.createRange().text;
}
else if (window.navigator.userAgent.indexOf("Firefox") >= 1) {
if (obj.files) {
return obj.files.item(0).getAsDataURL();
}
return obj.value;
}
return obj.value;
}
}
function goImport(){
layer.open({
type: 2,
title: '上传文件',
closeBtn: 1,
area: ['400px','500px'],
shade: 0,
btnAlign: 'c',
content: "/web/bpm/user/imports",
});
}
</script>
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<meta charset="UTF-8"/>
<title>工作流</title>
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://cdn.bootcss.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<link rel="stylesheet" th:href="@{/css/layui.css}" media="all">
</head>
<body class="text-center">
<div>
<body>
<!--top头部标题栏-->
<div id="top">
<!--用户注册-->
<div id="vl_registe">
<div>
<p class="userinfo">
<label class="layui-form-label" style=" width: 98px;">流程名称:</label>
<input type="text" name="name" id="name" value="" style=" width: 300px;" placeholder="流程名称" class="layui-input" onfocus="userNameFocus()" autocomplete="off" />
</p>
<p class="userinfo" style="margin-top: 20px">
<label class="layui-form-label" style=" width: 98px;">流程描述:</label>
<input type="text" name="content" id="content" style=" width: 300px;" value="" placeholder="流程描述" class="layui-input" autocomplete="off" />
</p>
<p class="userinfo" style=" margin-left: 55px;padding-top: 20px;">
<input type="file" name="file" id="file" class="file">
</p>
</div>
<button style="margin-top: 50px ; width: 100px;" onclick="register()" class="layui-btn">上传</button>
</div>
</div>
</body>
</div>
</body>
</html>
<style>
* {
font-family: "微软雅黑";
font-size: 15px;
margin: 0 auto;
}
div{
text-align:center;
padding-top:10px;
}
input,button{
margin-top:10px;
}
.btn{
border-color: #10c8ef;
background-color: #10c8ef;
color: #fff;
}
</style>
<script src="/js/plugins/jquery.min.js"></script>
<script src="/js/plugins/layer/layer.js"></script>
<script>
function register(){
var name=$("#name").val();
if(name==''){
layer.msg('流程名称不可为空');
return false
}
var content=$("#content").val();
if(content==''){
layer.msg('流程描述不可为空');
return false
}
var file=$('#file').val();
console.log(name)
console.log(content)
console.log(file)
$.post("/bpm/user/improtDeployMent",
{
name:name,
content:content,
file:file
},function (data) {
if(data.code==200){
layer.msg('添加成功!', {icon: 1,time:1000});
setTimeout(function (){
parent.location.reload();
},500);
}else {
layer.msg('添加失败!', {icon: 2,time:1000});
setTimeout(function (){
parent.location.reload();
},500);
}
},'json')
}
</script>
......@@ -7,7 +7,7 @@
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://cdn.bootcss.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<link rel="stylesheet" th:href="@{/css/layui.css}" media="all">
</head>
<body class="text-center">
<div>
......@@ -18,37 +18,29 @@
<div id="vl_registe">
<div>
<p class="userinfo">
<span class="left">
<span class="info" style="margin-left: -15px;">用户名:</span>
</span>
<input type="text" name="v_username" id="username" value="" placeholder="用户名" onfocus="userNameFocus()" autocomplete="off" />
<label class="layui-form-label" style=" width: 98px;">用户名:</label>
<input type="text" name="username" id="username" value="" style=" width: 250px;" placeholder="用户名" class="layui-input" autocomplete="off" />
</p>
<p class="userinfo">
<span class="left">
<span class="info">密码:</span>
</span>
<input type="password" name="v_passward" id="passward" value="" placeholder="密码" autocomplete="off" />
<label class="layui-form-label" style=" width: 98px;">密码:</label>
<input type="text" name="passward" id="passward" value="" style=" width: 250px;" placeholder="密码" class="layui-input" autocomplete="off" />
</p>
<p class="userinfo">
<span class="left">
<span class="info">邮箱:</span>
</span>
<input type="emaila" name="v_mail" id="email" value="" placeholder="邮箱" autocomplete="off" />
<label class="layui-form-label" style=" width: 98px;">邮箱:</label>
<input type="text" name="v_mail" id="email" value="" style=" width: 250px;" placeholder="邮箱" class="layui-input" autocomplete="off" />
</p>
<p class="userinfo">
<span class="left">
<span class="info" style="margin-left: -15px;">手机号:</span>
</span>
<input type="emaila" name="telephone" id="telephone" value="" placeholder="手机号" autocomplete="off" />
<label class="layui-form-label" style=" width: 98px;">手机号:</label>
<input type="text" name="telephone" id="telephone" value="" style=" width: 250px;" placeholder="手机号" class="layui-input" autocomplete="off" />
</p>
<p class="userinfo">
<span class="left">
<span class="info" style="margin-left: -29px;">用户描述:</span>
</span>
<input type="emaila" name="content" id="content" value="" placeholder="用户描述" autocomplete="off" />
<label class="layui-form-label" style=" width: 98px;">用户描述:</label>
<input type="text" name="content" id="content" value="" style=" width: 250px;" placeholder="用户描述" class="layui-input" autocomplete="off" />
</p>
</div>
<button onclick="register()" class="btn">添加</button>
<button style="margin-top: 50px ;margin-left: -80px;width: 100px;" onclick="register()" class="layui-btn">添加</button>
</div>
</div>
</body>
......
......@@ -101,19 +101,6 @@
<p class="title list_ti"><span>数据列表</span>
</p>
<table border="" cellspacing="" cellpadding="" class="layui-table" lay-size="sm">
<tr>
<th>序号</th>
<th>组织名称</th>
<th>上级组织</th>
<th >操作</th>
</tr>
<tr>
<td>1</td>
<td>办公室</td>
<td>三级菜单</td>
<td><a href="#">删除</a> <a href="#">编辑</a></td>
</tr>
</table>
</div>
<div class="footer" style="display: flex;justify-content: space-between;align-items:center;padding:10px 10px;border:1px solid #e4e4e4;font-size:14px;color:#999">
......
......@@ -203,7 +203,7 @@
area:['300px', '165px'],
content: '<div style="margin-top: 22px;margin-left: 8px;">您确定删除用户'+name+"吗?</div>"
,
btn:['保存','取消'],
btn:['确定','取消'],
btn1: function (index,layero) {
$.post("/bpm/user/deleteUser",
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment