流程相关
This commit is contained in:
311
src/main/webapp/jsp/activiti/bpmnFileList.jsp
Normal file
311
src/main/webapp/jsp/activiti/bpmnFileList.jsp
Normal file
@ -0,0 +1,311 @@
|
||||
<%@ page language="java" pageEncoding="UTF-8"%>
|
||||
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
|
||||
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
|
||||
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
|
||||
<%@ page import="com.sipai.entity.base.ServerObject"%>
|
||||
<%@ page import="com.sipai.entity.user.User"%>
|
||||
<%@ page import="com.sipai.entity.user.Company"%>
|
||||
<%@ page import="com.sipai.service.user.UnitService"%>
|
||||
<%@ page import="org.springframework.web.context.WebApplicationContext"%>
|
||||
<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
|
||||
<%@ page import="java.util.List" %>
|
||||
<%@ taglib uri="http://www.springsecurity.org/jsp" prefix="security"%>
|
||||
<%
|
||||
String contextPath = request.getContextPath();
|
||||
User cu = (User)request.getSession().getAttribute("cu");
|
||||
WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(request.getServletContext());
|
||||
UnitService unitService = (UnitService)ctx.getBean("unitService");
|
||||
List<Company> companies = null;
|
||||
if (cu != null) {
|
||||
companies = unitService.getCompaniesByUserId(cu.getId());
|
||||
}
|
||||
%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title><%= ServerObject.atttable.get("TOPTITLE")%> - BPMN流程文件管理</title>
|
||||
<jsp:include page="/jsp/inc.jsp"></jsp:include>
|
||||
<script type="text/javascript">
|
||||
var importBpmnFun = function(path, processName) {
|
||||
// 弹出对话框让用户选择公司
|
||||
var companyId = $('#companyIdSelect').val() || '';
|
||||
var companyHtml = '<select id="dialogCompanyId" class="form-control input-sm">';
|
||||
companyHtml += '<option value="">-- 不指定公司 --</option>';
|
||||
$('#companyIdSelect option').each(function() {
|
||||
companyHtml += '<option value="' + $(this).val() + '">' + $(this).text() + '</option>';
|
||||
});
|
||||
companyHtml += '</select>';
|
||||
|
||||
swal({
|
||||
title: '导入BPMN文件',
|
||||
html: '<div class="form-group">' +
|
||||
'<label>模型名称:</label><input type="text" id="dialogModelName" class="form-control input-sm" value="' + (processName || '') + '">' +
|
||||
'</div>' +
|
||||
'<div class="form-group">' +
|
||||
'<label>所属公司:</label>' + companyHtml +
|
||||
'</div>',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
preConfirm: function() {
|
||||
return new Promise(function(resolve) {
|
||||
resolve({
|
||||
modelName: $('#dialogModelName').val(),
|
||||
companyId: $('#dialogCompanyId').val()
|
||||
});
|
||||
});
|
||||
}
|
||||
}).then(function(result) {
|
||||
if (result && result.value) {
|
||||
$.post(ext.contextPath + '/activiti/workflow/model/importBpmnFile.do', {
|
||||
bpmnFilePath: path,
|
||||
modelName: result.value.modelName,
|
||||
description: "",
|
||||
companyId: result.value.companyId
|
||||
}, function(data) {
|
||||
if (data.res == 1) {
|
||||
showAlert('s', '导入成功!模型ID: ' + data.modelId);
|
||||
$("#table").bootstrapTable('refresh');
|
||||
} else {
|
||||
showAlert('d', '导入失败!');
|
||||
}
|
||||
}, 'json');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var deployBpmnFun = function(path, filename) {
|
||||
swal({
|
||||
text: "确定要直接部署此BPMN文件吗?",
|
||||
dangerMode: true,
|
||||
buttons: {
|
||||
cancel: {
|
||||
text: "取消",
|
||||
value: null,
|
||||
visible: true,
|
||||
className: "btn btn-default btn-sm",
|
||||
closeModal: true,
|
||||
},
|
||||
confirm: {
|
||||
text: "确定",
|
||||
value: true,
|
||||
visible: true,
|
||||
className: "btn btn-danger btn-sm",
|
||||
closeModal: true
|
||||
}
|
||||
}
|
||||
}).then(function(willDelete) {
|
||||
if (willDelete) {
|
||||
$.post(ext.contextPath + '/activiti/workflow/model/deployBpmnFile.do', {
|
||||
bpmnFilePath: path,
|
||||
deploymentName: filename
|
||||
}, function(data) {
|
||||
if (data.res == 1) {
|
||||
showAlert('s', '部署成功!部署ID: ' + data.deploymentId);
|
||||
} else {
|
||||
showAlert('d', '部署失败!');
|
||||
}
|
||||
}, 'json');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var viewBpmnFun = function(path) {
|
||||
window.open(ext.contextPath + '/activiti/workflow/model/getBpmnFileContent.do?bpmnFilePath=' + encodeURIComponent(path), '_blank');
|
||||
};
|
||||
|
||||
var importAllFun = function() {
|
||||
swal({
|
||||
text: "确定要导入所有BPMN文件到模型编辑器吗?",
|
||||
dangerMode: true,
|
||||
buttons: {
|
||||
cancel: {
|
||||
text: "取消",
|
||||
value: null,
|
||||
visible: true,
|
||||
className: "btn btn-default btn-sm",
|
||||
closeModal: true,
|
||||
},
|
||||
confirm: {
|
||||
text: "确定",
|
||||
value: true,
|
||||
visible: true,
|
||||
className: "btn btn-danger btn-sm",
|
||||
closeModal: true
|
||||
}
|
||||
}
|
||||
}).then(function(willDelete) {
|
||||
if (willDelete) {
|
||||
$.post(ext.contextPath + '/activiti/workflow/model/importAllBpmnFiles.do', {}, function(data) {
|
||||
if (data.res == 1) {
|
||||
showAlert('s', '批量导入完成!成功: ' + data.successCount + ', 失败: ' + data.failCount);
|
||||
$("#table").bootstrapTable('refresh');
|
||||
} else {
|
||||
showAlert('d', '批量导入失败!');
|
||||
}
|
||||
}, 'json');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function showTable() {
|
||||
$("#table").bootstrapTable({
|
||||
url: ext.contextPath + '/activiti/workflow/model/getBpmnFileList.do',
|
||||
cache: false,
|
||||
striped: true,
|
||||
pagination: true,
|
||||
pageList: [10, 20, 50],
|
||||
pageSize: 20,
|
||||
pageNumber: 1,
|
||||
sidePagination: 'client',
|
||||
columns: [
|
||||
{
|
||||
field: 'filename',
|
||||
title: '文件名',
|
||||
align: 'left',
|
||||
valign: 'middle'
|
||||
}, {
|
||||
field: 'processId',
|
||||
title: '流程ID',
|
||||
align: 'center',
|
||||
valign: 'middle'
|
||||
}, {
|
||||
field: 'processName',
|
||||
title: '流程名称',
|
||||
align: 'center',
|
||||
valign: 'middle'
|
||||
}, {
|
||||
field: 'path',
|
||||
title: '文件路径',
|
||||
align: 'left',
|
||||
valign: 'middle',
|
||||
formatter: function(value, row) {
|
||||
if (value && value.indexOf('diagrams/') >= 0) {
|
||||
return value.substring(value.indexOf('diagrams/'));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}, {
|
||||
title: "操作",
|
||||
align: 'center',
|
||||
valign: 'middle',
|
||||
width: 280,
|
||||
formatter: function(value, row, index) {
|
||||
var path = row.path;
|
||||
if (path && path.indexOf('diagrams/') >= 0) {
|
||||
path = path.substring(path.indexOf('diagrams/') + 9);
|
||||
}
|
||||
var str = '';
|
||||
str += '<button class="btn btn-default btn-sm" onclick="importBpmnFun(\'' + path + '\', \'' + (row.processName || row.filename) + '\')" title="导入到模型编辑器"><i class="fa fa-download"></i> 导入</button>';
|
||||
str += '<button class="btn btn-default btn-sm" onclick="deployBpmnFun(\'' + path + '\', \'' + row.filename + '\')" title="直接部署"><i class="fa fa-play"></i> 部署</button>';
|
||||
str += '<button class="btn btn-default btn-sm" onclick="viewBpmnFun(\'' + path + '\')" title="查看XML"><i class="fa fa-eye"></i> 查看</button>';
|
||||
return '<div class="btn-group">' + str + '</div>';
|
||||
}
|
||||
}
|
||||
],
|
||||
onLoadSuccess: function() {
|
||||
adjustBootstrapTableView("table");
|
||||
},
|
||||
onLoadError: function() {
|
||||
console.info("加载数据失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 上传BPMN文件
|
||||
var uploadBpmnFun = function() {
|
||||
var formData = new FormData($('#uploadForm')[0]);
|
||||
$.ajax({
|
||||
url: ext.contextPath + '/activiti/workflow/model/uploadBpmnFile.do',
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(data) {
|
||||
if (data.res == 1) {
|
||||
showAlert('s', '上传导入成功!模型ID: ' + data.modelId);
|
||||
window.location.href = ext.contextPath + '/activiti/workflow/model/showModelList.do';
|
||||
} else {
|
||||
showAlert('d', '上传导入失败!');
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
showAlert('d', '上传失败!');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$(function() {
|
||||
showTable();
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body class="hold-transition ${cu.themeclass} sidebar-mini">
|
||||
<div class="wrapper">
|
||||
<div class="content-wrapper">
|
||||
<section class="content container-fluid">
|
||||
<div id="alertDiv"></div>
|
||||
<!-- 隐藏的公司选择器 -->
|
||||
<select id="companyIdSelect" style="display:none;">
|
||||
<% if (companies != null) { for (Company company : companies) { %>
|
||||
<option value="<%= company.getId() %>"><%= company.getName() %></option>
|
||||
<% } } %>
|
||||
</select>
|
||||
|
||||
<div class="form-group" style="padding:0;">
|
||||
<div class="btn-group" style="padding-bottom:10px;">
|
||||
<!-- 上传按钮 -->
|
||||
<button type="button" class="btn btn-success btn-sm" data-toggle="modal" data-target="#uploadModal">
|
||||
<i class="fa fa-upload"></i> 上传BPMN
|
||||
</button>
|
||||
<button type="button" class="btn btn-primary btn-sm" onclick="importAllFun();">
|
||||
<i class="fa fa-download"></i> 批量导入所有
|
||||
</button>
|
||||
<a href="<%=contextPath%>/activiti/workflow/model/showModelList.do" class="btn btn-default btn-sm">
|
||||
<i class="fa fa-list"></i> 模型列表
|
||||
</a>
|
||||
</div>
|
||||
<div class="form-group pull-right">
|
||||
<span class="help-block">BPMN文件目录: src/main/resources/diagrams/</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 上传对话框 -->
|
||||
<div class="modal fade" id="uploadModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"><span>×</span></button>
|
||||
<h4 class="modal-title">上传BPMN文件</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="uploadForm" enctype="multipart/form-data">
|
||||
<div class="form-group">
|
||||
<label>选择BPMN文件:</label>
|
||||
<input type="file" name="file" class="form-control" accept=".bpmn,.bpmn20.xml" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>所属公司:</label>
|
||||
<select name="companyId" class="form-control">
|
||||
<option value="">-- 请选择 --</option>
|
||||
<% if (companies != null) { for (Company company : companies) { %>
|
||||
<option value="<%= company.getId() %>"><%= company.getName() %></option>
|
||||
<% } } %>
|
||||
</select>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
|
||||
<button type="button" class="btn btn-primary" onclick="uploadBpmnFun()">上传并导入</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table id="table"></table>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@ -72,16 +72,19 @@ var companyId = "${param.unitId}";
|
||||
alert(); // 执行一些动作...
|
||||
}); */
|
||||
|
||||
/* var editFlowFun = function(id) {
|
||||
var w = window.screen.width*0.7;
|
||||
var h = window.screen.height*0.7;
|
||||
var l = window.screen.width*(1-0.7)/2;
|
||||
window.open(ext.contextPath + '/modeler.html?modelId=' + id,'_black',
|
||||
/* 编辑流程图 - 打开Activiti Modeler */
|
||||
var editFlowFun = function(id) {
|
||||
var w = window.screen.width*0.8;
|
||||
var h = window.screen.height*0.8;
|
||||
var l = window.screen.width*(1-0.8)/2;
|
||||
var t = window.screen.height*(1-0.8)/2;
|
||||
window.open(ext.contextPath + '/modeler.html?modelId=' + id,'_blank',
|
||||
"left="+ l
|
||||
+ ",top=50,scrollbars=yes,location=no,status=no,toolbar=no,resizable=yes"
|
||||
+ ",top="+ t
|
||||
+ ",scrollbars=yes,location=no,status=no,toolbar=no,resizable=yes"
|
||||
+ ",width="+w
|
||||
+ ",height="+h);
|
||||
}; */
|
||||
};
|
||||
var copyFun = function(id) {
|
||||
swal({
|
||||
text: "您确定要为该模型生成副本?",
|
||||
@ -287,11 +290,12 @@ var companyId = "${param.unitId}";
|
||||
title: "操作",
|
||||
align: 'center',
|
||||
valign: 'middle',
|
||||
width: 240, // 定义列的宽度,单位为像素px
|
||||
width: 320, // 定义列的宽度,单位为像素px
|
||||
formatter: function (value, row, index) {
|
||||
var str = '';
|
||||
str += '<security:authorize buttonUrl="activiti/workflow/model/edit.do">';
|
||||
str += '<button class="btn btn-default btn-sm" onclick="editFun(\'' + row.id + '\')" data-toggle="tooltip" title="编辑"><i class="fa fa-edit"></i><span class="hidden-md hidden-lg"> 编辑</span></button>';
|
||||
str += '<button class="btn btn-default btn-sm" onclick="editFlowFun(\'' + row.id + '\')" data-toggle="tooltip" title="流程图编辑"><i class="fa fa-project-diagram"></i><span class="hidden-md hidden-lg"> 流程图</span></button>';
|
||||
str += '<button class="btn btn-default btn-sm" onclick="copyFun(\'' + row.id + '\')" data-toggle="tooltip" title="复制"><i class="fa fa-copy"></i><span class="hidden-md hidden-lg"> 复制</span></button>';
|
||||
str += '<button class="btn btn-default btn-sm" onclick="deployFun(\'' + row.id + '\')" data-toggle="tooltip" title="部署"><i class="fa fa-play"></i><span class="hidden-md hidden-lg"> 部署</span></button>';
|
||||
str += '</security:authorize>';
|
||||
@ -413,10 +417,13 @@ var companyId = "${param.unitId}";
|
||||
</li>
|
||||
</ul> -->
|
||||
<div class="form-group " style="padding:0;">
|
||||
<div class="btn-group" style="width: 220px;padding-bottom:10px;">
|
||||
<div class="btn-group" style="padding-bottom:10px;">
|
||||
<security:authorize buttonUrl="activiti/workflow/model/add.do">
|
||||
<button type="button" class="btn btn-default btn-sm" onclick="addFun();"><i class="fa fa-plus"></i> 新增</button>
|
||||
</security:authorize>
|
||||
<a href="<%=contextPath%>/activiti/workflow/model/showBpmnFileList.do" class="btn btn-default btn-sm">
|
||||
<i class="fa fa-file-code-o"></i> BPMN文件
|
||||
</a>
|
||||
</div>
|
||||
<div class="form-group pull-right" >
|
||||
<div class="input-group input-group-sm" style="width: 250px;">
|
||||
|
||||
Reference in New Issue
Block a user