890 lines
26 KiB
JavaScript
890 lines
26 KiB
JavaScript
$(function () {
|
||
recordShapeText();
|
||
$("#bar_save").off("click").on("click", function () {
|
||
if (isAutoSave == "1") {
|
||
var obj = Model.define;
|
||
//alert("保存");
|
||
var str = JSON.stringify(obj);
|
||
var imgPath = $("input[name='imgPath']").val();
|
||
$.base64.utf8encode = true;
|
||
var data = "jsonParams=" + $.base64.btoa(str) + "&imgPath=" + $.base64.btoa(imgPath);
|
||
$.ajax({
|
||
type: "POST",
|
||
url: "../coeTeamPalDesignerImageServlet.wf?&uuid=" + chartId,
|
||
data: data,
|
||
success: function (msg, textStatus, jqXHR) {
|
||
debugger;
|
||
if (msg == "true") {
|
||
alert("保存成功");
|
||
} else {
|
||
console.log(msg);
|
||
alert(msg);
|
||
}
|
||
},
|
||
error: function (jqXHR, textStatus, errorThrown) {
|
||
$.simpleAlert(errorThrown, 'err');
|
||
console.log(jqXHR);
|
||
console.log(textStatus);
|
||
console.log(errorThrown)
|
||
}
|
||
});
|
||
} else if (isAutoSave == "0") {
|
||
//保存开始时间戳
|
||
//var saveStartTime = new Date().getTime();
|
||
if (isCorrelateBpms) {
|
||
// if (type == "bpmn" && !isMarked && ($("#bar_rmark").length > 0 && $("#bar_rmark").is(":visible") || $("#bar_cancel_aws_correlate").length > 0 && $("#bar_cancel_aws_correlate").is(":visible"))) {
|
||
var op = "edit|" + processDefVersionId;
|
||
saveDesigner(null, true, op, true);
|
||
} else {
|
||
if (methodId == "process.bpmn2" && isPalManage) {
|
||
BPMNBiz.validateBPMN(false, function () {
|
||
save()
|
||
});
|
||
} else {
|
||
save();
|
||
}
|
||
|
||
function save() {
|
||
saveWps();
|
||
$.simpleAlert("正在保存", "loading");
|
||
var params = {
|
||
sid: CLB.sid,
|
||
cmd: "com.actionsoft.apps.coe.pal_pl_repository_process_lock_state_check",
|
||
uuid: ruuid
|
||
};
|
||
$.ajax({
|
||
type: "POST",
|
||
url: "./jd",
|
||
data: params,
|
||
success: function (msg, textStatus, jqXHR) {
|
||
if (msg.result == 'ok') {
|
||
var canSave = msg.data.canSave;
|
||
var lockUser = msg.data.lockUser;
|
||
if (!canSave) {
|
||
$.simpleAlert("该流程文件已被" + lockUser + "锁定", 'info', 2000, {
|
||
callback: function () {
|
||
BPMNBiz.refreshDesigner();//刷新
|
||
}
|
||
});
|
||
} else {
|
||
initSaveFun();
|
||
}
|
||
} else {
|
||
$.simpleAlert(msg.msg, 'error', 1500, {
|
||
callback: function () {
|
||
BPMNBiz.refreshDesigner();//刷新
|
||
}
|
||
});
|
||
}
|
||
},
|
||
error: function (jqXHR, textStatus, errorThrown) {
|
||
$.simpleAlert("close");
|
||
$.simpleAlert('保存失败', 'error', 1500);
|
||
}
|
||
});
|
||
}
|
||
|
||
function initSaveFun() {
|
||
Dock.showView('');
|
||
var obj = Model.define;
|
||
if (!obj.nodeLinkerRecord) {
|
||
obj.nodeLinkerRecord = definition.nodeLinkerRecord
|
||
}
|
||
var tempMessageArr = {};
|
||
// 保存前校验,过滤可能出现的错误数据
|
||
for (var messageId in messageArrayForSave) {
|
||
var action = messageArrayForSave[messageId].action;
|
||
if (action == 'remove' && obj.elements[messageId] != undefined) continue;
|
||
if ((action == 'create' || action == 'update') && messageArrayForSave[messageId].name == shapeTextRecord[messageId]) continue;
|
||
tempMessageArr[messageId] = messageArrayForSave[messageId];
|
||
}
|
||
var messageArray = JSON.stringify(tempMessageArr);
|
||
$.ajax({
|
||
type: "POST",
|
||
url: "./jd",
|
||
data: {
|
||
sid: CLB.sid,
|
||
cmd: "com.actionsoft.apps.coe.pal_repository_define_shape_attr_valid",
|
||
uuid: ruuid,
|
||
define: awsui.encode(obj),
|
||
},
|
||
success: function (msg, textStatus, jqXHR) {
|
||
/*if(msg.result == "ok") {*/
|
||
$.ajax({
|
||
type: "POST",
|
||
url: "./jd",
|
||
data: {
|
||
sid: CLB.sid,
|
||
cmd: "com.actionsoft.apps.coe.pal_repository_process_define_save",
|
||
uuid: ruuid,
|
||
define: awsui.encode(obj),
|
||
teamId: $("#teamId").val(),
|
||
BPMInstanceName: BPMInstanceName,
|
||
messages: messageArray
|
||
},
|
||
success: function (msg, textStatus, jqXHR) {
|
||
if (msg.result == "ok") {
|
||
$.simpleAlert("close");
|
||
messageArrayForSave = {};
|
||
$("#saving_tip").css("color", "rgb(26, 164, 125)");
|
||
$("#saving_tip").text("保存成功");
|
||
recordShapeText();// 记录最新的节点及其文本text
|
||
//更多属性的处理,当节点处理完成后再处理更多属性
|
||
if (saveAttributesJson.length > 0 || removeAttributeJson.length > 0) {
|
||
$.ajax({
|
||
type: "POST",
|
||
url: "./jd",
|
||
data: {
|
||
sid: encodeURI(CLB.sid),
|
||
cmd: "com.actionsoft.apps.coe.pal_pl_repository_more_attribute_save",
|
||
wsId: $("#wsId").val(),
|
||
uuid: ruuid,
|
||
attributesJson: JSON.stringify(saveAttributesJson),
|
||
removeAttributeJson: JSON.stringify(removeAttributeJson)
|
||
},
|
||
success: function (r) {
|
||
saveAttributesJson = [];
|
||
removeAttributeJson = [];
|
||
},
|
||
error: function (r) {
|
||
}
|
||
});
|
||
}
|
||
definition.nodeLinkerRecord = msg.data.define.nodeLinkerRecord;
|
||
$.simpleAlert("保存成功", "ok");
|
||
manualSave_resetTimes();// 触发定时保存重置
|
||
//保存结束时间戳
|
||
//var saveEndTime = new Date().getTime();
|
||
//console.log("流程保存时间:", (saveEndTime - saveStartTime) + "毫秒");
|
||
} else {
|
||
$.simpleAlert("close");
|
||
$.simpleAlert(msg.data.desc, 'error', 2000);
|
||
}
|
||
},
|
||
error: function (jqXHR, textStatus, errorThrown) {
|
||
$.simpleAlert("close");
|
||
$.simpleAlert('保存失败', 'error', 1500);
|
||
}
|
||
});
|
||
/*} else {
|
||
$.simpleAlert("close");
|
||
var result = msg.data;
|
||
var resultMsg = [];
|
||
for (var i = 0; i < result.length; i++) {
|
||
var o = result[i];
|
||
resultMsg.push('[' + o.shapeName + ']的[' + o.attrName + ']不能为空' );
|
||
}
|
||
$.simpleAlert(resultMsg.join('<br>'), 'error');
|
||
// $.simpleAlert(ro.msg, 'error');
|
||
}*/
|
||
},
|
||
error: function (jqXHR, textStatus, errorThrown) {
|
||
$.simpleAlert("close");
|
||
$.simpleAlert('校验失败', 'error', 1500);
|
||
}
|
||
})
|
||
}
|
||
}
|
||
}
|
||
//取消异步发送
|
||
});
|
||
if (isAutoSave == "0") {
|
||
window.onbeforeunload = function () {
|
||
if ($("#saving_tip").text() != "已保存成功" && $("#saving_tip").text() != "保存成功" && $("#saving_tip").text() != "您的文件已经成功保存" && $("#saving_tip").text() != "") {
|
||
return "页面中有未保存的内容,请先保存";
|
||
} else {
|
||
//关闭页面时,释放编辑权
|
||
awsui.ajax.request({
|
||
type: "POST",
|
||
url: "./jd",
|
||
async: false,
|
||
data: {
|
||
sid: CLB.sid,
|
||
cmd: "com.actionsoft.apps.coe.pal_repository_process_define_edit_releaselock",
|
||
uuid: ruuid
|
||
}
|
||
});
|
||
}
|
||
};
|
||
//在弹出“是否离开”的提示框后,选择离开,则触发onunload事件
|
||
window.onunload = function () {
|
||
//关闭页面时,释放编辑权
|
||
console.log("释放编辑权");
|
||
awsui.ajax.request({
|
||
type: "POST",
|
||
url: "./jd",
|
||
async: false,
|
||
data: {
|
||
sid: CLB.sid,
|
||
cmd: "com.actionsoft.apps.coe.pal_repository_process_define_edit_releaselock",
|
||
uuid: ruuid
|
||
}
|
||
});
|
||
};
|
||
// saveTimer();
|
||
intervalRefresh();
|
||
}
|
||
/**
|
||
* 质量校验
|
||
*/
|
||
$("#QualityInspection").off("click").on("click", function () {
|
||
$.simpleAlert("正在校验", "loading");
|
||
var obj = Model.define;
|
||
$.ajax({
|
||
type: "POST",
|
||
url: "./jd",
|
||
data: {
|
||
sid: CLB.sid,
|
||
cmd: "com.actionsoft.apps.coe.pal_repository_process_define_Quality_check",
|
||
wsId: $("#wsId").val(),
|
||
uuid: ruuid,
|
||
obj: awsui.encode(obj)
|
||
},
|
||
success: function (r) {
|
||
$.simpleAlert("close");
|
||
if (r.data.result == "error") {
|
||
$.simpleAlert(r.data.sb, "error");
|
||
} else {
|
||
$.simpleAlert("检测通过!", "ok");
|
||
}
|
||
},
|
||
error: function (r) {
|
||
}
|
||
});
|
||
});
|
||
/**
|
||
* 快捷发布
|
||
*/
|
||
$("#QuickPublishing").off("click").on("click", function () {
|
||
$.ajax({
|
||
type: "POST",
|
||
url: "./jd",
|
||
data: {
|
||
sid: CLB.sid,
|
||
palUUID:ruuid,
|
||
cmd: "com.actionsoft.apps.coe.pal.publisher.createProcess",
|
||
processDefId: "obj_fb1c7a54b98b412187388c8bab407362",
|
||
},
|
||
success: function (r) {
|
||
window.open(r.data.url);
|
||
},
|
||
error: function (r) {
|
||
}
|
||
});
|
||
/*var url="https://bpm.yili.com:8088/portal/r/w?sid="+$("#sid").val()+"&wsId="+$("#wsId").val()+"&teamId=&clazzName=com.actionsoft.apps.coe.pal.publisher.client.web.ProcessPublishWeb&cmd=com.actionsoft.apps.coe.pal_app_page#/";
|
||
window.open(url,'fullscreen');*/
|
||
});
|
||
|
||
//终止按钮
|
||
$("#processTermination").off("click").on("click", function () {
|
||
$.ajax({
|
||
type: "POST",
|
||
url: "./jd",
|
||
data: {
|
||
sid: CLB.sid,
|
||
palUUID:ruuid,
|
||
cmd: "com.actionsoft.apps.coe.pal.publisher.createProcess_processTermination",
|
||
processDefId: "obj_fb1c7a54b98b412187388c8bab407362",
|
||
},
|
||
success: function (r) {
|
||
if(r.result == "error"){
|
||
$.simpleAlert(r.msg, "error");
|
||
}else{
|
||
window.open(r.data.url);
|
||
}
|
||
|
||
},
|
||
error: function (r) {
|
||
}
|
||
});
|
||
});
|
||
//导出手册
|
||
$("#export_file").off("click").on("click", function () {
|
||
debugger;
|
||
menuSelected($(this));
|
||
});
|
||
|
||
/**
|
||
* 流程清单列表按钮
|
||
*/
|
||
$("#processManifest").off("click").on("click", function () {
|
||
getProcessManifestInfo();
|
||
});
|
||
/**
|
||
* 导引回放按钮
|
||
*/
|
||
$("#modelingGuide").off("click").on("click", function () {
|
||
initGuide();
|
||
});
|
||
|
||
/**
|
||
* 获取流程列表信息,并跳转到dw数据试图
|
||
*/
|
||
function getProcessManifestInfo() {
|
||
let url = "./w?sid=" + $("#sid").val() + "&cmd=CLIENT_DW_PORTAL&processGroupId=obj_4e95a7af7bf1414f9e878d013192675e&appId"
|
||
+ "=com.actionsoft.apps.coe.pal.publisher&dwViewId=obj_3ebec26134e345a2894e4bf0d0c628f0&hideSearcher=true&condition="
|
||
+ encodeURIComponent("[{cp:'=',fd:'MODELID',cv:'" + ruuid + "'}]");
|
||
//+"&condition=\"+encodeURIComponent(\"[{cp:'=',fd:'MODELID',cv:'"+ruuid+"'}]\"";
|
||
$.ajax({
|
||
type: "POST",
|
||
url: "./jd",
|
||
data: {
|
||
sid: sid,
|
||
cmd: "com.actionsoft.apps.coe.pal.publisher_process_manifest",
|
||
publishFileId: ruuid,
|
||
fileName: fileName
|
||
},
|
||
success: function (msg) {
|
||
if (msg.result == "ok") {
|
||
window.open(url, "fullscreen");
|
||
} else {
|
||
$.simpleAlert(msg.msg, "error");
|
||
}
|
||
},
|
||
});
|
||
}
|
||
|
||
// 编号刷点击事件
|
||
$('#bar_sort').off("click").on("click", function () {
|
||
if ($("#saving_tip").text() != "已保存成功" && $("#saving_tip").text() != "保存成功" && $("#saving_tip").text() != "您的文件已经成功保存" && $("#saving_tip").text() != "") {
|
||
$.simpleAlert('页面未保存,请先保存', 'error', 1500);
|
||
} else {
|
||
$.simpleAlert("正在编号", "loading");
|
||
$.ajax({
|
||
type: "POST",
|
||
url: "./jd",
|
||
data: {
|
||
sid: CLB.sid,
|
||
cmd: "com.actionsoft.apps.coe.pal_repository_designer_no_refresh",
|
||
uuid: ruuid,
|
||
},
|
||
success: function (r, textStatus, jqXHR) {
|
||
$.simpleAlert("close");
|
||
var data = r.data;
|
||
var elements = Model.define.elements;
|
||
var attrId = data.attrId;
|
||
var shapeNo = data.data;
|
||
var updateShape = [];
|
||
for (var i in elements) {
|
||
if (shapeNo[i] != undefined) {
|
||
var flag = false;
|
||
for (var a = 0; a < elements[i].dataAttributes.length; a++) {
|
||
if (elements[i].dataAttributes[a].attributesJsonArray !== undefined) {
|
||
for (var b = 0; b < elements[i].dataAttributes[a].attributesJsonArray.length; b++) {
|
||
if (elements[i].dataAttributes[a].attributesJsonArray[b].id == attrId) {
|
||
elements[i].dataAttributes[a].attributesJsonArray[b].value = shapeNo[i];
|
||
flag = true;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (flag) {
|
||
updateShape.push(elements[i]);
|
||
Designer.painter.renderShape(elements[i]);
|
||
}
|
||
}
|
||
}
|
||
if (updateShape.length > 0) {
|
||
Model.updateMulti(updateShape);
|
||
}
|
||
},
|
||
error: function (jqXHR, textStatus, errorThrown) {
|
||
$.simpleAlert("close");
|
||
$.simpleAlert('编号失败', 'error', 1500);
|
||
}
|
||
})
|
||
}
|
||
})
|
||
// 快捷调整画布大小点击事件
|
||
$('#bar_resize').off('click').on('click', function () {
|
||
var pos = getCanvasContentEdge()
|
||
var minPageWidth = 1050
|
||
var elements = Model.define.elements;
|
||
var shapeIds = [];
|
||
var contentWidth = pos.right - pos.left
|
||
var contentHeight = pos.bottom - pos.top
|
||
for (var shapeId in elements) {
|
||
shapeIds.push(shapeId);
|
||
}
|
||
Utils.selectShape(shapeIds);
|
||
var movingShapes = null
|
||
if (movingShapes == null) { // 形状移动 designer.extend.core.js方法挪用
|
||
var selected = Utils.getSelected();
|
||
var familyShapes = Utils.getFamilyShapes(selected);
|
||
selected = selected.concat(familyShapes);
|
||
var containedShapes = Utils.getContainedShapes(selected);
|
||
selected = selected.concat(containedShapes);
|
||
var attachedShapes = Utils.getAttachedShapes(selected);
|
||
selected = selected.concat(attachedShapes);
|
||
var outlinkers = Utils.getOutlinkers(selected);
|
||
movingShapes = selected.concat(outlinkers);
|
||
}
|
||
if (movingShapes.length > 0 && contentWidth <= minPageWidth - 180 * 2) {
|
||
// 右移或左移 距左部150 默认padding 60
|
||
Designer.op.moveShape(movingShapes, {
|
||
x: 210 - pos.left,
|
||
y: 0
|
||
});
|
||
// 下移或上移 距顶部120 默认padding 60
|
||
Designer.op.moveShape(movingShapes, {
|
||
x: 0,
|
||
y: 180 - pos.top
|
||
});
|
||
Designer.setPageStyle({
|
||
width: Math.trunc(minPageWidth),
|
||
height: Math.trunc(contentHeight + 360)
|
||
});
|
||
}
|
||
if (movingShapes.length > 0 && contentWidth > minPageWidth - 180 * 2) {
|
||
// 右移或左移 距左部150 默认padding 60
|
||
Designer.op.moveShape(movingShapes, {
|
||
x: 210 - pos.left,
|
||
y: 0
|
||
});
|
||
// 下移或上移 距顶部120 默认padding 60
|
||
Designer.op.moveShape(movingShapes, {
|
||
x: 0,
|
||
y: 180 - pos.top
|
||
});
|
||
Designer.setPageStyle({
|
||
width: Math.trunc(contentWidth + 210 * 2),
|
||
height: Math.trunc(contentHeight + 180 * 2)
|
||
});
|
||
}
|
||
Model.updateMulti(movingShapes);
|
||
$("#saving_tip").css("color", "rgb(255, 0, 0)");
|
||
$("#saving_tip").text("文件已修改,未保存");
|
||
movingShapes = null;
|
||
Designer.op.hideTip();
|
||
Utils.unselect();
|
||
})
|
||
// 自动保存
|
||
var autoSave_countdownStart = 30 * 1000; // 30秒
|
||
var autoSave_interval = 3 * 60 * 1000 - autoSave_countdownStart; // 3分钟
|
||
// var autoSave_countdownStart = 10 * 1000; // 30秒
|
||
// var autoSave_interval = 0.5 * 60 * 1000 - autoSave_countdownStart; // 3分钟
|
||
var autoSave_timer;
|
||
var autoSave_countdownTimer;
|
||
|
||
// 保存文档的函数
|
||
function autoSave_saveDocument() {
|
||
console.log('自动保存成功' + getCurrTime());
|
||
$("#bar_save").click(); // 实际的保存操作
|
||
$("#autoSave_countdown").hide(); // 保存后隐藏倒计时
|
||
}
|
||
|
||
function manualSave_resetTimes() {
|
||
$("#autoSave_countdown").hide(); // 保存后隐藏倒计时
|
||
autoSave_resetTimers();// 重置定时器
|
||
}
|
||
|
||
// 重置定时器的函数
|
||
function autoSave_resetTimers() {
|
||
clearTimeout(autoSave_timer);
|
||
clearTimeout(autoSave_countdownTimer);
|
||
$("#autoSave_countdown").hide(); // 隐藏倒计时提示
|
||
console.log(autoSave_interval + '后开始倒计时' + getCurrTime());
|
||
autoSave_timer = setTimeout(autoSave_autoSave, autoSave_interval);
|
||
}
|
||
|
||
// 自动保存的函数
|
||
function autoSave_autoSave() {
|
||
autoSave_resetTimers();// 保存后重置定时器
|
||
autoSave_countdown(); // 开始倒计时
|
||
}
|
||
|
||
// 倒计时的函数
|
||
function autoSave_countdown() {
|
||
if ($("#saving_tip").text() == "已保存成功" || $("#saving_tip").text() == "保存成功" || $("#saving_tip").text() == "您的文件已经成功保存" || $("#saving_tip").text() == "") {
|
||
// 保存成功,重新执行
|
||
console.log('已经是保存成功状态,不执行保存,重置保存定时器' + getCurrTime())
|
||
autoSave_resetTimers();
|
||
return;
|
||
}
|
||
console.log('清空settime,进入倒计时' + getCurrTime());
|
||
clearTimeout(autoSave_timer);
|
||
var countdownSeconds = autoSave_countdownStart / 1000;
|
||
$("#autoSave_countdown").css('display', 'inline-block');
|
||
$("#autoSave_countdown").text(countdownSeconds + " 秒后自动保存");
|
||
autoSave_countdownTimer = setInterval(function () {
|
||
countdownSeconds--;
|
||
$("#autoSave_countdown").text(countdownSeconds + " 秒后自动保存");
|
||
if (countdownSeconds <= 0) {
|
||
console.log('倒计时结束,清空倒计时' + getCurrTime());
|
||
clearInterval(autoSave_countdownTimer);
|
||
autoSave_saveDocument();
|
||
}
|
||
}, 1000);
|
||
}
|
||
|
||
// 初始化定时器
|
||
console.log('开始执行定时器' + getCurrTime());
|
||
autoSave_resetTimers();
|
||
});
|
||
|
||
function getCurrTime() {
|
||
var date = new Date();
|
||
return date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
|
||
}
|
||
|
||
function getCanvasContentEdge() {
|
||
var pos = {
|
||
top: 0,
|
||
bottom: 0,
|
||
left: 0,
|
||
right: 0
|
||
}
|
||
var elements = Model.define.elements
|
||
var xArr = []
|
||
var yArr = []
|
||
for (let key in elements) {
|
||
if (elements[key].points == undefined) { // 形状
|
||
xArr.push({
|
||
x: elements[key].props.x,
|
||
type: 'shape',
|
||
shapeWidth: elements[key].props.w
|
||
})
|
||
yArr.push({
|
||
y: elements[key].props.y,
|
||
type: 'shape',
|
||
shapeHeight: elements[key].props.h
|
||
})
|
||
} else {
|
||
xArr.push({
|
||
x: elements[key].from.x,
|
||
type: 'line'
|
||
})
|
||
xArr.push({
|
||
x: elements[key].to.x,
|
||
type: 'line'
|
||
})
|
||
yArr.push({
|
||
y: elements[key].from.y,
|
||
type: 'line'
|
||
})
|
||
yArr.push({
|
||
y: elements[key].to.y,
|
||
type: 'line'
|
||
})
|
||
for (let i = 0; i < elements[key].points.length; i++) {
|
||
xArr.push({
|
||
x: elements[key].points[i].x,
|
||
type: 'line'
|
||
})
|
||
yArr.push({
|
||
y: elements[key].points[i].y,
|
||
type: 'line'
|
||
})
|
||
}
|
||
}
|
||
}
|
||
pos.left = Math.min.apply(Math, xArr.map(item => {
|
||
return item.x
|
||
}))
|
||
pos.top = Math.min.apply(Math, yArr.map(item => {
|
||
return item.y
|
||
}))
|
||
// 特殊处理右和下 若有图形 加上图形的高/宽
|
||
for (let i = 0; i < xArr.length; i++) {
|
||
if (xArr[i].type == 'shape') {
|
||
xArr[i].x += xArr[i].shapeWidth
|
||
}
|
||
}
|
||
for (let i = 0; i < yArr.length; i++) {
|
||
if (yArr[i].type == 'shape') {
|
||
yArr[i].y += yArr[i].shapeHeight
|
||
}
|
||
}
|
||
pos.right = Math.max.apply(Math, xArr.map(item => {
|
||
return item.x
|
||
}))
|
||
pos.bottom = Math.max.apply(Math, yArr.map(item => {
|
||
return item.y
|
||
}))
|
||
return pos
|
||
}
|
||
|
||
/**定时保存**/
|
||
function saveTimer() {
|
||
// 每隔5分钟时间进行保存
|
||
setInterval(function () {
|
||
var count = 5;
|
||
var msg = "秒之后自动进行保存";
|
||
var alertmsg = function (count, msg) {
|
||
$.simpleAlert(count + msg, "info", 1000, {
|
||
callback: function () {
|
||
count--;
|
||
if (count < 1) {
|
||
$("#bar_save").click();
|
||
} else {
|
||
alertmsg(count, msg);
|
||
}
|
||
}
|
||
})
|
||
};
|
||
alertmsg(count, msg);
|
||
// $.simpleAlert("5秒之后自动进行保存", "info", 5000, {callback:function(){$("#bar_save").click();}});
|
||
}, 300000);
|
||
}
|
||
|
||
/**定时刷新,查询流程是否被其他人锁定**/
|
||
function intervalRefresh() {
|
||
//每隔5秒发送请求 检查当前用户是否发生变化
|
||
intervalInd = setInterval(function () {
|
||
awsui.ajax.request({
|
||
type: "POST",
|
||
url: "./jd",
|
||
data: {
|
||
sid: CLB.sid,
|
||
cmd: "com.actionsoft.apps.coe.pal_repository_process_define_get_lock_info",
|
||
uuid: ruuid
|
||
},
|
||
cache: false,
|
||
alert: false,
|
||
ok: function (msg) {
|
||
if (msg.data.isLocked) {
|
||
var m = '当前流程被 ' + msg.data.currentUserName + ' 强行获取编辑权或锁定';
|
||
$.simpleAlert(m, "info", 4000, {
|
||
mode: true, callback: function () {
|
||
if ($("#saving_tip").text() != "已保存成功" && $("#saving_tip").text() != "保存成功" && $("#saving_tip").text() != "您的文件已经成功保存" && $("#saving_tip").text() != "") {
|
||
$("#saving_tip").text('');// 防止reload时出现浏览器自带提示
|
||
}
|
||
window.location.reload();
|
||
}
|
||
});
|
||
}
|
||
}
|
||
});
|
||
}, 10000);
|
||
}
|
||
|
||
var CommonLock = {
|
||
lockOrLuckFun: function (optype) {//锁定 解锁流程
|
||
if (isAutoSave == "0") {
|
||
if ($("#saving_tip").text() != "已保存成功" && $("#saving_tip").text() != "保存成功" && $("#saving_tip").text() != "您的文件已经成功保存" && $("#saving_tip").text() != "") {
|
||
$.simpleAlert('页面中有未保存的内容,请先保存');
|
||
return;
|
||
}
|
||
}
|
||
$.post("./jd", {
|
||
cmd: "com.actionsoft.apps.coe.pal_pl_repository_lock_or_unlock_process",
|
||
sid: sid,
|
||
uuid: ruuid,
|
||
optype: optype
|
||
}, function t(msg) {
|
||
if (msg.result == 'ok') {
|
||
if (optype == 'unlockpro') {
|
||
$.simpleAlert("文件已解锁", 'ok', 500, {callback: CommonLock.refreshDesigner});
|
||
} else {
|
||
$.simpleAlert("文件已锁定", 'ok', 500, {callback: CommonLock.refreshDesigner});
|
||
}
|
||
} else {
|
||
CommonLock.refreshDesigner();
|
||
}
|
||
}, "json");
|
||
},
|
||
refreshDesigner: function () {
|
||
//刷新当前页面
|
||
if (top.location != self.location) {
|
||
location.href = location.href;
|
||
} else {
|
||
window.location.reload();
|
||
}
|
||
}
|
||
};
|
||
// 记录所有节点及节点名称,保存时对比
|
||
var shapeTextRecord = {};
|
||
|
||
function recordShapeText() {
|
||
shapeTextRecord = {};// 初始化
|
||
var obj = Model.define;
|
||
var shapes = obj.elements;
|
||
for (var shape in shapes) {
|
||
shapeTextRecord[shape] = shapes[shape].text;
|
||
}
|
||
}
|
||
|
||
function menuSelected(item) {
|
||
var action = item.attr("ac");
|
||
// 编辑菜单
|
||
if (action == "rename") {
|
||
$(".diagram_title").trigger("click");
|
||
} else if (action == "close") {
|
||
if (parent.closeTabById) {
|
||
parent.closeTabById(chartId);
|
||
} else {
|
||
window.close();
|
||
}
|
||
|
||
} else if (action == "saveAs") {
|
||
UI.showSaveAs();
|
||
} else if (action == "preview") {//在线预览流程图片
|
||
UI.doPreview();
|
||
} else if (action == "saveImage") {//生成图片和缩略图
|
||
UI.saveImage();
|
||
} else if (action == "versionCompare") {
|
||
UI.showVersionCompare();
|
||
} else if (action == "output") {// 导出流程手册并预览
|
||
UI.doOutputProcess();
|
||
} else if (action == "export") {
|
||
$("#export_dialog").dlg();
|
||
} else if (action == "processExport") {
|
||
UI.processExport();
|
||
} else if (action == "undo") {
|
||
MessageSource.undo();
|
||
} else if (action == "redo") {
|
||
MessageSource.redo();
|
||
} else if (action == "cut") {
|
||
Designer.clipboard.cut();
|
||
} else if (action == "copy") {
|
||
Designer.clipboard.copy();
|
||
} else if (action == "paste") {
|
||
Designer.clipboard.paste();
|
||
} else if (action == "duplicate") {
|
||
Designer.clipboard.duplicate();
|
||
} else if (action == "brush") {
|
||
Designer.clipboard.brush();
|
||
} else if (action == "selectall") {
|
||
Designer.selectAll();
|
||
} else if (action == "openNewPage") {
|
||
UI.openNewPage();//新页面打开
|
||
} else if (action == "batchreplace") {
|
||
UI.batchReplace();
|
||
} else if (action == "delete") {
|
||
Designer.op.removeShape();
|
||
// 视图缩放
|
||
} else if (action == "zoom") {
|
||
var zoom = item.attr("zoom");
|
||
if (zoom == "in") {
|
||
Designer.zoomIn();
|
||
} else if (zoom == "out") {
|
||
Designer.zoomOut();
|
||
} else {
|
||
var zoomScale = parseFloat(zoom);
|
||
Designer.setZoomScale(zoomScale);
|
||
}
|
||
// 插入
|
||
} else if (action == "insert") {
|
||
var insertType = item.attr("in");
|
||
if (insertType == "text") {
|
||
Designer.op.changeState("creating_free_text");
|
||
} else if (insertType == "image") {
|
||
UI.showImageSelect(function(fileId, w, h) {
|
||
UI.insertImage(fileId, w, h);
|
||
});
|
||
} else if (insertType == "line") {
|
||
Designer.op.changeState("creating_free_linker");
|
||
}
|
||
// 页面
|
||
} else if (action == "set_page_size") {
|
||
var w = parseInt(item.attr("w"));
|
||
var h = parseInt(item.attr("h"));
|
||
Designer.setPageStyle({
|
||
width: w,
|
||
height: h
|
||
});
|
||
} else if (action == "set_page_padding") {
|
||
var p = parseInt(item.attr("p"));
|
||
Designer.setPageStyle({
|
||
padding: p
|
||
})
|
||
} else if (action == "set_page_showgrid") {
|
||
if (item.menuitem("isSelected")) {
|
||
item.menuitem("unselect");
|
||
Designer.setPageStyle({
|
||
showGrid: false
|
||
});
|
||
} else {
|
||
item.menuitem("select");
|
||
Designer.setPageStyle({
|
||
showGrid: true
|
||
});
|
||
}
|
||
} else if (action == "set_page_gridsize") {
|
||
var s = parseInt(item.attr("s"));
|
||
Designer.setPageStyle({
|
||
gridSize: s
|
||
})
|
||
}
|
||
// 排列
|
||
else if (action == "front") {
|
||
Designer.layerShapes("front");
|
||
} else if (action == "back") {
|
||
Designer.layerShapes("back");
|
||
} else if (action == "forward") {
|
||
Designer.layerShapes("forward");
|
||
} else if (action == "backward") {
|
||
Designer.layerShapes("backward");
|
||
} else if (action == "align_shape") {
|
||
var align = item.attr("al");
|
||
Designer.alignShapes(align);
|
||
} else if (action == "distribute_shape") {
|
||
var type = item.attr("dis");
|
||
Designer.distributeShapes(type);
|
||
} else if (action == "match_size") {
|
||
if (item.attr("custom")) {
|
||
Dock.showView("metric");
|
||
} else {
|
||
var type = {};
|
||
var w = item.attr("w");
|
||
var h = item.attr("h");
|
||
if (w) {
|
||
type.w = w;
|
||
}
|
||
if (h) {
|
||
type.h = h;
|
||
}
|
||
Designer.matchSize(type);
|
||
}
|
||
} else if (action == "lock") {
|
||
Designer.lockShapes();
|
||
} else if (action == "unlock") {
|
||
Designer.unlockShapes();
|
||
} else if (action == "group") {
|
||
Designer.group();
|
||
} else if (action == "ungroup") {
|
||
Designer.ungroup();
|
||
} else if (action == "hotkey") {
|
||
UI.showHotKey();
|
||
} else if (action == "feedback") {
|
||
UI.showFeedBack();
|
||
} else if (action == "getting_started") {
|
||
UI.gettingStart();
|
||
} else if (action == "modelConvert"){
|
||
var targetMethod = item.attr("methodId");
|
||
$.simpleAlert('转换后同名校验中', 'loading');
|
||
$.ajax({
|
||
type: "POST",
|
||
url: "./jd",
|
||
data: {
|
||
sid: sid,
|
||
cmd: "com.actionsoft.apps.coe.pal.check_repository_name_exist",
|
||
repositoryId: ruuid,
|
||
targetMethod: targetMethod
|
||
},
|
||
success: function (r,textStatus,jqXHR) {
|
||
$.simpleAlert("close");
|
||
if(r.result == 'ok' ) {
|
||
if (r.data.duplicateName){
|
||
$.confirm({
|
||
title: '提示',
|
||
content: '文件【'+r.data.repositoryName+'】名称已存在,是否新建副本?',
|
||
onConfirm: function () {
|
||
modelConvertFn(targetMethod,r.data.duplicateName);
|
||
},
|
||
onCancel: function () {}
|
||
});
|
||
}else {
|
||
modelConvertFn(targetMethod,r.data.duplicateName);
|
||
}
|
||
}else {
|
||
$.simpleAlert(r.data.desc, 'error');
|
||
}
|
||
},
|
||
error: function (jqXHR,textStatus,errorThrown) {
|
||
$.simpleAlert(errorThrown, 'err');
|
||
}
|
||
});
|
||
}
|
||
} |