first commit
This commit is contained in:
89
bin/WebRoot/JS/activiti/leave-complete.js
Normal file
89
bin/WebRoot/JS/activiti/leave-complete.js
Normal file
@ -0,0 +1,89 @@
|
||||
|
||||
/**
|
||||
* 完成任务进入子流程
|
||||
* @param {Object} taskId
|
||||
*/
|
||||
/*function completeToSub(dialog,taskId,variables) {
|
||||
// comment为任务备注信息
|
||||
var keys = "", values = "", types = "",comment="";
|
||||
var varobj={
|
||||
keys: keys,
|
||||
values: values,
|
||||
types: types
|
||||
};
|
||||
if (variables) {
|
||||
keys = variables[0].key;
|
||||
values = variables[0].value;
|
||||
types = variables[0].type;
|
||||
varobj={
|
||||
keys: keys,
|
||||
values: values,
|
||||
types: types
|
||||
};
|
||||
comment = variables[0].comment;
|
||||
}
|
||||
alert("noleave");
|
||||
if(!comment){
|
||||
comment="";
|
||||
}
|
||||
// 发送任务完成请求
|
||||
$.post(ext.contextPath + '/activiti/leavew/complete.do' ,{taskId : taskId,comment:comment, varr:JSON.stringify(varobj)}, function(resp) {
|
||||
if (resp == 1) {
|
||||
alert('任务完成');
|
||||
dialog.dialog("destroy");
|
||||
} else {
|
||||
alert('操作失败!');
|
||||
}
|
||||
|
||||
});
|
||||
}*/
|
||||
/**
|
||||
* 完成任务附带对象信息
|
||||
* @param {Object} taskId
|
||||
* @param {Object} variables
|
||||
* @param {Object} serial 对象信息
|
||||
*/
|
||||
function complete(dialog,taskId,variables,serial) {
|
||||
// comment为任务备注信息
|
||||
var keys = "", values = "", types = "",comment="";
|
||||
var varobj={
|
||||
keys: keys,
|
||||
values: values,
|
||||
types: types
|
||||
};
|
||||
if (variables) {
|
||||
$.each(variables, function() {
|
||||
if (keys != "") {
|
||||
keys += ",";
|
||||
values += ",";
|
||||
types += ",";
|
||||
}
|
||||
keys += this.key;
|
||||
values += this.value;
|
||||
types += this.type;
|
||||
});
|
||||
varobj={
|
||||
keys: keys,
|
||||
values: values,
|
||||
types: types
|
||||
};
|
||||
comment = variables[0].comment;
|
||||
}
|
||||
if(!comment){
|
||||
comment="";
|
||||
}else{
|
||||
comment = encodeURI(encodeURI(comment));
|
||||
}
|
||||
// 发送任务完成请求
|
||||
$.post(ext.contextPath + '/activiti/leavew/complete.do?taskId='+taskId+'&comment='+comment+'&varr='+JSON.stringify(varobj) , serial, function(resp) {
|
||||
if (resp == 1) {
|
||||
alert('任务完成');
|
||||
dialog.dialog("destroy");
|
||||
} else {
|
||||
alert('操作失败!');
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
421
bin/WebRoot/JS/activiti/leave-todo.js
Normal file
421
bin/WebRoot/JS/activiti/leave-todo.js
Normal file
@ -0,0 +1,421 @@
|
||||
/**
|
||||
* 请假流程任务办理
|
||||
*/
|
||||
$(function() {
|
||||
|
||||
// 签收
|
||||
$('.claim').button({
|
||||
icons: {
|
||||
primary: 'ui-icon-person'
|
||||
}
|
||||
});
|
||||
|
||||
// 办理
|
||||
$('.handle').button({
|
||||
icons: {
|
||||
primary: 'ui-icon-comment'
|
||||
}
|
||||
}).click(handle);
|
||||
|
||||
// 跟踪
|
||||
$('.trace').click(graphTrace);
|
||||
alert();
|
||||
});
|
||||
|
||||
|
||||
// 用于保存加载的详细信息
|
||||
var detail = {};
|
||||
|
||||
/**
|
||||
* 加载详细信息
|
||||
* @param {Object} id
|
||||
*/
|
||||
function loadDetail(id, withVars, callback) {
|
||||
var dialog = this;
|
||||
$.getJSON(ctx + '/oa/leave/detail/' + id, function(data) {
|
||||
detail = data;
|
||||
$.each(data, function(k, v) {
|
||||
|
||||
// 格式化日期
|
||||
if (k == 'applyTime' || k == 'startTime' || k == 'endTime') {
|
||||
$('.view-info td[name=' + k + ']', dialog).text(new Date(v).format('yyyy-MM-dd hh:mm'));
|
||||
} else {
|
||||
$('.view-info td[name=' + k + ']', dialog).text(v);
|
||||
}
|
||||
|
||||
});
|
||||
if ($.isFunction(callback)) {
|
||||
callback(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载详细信息,同时读取流程任务变量
|
||||
* @param {Object} id
|
||||
*/
|
||||
function loadDetailWithTaskVars(leaveId, taskId, callback) {
|
||||
var dialog = this;
|
||||
$.getJSON(ctx + '/oa/leave/detail-with-vars/' + leaveId + "/" + taskId, function(data) {
|
||||
detail = data;
|
||||
$.each(data, function(k, v) {
|
||||
// 格式化日期
|
||||
if (k == 'applyTime' || k == 'startTime' || k == 'endTime') {
|
||||
$('.view-info td[name=' + k + ']', dialog).text(new Date(v).format('yyyy-MM-dd hh:mm'));
|
||||
} else {
|
||||
$('.view-info td[name=' + k + ']', dialog).text(v);
|
||||
}
|
||||
});
|
||||
if ($.isFunction(callback)) {
|
||||
callback(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成任务
|
||||
* @param {Object} taskId
|
||||
*/
|
||||
function complete(taskId, variables) {
|
||||
var dialog = this;
|
||||
|
||||
// 转换JSON为字符串
|
||||
var keys = "", values = "", types = "";
|
||||
if (variables) {
|
||||
$.each(variables, function() {
|
||||
if (keys != "") {
|
||||
keys += ",";
|
||||
values += ",";
|
||||
types += ",";
|
||||
}
|
||||
keys += this.key;
|
||||
values += this.value;
|
||||
types += this.type;
|
||||
});
|
||||
}
|
||||
|
||||
$.blockUI({
|
||||
message: '<h2><img src="' + ctx + '/images/ajax/loading.gif" align="absmiddle"/>正在提交请求……</h2>'
|
||||
});
|
||||
|
||||
// 发送任务完成请求
|
||||
$.post(ctx + '/oa/leave/complete/' + taskId, {
|
||||
keys: keys,
|
||||
values: values,
|
||||
types: types
|
||||
}, function(resp) {
|
||||
$.unblockUI();
|
||||
if (resp == 'success') {
|
||||
alert('任务完成');
|
||||
location.reload();
|
||||
} else {
|
||||
alert('操作失败!');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 使用json方式定义每个节点的按钮
|
||||
* 以及按钮的功能
|
||||
*
|
||||
* open:打开对话框的时候需要处理的任务
|
||||
* btns:对话框显示的按钮
|
||||
*/
|
||||
var handleOpts = {
|
||||
deptLeaderAudit: {
|
||||
width: 300,
|
||||
height: 300,
|
||||
open: function(id) {
|
||||
|
||||
// 打开对话框的时候读取请假内容
|
||||
loadDetail.call(this, id);
|
||||
},
|
||||
btns: [{
|
||||
text: '同意',
|
||||
click: function() {
|
||||
var taskId = $(this).data('taskId');
|
||||
|
||||
// 设置流程变量
|
||||
complete(taskId, [{
|
||||
key: 'deptLeaderPass',
|
||||
value: true,
|
||||
type: 'B'
|
||||
}]);
|
||||
}
|
||||
}, {
|
||||
text: '驳回',
|
||||
click: function() {
|
||||
var taskId = $(this).data('taskId');
|
||||
|
||||
$('<div/>', {
|
||||
title: '填写驳回理由',
|
||||
html: "<textarea id='leaderBackReason' style='width: 250px; height: 60px;'></textarea>"
|
||||
}).dialog({
|
||||
modal: true,
|
||||
open: function() {
|
||||
|
||||
},
|
||||
buttons: [{
|
||||
text: '驳回',
|
||||
click: function() {
|
||||
var leaderBackReason = $('#leaderBackReason').val();
|
||||
if (leaderBackReason == '') {
|
||||
alert('请输入驳回理由!');
|
||||
return;
|
||||
}
|
||||
|
||||
// 设置流程变量
|
||||
complete(taskId, [{
|
||||
key: 'deptLeaderPass',
|
||||
value: false,
|
||||
type: 'B'
|
||||
}, {
|
||||
key: 'leaderBackReason',
|
||||
value: leaderBackReason,
|
||||
type: 'S'
|
||||
}]);
|
||||
}
|
||||
}, {
|
||||
text: '取消',
|
||||
click: function() {
|
||||
$(this).dialog('close');
|
||||
$('#deptLeaderAudit').dialog('close');
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
}, {
|
||||
text: '取消',
|
||||
click: function() {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
}]
|
||||
},
|
||||
hrAudit: {
|
||||
width: 300,
|
||||
height: 300,
|
||||
open: function(id) {
|
||||
// 打开对话框的时候读取请假内容
|
||||
loadDetail.call(this, id);
|
||||
},
|
||||
btns: [{
|
||||
text: '同意',
|
||||
click: function() {
|
||||
var taskId = $(this).data('taskId');
|
||||
|
||||
// 设置流程变量
|
||||
complete(taskId, [{
|
||||
key: 'hrPass',
|
||||
value: true,
|
||||
type: 'B'
|
||||
}]);
|
||||
}
|
||||
}, {
|
||||
text: '驳回',
|
||||
click: function() {
|
||||
var taskId = $(this).data('taskId');
|
||||
|
||||
$('<div/>', {
|
||||
title: '填写驳回理由',
|
||||
html: "<textarea id='hrBackReason' style='width: 250px; height: 60px;'></textarea>"
|
||||
}).dialog({
|
||||
modal: true,
|
||||
buttons: [{
|
||||
text: '驳回',
|
||||
click: function() {
|
||||
var hrBackReason = $('#hrBackReason').val();
|
||||
if (hrBackReason == '') {
|
||||
alert('请输入驳回理由!');
|
||||
return;
|
||||
}
|
||||
|
||||
// 设置流程变量
|
||||
complete(taskId, [{
|
||||
key: 'hrPass',
|
||||
value: false,
|
||||
type: 'B'
|
||||
}, {
|
||||
key: 'hrBackReason',
|
||||
value: hrBackReason,
|
||||
type: 'S'
|
||||
}]);
|
||||
}
|
||||
}, {
|
||||
text: '取消',
|
||||
click: function() {
|
||||
$(this).dialog('close');
|
||||
$('#deptLeaderAudit').dialog('close');
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
}, {
|
||||
text: '取消',
|
||||
click: function() {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
}]
|
||||
},
|
||||
modifyApply: {
|
||||
width: 500,
|
||||
height: 470,
|
||||
open: function(id, taskId) {
|
||||
var dialog = this;
|
||||
|
||||
$('#startTime,#endTime', this).datetimepicker({
|
||||
stepMinute: 5
|
||||
});
|
||||
|
||||
// 打开对话框的时候读取请假内容
|
||||
loadDetailWithTaskVars.call(this, id, taskId, function(data) {
|
||||
// 显示驳回理由
|
||||
$('.info').show().html("<b>领导:</b>" + (data.variables.leaderBackReason || "") + "<br/><b>HR:</b>" + (data.variables.hrBackReason || ""));
|
||||
|
||||
// 读取原请假信息
|
||||
$('#modifyApplyContent #leaveType option[value=' + data.leaveType + ']').attr('selected', true);
|
||||
$('#modifyApplyContent #startTime').val(new Date(data.startTime).format('yyyy-MM-dd hh:mm'));
|
||||
$('#modifyApplyContent #endTime').val(new Date(data.endTime).format('yyyy-MM-dd hh:mm'));
|
||||
$('#modifyApplyContent #reason').val(data.reason);
|
||||
});
|
||||
|
||||
// 切换状态
|
||||
$("#radio").buttonset().change(function(){
|
||||
var type = $(':radio[name=reApply]:checked').val();
|
||||
if (type == 'true') {
|
||||
$('#modifyApplyContent').show();
|
||||
} else {
|
||||
$('#modifyApplyContent').hide();
|
||||
}
|
||||
});
|
||||
},
|
||||
btns: [{
|
||||
text: '提交',
|
||||
click: function() {
|
||||
var taskId = $(this).data('taskId');
|
||||
var reApply = $(':radio[name=reApply]:checked').val();
|
||||
|
||||
// 提交的时候把变量
|
||||
complete(taskId, [{
|
||||
key: 'reApply',
|
||||
value: reApply,
|
||||
type: 'B'
|
||||
}, {
|
||||
key: 'leaveType',
|
||||
value: $('#modifyApplyContent #leaveType').val(),
|
||||
type: 'S'
|
||||
}, {
|
||||
key: 'startTime',
|
||||
value: $('#modifyApplyContent #startTime').val(),
|
||||
type: 'D'
|
||||
}, {
|
||||
key: 'endTime',
|
||||
value: $('#modifyApplyContent #endTime').val(),
|
||||
type: 'D'
|
||||
}, {
|
||||
key: 'reason',
|
||||
value: $('#modifyApplyContent #reason').val(),
|
||||
type: 'S'
|
||||
}]);
|
||||
}
|
||||
},{
|
||||
text: '取消',
|
||||
click: function() {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
}]
|
||||
},
|
||||
reportBack: {
|
||||
width: 400,
|
||||
height: 400,
|
||||
open: function(id, taskId) {
|
||||
// 打开对话框的时候读取请假内容
|
||||
loadDetail.call(this, id, taskId);
|
||||
$('#realityStartTime,#realityEndTime').datetimepicker({
|
||||
stepMinute: 5
|
||||
});
|
||||
},
|
||||
btns: [{
|
||||
text: '提交',
|
||||
click: function() {
|
||||
var realityStartTime = $('#realityStartTime').val();
|
||||
var realityEndTime = $('#realityEndTime').val();
|
||||
|
||||
if (realityStartTime == '') {
|
||||
alert('请选择实际开始时间!');
|
||||
return;
|
||||
}
|
||||
|
||||
if (realityEndTime == '') {
|
||||
alert('请选择实际结束时间!');
|
||||
return;
|
||||
}
|
||||
|
||||
var taskId = $(this).data('taskId');
|
||||
complete(taskId, [{
|
||||
key: 'realityStartTime',
|
||||
value: realityStartTime,
|
||||
type: 'D'
|
||||
}, {
|
||||
key: 'realityEndTime',
|
||||
value: realityEndTime,
|
||||
type: 'D'
|
||||
}]);
|
||||
}
|
||||
},{
|
||||
text: '取消',
|
||||
click: function() {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
}]
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 办理流程
|
||||
*/
|
||||
function handle() {
|
||||
// 当前节点的英文名称
|
||||
var tkey = $(this).attr('tkey');
|
||||
|
||||
// 当前节点的中文名称
|
||||
var tname = $(this).attr('tname');
|
||||
|
||||
// 请假记录ID
|
||||
var rowId = $(this).parents('tr').attr('id');
|
||||
|
||||
// 任务ID
|
||||
var taskId = $(this).parents('tr').attr('tid');
|
||||
|
||||
// 使用对应的模板
|
||||
$('#' + tkey).data({
|
||||
taskId: taskId
|
||||
}).dialog({
|
||||
title: '流程办理[' + tname + ']',
|
||||
modal: true,
|
||||
width: handleOpts[tkey].width,
|
||||
height: handleOpts[tkey].height,
|
||||
open: function() {
|
||||
handleOpts[tkey].open.call(this, rowId, taskId);
|
||||
},
|
||||
buttons: handleOpts[tkey].btns
|
||||
});
|
||||
}
|
||||
|
||||
Date.prototype.format = function(format) {
|
||||
var o = {
|
||||
"M+": this.getMonth() + 1, //month
|
||||
"d+": this.getDate(), //day
|
||||
"h+": this.getHours(), //hour
|
||||
"m+": this.getMinutes(), //minute
|
||||
"s+": this.getSeconds(), //second
|
||||
"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
|
||||
"S": this.getMilliseconds() //millisecond
|
||||
}
|
||||
if (/(y+)/.test(format))
|
||||
format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
|
||||
for (var k in o)
|
||||
if (new RegExp("(" + k + ")").test(format))
|
||||
format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
|
||||
return format;
|
||||
}
|
||||
156
bin/WebRoot/JS/activiti/workflow.js
Normal file
156
bin/WebRoot/JS/activiti/workflow.js
Normal file
@ -0,0 +1,156 @@
|
||||
/*options流程附加信息显示标示
|
||||
pid_流程实例id
|
||||
pdid_流程定义id*/
|
||||
function graphTrace(pid_,pdid_,taskid_) {
|
||||
//alert(pdid_);
|
||||
var _defaults = {
|
||||
srcEle: this,
|
||||
pid: pid_,//$(this).attr('pid'),
|
||||
pdid: pdid_,// $(this).attr('pdid')
|
||||
taskid: taskid_// $(this).attr('pdid')
|
||||
};
|
||||
var opts = $.extend(true, _defaults);
|
||||
// 获取图片资源,如果流程实例id不为空,根据实例id调用资源显示;若为空则调用流程定义资源显示
|
||||
if(opts.pid!=""){
|
||||
var imageUrl = ext.contextPath + "/activiti/workflow/resource/process-instance.do?pid=" + opts.pid + "&type=image";
|
||||
$.getJSON(ext.contextPath + '/activiti/workflow/process/trace.do?pid=' + opts.pid+'&taskId='+opts.taskid, function(infos) {
|
||||
var positionHtml = "";
|
||||
var toppx=60;
|
||||
var leftpx=8;
|
||||
//console.info("trace返回结果",infos)
|
||||
// 生成图片
|
||||
var varsArray = new Array();
|
||||
$.each(infos, function(i, v) {
|
||||
//console.info("第"+i+"个节点",v)
|
||||
var $positionDiv = $('<div/>', {
|
||||
'class': 'activity-attr'
|
||||
}).css({
|
||||
position: 'absolute',
|
||||
left: (v.x + leftpx-1),
|
||||
top: (v.y + toppx-1),
|
||||
width: (v.width - 2),
|
||||
height: (v.height - 2),
|
||||
backgroundColor: 'black',
|
||||
opacity: 0
|
||||
});
|
||||
// alert("节点边框");
|
||||
// 节点边框
|
||||
var $border = $('<div/>', {
|
||||
'class': 'activity-attr-border'
|
||||
}).css({
|
||||
position: 'absolute',
|
||||
left: (v.x+leftpx),
|
||||
top: (v.y+toppx),
|
||||
width: (v.width -4),
|
||||
height: (v.height -4 ),
|
||||
});
|
||||
|
||||
if (v.currentActiviti) {
|
||||
console.log("当前节点",v)
|
||||
$border.addClass('ui-corner-all-12').css({
|
||||
border: '3px solid red'
|
||||
});
|
||||
|
||||
}
|
||||
// alert($positionDiv.prop('outerHTML'));
|
||||
positionHtml += $positionDiv.prop('outerHTML') + $border.prop('outerHTML');
|
||||
|
||||
varsArray[varsArray.length] = v.vars;
|
||||
|
||||
});
|
||||
|
||||
if ($('#workflowTraceDialog').length == 0) {
|
||||
$('<div/>', {
|
||||
id: 'workflowTraceDialog',
|
||||
title: '查看流程',
|
||||
html: "<div style='position:relative'><img style='margin:" + toppx + "px 0 0 "+ leftpx + "px' src='" + imageUrl + "' />" +
|
||||
"<div id='processImageBorder' style='position:absolute; left:0px; top:0px;'>" +
|
||||
positionHtml +
|
||||
"</div>" +
|
||||
"</div>"
|
||||
}).appendTo('body');
|
||||
$(document.body).addClass("easyui-layout");
|
||||
} else {
|
||||
$('#workflowTraceDialog img').attr('src', imageUrl);
|
||||
$('#workflowTraceDialog #processImageBorder').html(positionHtml);
|
||||
}
|
||||
// 设置每个节点的data
|
||||
$('#workflowTraceDialog .activity-attr').each(function(i, v) {
|
||||
$(this).data('vars', varsArray[i]);
|
||||
});
|
||||
// 打开对话框
|
||||
$('#workflowTraceDialog').dialog({
|
||||
modal: true,
|
||||
resizable: true,
|
||||
dragable: false,
|
||||
open: function() {
|
||||
$('#workflowTraceDialog').dialog('option', 'title', '查看流程()<button id="changeImg">如果坐标错乱请点击这里</button><button id="diagram-viewer">Diagram-Viewer</button>');
|
||||
$('#workflowTraceDialog').css('padding', '0.2em');
|
||||
$('#workflowTraceDialog .ui-accordion-content').css('padding', '0.2em').height($('#workflowTraceDialog').height() - 75);
|
||||
|
||||
// 此处用于显示每个节点的信息,如果不需要可以删除
|
||||
$('.activity-attr').qtip({
|
||||
content: function() {
|
||||
var vars = $(this).data('vars');
|
||||
var tipContent = "<table class='need-border'>";
|
||||
$.each(vars, function(varKey, varValue) {
|
||||
if (varValue) {
|
||||
tipContent += "<tr><td class='label'>" + varKey + "</td><td>" + varValue + "<td/></tr>";
|
||||
}
|
||||
});
|
||||
tipContent += "</table>";
|
||||
return tipContent;
|
||||
},
|
||||
position: {
|
||||
at: 'bottom left',
|
||||
adjust: {
|
||||
x: 3
|
||||
}
|
||||
}
|
||||
});
|
||||
// end qtip
|
||||
},
|
||||
close: function() {
|
||||
$('#workflowTraceDialog').remove();
|
||||
},
|
||||
width: document.documentElement.clientWidth * 0.95,
|
||||
height: document.documentElement.clientHeight * 0.95
|
||||
});
|
||||
|
||||
});
|
||||
}else{
|
||||
//调用流程定义资源显示
|
||||
var imageUrl = ext.contextPath + "/activiti/workflow/resource/read.do?processDefinitionId=" + opts.pdid + "&resourceType=image";
|
||||
var positionHtml = "";
|
||||
var toppx=60;
|
||||
var leftpx=8;
|
||||
$.getJSON(ext.contextPath + '/activiti/workflow/processDefinition/trace.do?pdid=' + opts.pdid, function(infos) {
|
||||
// 生成图片
|
||||
if ($('#workflowTraceDialog').length == 0) {
|
||||
$('<div/>', {
|
||||
id: 'workflowTraceDialog',
|
||||
title: '查看流程',
|
||||
html: "<div><img style='overflow:scroll;margin:" + toppx + "px 0 0 "+ leftpx + "px' src='" + imageUrl + "'/>" +
|
||||
"</div>"
|
||||
}).appendTo('body');
|
||||
$(document.body).addClass("easyui-layout");
|
||||
} else {
|
||||
$('#workflowTraceDialog img').attr('src', imageUrl);
|
||||
}
|
||||
// 打开对话框
|
||||
$('#workflowTraceDialog').dialog({
|
||||
modal: true,
|
||||
resizable: true,
|
||||
dragable: false,
|
||||
onOpen: function() {
|
||||
},
|
||||
onClose: function() {
|
||||
$('#workflowTraceDialog').remove();
|
||||
},
|
||||
width: document.documentElement.clientWidth * 0.95,
|
||||
height: document.documentElement.clientHeight * 0.95
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
132
bin/WebRoot/JS/activiti/workflow_xml.js
Normal file
132
bin/WebRoot/JS/activiti/workflow_xml.js
Normal file
@ -0,0 +1,132 @@
|
||||
/*options流程附加信息显示标示.线边库存为xbk,品质扣料为kl
|
||||
pid_流程实例id
|
||||
pdid_流程定义id*/
|
||||
function graphTrace(options,pdid_) {
|
||||
//alert(pdid_);
|
||||
var _defaults = {
|
||||
srcEle: this,
|
||||
pdid: pdid_,// $(this).attr('pdid')
|
||||
detail: options// $(this).attr('pdid')
|
||||
};
|
||||
var opts = $.extend(true, _defaults);
|
||||
// 获取图片资源,如果流程实例id不为空,根据实例id调用资源显示;若为空则调用流程定义资源显示
|
||||
//console.info(opts)
|
||||
if(opts.detail!=""){
|
||||
//调用流程定义资源显示
|
||||
var imageUrl = ext.contextPath + "/activiti/workflow/resource/read.do?processDefinitionId=" + opts.pdid + "&resourceType=image";
|
||||
var positionHtml = "";
|
||||
var toppx=60;
|
||||
var leftpx=8;
|
||||
var key =opts.detail;
|
||||
$.getJSON(ext.contextPath + '/work/scadaPic/traceProcessDefinitionWithPInfo.do?pdid=' + opts.pdid+"&key="+key, function(infos) {
|
||||
//console.info("infos:",infos)
|
||||
// 生成图片
|
||||
var varsArray = new Array();
|
||||
$.each(infos, function(i, v) {
|
||||
var $positionDiv = $('<div/>', {
|
||||
'class': 'activity-attr'
|
||||
}).css({
|
||||
position: 'absolute',
|
||||
left: (v.x +leftpx),
|
||||
top: (v.y +toppx),
|
||||
width: (v.width ),
|
||||
height: (v.height),
|
||||
opacity: 1,
|
||||
textAlign:"center"
|
||||
});
|
||||
// 节点边框
|
||||
var $border = $('<div/>', {
|
||||
'class': 'activity-attr-border'
|
||||
}).css({
|
||||
position: 'absolute',
|
||||
left: (v.x + leftpx ),
|
||||
top: (v.y +toppx),
|
||||
width: (v.width ),
|
||||
height: (v.height )
|
||||
});
|
||||
|
||||
if (v.taskActiviti) {
|
||||
$border.addClass('ui-corner-all-12').css({
|
||||
border: '3px solid red'
|
||||
});
|
||||
}
|
||||
//$positionDiv.textbox("setValue","sssss");
|
||||
positionHtml += $positionDiv.prop("outerHTML") + $border.prop("outerHTML");
|
||||
varsArray[varsArray.length] = v.vars;
|
||||
});
|
||||
if ($('#workflowTraceDialog').length == 0) {
|
||||
$('<div/>', {
|
||||
id: 'workflowTraceDialog',
|
||||
title: '查看流程',
|
||||
html: "<div ><img style='margin:" + toppx + "px 0 0 "+ leftpx + "px' src='" + imageUrl + "' />" +
|
||||
"<div id='processImageBorder'>" +
|
||||
positionHtml +
|
||||
"</div>" +
|
||||
"</div>"
|
||||
}).appendTo('body');
|
||||
$(document.body).addClass("easyui-layout");
|
||||
} else {
|
||||
$('#workflowTraceDialog img').attr('src', imageUrl);
|
||||
}
|
||||
// 设置每个节点的data
|
||||
$('#workflowTraceDialog .activity-attr').each(function(i, v) {
|
||||
//console.info("setVars")
|
||||
$(this).data('vars', varsArray[i]);
|
||||
});
|
||||
//console.info("activity-attr-info:",$('#workflowTraceDialog .activity-attr'))
|
||||
//console.info(varsArray)
|
||||
// $('#workflowTraceDialog').dialog('option', 'title', '查看流程<button id="changeImg">如果坐标错乱请点击这里</button><button id="diagram-viewer">Diagram-Viewer</button>');
|
||||
// $('#workflowTraceDialog').css('padding', '0.2em');
|
||||
// $('#workflowTraceDialog .ui-accordion-content').css('padding', '0.2em').height($('#workflowTraceDialog').height() - 75);
|
||||
console.info("open")
|
||||
// 此处用于显示每个节点的信息,如果不需要可以删除
|
||||
//console.info($('.activity-attr'));
|
||||
$('.activity-attr').each(function(i,v){
|
||||
var vars = $(this).data('vars');
|
||||
//console.info("每个节点信息"+vars)
|
||||
var content="";
|
||||
$.each(vars, function(varKey, varValue) {
|
||||
if (varKey==key) {
|
||||
content += '<span style="color:#117cb0">'+varValue+'</span>';;
|
||||
}
|
||||
|
||||
});
|
||||
$(this).append(content);
|
||||
});
|
||||
});
|
||||
}else{
|
||||
//调用流程定义资源显示
|
||||
var imageUrl = ext.contextPath + "/activiti/workflow/resource/read.do?processDefinitionId=" + opts.pdid + "&resourceType=image";
|
||||
var positionHtml = "";
|
||||
var toppx=60;
|
||||
var leftpx=8;
|
||||
$.getJSON(ext.contextPath + '/activiti/workflow/processDefinition/trace.do?pdid=' + opts.pdid, function(infos) {
|
||||
// 生成图片
|
||||
if ($('#workflowTraceDialog').length == 0) {
|
||||
$('<div/>', {
|
||||
id: 'workflowTraceDialog',
|
||||
title: '查看流程',
|
||||
html: "<div><img style='overflow:scroll;margin:" + toppx + "px 0 0 "+ leftpx + "px' src='" + imageUrl + "' />" +
|
||||
"</div>"
|
||||
}).appendTo('body');
|
||||
$(document.body).addClass("easyui-layout");
|
||||
} else {
|
||||
$('#workflowTraceDialog img').attr('src', imageUrl);
|
||||
}
|
||||
// 打开对话框
|
||||
/* $('#workflowTraceDialog').dialog({
|
||||
modal: true,
|
||||
resizable: true,
|
||||
dragable: false,
|
||||
onOpen: function() {
|
||||
},
|
||||
onClose: function() {
|
||||
$('#workflowTraceDialog').remove();
|
||||
},
|
||||
width: document.documentElement.clientWidth * 0.95,
|
||||
height: document.documentElement.clientHeight * 0.95
|
||||
});*/
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user