apps/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/js/coe.pal.processlevel.create.js

1481 lines
42 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.

var manager = "";
var result = "";
var Sys = {};
var comboboxs = {};
jQuery(function() {
//文件属性中流程名称不允许修改
var frameId = window.frameElement && window.frameElement.id || '';
if(frameId == 'file_attribute') {
jQuery('#plName').attr("disabled", "disabled");
}
awsui.parse();
// 调整样式兼容性============================================START
var ua = navigator.userAgent.toLowerCase();
var s;
(s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] : (s = ua
.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] : (s = ua
.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] : (s = ua
.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] : (s = ua
.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;
/** ***********************调整buttonedit在不同页面下的样式********************************** */
if (parent.location.href.indexOf("com.actionsoft.apps.coe.pal_pl_repository_designer") != -1) {
if (Sys.firefox || Sys.safari) {
$("input[type=text].txt").css({
width : "233px",
height : "17px"
});
} else {
$("input[type=text].txt").css({
width : "235px",
height : "17px"
});
}
} else {
if (Sys.firefox || Sys.safari) {
$("input[type=text].txt").css({
width : "450px",
height : "17px"
});
} else {
$("input[type=text].txt").css({
width : "452px",
height : "17px"
});
}
}
initButtonEdit();
if (parent.location.href.indexOf("com.actionsoft.apps.coe.pal_pl_repository_designer") != -1) {
if (Sys.firefox) {
$(".awsui-buttonedit-right").css({
left : "208px",
top : "1px",
height : "25px"
});
} else {
$(".awsui-buttonedit-right").css({
left : "210px",
top : "1px"
});
}
} else {
if (Sys.firefox) {
$(".awsui-buttonedit-right").css({
left : "424px",
top : "1px"
});
} else {
$(".awsui-buttonedit-right").css({
left : "426px",
top : "1px"
});
}
}
// 调整样式兼容性============================================END
var id = $("#id").val();
var processLevel = parseInt(jQuery("#plLevel").val());
// var isShowColor=parent.$("#iflowlist").get(0).contentWindow.isShowColor;
if (id == "0") {
jQuery("#plLevel").val(processLevel + 1);
} else {
if (processLevel >= 0) {
getIsHasChildren(id, jQuery("#wsid").val());
} else {
result = 1;
}
}
// if(isShowColor!=undefined&&isShowColor==false){
// jQuery("#colortr").hide();
// }
var methodId = jQuery("#methodId").val();
if (methodId != "default") {
jQuery("#methodId").attr("disabled", true);
jQuery("#methodId").next().removeClass("awsui-select-span");
}
// 为最顶级窗口添加一个弹窗
window.top.$("#attr_dialog").remove();
var iframeWindow = '<div title="" style="width:332px;display:none;" id="attr_dialog-normal"> <div id="attr_content" style="margin:10px;height:380px;"><iframe width="100%" id="attr_content_iframe_more" name="attr_content_iframe_more" frameBorder="0" style="width: 100%; height: 420px;"></iframe></div></div>';
window.top.$("body").append(iframeWindow);
// 根据相应的引用页面隐藏titile
/** ****************************调整select在不同页面下的样式********************************* */
if (parent.location.href.indexOf("com.actionsoft.apps.coe.pal_pl_repository_designer") != -1) {
// jQuery("#plNameTr").css("display", "none");
jQuery("#plDescTD").attr("width", "20%");
if (Sys.firefox) {
$(".awsui-select").css({
width : "225px",
height : "21px"
});
$(".awsui-select-span").css("width", "220px");
$(".awsui-select-span span").css("width", "218px");
} else {
$(".awsui-select").css({
width : "230px",
height : "21px"
});
$(".awsui-select-span").css("width", "225px");
$(".awsui-select-span span").css("width", "223px");
}
} else {
/*
if (Sys.firefox) {
if (parent.location.href.indexOf("com.actionsoft.apps.network_home") == -1) {// 从流程团队中打开设计器时
$(".awsui-select").css({
width : "225px",
height : "21px"
});
$(".awsui-select-span").css("width", "220px");
$(".awsui-select-span span").css("width", "218px");
} else {
$(".awsui-select").css("width", "440px");
}
} else {
$(".awsui-select").css("width", "448px");
}
*/
$(".awsui-select").css("width", "448px");
}
$(".awsui-select").customSelect();
// 为最顶级窗口添加一个弹窗
window.top.$("#attr_dialog").remove();
var iframeWindow = '<div title="" style="width:280px;display:none;" id="attr_dialog-normal"> <div id="attr_content" style="margin:10px;height:280px;"><iframe width="100%" id="attr_content_iframe_more" name="attr_content_iframe_more" frameBorder="0" style="width: 100%; height: 280px;"></iframe></div></div>';
parent.$("body").append(iframeWindow);
// textarea添加点击事件
$('#frmMain').find('textarea.awsui-textarea').off("click").on("click", function() {
if (!$("#textarea-dialog").is(":hidden")) {
return;
}
var title = $(this).parent().siblings("td").text();
openTextareaDialog($(this), title);
});
});
/**
* 调整buttonedit
*/
function initButtonEdit() {
// $("#plRD").buttonedit({
// onClick : function() {
// openDepartmentTree(frmMain, '', 'plRDId', 'plRD', false, '');
// }
// });
// $("#plRP").buttonedit({
// onClick : function() {
// openAddressBook($("#plRP"));
// }
// });
$("#plSecurityWName").buttonedit({
onClick : function() {
openManagerTree('m');
}
});
$("#plSecurityRName").buttonedit({
onClick : function() {
openManagerTree('r');
}
});
}
/**
* 功能:去除字符串中所有空格 传参:需要处理的字符串 返回值:去除空格后的字符串
*/
function trimSpaces(Str) {
var ResultStr = "";
Temp = Str.split(/\s/);
for (i = 0; i < Temp.length; i++) {
ResultStr += Temp[i];
}
return ResultStr;
}
function getIsHasChildren(id, wsId) {
var params = {
wsid : wsId,
pid : id
};
jQuery.ajax({
type : "POST",
url : "./w?sid=" + encodeURIComponent(jQuery('#sid').val())
+ "&cmd=com.actionsoft.apps.coe.pal_processlevel_istreechildren",
data : params,
success : function(msg) {
result = msg;
if (result == 1 || editable == "0") {
jQuery("#plIsBottomLevel").attr("disabled", true);
result = "";
} else {
jQuery("#plIsBottomLevel").attr("disabled", false);
}
}
});
}
function mouseUp(treeNode) {
}
// function getChildNo(node, id) {
// var sid=jQuery("#sid").val();
// if (node) {
// var children = jQuery('#processIds').tree('getChildren', node.target);
// var s = '';
// //查看每个节点的孩子
// for (var i = 0; i < children.length; i++) {
// getChildNo(children[i], id);
// }
// //当前节点没有孩子 请求数据
// if (children.length == 0) {
// if (node.attributes.requestType) {
// if (!treearray[node.id]) {
// jQuery.post("./w", {
// sid : sid,
// cmd : 'COE_TEAM_DIMENSION_TREEJSON',
// requestType : node.attributes.requestType,
// param1 : node.text,
// param2 : id
// }, function getChildNodesHD(nodes) {
// for (var i = 0; i < nodes.length; i++) {
// var n = nodes[i];
// jQuery('#processIds').tree('append', {
// parent : node.target,
// data : [{
// id : n.id,
// iconCls : n.iconCls,
// attributes : n.attributes,
// state : n.state,
// text : n.text,
// checked : true
// }]
// });
// }
// treearray[node.id] = node.id;
// }, "json");
// }
// }
// }
// }
// }
function openTree() {
initDimensionId("0");
// jQuery('#workflowTree').dialog('open');
}
// function closeTreeDialog(){
// jQuery('#workflowTree').dialog('close');
// }
// 关联流程
function saveAssociationProcess() {
var nodes = jQuery('#processIds').tree('getSelected');
var s = '';
var name = '';
var wfmaster = "";
if (nodes.attributes.uuid && nodes.attributes.uuid != "") {
s += nodes.attributes.uuid;
name += nodes.text;
wfmaster = nodes.attributes.wfmaster;
}
if (s.length < 1) {
window.top.$.simpleAlert(请选择有效流程);
return false;
}
closeTreeDialog();
jQuery("#plAwsPidName").val(name);
jQuery("#plAwsPid").val(s);
jQuery("#plRP").val(wfmaster);
}
// 显示可管理该记录小组树
function managerTreamTree(m) {
var sid = $("#sid").val();
var wsId = parent.$("#coeContent").get(0).contentWindow.document
.getElementById("coeContentiframe").contentWindow.$("#wsId").val();
var ids = "";
if (m == 'm') {
ids = jQuery("#plSecurityW").val();
} else {
ids = jQuery("#plSecurityR").val();
}
jQuery('#teamIds').tree({
checkbox : true,
url : encodeURI('./w?sid=' + sid
+ '&cmd=COE_PAL_PROCESSLEVEL_TREAM_TREEJSON&wsid=' + wsId
+ "&ids=" + ids),
onClick : function(node) {
},
onBeforeExpand : function(node, param) {
if (!node.checked) {
jQuery(this).tree('options').url = encodeURI('./w?sid=' + sid
+ '&cmd=COE_PAL_PROCESSLEVEL_TREAM_TREEJSON&wsid='
+ wsId + '&pid=' + node.pid + "&ids=" + ids);
}
},
onLoadSuccess : function(node, data) {
var root = jQuery(this).tree("find", "0");
if (root) {
jQuery(this).tree("expand", root.target);
}
if (node) {
jQuery(this).tree("expand", node.target);
}
},
onCheck : function(node, checked) {
}
});
}
// 打开可管理该记录小组树
function openManagerTree(type) {
managerTreamTree(type);
if (type == 'r') {
jQuery(".panel-title").text(访问该记录的小组);
} else {
jQuery(".panel-title").text(可管理该记录的小组);
}
manager = type;
jQuery('#managerTree').dialog('open');
}
// 设置可管理该记录小组值
function setValue() {
var nodes = jQuery('#teamIds').tree('getChecked');
var s = "";
var name = '';
if (nodes) {
var mm = 0;
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].id > 0 && nodes[i].id != "" && nodes[i].id != null) {
if (mm == 0) {
s += nodes[i].id;
name += nodes[i].text;
} else {
s += "," + nodes[i].id;
name += "," + nodes[i].text;
}
mm++;
}
}
}
// if (s.length < 1) {
// jQuery.messager.window.top.$.simpleAlert(提示, 请选择小组, "info");
// return false;
// }
closeManagerDialog();
if (manager == "m") {
jQuery("#plSecurityWName").val(name);
jQuery("#plSecurityW").val(s);
} else {
jQuery("#plSecurityRName").val(name);
jQuery("#plSecurityR").val(s);
}
}
function closeManagerDialog() {
jQuery('#managerTree').dialog('close');
}
function openmailtree(form, mail_target) {
form.cmd.value = "CLIENT_UI_ADDRESS_INNER_OPEN";
form.groupstylevalue.value = '';
form.groupstyle.value = 0;
form.mail_target.value = mail_target;
// form.mail_user.value = form.stepTogetherUser.value;
var width = window.screen.availWidth;
var height = window.screen.availHeight;
var left = (width - 660) / 2;
var top = (height - 380) / 2;
window.open(
'../commons/wait.htm',
'openmailtree',
'left='
+ left
+ ',top='
+ top
+ ',width=660,height=380,location=no,menubar=no,toolbar=no,status=no,directories=no,scrollbars=no,resizable=no');
form.target = "openmailtree";
form.submit();
return false;
}
function initCombobox(refs, parentObj) {
var inDesigner = false;
if (parent.location.href.indexOf("com.actionsoft.apps.coe.pal_pl_repository_designer") != -1) {
inDesigner = true;
} else {
inDesigner = false;
}
parentObj.find("input[inputType=select], input[inputType=select_m]").each(function(){
var objId = $(this).attr("objid");
var isRequired = $(this).attr("isRequired");
var optionData = new Array();
var ref = refs[objId];
if (ref == undefined) {
ref = "";
}
ref = ref.split(",");
for (var i = 0; i < ref.length; i++) {
optionData.push(ref[i]);
}
var options = {
width : 230,
height : 25,
placeholder : "请选择",
editable : false,
sep : ",",
objId : objId,
select: function() {
$("#" + this.objId).val(comboboxs[this.objId].getValue());
if (isRequired == 'true' && $("#" + this.objId).val() == '') {
$.simpleAlert("不能为空", "warning");
return
}
saveContent($("#" + this.objId));
}
};
if (inDesigner) {
options.width = 230;
} else {
options.width = 445;
}
options.data = optionData;
if($(this).attr("inputType") == "select") {
options.multiple = false;
} else {
options.multiple = true;
}
if (options) {
var comboboxObj = $(this).combobox(options);
comboboxs[objId] = comboboxObj;
if (editable == "0") {
comboboxObj.disable();
}
}
})
}
// 替换掉不存在的checkid
function replaceNotExitsId(str, tempArr) {
for (var index = 0; index < tempArr.length; index++) {
if (tempArr[index] != 0 && tempArr[index] != "0"
&& tempArr[index] != "") {
str = str.replace(tempArr[index] + "|", "");
}
}
return str;
}
// 过滤出当在节点上不选中时的属性
function filterNotCheckedAttribute(checkedObj, existTempIds) {
var exitObj = existTempIds.split("|");
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 == checkedArr1.id) {
result1.push(checkedArr1);
break;
}
}
}
return result1;
}
}
// 移除图形属性中部分已存在的元素并返回不同元素
function removeAttributeAndReturnDifferent(existTempIds, newObj1) {
var exitObj = existTempIds.split("|");
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] == obj1.id) {
result1.push(i);
//break;
}
}
}
for (var i = 0; i < result1.length; i++) {
exitObj[result1[i]] = 0;
}
return exitObj;
}
//获取未选中的元素
function getNotCheckedAttr(tempArr) {
var str = "";
for (var index = 0; index < tempArr.length; index++) {
if (tempArr[index] != 0 && tempArr[index] != "0"
&& tempArr[index] != "") {
str += "," + tempArr[index];
}
}
str = str.substring(1);
return str;
}
// 删除没有选中的元素
function removeNotCheckedAttribute(tempArr, url1, data1) {
var str = "";
for (var index = 0; index < tempArr.length; index++) {
if (tempArr[index] != 0 && tempArr[index] != "0"
&& tempArr[index] != "") {
str += tempArr[index] + "|";
}
}
if (str != "") {
str = str.substring(0, str.lastIndexOf("|"));
data1 = data1 + "&attrJsonIds=" + str;
jQuery.ajax({
type : "POST",
url : url1,
data : data1,
success : function(msg) {
for (var index = 0; index < tempArr.length; index++) {
if (tempArr[index] != 0
&& tempArr[index] != "0"
&& tempArr[index] != "") {
$("#tr_" + tempArr[index] + "").remove();
}
}
/***************************************************
* 发送"删除属性"监听事件 begin
**************************************************/
var changeItems = {
action : "removeAttribute",
content : {
iframe : "file_attribute",
id : "moreAttr",
value : tempArr,
existIds : existIds
}
};
var messagesStr = JSON.stringify(changeItems);
sendListenEvent("[" + messagesStr + "]");
/** ***************发送"删除属性"监听事件 end****************** */
}
});
}
}
function saveDialogTableValue(tableValue,id,dom) {
let sid = $("#sid").val();
let uuid = $("#id").val();
let jsonContent = JSON.stringify(tableValue)
jQuery.ajax({
type : "POST",
url : "./w?sid=" + encodeURIComponent(sid)
+ "&cmd=com.actionsoft.apps.coe.pal_processlevel_more_attr_content_save",
data : "uuid=" + uuid + "&josnKey=" + encodeURIComponent(id)
+ "&josnContent=" + jsonContent,
success : function(msg) {
if(awsui.decode(msg).result == "error") {
$.simpleAlert(awsui.decode(msg).msg, "error");
}
if(awsui.decode(msg).result == "ok") {
let tableEvent = "showTableDialog($(this)," + JSON.stringify(tableValue).replace(/\"/g,"'") +", '"+id+"')"
dom.attr('onclick',tableEvent)
if (tableValue.table.length > 1) {
$("#" + id).val('请查看')
} else {
$("#" + id).val('请输入')
}
}
if (msg == "true") {
// 发送"修改属性"监听事件
var changeItems = {
action : "updateAttribute",
content : {
iframe : "file_attribute",
id : id,
value : jsonContent
}
};
var messagesStr = JSON.stringify(changeItems);
sendListenEvent("[" + messagesStr + "]");
}
}
});
}
function saveContent(obj) {
// debugger;
var sid = $("#sid").val();
var uuid = $("#id").val();
var id = obj.attr("id");
var jsonContent = obj.val();
var isRequired = obj.attr('isRequired')
if (isRequired == 'true' && jsonContent == '') {
obj.attr('placeholder','不能为空')
obj.addClass("required_input_css");
}
if (jsonContent.indexOf("</script>") > -1) {
$(obj).val("");
$.simpleAlert("禁止输入js脚本", "warning");
return;
}
//原先值与离焦时的值比较,相同则不触发事件
var originvalue = $(obj).attr("data-originvalue");
if(originvalue == jsonContent){
return;
}
if (obj.attr("relationFileId") != undefined) {
jsonContent = {
fileId : uuid,
shapeId : "",
shapeText : "",
attrId : obj.attr("id"),
relationFileId : obj.attr("relationFileId"),
relationShapeId : obj.attr("relationShapeId"),
relationShapeText : obj.val(),
groupPath : obj.attr("groupPath")
}
}
if (typeof(jsonContent) == "object") {
jsonContent = JSON.stringify(jsonContent);
}
jQuery.ajax({
type : "POST",
url : "./w?sid=" + encodeURIComponent(sid)
+ "&cmd=com.actionsoft.apps.coe.pal_processlevel_more_attr_content_save",
data : "uuid=" + uuid + "&josnKey=" + encodeURIComponent(id)
+ "&josnContent=" + jsonContent,
success : function(msg) {
if(awsui.decode(msg).result == "error") {
$.simpleAlert(awsui.decode(msg).msg, "error");
}
if(awsui.decode(msg).result == "ok") {
//修改成功将data-originvalue更新为最新值
if(originvalue != jsonContent){
$(obj).attr("data-originvalue",jsonContent);
}
}
if (msg == "true") {
// 发送"修改属性"监听事件
var changeItems = {
action : "updateAttribute",
content : {
iframe : "file_attribute",
id : id,
value : jsonContent
}
};
var messagesStr = JSON.stringify(changeItems);
sendListenEvent("[" + messagesStr + "]");
}
}
});
}
var maskStackCount = 0;
function mask(method) {
var winObj = parent.$("body").find("iframe[name='dialognormaliframe']");
if (typeof method == "undefined") {
method = "open";
}
if (method == "open") {
if (maskStackCount <= 0) {
var mask = $("<div id='window-mask' class='window-mask' style='display:none'></div>")
.appendTo("body");
mask.css({
width : winObj.width() + "px",
height : winObj.height() + "px",
filter : "alpha(opacity=60)"
}).show();
winObj.on("resize.mask", function() {
mask.css({
width : winObj.width() + "px",
height : winObj.height() + "px"
});
});
}
maskStackCount++;
} else if (method == "close") {
maskStackCount--;
$("#window-mask").remove();
winObj.off("resize.mask");
}
}
// 组合已有和当前窗口选择的属性
function filterRepeatAttribute(arr1, arr2) {
var result = [];
var exitObj = arr2.split("|");
for (var a = 0; a < arr1.length; a++) {
var arrEle1 = arr1[a];
var re = false;
for (var i = 0, n = 0; i < exitObj.length; i++) {
if (exitObj[i] == arrEle1.id) {
re = true;
}
}
if (re) {
if ($("#" + arrEle1.id).val() != undefined) {
arrEle1.value = $("#" + arrEle1.id).val();
}
}
result.push(arrEle1);
}
return result;
}
// function refeshIpad(){
// // $("select#plM").click();
// window.top.$.simpleAlert($("#plM").length)
// }
function openUpFile() {
if (parent.isParentShow) {
var conObj = parent.$("#upfile-content").empty();
var str = '<iframe width="100%" id="upfile-content-iframe" name="upfile-content-iframe" frameBorder="0" style="width: 100%; height:100%;"></iframe>';
conObj.append(str);
parent.$("#upfile-dialog").attr("title", "附件");
parent.$('#upfile-content-iframe').attr(
'src',
"./w?sid=" + $("#sid").val()
+ "&cmd=com.actionsoft.apps.coe.pal_processlevel_upfile_portal_page&pl_uuid="
+ $("#id").val() + "&shape_uuid=" + "&type=file");
parent.$("#upfile-dialog").dialog({
buttons : [{
text : '关闭',
handler : function() {
parent.$("#upfile-dialog").dialog("close");
}
}]
});
} else {
var conObj = $("#upfile-content").empty();
var str = '<iframe width="100%" id="upfile-content-iframe" name="upfile-content-iframe" frameBorder="0" style="width: 100%; height:100%;"></iframe>';
conObj.append(str);
$("#upfile-dialog").attr("title", "附件");
$('#upfile-content-iframe').attr(
'src',
"./w?sid=" + $("#sid").val()
+ "&cmd=com.actionsoft.apps.coe.pal_processlevel_upfile_portal_page&pl_uuid="
+ $("#id").val() + "&shape_uuid=" + "&type=file");
$("#upfile-dialog").dialog({
buttons : [{
text : '关闭',
handler : function() {
$("#upfile-dialog").dialog("close");
}
}]
});
}
}
/*
* 发送"修改属性"监听事件
*/
function sendListenEvent(messagesStr) {
if (parent.CLB) {
var a = {
action : "changeAttribute",
messages : messagesStr,
ignore : "messages"
};
parent.CLB.cmdList = [{
"type" : "message",
"cmd" : "com.actionsoft.apps.coe.pal_pl_repository_designer_add_realtimeevents"
}];
parent.CLB.send(a);
}
}
// 打开多行文本辅助编辑框
function openTextareaDialog(obj, title,id) {
if (title == "undefined") {
title = "";
}
if(title == '') {
title = "请输入";
}
$(obj).blur();
var isRequired = obj.attr('isRequired')
if (parent.isParentShow) {
parent.$("#textarea-dialog textarea").val(obj.val());
parent.$("#textarea-dialog").attr("title", title);
// parent.$("#textarea-dialog textarea").blur();
parent.$("#textarea-dialog").dialog({
draggable: true,
buttons : [{
text : '确定',
cls : "blue",
handler : function() {
if (isRequired == 'true' && parent.$("#textarea-dialog textarea").val() == '') {
obj.val(parent.$("#textarea-dialog textarea").val());
obj.attr('placeholder',title+'不能为空')
obj.addClass("required_input_css");
parent.$("#textarea-dialog").dialog("close");
return
}
obj.val(parent.$("#textarea-dialog textarea").val());
saveContent($(obj));
parent.$("#textarea-dialog").dialog("close");
}
}, {
text : '取消',
handler : function() {
parent.$("#textarea-dialog").dialog("close");
}
}]
});
parent.$("#textarea-dialog textarea").focus();
} else {
$("#textarea-dialog textarea").val(obj.val());
$("#textarea-dialog").attr("title", title);
// $("#textarea-dialog textarea").blur();
$("#textarea-dialog").dialog({
buttons : [{
text : '确定',
cls : "blue",
handler : function() {
if (isRequired == 'true' && $("#textarea-dialog textarea").val() == '') {
obj.val($("#textarea-dialog textarea").val());
obj.attr('placeholder',title+'不能为空')
obj.addClass("required_input_css");
$("#textarea-dialog").dialog("close");
return
}
obj.val($("#textarea-dialog textarea").val());
saveContent($(obj));
$("#textarea-dialog").dialog("close");
}
}, {
text : '取消',
handler : function() {
$("#textarea-dialog").dialog("close");
}
}]
});
$("#textarea-dialog textarea").focus();
}
}
// 打开文件属性表格弹框
function showTableDialog(obj,value,id) {
let tableRef = JSON.parse($(obj).attr('ref'))
let tableName = $(obj).attr('tableTitle')
let tableList = []
if (JSON.stringify(value) == '{}') {
tableList = [
{ id: 'table_head' ,name: tableRef.firstColumn, desc: tableRef.secondColumn}
]
} else {
tableList = value.table
tableList[0] = { id: 'table_head' ,name: tableRef.firstColumn, desc: tableRef.secondColumn}
}
parent.operateList = tableList
var thead =
'<tr id="' + tableList[0].id + '">'
+ '<td style="width: 100px;" class="dialogTableHead">'
+ tableList[0].name
+ '</td>'
+ '<td style="width: 270px;" class="dialogTableHead">'
+ tableList[0].desc
+ '</td>'
+ '<td style="width: 80px;" class="dialogTableHead">操作</td>'
+ '</tr>'
if (parent.isParentShow) {
parent.$('#attribute-table-content1').empty()
parent.$('#attribute-add-content1').empty()
parent.$('#attribute-table-content1').append(thead)
for ( let i = 1; i < tableList.length; i++) {
let str =
'<tr id="' + tableList[i].id + '">'
+ '<td style="width: 100px;">'
+ '<textarea type="textarea" rows="5" class="dialog_table_input_css" value="' + tableList[i].name + '">' + tableList[i].name + '</textarea>'
+ '</td>'
+ '<td style="width: 270px;">'
+ '<textarea type="textarea" rows="5" class="dialog_table_input_css" value="' + tableList[i].desc + '">' + tableList[i].desc + '</textarea>'
+ '</td>'
+ '<td style="width: 80px;text-align: center;" class="dialogTableDelete" onclick="removeTr(this)">删除</td>'
+'</tr>'
parent.$('#attribute-table-content1').append(str)
}
parent.$('#attribute-add-content1').append('<button onclick="addTr()">新增</button>')
parent.$("#attribute-table-window1").dialog({
draggable: true,
title: tableName,
buttons : [{
text : '确定',
cls : "blue",
handler : function() {
// let name = parent.$("#attribute-title-content1").val()
// $("#" + id).val(name)
let inputs = parent.$('#attribute-table-content1').find('textarea')
for (let i = 1; i < parent.operateList.length; i++) {
parent.operateList[i].name = inputs[2*(i-1)].value
parent.operateList[i].desc = inputs[2*(i-1) + 1].value
}
let value = {
name: tableName,
table: parent.operateList
}
if(value.table.some(item => item.name == '') || value.table.some(item => item.desc == '')) { // 表格存在空值
$.simpleAlert("表格内容不能存在空值",'warning')
} else {
saveDialogTableValue(value,id,obj)
}
parent.$("#attribute-table-window1").dialog("close");
}
}, {
text : '取消',
handler : function() {
parent.$("#attribute-table-window1").dialog("close");
}
}]
});
} else {
}
}
var operateList = []
function addTr() {
let newTrId = Date.now().toString(36)
let defaultStr =
' <tr id="'+ newTrId + '">'
+ '<td style="width: 100px;"><textarea type="textarea" rows="5" class="dialog_table_input_css" value=""></textarea></td>'
+ '<td style="width: 270px;"><textarea type="textarea" rows="5" class="dialog_table_input_css" value=""></textarea></td>'
+ '<td style="width: 80px;text-align: center" class="dialogTableDelete" onclick="removeTr(this)">删除</td>'
+ '</tr>'
operateList.push({ id: newTrId ,name: '',desc: ''})
$('#attribute-table-content1').append(defaultStr)
}
function removeTr(obj) {
let removeId = obj.parentNode.id
operateList.splice(operateList.findIndex(item => item.id == removeId), 1)
let tr = obj.parentNode
tr.remove()
}
//打开对象关联Dialog
function openRelationDialog(obj, callback) {
var title = obj.closest('tr').find('td:first').text();
if (title == undefined || title == '') {
title = '选择模型对象';
}
var ref = obj.attr('ref');// 存储关联范围配置
var method=JSON.parse(ref).method;
var methodName="";
if(title=="支持文件"){
methodName="新建表单模型";
method="data.form";
}else if(method=="control.kpi"){
methodName="新建绩效模型";
}
var getteamId=parent.$("#teamId").val()==undefined?"":parent.$('#teamId').val();
if(method=="control.kpi") {
//根据角色
$.ajax({
type: "POST",
url: "./jd?sid="
+ $("#sid").val()
+ "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_relation_find_same_role",
data: {
uuid: uuid,
methodId: method
},
success: function (msg) {
if (msg.data.result == "ok") {
var relationDlg = parent.FrmDialog.open({
title: title,
width: 710,
height: 400,
url: "./w",
data: {
sid: $("#sid").val(),
cmd: "com.actionsoft.apps.coe.pal_pl_repository_designer_shapes_tree",
wsId: $("#wsid").val(),
ref: ref,
shapeId: "",
attrId: obj.attr("id"),
relationShapeIds: obj.attr("relationShapeId"),
relationFileIds: obj.attr("relationFileId"),
modelId: $("#id").val(),
ruuid: uuid
},
id: "relationDialog",
buttons: [
{
text: '确定', cls: "blue", handler: function () {
var attrId = obj.attr("id");
var relationFileId = "";
var relationShapeId = "";
var relationShapeText = "";
var relations = relationDlg.win().getRelationShapeInfos();
var isRequired = obj.attr('isRequired')
if (isRequired == 'true' && relations.length == 0) {
obj.val('');
obj.attr('placeholder', title + '不能为空')
obj.addClass("required_input_css");
parent.FrmDialog.close("relationDialog");
return;
}
if (relations != undefined && relations.length > 0) {
for (var i = 0; i < relations.length; i++) {
var relationShape = relations[i];
if (i == relations.length - 1) {
relationFileId += relationShape.relationFileId;
relationShapeId += relationShape.relationShapeId;
relationShapeText += relationShape.relationShapeText;
} else {
relationFileId += relationShape.relationFileId + ",";
relationShapeId += relationShape.relationShapeId + ",";
relationShapeText += relationShape.relationShapeText + ",";
}
}
}
obj.attr("attrId", attrId);
obj.attr("relationFileId", relationFileId);
obj.attr("relationShapeId", relationShapeId);
obj.val(relationShapeText);
if (callback && callback == "saveContent") {
saveContent(obj);
}
parent.FrmDialog.close("relationDialog");
}
},
{
text: '取消', handler: function () {
parent.FrmDialog.close("relationDialog");
}
}
]
});
} else {
var relationDlg = parent.FrmDialog.open({
title: title,
width: 710,
height: 400,
url: "./w",
data: {
sid: $("#sid").val(),
cmd: "com.actionsoft.apps.coe.pal_pl_repository_designer_shapes_tree",
wsId: $("#wsid").val(),
ref: ref,
shapeId: "",
attrId: obj.attr("id"),
relationShapeIds: obj.attr("relationShapeId"),
relationFileIds: obj.attr("relationFileId"),
modelId: $("#id").val(),
ruuid: uuid
},
id: "relationDialog",
buttons: [
{
text: '刷新',
cls: "yellow",
handler: function () {
// 刷新页面
parent.document.getElementById("id-awsui-win-frm-2013-frmrelationDialog").contentWindow.location.reload(true);
}
}, {
text: methodName,
cls: "green",
handler: function () {
//根据角色
$.ajax({
type: "POST",
url: "./jd?sid="
+ $("#sid").val()
+ "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_relation_find_same_role",
data: {
uuid: uuid,
methodId: method
},
success: function (msg) {
if (msg.data.result == "ok") {
window.top.$.simpleAlert("请勿重复" + methodName + "!!!");
} else {
//跳转表单/绩效模型
$.ajax({
type: "POST",
url: "./jd?sid="
+ $("#sid").val()
+ "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_relation_shape_createDialogModel",
data: {
uuid: uuid,
methodId: method,
wsId: $("#wsid").val(),
teamId: parent.$('#teamId').val()
},
success: function (msg) {
if (msg.result == "ok") {
//关闭新建按钮
var dlgButton = parent.$(".dlg-button button");
for (var i = 0; i < dlgButton.length; i++) {
var text = dlgButton.eq(i).text();
if (text == "新建绩效模型") {
dlgButton.eq(i).hide();
}
}
window.open("./w?uuid=" + msg.data.uuid + "&teamId="+getteamId
+ "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer&sid=" + encodeURIComponent($('#sid').val()));
}
}
});
}
}
});
}
},
{
text: '确定', cls: "blue", handler: function () {
var attrId = obj.attr("id");
var relationFileId = "";
var relationShapeId = "";
var relationShapeText = "";
var relations = relationDlg.win().getRelationShapeInfos();
var isRequired = obj.attr('isRequired')
if (isRequired == 'true' && relations.length == 0) {
obj.val('');
obj.attr('placeholder', title + '不能为空')
obj.addClass("required_input_css");
parent.FrmDialog.close("relationDialog");
return;
}
if (relations != undefined && relations.length > 0) {
for (var i = 0; i < relations.length; i++) {
var relationShape = relations[i];
if (i == relations.length - 1) {
relationFileId += relationShape.relationFileId;
relationShapeId += relationShape.relationShapeId;
relationShapeText += relationShape.relationShapeText;
} else {
relationFileId += relationShape.relationFileId + ",";
relationShapeId += relationShape.relationShapeId + ",";
relationShapeText += relationShape.relationShapeText + ",";
}
}
}
obj.attr("attrId", attrId);
obj.attr("relationFileId", relationFileId);
obj.attr("relationShapeId", relationShapeId);
obj.val(relationShapeText);
if (callback && callback == "saveContent") {
saveContent(obj);
}
parent.FrmDialog.close("relationDialog");
}
},
{
text: '取消', handler: function () {
parent.FrmDialog.close("relationDialog");
}
}
]
});
}
}
});
}else if(title=="支持文件"){
var relationDlg = parent.FrmDialog.open({
title: title,
width: 710,
height: 400,
url: "./w",
data: {
sid: $("#sid").val(),
cmd: "com.actionsoft.apps.coe.pal_pl_repository_designer_shapes_tree",
wsId: $("#wsid").val(),
ref: ref,
shapeId: "",
attrId: obj.attr("id"),
relationShapeIds: obj.attr("relationShapeId"),
relationFileIds: obj.attr("relationFileId"),
modelId: $("#id").val(),
ruuid: uuid
},
id: "relationDialog",
buttons: [
{
text: '刷新',
cls: "yellow",
handler: function () {
// 刷新页面
parent.document.getElementById("id-awsui-win-frm-2013-frmrelationDialog").contentWindow.location.reload(true);
}
}, {
text: methodName,
cls: "green",
handler: function () {
//跳转表单/绩效模型
$.ajax({
type: "POST",
url: "./jd?sid="
+ $("#sid").val()
+ "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_relation_shape_createDialogModel",
data: {
uuid: uuid,
methodId: method,
wsId: $("#wsid").val(),
teamId: parent.$('#teamId').val()
},
success: function (msg) {
if (msg.result == "ok") {
window.open("./w?uuid=" + msg.data.uuid + "&teamId="+getteamId
+ "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer&sid=" + encodeURIComponent($('#sid').val()));
}
}
});
}
},
{
text: '确定', cls: "blue", handler: function () {
var attrId = obj.attr("id");
var relationFileId = "";
var relationShapeId = "";
var relationShapeText = "";
var relations = relationDlg.win().getRelationShapeInfos();
var isRequired = obj.attr('isRequired')
if (isRequired == 'true' && relations.length == 0) {
obj.val('');
obj.attr('placeholder', title + '不能为空')
obj.addClass("required_input_css");
parent.FrmDialog.close("relationDialog");
return;
}
if (relations != undefined && relations.length > 0) {
for (var i = 0; i < relations.length; i++) {
var relationShape = relations[i];
if (i == relations.length - 1) {
relationFileId += relationShape.relationFileId;
relationShapeId += relationShape.relationShapeId;
relationShapeText += relationShape.relationShapeText;
} else {
relationFileId += relationShape.relationFileId + ",";
relationShapeId += relationShape.relationShapeId + ",";
relationShapeText += relationShape.relationShapeText + ",";
}
}
}
obj.attr("attrId", attrId);
obj.attr("relationFileId", relationFileId);
obj.attr("relationShapeId", relationShapeId);
obj.val(relationShapeText);
if (callback && callback == "saveContent") {
saveContent(obj);
}
parent.FrmDialog.close("relationDialog");
}
},
{
text: '取消', handler: function () {
parent.FrmDialog.close("relationDialog");
}
}
]
});
}else{
var relationDlg = parent.FrmDialog.open({
title: title,
width:710,
height: 400,
url:"./w",
data:{
sid: $("#sid").val(),
cmd: "com.actionsoft.apps.coe.pal_pl_repository_designer_shapes_tree",
wsId: $("#wsid").val(),
ref: ref,
shapeId: "",
attrId: obj.attr("id"),
relationShapeIds: obj.attr("relationShapeId"),
relationFileIds: obj.attr("relationFileId"),
modelId: $("#id").val(),
ruuid: uuid
},
id:"relationDialog",
buttons: [
{text:'确定',cls:"blue",handler:function(){
var attrId = obj.attr("id");
var relationFileId = "";
var relationShapeId = "";
var relationShapeText = "";
var relations = relationDlg.win().getRelationShapeInfos();
var isRequired = obj.attr('isRequired')
if (isRequired == 'true' && relations.length == 0) {
obj.val('');
obj.attr('placeholder',title +'不能为空')
obj.addClass("required_input_css");
parent.FrmDialog.close("relationDialog");
return;
}
if (relations != undefined && relations.length > 0) {
for(var i = 0; i < relations.length; i++) {
var relationShape = relations[i];
if(i == relations.length -1) {
relationFileId += relationShape.relationFileId;
relationShapeId += relationShape.relationShapeId;
relationShapeText += relationShape.relationShapeText;
} else {
relationFileId += relationShape.relationFileId + ",";
relationShapeId += relationShape.relationShapeId + ",";
relationShapeText += relationShape.relationShapeText + ",";
}
}
}
obj.attr("attrId", attrId);
obj.attr("relationFileId", relationFileId);
obj.attr("relationShapeId", relationShapeId);
obj.val(relationShapeText);
if (callback && callback == "saveContent") {
saveContent(obj);
}
parent.FrmDialog.close("relationDialog");
}},
{text:'取消',handler:function(){
parent.FrmDialog.close("relationDialog");
}}
]
});
}
}
function selectAttrTabTag(showContent, selfObj) {
// 操作标签
var tag = $("#tabUlContainer li");
var taglength = tag.length;
for (var i = 0; i < taglength; i++) {
tag[i].className = "";
}
selfObj.parentNode.className = "selectTag";
// 操作内容
$('div[data-type=tag]').css('display', 'none');
$('#' + showContent).css('display', 'block');
}
// 关联bpm组织架构dlg
function openRelationAwsorgDialog(obj) {
var title = obj.closest('tr').find('td:first').text();
if (title == undefined || title == '') {
title = '添加AWS PaaS平台组织';
}
var objId = obj.attr("id");
var ref = obj.attr('ref');// 存储关联范围配置
var isRequired = obj.attr('isRequired')
var relationAwsorgDialog = parent.FrmDialog.open({
title: title,
width:710,
height: 400,
url:"./w",
data:{
sid: $("#sid").val(),
cmd: "com.actionsoft.apps.coe.pal_pl_repository_designer_aws_org_page",
wsId: $("#wsid").val(),
ref: ref,
fileId: uuid,
shapeId: "",
attrId: objId
},
id:"relationAwsorgDialog",
buttons: [
{text:'确定',cls:"blue",handler:function(){
var obj = relationAwsorgDialog.win().getRelevanceAwsData();
var checkedOrgList = [];
for (var i in obj) {
checkedOrgList.push(obj[i]);
}
if (isRequired == 'true' && checkedOrgList.length == 0) {
$('#' + objId).attr('placeholder',title+'不能为空')
$('#' + objId).addClass("required_input_css");
parent.FrmDialog.close("relationAwsorgDialog");
return
}
// 更新数据库
saveRelevanceAwsOrgShapesTODB(checkedOrgList, "", "", objId);
parent.FrmDialog.close("relationAwsorgDialog");
}},
{text:'取消',handler:function(){
parent.FrmDialog.close("relationAwsorgDialog");
}}
]
});
}
//将关联关系保存到数据库(AWS org)
function saveRelevanceAwsOrgShapesTODB(awsorgValueArr, shapeId, shapeName, objId) {
$.ajax({
type : "POST",
url : "./jd?sid=" + $("#sid").val()
+ "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_aws_org_relevance_save",
data : {
relationAwsOrg : JSON.stringify(awsorgValueArr),
shapeId : shapeId,
fileId : uuid,
shapeGroupId : '',
attrId : objId,
shapeText : shapeName
},
success : function(msg) {
if (msg.result == "ok") {
var name = [];
var name1 = [];
var name2 = [];
var name3 = [];
var name4 = [];
for (var i = 0; i < awsorgValueArr.length; i++) {
if (awsorgValueArr[i].type == 'department') {
name1.push(awsorgValueArr[i].name);
}
if (awsorgValueArr[i].type == 'user') {
name2.push(awsorgValueArr[i].name);
}
if (awsorgValueArr[i].type == 'position') {
name3.push(awsorgValueArr[i].name);
}
if (awsorgValueArr[i].type == 'role') {
name4.push(awsorgValueArr[i].name);
}
}
if (name1.length > 0) {
name = name.concat(name1);
}
if (name2.length > 0) {
name = name.concat(name2);
}
if (name3.length > 0) {
name = name.concat(name3);
}
if (name4.length > 0) {
name = name.concat(name4);
}
$('#' + objId).val(name.join(","));
$('#' + objId).attr('data-value', awsorgValueArr);
}
}
});
}