apps/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/extend/js/designer.extend.link.view.portal.js
2022-07-23 15:49:35 +08:00

2093 lines
63 KiB
JavaScript
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* @author wangyh 与插入链接属性关系相关的js内容
*/
var selectedShapes = [];
var linkType; // 链接类型custom自定义链接file文件链接
$(document).ready(function() {
showPainting();
setTimeout(function() {
Designer.hotkey.init();// 解决快捷健绑定不成功
DesignerCopyPaste.changeTitleListen();
if (selectedElementId && selectedElementId != "") {
Utils.selectShape(selectedElementId);
}// 复制粘贴形状内容同步的监听
}, 1000);
});
/**
* 兼容1024*768画布显示
*
* @param {}
*
*/
function showPainting() {
var width = screen.width;
if (width == 1024) {
$("#toolbar_wfversion_info").addClass("showPainting");
if (parent.getWidthToolbar() > 750) {
$(".toolbar").removeClass("heightCssToolbar")
.addClass("toolbarExtend");
$("#bar_back").removeClass("cssToolbar");
} else {
$(".toolbar").addClass("heightCssToolbar")
.removeClass("toolbarExtend");
$("#bar_back").addClass("cssToolbar");
}
}
}
/**
* 重写单击图形时的触发的事件
*
* @param {}
*
* @returns {}
*/
Designer.op.shapeSelectable = function(a) {
var b = $("#designer_canvas");
b.bind("mousedown.select", function(d) {
Designer.op.changeState("seelcting_shapes");
var e = a.id;
var c = [];
if (d.ctrlKey) {
var c = Utils.getSelectedIds();
if (Utils.isSelected(e)) {
Utils.removeFromArray(c, e);
} else {
c.push(e);
}
Utils.unselect();
if (c.length > 0) {
Utils.selectShape(c);
}
} else {
if (Utils.selectIds.indexOf(e) < 0) {
Utils.unselect();
Utils.selectShape(e);
}
}
$(document).bind("mouseup.select", function() {
Designer.op.resetState();
b.unbind("mousedown.select");
$(document).unbind("mouseup.select");
});
// selectedShapes
DesignerCopyPaste.selectedShapeId = Utils.getSelected()[0].id;
if ($("div.dock_view_attribute").is(":visible")) {
showShapeRelationTab(null);
attributeShowTabContent(null);
shapeCopyAndPasteCount(null);
showRelevanceShapesContent();
}
});
};
var myshapeLink = "";
var linkIndex = 0;
var selectShape = Utils.getSelected()[0];
/**
* 功能:去除字符串中所有空格 传参:需要处理的字符串 返回值:去除空格后的字符串
*/
function trimSpaces(Str) {
var ResultStr = "";
Temp = Str.split(/\s/);
for (i = 0; i < Temp.length; i++) {
ResultStr += Temp[i];
}
return ResultStr;
}
//风险控制
UI.showRiskDlg = function(){
var shape = Utils.getSelected()[0];
var number;
if (shape.dataAttributes != undefined) {
for (var i = 0; i < shape.dataAttributes.length; i++) {
if (shape.dataAttributes[i].privateAttributeContent != null) {
var privateAttributeContent = shape.dataAttributes[i].privateAttributeContent;
if (typeof(privateAttributeContent) == "string") {
privateAttributeContent = eval("(" + privateAttributeContent + ")");
}
number = privateAttributeContent.number;
}
}
}
if (number == undefined || number == "") {
$.simpleAlert("请先维护该节点编号");
return;
}
var riskDlg = FrmDialog.open({
width:800,
height:700,
url:"./w?sid=" + $("#sid").val() + "&cmd=com.actionsoft.apps.coe.pal.risk_pal_designer_risk",
data:{"plId":ruuid, "taskId": shape.id, "taskNum": number}
});
}
//流程节点的风险控制不为空重新渲染shape
function renderShapeRisks(risk, control) {
var shape = Utils.getSelected()[0];
if (shape.dataAttributes != undefined) {
var riskFlag = false;
var controlFlag = false;
for (var i = 0; i < shape.dataAttributes.length; i++) {
if (shape.dataAttributes[i].risk != undefined) {
shape.dataAttributes[i].risk = risk;
riskFlag = true;
}
if (shape.dataAttributes[i].control != undefined) {
shape.dataAttributes[i].control = control;
controlFlag = true;
}
}
if (!riskFlag) {
var index = shape.dataAttributes.length -1;
shape.dataAttributes[index].risk = risk;
}
if (!controlFlag) {
var index = shape.dataAttributes.length -1;
shape.dataAttributes[index].control = control;
}
}
Designer.painter.renderShape(shape);
}
// 判断给定的对象是不是数组
function isArray(o) {
return Object.prototype.toString.call(o) === '[object Array]';
}
// 出现复制图形的统计
function shapeCopyAndPasteCount(shape) {
if (!$("#tagContent2").is(":visible")) {
return;
}
if (shape == null)
shape = Utils.getSelected()[0];
$("#tagContentTableTitleContent2").empty();
var shapeGroupId = "";
var isCopy = "";
var shapeId = shape.id;
for (var i = 0; i < shape.dataAttributes.length; i++) {
var attr = shape.dataAttributes[i];
if (attr.shapeGroupId) {
shapeGroupId = attr.shapeGroupId;
isCopy = attr.isCopy;
break;
}
}
var data = "shapeGroupId=" + shapeGroupId + "&shapeId=" + shapeId
+ "&isCopy=" + isCopy;
}
function showRelevanceShapesContent() {
if (!$("#tagContent3").is(":visible")) {
return;
}
$.ajax({
type : "POST",
url : "./jd?sid="
+ CLB.sid
+ "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_relation_shape_relevance_show",
data : {
shapeId : Utils.getSelected()[0].id,
fileId: ruuid
},
success : function(msg) {
$("#tagContentTableTitleContent3").empty();
if (msg.data.result == "ok") {
var shapesObj = msg.data.list;
var mouseover = "onmouseout=\"hideRemoveTrAttribute(this);\"";
var mouseout = "onmouseover=\"showRemoveTrAttribute(this);\"";
if (role == "viewer") {
mouseover = "";
mouseout = "";
}
for (var i = 0; i < shapesObj.length; i++) {
var style = "";
var onclick = "";
if (editable || filePerms == "-" || filePerms.indexOf(shapesObj[i].fileVersionId) > -1) {
style = "cursor:pointer;color:blue;";
if (parent.openDesginerFromAttr) {
onclick = 'parent.openDesginerFromAttr(\''
+ shapesObj[i].fileId
+ '\',0,\''
+ shapesObj[i].fileName
+ '\',\'\',\'\',false,\''
+ shapesObj[i].shapeId
+ '\')';
} else if (window.opener.openDesginer) {
var obj = {
id: shapesObj[i].fileId,
processDefId: ''
}
onclick = 'window.opener.openDesginer({id:\'' + shapesObj[i].fileId + '\', processDefId:\'\'})';
}
}
var content = '<tr ' + mouseout + mouseover + ' objid="'
+ shapesObj[i].id
+ '" class="tagContentTableTr"><td style="' + style + '" onclick="' + onclick + '">'
+ '<div style="line-height:22px;height:22px;overflow:hidden;" class="attribute_td_div_css">'
+ shapesObj[i].fileName
+ '(V ' + shapesObj[i].fileVersion + '.0)'
+ '</div>'
+ '</td><td><div style="line-height:22px;height:22px;overflow:hidden;" class="attribute_td_div_css">'
+ shapesObj[i].shapeText
+ '</div></td></tr>';
$("#tagContentTableTitleContent3").append(content);
}
}
}
});
}
function getPrivateAttributeHtml(attributesJsonArray, tbodyId, shape) {
// 属性排序
var defaultMoreAttr = $('#defaultMoreAttrSort').val();
if(defaultMoreAttr.length > 0) {
var arr = defaultMoreAttr.split('|');
var tempAttrArray = [];
for(var i = 0; i < arr.length; i++) {
for(var j = 0; j < attributesJsonArray.length; j++) {
if(attributesJsonArray[j] == undefined || attributesJsonArray[j] == null) {
continue;
}
if(arr[i] == attributesJsonArray[j].id) {
tempAttrArray.push(attributesJsonArray[j]);
}
}
}
//取新添加的属性
if (tempAttrArray.length > 0) {
var newAttrArray = [];
newAttrArray = tempAttrArray.concat(attributesJsonArray).filter(function(v, i, arr) {
return arr.indexOf(v) === arr.lastIndexOf(v);
});;
attributesJsonArray = tempAttrArray.concat(newAttrArray);
}
}
var flag = false;
var objIds = [];
var selectFlag = false;
var selectValues = [];
var mouseover = "onmouseout=\"hideRemoveTrAttribute(this);\"";
var mouseout = "onmouseover=\"showRemoveTrAttribute(this);\"";
if (role == "viewer") {
mouseover = "";
mouseout = "";
}
var userAddress = false;
var deptAddress = false;
var userObjIds = new Array();
var deptObjIds = new Array();
var deptIds = "";
for (var index = 0; index < attributesJsonArray.length; index++) {
var obj = attributesJsonArray[index];
if (obj != null && obj != undefined && obj.value != undefined) {
if(obj.name=="活动序号"){
continue;
}
var constr = '<tr>';
/*constr += '<td style="padding-left:20px;" class="tableContent">' + obj.name + '</td>';*/
constr += '<td class="tableContent">' + obj.name + ':' + obj.value + '</td>';
constr += '</tr>';
if ((!obj.readonly && obj.type == "string")
|| (!obj.readonly && obj.type == "list")) {
// 目前支持到文本的输入 ,需求定下了再改
constr = '<tr>';
/*constr += '<td style="padding-left:20px;" class="tableContent">' + obj.name + '</td>';*/
constr += '<td id="' + shape.id + obj.id + '" class="tableContent">' + '【' + obj.name + '】'+'&nbsp;'+ obj.value + '</td>';
constr += '</tr>';
} else if (!obj.readonly && obj.type == "link") {
constr = '<tr>';
/*constr += '<td style="padding-left:20px;" class="tableContent">' + obj.name + '</td>';*/
// constr += '<td id="' + shape.id + obj.id + '" colspan="2" class="tableContent">' + obj.value + '</td>';
constr += '<td id="' + shape.id + obj.id + '" class="tableContent">' + '【' + obj.name + '】'+'&nbsp;'+ '<a href="' + obj.value + '" target="_blank">' + obj.value + '</a>' + '</td>';
constr += '</tr>';
} else if (!obj.readonly && obj.type == "number") {
constr = '<tr>';
/*constr += '<td style="padding-left:20px;" class="tableContent">' + obj.name + '</td>';*/
constr += '<td id="' + shape.id + obj.id + '" class="tableContent">' + '【' + obj.name + '】'+'&nbsp;'+ obj.value + '</td>';
constr += '</tr>';
} else if (!obj.readonly && obj.type == "boolean") {
constr = '<tr>';
/*constr += '<td style="padding-left:20px;" class="tableContent">' + obj.name + '</td>';*/
constr += '<td id="' + shape.id + obj.id + '" class="tableContent">' + '【' + obj.name + '】'+'&nbsp;'+ '</td>';
constr += '</tr>';
} else if (!obj.readonly && obj.type == "textarea") {
constr = '<tr>';
/*constr += '<td style="padding-left:20px;" class="tableContent">' + obj.name + '</td>';*/
if (obj.value == undefined) {
obj.value = '';
}
constr += '<td id="' + shape.id + obj.id + '"class="tableContent">' + '【' + obj.name + '】'+'&nbsp;'+ obj.value.replace(/\n/g, '<br>') + '</td>';
constr += '</tr>';
} else if (obj.readonly && obj.type == "relation") {
var relationValue = "";
if (relationShapesData[shape.id] !== null && relationShapesData[shape.id][obj.id] != null) {
relationValue = relationShapesData[shape.id][obj.id];
}
constr = '<tr>';
/*constr += '<td style="padding-left:20px;" class="tableContent">' + obj.name + '</td>';*/
constr += '<td id="' + shape.id + obj.id + '" class="tableContent">' + '【' + obj.name + '】'+'&nbsp;'+ relationValue + '</td>';
constr += '</tr>';
} else if (obj.type == "select" || obj.type == "select_m") {
constr = '<tr>';
/*constr += '<td style="padding-left:20px;" class="tableContent">' + obj.name + '</td>';*/
constr += '<td id="' + shape.id + obj.id + '" class="tableContent">' + '【' + obj.name + '】'+'&nbsp;'+ obj.value + '</td>';
constr += '</tr>';
selectFlag = true;
var selectValue = {
"objId": obj.id,
"objValue": obj.value,
"objType": obj.type
};
selectValues.push(selectValue);
} else if (obj.readonly && obj.type == "userAddress") {
userAddress = true;
userObjIds.push(obj.id);
var relationValue = "";
if (relationShapesData[shape.id] !== null && relationShapesData[shape.id][obj.id] != null) {
relationValue = relationShapesData[shape.id][obj.id];
}
constr = '<tr>';
/*constr += '<td style="padding-left:20px;" class="tableContent">' + obj.name + '</td>';*/
constr += '<td id="' + shape.id + obj.id + '" class="tableContent">' + '【' + obj.name +'】'+'&nbsp;'+ relationValue + '</td>';
constr += '</tr>';
} else if (obj.readonly && obj.type == "deptAddress") {
deptAddress = true;
deptObjIds.push(obj.id);
deptIds += "," + obj.value;
var relationValue = "";
if (relationShapesData[shape.id] !== null && relationShapesData[shape.id][obj.id] != null) {
relationValue = relationShapesData[shape.id][obj.id];
}
constr = '<tr>';
/*constr += '<td style="padding-left:20px;" class="tableContent">' + obj.name + '</td>';*/
constr += '<td id="' + shape.id + obj.id + '" class="tableContent">' + '【' + obj.name +'】'+'&nbsp;'+ relationValue + '</td>';
constr += '</tr>';
} else if (obj.readonly && obj.type == "awsorg") {
var relationValue = "";
if (relationShapesData[shape.id] !== null && relationShapesData[shape.id][obj.id] != null) {
relationValue = relationShapesData[shape.id][obj.id];
}
constr = '<tr>';
/*constr += '<td style="padding-left:20px;" class="tableContent">' + obj.name + '</td>';*/
constr += '<td id="' + shape.id + obj.id + '" class="tableContent">' + '【' + obj.name +'】'+'&nbsp;'+ relationValue + '</td>';
constr += '</tr>';
} else if (obj.readonly && obj.type == "hidden") {
constr = '<tr ' + mouseout + mouseover + ' objid="' + obj.id+ '" class="tagContentTableTr" style="display:none;">'
+ ' <td>' + obj.name + '</td>'
+ ' <td class="tagContentTableTrTd">'
+ ' <input objid="' + obj.id + '" class="attribute_input_css" name="attribute_name_input_' + obj.id + '" value="' + obj.value + '" scope="' + obj.groupPath + '" readonly="' + obj.readonly + '" />'
//+ '<div objid="' + obj.id + '" onclick="removeTrAttribute(this)" id= "ico_attribute_delete_"' + obj.id + ' class="ico_attribute_delete"></div>'
+ '</td></tr>';
} else if (obj.type == "table") {
let tableInput = '请输入'
if (obj.value.table.length > 1) {
tableInput = '请查看'
}
constr = '<tr>';
/*constr += '<td style="padding-left:20px;" class="tableContent">' + obj.name + '</td>';*/
constr += '<td id="' + shape.id + obj.id + '" class="tableContent">' + '【' + obj.name +'】'+'&nbsp;'+ '<span id="' + obj.id + ' " onclick="openDialog(' + JSON.stringify(obj.value).replace(/\"/g, "'") + ')"> ' + tableInput + '</span>' + '</td>';
constr += '</tr>';
}
$('#' + tbodyId + ' table[name=' + shape.id + ']').append(constr);
}
}
if (selectFlag) {
getSelectOptions(shape.category, selectValues); //处理select类型
}
}
// table表格
function openDialog(obj) {
let tableName = obj.name
let dialogTable = obj.table
$("#attribute-table-content2").empty()
let thead =
'<tr id="' + dialogTable[0].id + '" >'
+ '<td style="width: 30%;" class="dialogTableHead">' + dialogTable[0].name + '</td>'
+ '<td style="width: 70%;" class="dialogTableHead">' + dialogTable[0].desc + '</td>'
+'</tr>'
$('#attribute-table-content2').append(thead)
for ( let i = 1; i < dialogTable.length; i++) {
let str =
'<tr id="' + dialogTable[i].id + '">'
+ '<td style="width: 30%;">' + dialogTable[i].name + '</td>'
+ '<td style="width: 70%;">' + dialogTable[i].desc + '</td>'
+'</tr>'
$('#attribute-table-content2').append(str)
}
$("#attribute-table-window2").dialog({
title: tableName,
draggable: true,
buttons : [{
text : '确定',
cls : "blue",
handler : function() {
$("#attribute-table-window2").dialog('close');
}
}, {
text : '取消',
handler : function() {
$("#attribute-table-window2").dialog('close');
}
}]
})
}
Array.prototype.unique = function(){
var res = [];
var json = {};
for(var i = 0; i < this.length; i++){
if(!json[this[i]]){
res.push(this[i]);
json[this[i]] = 1;
}
}
return res;
}
// 得到不同属性值关联的形状
function getAttributeByAttrId(shape, objId, relationShapes) {
//objId 属性的key值
var exitAttributesJsonArray = [];
var attrArr = []; //修改后的属性值
for (var i = 0; i < relationShapes.length; i++) {
var shapeObjT = relationShapes[i];
attrArr.push(shapeObjT.relationShapeId);
}
attrArr = attrArr.unique(); //属性值去重
if (attrArr.length > 0) {
for (var i = 0; i < shape.dataAttributes.length; i++) {
var attr = shape.dataAttributes[i];
if (attr.attributesJsonArray) {
exitAttributesJsonArray = attr.attributesJsonArray;
break;
}
}
for (var c = 0; c < exitAttributesJsonArray.length; c++) {
var el = exitAttributesJsonArray[c];
if(el == null) continue;
if (el.id == objId) {
el.value = attrArr.join(",");
break;
}
}
for (var i = 0; i < shape.dataAttributes.length; i++) {
var attr = shape.dataAttributes[i];
if (attr.attributesJsonArray) {
attr.attributesJsonArray = exitAttributesJsonArray;
break;
}
}
for (var j = 0, len = attrArr.length; j < len; j++) {
var attrShapeId = attrArr[j];
relationShapesObject[attrShapeId] = {"relationShapeId" : attrShapeId};
}
$("input[objid_shapeId='" + objId + "']").val(attrArr.join(","));
} else {
$("input[objid_shapeId='" + objId + "']").val("");
}
return shape;
}
Array.prototype.notDistinct = function() {
var newArr = [], obj = {};
for (var i = 0, len = this.length; i < len; i++) {
if (!obj[this[i]]) {
newArr.push(this[i]);
obj[this[i]] = 'new';
}
}
return newArr;
}
// 删除掉关联形状
function removeTrRelevanceShapes(obj) {
var options = {
title : "提示",
content : "确定删除吗?",
model : false,
onConfirm : function() {
// 确定删除
var shape = Utils.getSelected()[0];
var tempArray = new Array();
var count = 0;
if (shape) {
var relevanceShapes = [];
for (var i = 0; i < shape.dataAttributes.length; i++) {
var attr = shape.dataAttributes[i];
if (attr.relevanceShapes) {
relevanceShapes = attr.relevanceShapes;
break;
}
}
for (var index = 0; index < relevanceShapes.length; index++) {
var tempObj = relevanceShapes[index];
if (tempObj.id == $(obj).attr("objid")) {
continue;
}
tempArray[count++] = tempObj;
}
for (var i = 0; i < shape.dataAttributes.length; i++) {
var attr = shape.dataAttributes[i];
if (attr.relevanceShapes) {
attr.relevanceShapes = tempArray;
break;
}
}
Model.update(shape);
}
$(obj).hide();
$(obj).parent().parent().remove();
$.ajax({
type : "POST",
url : "./jd?sid="
+ CLB.sid
+ "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_relation_shape_relevance_remove",
data : {
uuid : $(obj).attr("objid"),
},
success : function(msg) {
}
});
}
};
window.top.$.confirm(options);
}
// 过虑 掉重复的图形
function filterRepeatShapes(arr1, shape) {
var arr2 = [];
var arr = [];
for (var i = 0; i < shape.dataAttributes.length; i++) {
var attr = shape.dataAttributes[i];
if (attr.relevanceShapes) {
arr2 = attr.relevanceShapes;
break;
}
}
var flag = false;
for (var a = 0; a < arr1.length; a++) {
var arrEle1 = arr1[a];
for (var b = 0; b < arr2.length; b++) {
var arrEle2 = arr2[b];
if (arrEle1.id == arrEle2.id) {
flag = true;
break;
}
}
if (flag) {
flag = false;
continue;
}
arr2.push(arrEle1);
}
for (var i = 0; i < shape.dataAttributes.length; i++) {
var attr = shape.dataAttributes[i];
if (attr.relevanceShapes) {
attr.relevanceShapes = arr2;
break;
}
}
return shape;
}
function updateModelElementsAttribute(selectedShape, nodes) {
var shapes = Model.define.elements;
for (var shapeId in shapes) {
var obj = nodes;
var shape = shapes[shapeId];
if(shape.name != "linker" && shape.id != selectedShape.id && shape.name == selectedShape.name){
var exitAttributesJsonArray = [];
var attrIndex = 0;
for (var i = 0; i < shape.dataAttributes.length; i++) {
var attr = shape.dataAttributes[i];
if (attr.attributesJsonArray) {
exitAttributesJsonArray = attr.attributesJsonArray;
attrIndex = i;
break;
}
}
var arrJsontemp = [];
for (var t = 0; t < exitAttributesJsonArray.length; t++) {
if(exitAttributesJsonArray[t] == null) {
continue;
}
arrJsontemp.push(exitAttributesJsonArray[t]);
}
obj = filterRepeatAttribute(obj, exitAttributesJsonArray, shape.dataAttributes[attrIndex].attributesJsonArray);
for (var a = 0; a < obj.length; a++) {
for (var i = 0; i < shape.dataAttributes.length; i++) {
var attr = shape.dataAttributes[i];
if (attr.attributesJsonArray) {
attr.attributesJsonArray.push(obj[a]);
break;
}
}
}
if (arrJsontemp.length != 0) {
var tempArr = removeShepeAttributeAndReturnDifferent(arrJsontemp, filterNotCheckedAttribute(nodes, arrJsontemp));
var tempArray = new Array();
for (var e = 0; e < tempArr.length; e++) {
if (tempArr[e] != 0 && tempArr[e] != "0") {
removeNotCheckedAttribute(shape, tempArr[e]);
}
}
if (tempArray.length != 0) {
shape.attributesJsonArray = tempArray;
for (var i = 0; i < shape.dataAttributes.length; i++) {
var attr = shape.dataAttributes[i];
if (attr.attributesJsonArray) {
attr.attributesJsonArray = tempArray;
break;
}
}
}
}
Model.update(shape);
//修改属性时,后台查询是否有关联属性,如果删除的属性有关联属性,需要删除关联表中的数据
var attrIds = ",";
if (nodes != undefined) {
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].type) {
attrIds += nodes[i].id + ",";
}
}
awsui.ajax.request({
url : "./jd",
method : "POST",
data : {
sid:sid,
cmd:"com.actionsoft.apps.coe.pal_pl_repository_designer_relation_shape_relevance_check",
fileId: ruuid,
shapeId: shape.id,
attrIds: attrIds
},
ok : function(r) {
},
err:function(r){
}
});
}
}
}
}
// 过虑出当在节点上不选中时的属性
function filterNotCheckedAttribute(checkedObj, exitObj) {
var result1 = [];
if (checkedObj.length == 0) {
return [];
} else {
var flag = false;
for (var b = 0; b < checkedObj.length; b++) {
var checkedArr1 = checkedObj[b];
for (var a = 0; a < exitObj.length; a++) {
var exitArr1 = exitObj[a];
if (exitArr1.id == checkedArr1.id) {
result1.push(checkedArr1);
break;
}
}
}
return result1;
}
}
// 移除图形属性中部分已存在的元素并返回不同元素
function removeShepeAttributeAndReturnDifferent(exitObj, newObj1) {
var result1 = [];
for (var a = 0; a < newObj1.length; a++) {
var obj1 = newObj1[a];
for (var i = 0, n = 0; i < exitObj.length; i++) {
if (exitObj[i].id == obj1.id) {
result1.push(i);
break;
}
}
}
for (var i = 0; i < result1.length; i++) {
exitObj[result1[i]] = 0;
}
return exitObj;
}
// 删除没有选中的元素
function removeNotCheckedAttribute(shape, obj1) {
var tempArray = new Array();
var attributesJsonArray1 = [];
for (var i = 0; i < shape.dataAttributes.length; i++) {
var attr = shape.dataAttributes[i];
if (attr.attributesJsonArray) {
attributesJsonArray1 = attr.attributesJsonArray;
break;
}
}
for (var index = 0; index < attributesJsonArray1.length; index++) {
if(attributesJsonArray1[index] == null) {
continue;
}
var tempObj1 = attributesJsonArray1[index];
if (tempObj1.id == obj1.id) {
continue;
}
tempArray.push(tempObj1);
}
for (var i = 0; i < shape.dataAttributes.length; i++) {
var attr = shape.dataAttributes[i];
if (attr.attributesJsonArray) {
attr.attributesJsonArray = tempArray;
break;
}
}
// shape.attributesJsonArray = tempArray;
// Model.update(shape);
$("#" + shape.id + " name=[tagContentTable0] tr[objid='" + obj1.id + "']").remove();
}
// 过滤掉重复的属性生成新的数组
function filterRepeatAttribute(arr1, arr2, shape) {
var result = [];
var flag = false;
for (var a = 0; a < arr1.length; a++) {
var arrEle1 = arr1[a];
for (var b = 0; b < arr2.length; b++) {
var arrEle2 = arr2[b];
if(arrEle2 == null) {
continue;
}
if (arrEle1.id == arrEle2.id) {
shape[b].name = arrEle1.name;
flag = true;
break;
}
}
if (flag) {
flag = false;
continue;
}
result.push(arrEle1);
}
return result;
}
// 当属性为可编辑时,编辑时自动保存
function showEditButton(obj) {
$(obj).siblings("span::contains('...')").show();
}
function saveInputContent(obj) {
// 按钮
// $(obj).siblings("span::contains('...')").hide();
var objValue = $(obj).val();
if ($(obj).attr("inputType") == "number") {
var val = $(obj).val();
if (/\D/.test(val)) {
$.simpleAlert("此处只能输入数字", "info", 2000);
$("#simplealert>.msg").css("top", "15px");
return;
}
}
updateAttributeById($(obj).attr("objid"), objValue);
}
function saveSelectContent(objAttr,objValue){
updateAttributeById(objAttr, objValue);
}
// 显示select下拉框
function showSelectOption(obj) {
var str = $(obj).attr("ty");
if (str == "td") {
$(obj).children("select").show();
$(obj).children("span").hide();
} else {
updateAttributeById($(obj).attr("objid"), $(obj)
.find("option:selected").text());
$(obj).hide();
$(obj).siblings("span").text($(obj).find("option:selected").text())
.show();
}
}
// 属性编辑打开窗口
function showAttributedEditWindow(obj) {
var objId = $(obj).attr("objid");
var shape = Utils.getSelected()[0];
if (shape) {
if (objId == "desc") {
for (var i = 0; i < shape.dataAttributes.length; i++) {
var attr = shape.dataAttributes[i];
if (attr.shapeDesc != undefined) {
$("#attribute-edit-title").text("描述/定义");
$("#attribute-edit-content").html(attr.shapeDesc == undefined ? "" : attr.shapeDesc.replace(/\n/g,'<br>'));
break;
}
}
} else {
var attributesJsonArray = [];
for (var i = 0; i < shape.dataAttributes.length; i++) {
var attr = shape.dataAttributes[i];
if (attr.attributesJsonArray) {
attributesJsonArray = attr.attributesJsonArray;
break;
}
}
for (var index = 0; index < attributesJsonArray.length; index++) {
var tempObj = attributesJsonArray[index];
if (tempObj.id == objId) {
$("#attribute-edit-title").text(tempObj.name);
$("#attribute-edit-content").val(tempObj.value);
break;
}
}
}
}
$("#attribute-edit-window").dialog({
draggable: false,
buttons : [{
text : '确定',
cls : "blue",
handler : function() {
var str = $("#attribute-edit-content").val();
if (objId == "desc") {
for (var i = 0; i < shape.dataAttributes.length; i++) {
var attr = shape.dataAttributes[i];
if (attr.shapeDesc != undefined) {
shape.dataAttributes[i].shapeDesc = str;
break;
}
}
Model.update(shape);
} else {
updateAttributeById($(obj).attr("objid"), str);
}
$(obj).val(str);
$("#attribute-edit-window").dialog('close');
}
}, {
text : '关闭',
handler : function() {
$("#attribute-edit-window").dialog('close');
}
}]
});
}
// 对单个属性的更新操作
function updateAttributeById(objId, va) {
// var shape = Utils.getSelected()[0];
var shape = selectShape;
var tempArray = new Array();
var count = 0;
if (shape) {
/*
* for (var i = 0; i < shape.dataAttributes.length; i++) { var attr =
* shape.dataAttributes[i]; if (attr.attributesContent) {
* attr.attributesContent = $("#" + shape.id + " tbody[name=tagContentTable0]").html(); break; } }
*/
var attributesJsonArray = shape.attributesJsonArray;
for (var i = 0; i < shape.dataAttributes.length; i++) {
var attr = shape.dataAttributes[i];
if (attr.attributesJsonArray) {
attributesJsonArray = attr.attributesJsonArray;
break;
}
}
for (var index = 0; index < attributesJsonArray.length; index++) {
var tempObj = attributesJsonArray[index];
if(tempObj == null) {
continue;
}
if (tempObj.id == objId) {
tempObj.value = va;
tempArray[count++] = tempObj;
continue;
}
tempArray[count++] = tempObj;
}
if (tempArray.length > 0) {
shape.attributesJsonArray = tempArray;
for (var i = 0; i < shape.dataAttributes.length; i++) {
var attr = shape.dataAttributes[i];
if (attr.attributesJsonArray) {
attr.attributesJsonArray = tempArray;
break;
}
}
if ("isAutoSave" == 1) {
CLB.cmdList = [{
"type" : "message",
"cmd" : "com.actionsoft.apps.coe.pal_pl_repository_designer_message"
}];
}
Model.update(shape);
}
}
}
// 删除行上的属性
function removeTrAttribute(obj) {
var options = {
title : "提示",
content : "确定删除吗?",
model : false,
onConfirm : function() {
// 确定删除
var shape = Utils.getSelected()[0];
var tempArray = new Array();
var count = 0;
if (shape) {
// shape.attributesContent = $("#" + shape.id + " tbody[name=tagContentTable0]").html();
var attributesJsonArray = [];
for (var i = 0; i < shape.dataAttributes.length; i++) {
var attr = shape.dataAttributes[i];
if (attr.attributesJsonArray) {
attributesJsonArray = attr.attributesJsonArray;
break;
}
}
for (var index = 0; index < attributesJsonArray.length; index++) {
var tempObj = attributesJsonArray[index];
if (tempObj.id == $(obj).attr("objid")) {
continue;
}
tempArray[count++] = tempObj;
}
// if (tempArray.length >= 0) {
shape.attributesJsonArray = tempArray;
for (var i = 0; i < shape.dataAttributes.length; i++) {
var attr = shape.dataAttributes[i];
if (attr.attributesJsonArray) {
attr.attributesJsonArray = tempArray;
break;
}
}
Model.update(shape);
// }
}
$(obj).hide();
$(obj).parent().parent().remove();
$.ajax({
type : "POST",
url : "./jd?sid="
+ CLB.sid
+ "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_relation_shape_relevance_remove",
data : {
uuid : $(obj).attr("objid"),
shapeId : Utils.getSelected()[0].id,
fileId : ruuid
},
success : function(msg) {
}
});
}
};
window.top.$.confirm(options);
}
// 显示删除按钮
function showRemoveTrAttribute(obj) {
$(obj).addClass("attr_bg_color_tr");
$("input[name=attribute_name_input_" + $(obj).attr("objid") + "]")
.addClass("attr_bg_color_tr");
$("input[name=attribute_name_input_" + $(obj).attr("objid") + "]").parent()
.addClass("attr_bg_color_tr");
$(obj).children("td").children(".ico_attribute_delete").show();
if ($(obj).attr("ty") == "sel") {
$(obj).children("td").children("select").show();
$(obj).children("td").children("span").hide();
}
}
// 隐藏删除按钮
function hideRemoveTrAttribute(obj) {
$(obj).removeClass("attr_bg_color_tr");
$("input[name=attribute_name_input_" + $(obj).attr("objid") + "]")
.removeClass("attr_bg_color_tr");
$("input[name=attribute_name_input_" + $(obj).attr("objid") + "]").parent()
.removeClass("attr_bg_color_tr");
$(obj).children("td").children(".ico_attribute_delete").hide();
if ($(obj).attr("ty") == "sel") {
$(obj).children("td").children("select").hide();
$(obj).children("td").children("span").show();
}
}
// 经常用的是通过遍历,重构数组.
Array.prototype.remove = function(dx) {
if (isNaN(dx) || dx > this.length) {
return false;
}
for (var i = 0, n = 0; i < this.length; i++) {
if (this[i] != this[dx]) {
this[n++] = this[i];
}
}
this.length -= 1;
};
function removeElementFromArr(dx, obj) {
if (isNaN(dx) || dx > obj.length) {
return false;
}
for (var i = 0, n = 0; i < obj.length; i++) {
if (obj[i] != obj[dx]) {
obj[n++] = obj[i];
}
}
obj.length -= 1;
return obj;
}
// 在数组中获取指定值的元素索引
Array.prototype.getIndexByValue = function(value) {
var index = -1;
for (var i = 0; i < this.length; i++) {
if (this[i].url == value) {
index = i;
break;
}
}
return index;
};
Array.prototype.getIndexByValueById = function(value) {
var index = -1;
for (var i = 0; i < this.length; i++) {
if (this[i] == value) {
index = i;
break;
}
}
return index;
};
// 重写链接创建后的事件
Designer.events.addEventListener("linkerCreated", function(linker) {
/**
* var toId = linker.to.id; //当前选中的图形 var fromShape =
* Utils.getSelected()[0]; //目标图形 var toShape =
* Model.getShapeById(toId); var toShapeTemp = []; for (var index =
* 0; index < linkerRelationship.length; index++) { var shapes =
* linkerRelationship[index]; var fromShapeId = shapes.fromShapeId;
* var toShapeIds = shapes.toShapeId; if (fromShape.name ==
* fromShapeId) { if (toShapeIds != "*") { //判断是针对哪些图形有效 if
* (toShapeIds.indexOf(",") > 0) { toShapeTemp =
* toShapeIds.split(","); } else { toShapeTemp.push(toShapeIds); } } } }
* if (toShapeTemp.length != 0) { for (var index = 0; index <
* toShapeTemp.length; index++) { var tempShapeId =
* toShapeTemp[index]; //删除这条线 if (toShape.name != tempShapeId) {
* $.simpleAlert("不支持所选对象与目标对象的这种关系", "error", 2500); //待续未完
* deleteLinkerSelected(linker); } } } // if (toShape.name == "xxx") { //
* linker.to.id = null; //} //获取选中的链接线 var outlinkers =
* Utils.getOutlinkers(fromShape); var l = linker; //
* consloe.log(l);
*/
// 判断是不是支持这种关系类型
// isObjectRelationshipModel(linker, true);
// showShapeRelationTab(null);
// attributeShowTabContent(null);
// showRelevanceShapesContent();
// shapeCopyAndPasteCount(null);
});
/**
* 图形创建后重写
*/
Designer.events.addEventListener("created", function(shape) {
if (Designer.status == "demo" && !demoCreatedTiped) {
UI.showStartStep("created", $("#" + shape.id));
demoCreatedTiped = true;
}
/***************************************************************************
* var selectedShape = Utils.getSelected()[0]; var linkerIds =
* Model.getShapeLinkers(selectedShape.id);
* if(linkerIds&&linkerIds.length>0){ var linker =
* Model.getShapeById(linkerIds[0]); isObjectRelationshipModel(linker,
* true); }
**************************************************************************/
showShapeRelationTab(shape);
if(shape.category == "control_risk") {
initPrivateAttribute(shape, "control_risk"); // 创建节点后编号提供默认值
}
if(shape.category == "process_flowchart" || shape.category == "process_bpmn2") {// 流程flowchar编号初始化编号
if (!IsGroupChild(shape)) {// 不在组内部或者新建立的节点为组节点
// 获取最大编号
initPrivateAttribute(shape, shape.category);
}
if(shape.name == "group") {// 组置于最底层
// Designer.layerShapes("back");
var start = Model.orderList[0].zindex; //取到最小的zindex
start -= 1;
shape.props.zindex = start;
}
}
attributeShowTabContent(shape);
// shapeCopyAndPasteCount(shape);
});
// 设置编号属性默认值
function initPrivateAttribute(newShape, type) {
if (type == "control_risk") {
var shapes = Model.define.elements;
var max = 0;
for (var shapeId in shapes) {
var shape = shapes[shapeId];
if(shape.category == "control_risk") { // 过滤其他模型图形
var dataAttr = shape.dataAttributes[0];
var number = typeof dataAttr.privateAttributeContent == "string" ? JSON.parse(dataAttr.privateAttributeContent.replace(/'/g,'"')).number : dataAttr.privateAttributeContent.number;
if(typeof number == 'string') number = number.replace(/^\s+|\s+$/g,"");
if(!isNaN(number)) if(number > max) max = number;
}
}
max = Math.floor(max) + 1;
newShape.dataAttributes[0].privateAttributeContent = {'number': max };
} else {
var shapes = Model.define.elements;
var max = 0;
for (var shapeId in shapes) {
var shape = shapes[shapeId];
if (shape.dataAttributes != undefined) {
for (var i = 0; i < shape.dataAttributes.length; i++) {
if (shape.dataAttributes[i].privateAttributeContent != null) {
var privateAttributeContent = shape.dataAttributes[i].privateAttributeContent;
if (typeof(privateAttributeContent) == "string") {
privateAttributeContent = eval("(" + privateAttributeContent + ")");
}
var number = privateAttributeContent.number;
if(number != undefined && number != null && number != "") {
if(typeof number == 'string') number = number.replace(/^\s+|\s+$/g,"");
if(!isNaN(number)) if(parseInt(number) > parseInt(max)) max = number;
}
}
}
}
}
// 设置最大编号为max+1
var json = "{'number':'编号'}";
// var json2 = "{'number':'" + (parseInt(max)+1) + "'}";
String.prototype.padLeft = Number.prototype.padLeft = function(total, pad) {
return (Array(total).join(pad || 0) + this).slice(-total);
}
var no = ((parseInt(parseInt(max)/10) + 1)*10);
if(no < 1000) {
no = no.padLeft(3);
}
var json2 = "{'number':'" + no + "'}";
var shapeName = newShape.name;
if (shapeName.indexOf("_custom") > -1) {
shapeName = shapeName.substring(0, shapeName.indexOf("_"));
}
if (shapeName == "control" || shapeName == "risk" || shapeName == "item"
|| shapeName == "regulation" || shapeName == "procedure"
|| shapeName == "method" || shapeName == "manualOperation"
|| shapeName == "predefinedProcess"
|| shapeName == "callActivityCallingProcess"
|| shapeName == "businessRuleTask" || shapeName == "scriptTask"
|| shapeName == "sendTask" || shapeName == "userTask"
|| shapeName == "serviceTask" || shapeName == "manualTask"
|| shapeName == "receiveTask" || shapeName == "process"
|| shapeName == "decision" || shapeName == "group") {
for (var i = 0; i < newShape.dataAttributes.length; i++) {
var attr = newShape.dataAttributes[i];
if (attr.privateAttribute) {
attr.privateAttribute = json;
}
if(attr.privateAttributeContent) {
attr.privateAttributeContent = json2;
}
}
}
}
}
//判断新建立的节点是否在shapeName为group的组内部
function IsGroupChild(newShape) {
var result = false;
var newObj = newShape.props;
var x2 = parseInt(newObj.x);
var y2 = parseInt(newObj.y);
var w2 = parseInt(newObj.w);
var h2 = parseInt(newObj.h);
if (newShape.name == "group") {
return false;
} else { // 是否在组内部
var shapes = Model.define.elements;
for (var shapeId in shapes) {
if (newShape.id == shapeId) continue;
var shape = shapes[shapeId];
if (shape.name == "group") {// 存在组节点
var obj = shape.props;
var x1 = parseInt(obj.x);
var y1 = parseInt(obj.y);
var w1 = parseInt(obj.w);
var h1 = parseInt(obj.h);
if (x1<x2 && y1<y2 && y1+h1>y2+h2 && x1+w1>x2+w2 && x1+w1>x2+w2 && y1+h1>y2+h2) { // 新建立节点在组内部
result = true;
break;
}
}
}
}
return result;
}
// 当不符合配置的关系时删除链接线
function deleteLinkerSelected(linker) {
// moveShape移除图片 moveLinker移除链线 shapeMultiSelectable图形选中事件 designer.core.js
var d = linker;
if (d.length > 0) {
Utils.unselect();
var e = Utils.getAttachedShapes(d);
d = d.concat(e);
var c = [];
for (var b = 0; b < d.length; b++) {
var a = Utils.getChildrenShapes(d[b]);
c = c.concat(a)
}
d = d.concat(c);
Model.remove(d)
}
}
// 显示图形关系特性
function showShapeRelationTab(currentShape) {
if (!$("#tagContent0").is(":visible")) {
return;
}
// 拿到所选的图形
var selectedShape = Utils.getSelected()[0];
if (!selectedShape)
return;
if (currentShape) {
selectedShape = currentShape
}
var linkers = Model.getShapeLinkers(selectedShape.id);
var outlinkers = Utils.getOutlinkers(Utils.getSelected());
var l = linkers;
$("#tagContentTable1").empty();
if (linkers != undefined) {
for (var a = 0; a < linkers.length; a++) {
// 根据连线的id拿到连线图形这个对象,再根据这个对象来找到他所关联的图形
var element = linkers[a];
var linkerObjs = Model.getShapeById(element);
// 来自哪个图形 的id
var fromId = linkerObjs.from.id;
var toId = linkerObjs.to.id;
var fromShape = Model.getShapeById(fromId);
var toShape = Model.getShapeById(toId);
if (fromShape != undefined && toShape != undefined) {
// 此处判断的是从本图形出去的连线
if (fromShape.id == selectedShape.id) {
for (var b = 0; b < linkerRelationship.length; b++) {
var shapes = linkerRelationship[b];
var fromShapeId = shapes.fromShapeId;
var toShapeIds = shapes.toShapeId;
if (fromShape.name == fromShapeId) {
if (toShapeIds != "*") {
// 判断是针对哪些图形有效
if (toShapeIds.indexOf(",") > 0) {
var toShapeTemp = toShapeIds.split(",");
for (var c = 0; c < toShapeTemp.length; c++) {
var josnShapeId = toShapeTemp[c];
if (josnShapeId == toShape.name) {
addtagContentTableContent(
fromShape,
shapes.outcomingName,
toShape);
}
}
} else {
if (toShapeIds == toShape.name) {
addtagContentTableContent(fromShape,
shapes.outcomingName, toShape);
}
}
} else {
// 当没有限制的时候
addtagContentTableContent(fromShape,
shapes.outcomingName, toShape);
}
}
}
} else if (toShape.id == selectedShape.id) {
// 此处需要完善当不扶持 对像关系类型时下面的代码 不执行
// 判断进来的链线开始
for (var b = 0; b < linkerRelationship.length; b++) {
var shapes = linkerRelationship[b];
var fromShapeId = shapes.fromShapeId;
var toShapeIds = shapes.toShapeId;
// if (toShape.name == fromShapeId) {
// 判断这两种图形中是否有这种关系
// if (isObjectRelationshipModel(linkerObjs, false))
// addtagContentTableContent(fromShape,
// shapes.incomingName);
// }
if (fromShape.name == fromShapeId) {
if (toShapeIds != "*") {
// 判断是针对哪些图形有效
if (toShapeIds.indexOf(",") > 0) {
var toShapeTemp = toShapeIds.split(",");
for (var c = 0; c < toShapeTemp.length; c++) {
var josnShapeId = toShapeTemp[c];
if (josnShapeId == selectedShape.name) {
addtagContentTableContent(toShape,
shapes.incomingName,
fromShape);
}
}
} else {
if (toShapeIds == selectedShape.name) {
addtagContentTableContent(toShape,
shapes.incomingName, fromShape);
}
}
} else {
// 当没有限制的时候
addtagContentTableContent(toShape,
shapes.incomingName, fromShape);
}
}
}
// 判断进来的线结束
}
}
var e = element;
}
}
}
// 给关系类型增加内容
function addtagContentTableContent(shape1, str, obj) {
if (obj.text == "") {
obj.text = obj.title;
}
var constr = '<tr onmouseout="hideRemoveTrAttribute(this);" onmouseover="showRemoveTrAttribute(this);" class="tagContentTableTr"><td>'
// + shape1.text
+ str
+ '</td><td><div class="attribute_td_div_css">'
+ obj.text
+ '</div> </td></tr>';
$("#tagContentTable1").append(constr);
}
// 判断是不是支持对象的关系类型
function isObjectRelationshipModel(linker, isAlert) {
var flag = false;
var toId = linker.to.id;
if (toId == null)
return false;
// 当前选中的图形
var fromShape = Utils.getSelected()[0];
// 目标图形
var toShape = Model.getShapeById(toId);
var toShapeTemp = [];
for (var index = 0; index < linkerRelationship.length; index++) {
var shapes = linkerRelationship[index];
var fromShapeId = shapes.fromShapeId;
var toShapeIds = shapes.toShapeId;
if (fromShape) {
if (fromShape.name == fromShapeId) {
if (toShapeIds != "*") {
// 判断是针对哪些图形有效
if (toShapeIds.indexOf(",") > 0) {
toShapeTemp = toShapeIds.split(",");
} else {
toShapeTemp.push(toShapeIds);
}
}
}
}
}
if (toShapeTemp.length != 0) {
for (var index = 0; index < toShapeTemp.length; index++) {
var tempShapeId = toShapeTemp[index];
// 删除这条线
if (toShape && toShape.name == tempShapeId) {
// 画线时的操作
// 显示关系类型里的操作
flag = true;
break;
// 待续未完
}
}
} else {
flag = true;
}
if (!flag) {
if (isAlert) {
// $.simpleAlert("不支持所选对象与目标对象的这种关系", "error", 2000);
// deleteLinkerSelected(linker);
}
}
return flag;
}
// 文件属性的处理
function initProcessDesc() {
console.log(processDesc)
var length = Object.keys(processDesc).length;
var t = '';
var wid='60%';
for(var i = 1; i <= length; i++) {
var obj = processDesc[i];
t += '<tr><td>';
t += '<div class="tableContent">' + "【"+obj.name +"】"+ '</div>';
if(obj.name.length >=5){
wid='60%';
}
var value = obj.value;
if (value == undefined) {
value = '';
t += '<div class="tableContent" style="width:'+wid+'" >'+ value + '</div>';
t += '</td></tr>';
} else if(obj.type == 'table') {
if(value == '') {
t += '<div class="tableContent" style="width: '+wid+'">' + value + '</div>';
t += '</td></tr>';
} else {
let tableValue = JSON.parse(value.replace(/&quot;/g,'\"'))
let tableFlag = '请输入'
if (tableValue.table.length > 1) {
tableFlag = '请查看'
}
t += '<div class="tableContent" style="width: '+wid+'" onclick="openDialog(' + JSON.stringify(tableValue).replace(/\"/g,"'") +')">' +'<span style="color:blue">'+tableFlag+'</span>'+'</div>';
t += '</td></tr>';
}
}
else {
value = value.replace(/\n/g,'<br>')
t += '<div class="tableContent" style="width: '+wid+'">' + value + '</div>';
t += '</td></tr>';
}
// t += '<td colspan="2" class="tableContent">' + value + '</td>';
// t += '</tr>';
}
$('#portalDescDock').find('table').append(t);
// $('#portalDescDock').append('<table class="awsui-table"><tr><td>&nbsp;</td></tr></table>');
}
function autoClickAttr() {
// 属性自动切换
if ($('#openTab').is(':hidden')) {
var name = '';
if (Utils.getSelected()[0] == null) {
name = 'processDesc';
} else {
name = 'processAttr';
}
$('#tab').find('div').removeClass('selected');
$('#' + name).addClass('selected');
$('.newadd_portalAttr').hide();
if(name == "processDesc") {
dockShowView('portalDescShow');
}
if(name == "processAttr") {
dockShowView('portalAttrShow');
}
if(name == "processFile") {
dockShowView('portalFileShow');
}
}
}
function dockShowView(name) {
if ($("#dock_btn_" + name).button("isDisabled")) {
return;
}
$(".dock_view").hide();
$(".dock_view_" + name).show();
$(".dock_buttons").children().removeClass("selected");
$("#dock_btn_" + name).addClass("selected");
if (Dock.currentView == "history" && name != "history") {
Dock.closeHistory();
}
Dock.currentView = name;
}
// 点击页面时变更显示内容
function changeArributeByShape() {
if(!isClickTab) {
autoClickAttr();
}
isClickTab = false;
var lastTable = '<table name="lastTable" class="awsui-table"><tr><td>&nbsp;</td></tr></table>';
//节点属性和附件的处理文件属性见initProcessDesc()
if (Utils.getSelected()[0] == null) {
initShapeAttribute('0');
initUpfileData('0');
ProcessManual();
$('table[name=lastTable]').remove();
if($('#portalAttrDock').children('table').length > 0) {
// $('#portalAttrDock').append(lastTable);
}
if($('#portalFileDock').children('table').length > 0) {
// $('#portalFileDock').append(lastTable);
}
} else {
selectShape = Utils.getSelected()[0];
initShapeAttribute(Utils.getSelected()[0].id);
initUpfileData(Utils.getSelected()[0].id);
$('table[name=lastTable]').remove();
if ($('#portalAttrDock table[name=' + Utils.getSelected()[0].id + ']').length > 0) {
// $('#portalAttrDock').append(lastTable);
}
if ($('#portalFileDock table[name=' + Utils.getSelected()[0].id + ']').length > 0) {
// $('#portalFileDock').append(lastTable);
}
}
}
function ProcessManual() {
$('#processFileDock').empty();
var t = '';
t += '<table class="awsui-table">';
t += '<tr><td>';
t += '<div class="filetableHeader"><i class="awsui-iconfont" style="color: #999999;margin-top: 2px;">&#xe7cf;</i> 流程手册:</div>';
t += '<div class="tableContent"><a href="javascript:void(0);" onclick="openOutputFile(\''+ taskId +'\')">'+ fileName +'</a></div>';
t += '<i class="awsui-iconfont" style="color: #999999;margin-top: 2px;" onclick="downloadProcessFile(\''+taskId+'\')">&#xe653;</i>';
t += '</td></tr>';
t += '</table>';
$('#processFileDock').append(t);
}
function openOutputFile(taskId) {
// 打开流程手册
$.simpleAlert('正在打开', 'loading');
$.ajax({
type : "POST",
url : "./jd?sid=" + sid
+ "&cmd=com.actionsoft.apps.coe.pal_outputreport_output_process_preview",
data : {
taskId : taskId
},
success : function(msg) {
if (msg.result == "ok") {
$.simpleAlert("close");
if (msg['data']) {
var url = msg['data']['url'];
window.open(url);
}
} else {
$.simpleAlert("close");
$.simpleAlert(msg['msg'], 'info');
}
}
});
}
function downloadProcessFile(taskId) {
$.ajax({
type : "POST",
url : "./jd?sid=" + sid
+ "&cmd=com.actionsoft.apps.coe.pal_outputreport_output_process_download",
data : {
taskId : taskId
},
success : function(msg) {
if (msg.result == "ok") {
window.location.href = msg.data.url;
}
}
});
}
// 初始化上传附件
function initUpfileData(obj) {
$('#alertMessage').remove();
if (obj == undefined || obj == '0') {
$('#portalFileDock').empty();
var t = '';
var processFile = upfileData['file'];
if(processFile.length > 0) {
t += '<table name="file" class="awsui-table">';
t += '<tr><td>';
t += '<div class="filetableHeader"><i class="awsui-iconfont" style="color: #999999;margin-top: 2px;">&#xe7cf;</i> 相关文件:</div>';
for(var i = 0; i < processFile.length; i++) {
var obj = processFile[i];
t += '<div class="tableContent"><a href="javascript:void(0);" onclick="readFile(\''+ obj.id +'\')">'+ obj.name +'</a></div>';
}
t += '</td></tr></table>';
}
var elements = Model.define.elements;
for(var e in elements) {
var ele = elements[e];
if(ele.name == 'linker') {
continue;
}
var processShape = upfileData[ele.id];
if(processShape != null && processShape.length > 0) {
t += '<table name="' + ele.id + '" class="awsui-table">';
t += '<tr><td>';
t += '<div class="filetableHeader"><i class="awsui-iconfont" style="color: #999999;margin-top: 2px;">&#xe7cf;</i>' + ele.text + '</div>';
for(var i = 0; i < processShape.length; i++) {
var obj = processShape[i];
t += '<div class="tableContent"><a href="javascript:void(0);" onclick="readFile(\''+ obj.id +'\')">'+ obj.name +'</a></div>';
t += '</td></tr>';
}
t += '</table>';
}
}
$('#portalFileDock').append(t);
} else {
$('#portalFileDock table').show();
$('#portalFileDock table[name=' + obj + ']').show();
}
var isHidden = true;
$('#portalFileDock table').each(function(){
if ($(this).css('display') != 'none') {
isHidden = false;
}
});
if (isHidden) {
var $noContent = $('#noContent').clone(true);
$noContent.attr('id', 'alertMessage');
$('#portalFileDock').append($noContent);
$('#alertMessage').show();
}
}
//附件在线预览
function readFile(uuid) {
$.simpleAlert("文件正在处理", "loading");
awsui.ajax.request({
type: "POST",
url: "./jd?sid=" + encodeURIComponent(sid) + "&cmd=com.actionsoft.apps.coe.pal_processlevel_upfile_read",
data: {uuid: uuid},
ok: function(msg) {
$.simpleAlert("close");
var url = msg.data.url;
if (msg.data.noSupport) {
window.location.href = url;
} else {
window.open(url);
}
},
err: function(msg) {
}
});
}
function sortModelByNumber() {
// 序号升序,无序号在后面
var recordId = [];
var hasNumArr = [];
/*for (var shapeId in Model.define.elements) {
var shape = Model.define.elements[shapeId];
for (var i = 0; i < shape.dataAttributes.length; i++) {
var attrArr = shape.dataAttributes[i];
if (attrArr.attributesJsonArray && attrArr.attributesJsonArray.length > 0) {
for (var j = 0; j < attrArr.attributesJsonArray.length; j++) {
var attr = attrArr.attributesJsonArray[j];
if (attr != null && attr.id && attr.id == 'number') {
var number = attr.value;
if(typeof number == 'string') {
number = number.replace(/^\s+|\s+$/g,"")
};
if(number != undefined && number != null && number != "") {
var obj = {};
obj.text = shape.text;
obj.id = shapeId;
obj.orderIndex = number;
hasNumArr.push(obj);
recordId.push(shapeId);
}
break;
}
}
break;
}
}
}*/
/*******************************排序方法重构***by zhaolei**********************************************/
for (var shapeId in Model.define.elements) {
var shape = Model.define.elements[shapeId];
for (var i = 0; i < shape.dataAttributes.length; i++) {
var attrArr = shape.dataAttributes[i];
if (attrArr.attributesJsonArray && attrArr.attributesJsonArray.length > 0) {
for (var j = 0; j < attrArr.attributesJsonArray.length; j++) {
var attr = attrArr.attributesJsonArray[j];
//根据活动序号排序
if (attr != null && attr.id) {
if(attr.id=="activity_number"){
var number = attr.value;
var subNumer=number< 10 ? number.substr(1,1) : number;
if(typeof subNumer == 'string') {
subNumer = subNumer.replace(/^\s+|\s+$/g,"")
};
if(subNumer != undefined && subNumer != null && subNumer != "") {
var obj = {};
obj.text = shape.text;
obj.id = shapeId;
obj.orderIndex = subNumer;
hasNumArr.push(obj);
recordId.push(shapeId);
}
}
}
}
}
}
}
// 有序号的元素升序排序
var compare = function (prop) {
return function (obj1, obj2) {
var val1 = obj1[prop];
var val2 = obj2[prop];
if (!isNaN(Number(val1)) && !isNaN(Number(val2))) {
val1 = Number(val1);
val2 = Number(val2);
}
if (val1 < val2) {
return -1;
} else if (val1 > val2) {
return 1;
} else {
return 0;
}
}
}
hasNumArr.sort(compare("orderIndex"));
/*for (var shapeId in Model.define.elements) {
if($.inArray(shapeId, recordId) == -1) {
var obj = {};
obj.id = shapeId;
hasNumArr.push(obj);
}
}*/
return hasNumArr;
}
// 初始化流程步骤说明
function initShapeAttribute(obj) {
if (obj == undefined || obj == '0') {
$('#portalAttrDock').empty();
var elements = Model.define.elements;
var sortNumShapeArr = sortModelByNumber();
for(var sortIndex = 0; sortIndex < sortNumShapeArr.length; sortIndex++) {
var temp = sortNumShapeArr[sortIndex];
var shape = elements[temp.id];
if(shape.name == 'linker') {
continue;
}
// 属性弹出层显示的内容
var attributesJsonArray = "";
var attributesJsonArrayT = [];
for (var i = 0; i < shape.dataAttributes.length; i++) {
var attr = shape.dataAttributes[i];
if (attr.attributesJsonArray) {
attributesJsonArrayT = attr.attributesJsonArray;
break;
}
}
// 属性排序
var defaultMoreAttr = $('#defaultMoreAttrSort').val();
if(defaultMoreAttr.length > 0) {
var arr = defaultMoreAttr.split('|');
var tempAttrArray = [];
for(var i = 0; i < arr.length; i++) {
for(var j = 0; j < attributesJsonArrayT.length; j++) {
if(attributesJsonArrayT[j] == undefined || attributesJsonArrayT[j] == null) {
continue;
}
if(arr[i] == attributesJsonArrayT[j].id) {
tempAttrArray.push(attributesJsonArrayT[j]);
}
}
}
//取新添加的属性
if (tempAttrArray.length > 0) {
var newAttrArray = [];
newAttrArray = tempAttrArray.concat(attributesJsonArrayT).filter(function(v, i, arr) {
return arr.indexOf(v) === arr.lastIndexOf(v);
});
attributesJsonArrayT = tempAttrArray.concat(newAttrArray);
}
}
//流程阅览只显示线上审批、线下审批、系统任务、人工审批
if(shape.title=="线上审批" || shape.title=="线下审批" || shape.title=="系统任务" ||shape.title=="人工任务") {
var no = "";
for (var i = 0; i < attributesJsonArrayT.length; i++) {
var id = attributesJsonArrayT[i].id;
if (id == "activity_number") {
var numberValue = attributesJsonArrayT[i].value;
if (numberValue != "") {
no = numberValue;
}
}
}
var novalue=no+"."+shape.text;
var t = '';
t += '<div class="task-box" id="box' + shape.id + '">';
t += '<span id="span' + shape.id + '">';
t += '</span>';
t += '<i class="awsui-iconfont newadd_up" id="searchChange' + shape.id + '" onclick="searchChange(\'' + shape.id + '\',\''+novalue+'\')">&#xe718;</i>';
t += '<input type="hidden" name="searchChangeFlg" id="searchChangeFlg' + shape.id + '" value="0" />';
t += '<table class="awsui-table awsui-table-bordered" name="' + shape.id + '" id="' + shape.id + 'change" >';
t += '<tr name="trHeader">';
t += '<td class="tableHeader" >' +no+"."+shape.text +'</td>';
t += '</tr>';
t += '<tr>';
/*t += '<td style="padding-left:20px;" class="tableContent"></td>';*/
t += '<td id="' + shape.id + 'type" class="tableContent"></td>';
t += '</tr>';
t += '</table></div>';
$('#portalAttrDock').append(t);
if (shape && attributesJsonArrayT) {
// {}函数,改为图形创建时增加私有属性
attributesJsonArray = attributesJsonArrayT;
var shapeTitle = shape.title == undefined ? "" : shape.title;
$("#" + shape.id + "type").text(shapeTitle);
for (var i = 0; i < shape.dataAttributes.length; i++) {
var attr = shape.dataAttributes[i];
if (attr.shapeDesc) {
$("#" + shape.id + "desc").html(attr.shapeDesc == undefined ? "" : attr.shapeDesc.replace(/\n/g, '<br>'));
break;
}
}
// 此处遍历attributesJsonArray输入 内容
if (attributesJsonArray.length != 0) {
getPrivateAttributeHtml(attributesJsonArray, "portalAttrDock", shape);
}
}
}
}
} else {
$('#portalAttrDock table').hide();
$('#portalAttrDock table[name=' + obj + ']').show();
var elements = Model.define.elements;
var sortNumShapeArr = sortModelByNumber();
for(var sortIndex = 0; sortIndex < sortNumShapeArr.length; sortIndex++) {
var temp = sortNumShapeArr[sortIndex];
var shape = elements[temp.id];
if(shape.title=="线上审批" || shape.title=="线下审批" || shape.title=="系统任务" ||shape.title=="人工任务") {
if(obj==shape.id){
continue;
}
document.getElementById("box"+shape.id).style.display="none";
}
//document.getElementById("span"+shape.id).innerHTML=no+"."+shape.text;
}
}
}
function searchChange(id,text) {
if (document.getElementById("searchChangeFlg"+id).value == "1") {
document.getElementById(id+"change").style.display="";
document.getElementById("searchChange"+id).innerHTML = "&#xe718;";
document.getElementById("searchChangeFlg"+id).value = "0";
document.getElementById("span"+id).innerHTML="";
} else {
document.getElementById(id+"change").style.display="none";
document.getElementById("searchChange"+id).innerHTML = "&#xe716;";
document.getElementById("searchChangeFlg"+id).value = "1";
document.getElementById("span"+id).innerHTML=text;
}
}
//获取select类型属性的option
var comboboxs = [];
function getSelectOptions(category, selectValues) {
$.ajax({
type : "POST",
url : "./jd?sid="
+ CLB.sid
+ "&cmd=com.actionsoft.apps.coe.pal_pl_attribute_option",
data : {
category : category
},
success : function(msg) {
if (msg.result == "ok") {
var data = msg.data.data;
for (var i = 0; i < selectValues.length; i++) {
var objId = selectValues[i].objId;
var objValue = selectValues[i].objValue;
var objType = selectValues[i].objType;
var multiple = false;
var closeSelect = true;
if (objType == "select_m") {
multiple = true;
closeSelect = false;
}
var optionsData = data[objId];
if (optionsData) {
optionsData = optionsData.split(",");
var selectData = [];
var selectedData = [];
if(objValue != null && objValue != ''){
var selectedArr = objValue.split(',');
}
var y = 0;
if (optionsData.length > 0) {
for (var j = 0, len = optionsData.length; j < len; j++) {
var dataObj = {
id : j,
text : optionsData[j]
};
selectData.push(dataObj);
if(objValue != null && objValue != ''){
for(var x = 0; x < selectedArr.length; x++){
if(selectedArr[x] == optionsData[j]){
selectedData[y] = j;
y++;
}
}
}
}
}
$.fn.select2.defaults.set("language", "zh-CN");
var opt1 = {
width : 244,
multiple:multiple,
closeOnSelect:closeSelect,
/*templateResult:formatState,
templateSelection:formatRepoSelection,*/
placeholder:'请选择...'
};
opt1.data = selectData;
$("#attribute_name_input_" + objId).parent().css("padding-left", "0px");
var $obj = $("#attribute_name_input_" + objId).select2(opt1);
if(multiple){//多选
$("#attribute_name_input_" + objId).val(selectedData).trigger("change");
} else {//单选
if(selectedData != null && selectedData != ''){
$("#attribute_name_input_" + objId).val(selectedData[0]).trigger("change");
}
}
$obj.off("select2:close").on("select2:close", function(e){//只能在关闭多选框时触发事件close与unselect事件冲突待完善
var type = this.id.substring(this.id.lastIndexOf('_')+1);
var selectValue = [];
var selected = $('#' + this.id).select2('data');
for(var j = 0; j < selected.length; j++){
selectValue[j] = selected[j].text;
}
comboboxs[type] = selectValue.join(',');
saveSelectContent(type,comboboxs[type]);
});
$("#attribute_name_input_" + objId + "_Tip").css({"float" : "left", "border" : "0"});
}
}
}
}
});
}
function getScreenResolution() {
if (screen.width == 1024) {
}
}
/**
* 图形创建后事件
*/
/*
* Designer.events.addEventListener("created", function(a) { //alert(a.name)
* if(a.name != "linker"){ attributeShowTabContent(null); //Model.update(a); }
* if (Designer.status == "demo" && !demoCreatedTiped) {
* UI.showStartStep("created", $("#" + a.id)); demoCreatedTiped = true } });
*/
// 重构
function openLinkUrlRewrite(type, url, target, uuid, obj, fileName, inspected) {
if (type == "custom") {
$("#link-dialog-normal_contextmenu").hide();
if (target == "newTab" && parent.openTabCustom != undefined) {
parent.openTabCustom(uuid, url, fileName);
} else if (target == "_seft") {
if (parent.changeTabTitle) {
parent.changeTabTitle(chartId, fileName, uuid, "custom");
}
window.location.href = url;
} else {
window.open(url, target);
}
} else {
// 判断权限,判断是否存在文件
// uuid 要打开的目标文件
$.ajax({
type:'POST',
url:'./jd?cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_viewer_portal_link_perm_check',
dataType : "JSON",
data:{
sid : $("#sid").val(),
uuid:uuid
},
success:function(r) {
switch(r.data.data) {
case 'ok':
window.open("./w?cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_viewer_portal_open_page&uuid=" + uuid + "&sid=" + sid);
break;
case 'noPerm':
$.simpleAlert('无权限访问', 'info');
break;
case 'notFound':
$.simpleAlert('文件未找到', 'info');
break;
case 'notPublish':
$.simpleAlert('文件未发布,无法访问', 'info');
break;
default:
break;
}
}
})
}
}