vue-apps/com.actionsoft.apps.coe.pal/api/commonFun.js
shangxiaoran@qq.com 9d8f9f0e92 初始化应用
2022-06-28 01:29:37 +08:00

84 lines
2.3 KiB
JavaScript
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.

// 通用js方法文件
/**
* 打开一个新的窗口,post请求
* @param id id 唯一值body中创建请求表单的id
* @param sid sessionId
* @param cmd 请求cmd
* @param params 参数列表{param1 : value1,param2 : value2}
* @param target 不给定则默认_blank新窗口
*/
const newPageWin = function (id, sid, cmd, params, target) {
if (!params) {
params = {};
}
params.cmd = cmd;
params.sid = sid;
newWin(id, wHref, params, target);
}
/**
* 打开一个新的窗口,post请求
* @param id 唯一值body中创建请求表单的id
* @param url 例如 ./w./jd
* @param params 这个{param1 : value1,param2 : value2}
* @param target 打开窗口方式 _blank_self
*/
const newWin = function (id, url, params, target) {
// 防止反复添加
var dom = document.getElementById(id);
if(dom) {
document.body.removeChild(dom);
}
var temp_form = document.createElement("form");
temp_form.action = url;
temp_form.target = target == undefined ? "_blank" : target;
temp_form.method = "get";
temp_form.style.display = "none";
for (var x in params) {
var opt = document.createElement("textarea");
opt.name = x;
opt.value = params[x];
temp_form.appendChild(opt);
}
temp_form.setAttribute('id', id);
document.body.appendChild(temp_form);
temp_form.submit();
}
// 打开流程模型文件
const openDesigner = function(teamId, id, sid) {
newPageWin('palDesigner', sid, 'com.actionsoft.apps.coe.pal_pl_repository_designer', {uuid: id, teamId: teamId});
}
// 退出pal
const logout = function(sid) {
window.location.replace("./w?sid=" + sid + "&cmd=com.actionsoft.apps.coe.pal_user_logout");
}
// 类jquery方法
const closest = function(node, targetNodeName) {// 类似jquery closest函数获得匹配选择器的第一个祖先元素从当前元素开始沿 DOM 树向上
let curr = node;
while (curr.nodeName != targetNodeName && curr.nodeName != 'BODY') {
curr = curr.parentNode;
}
if (curr.nodeName == targetNodeName) {
return curr;
} else {
return null;
}
}
/**
* 修改PAL网页标题
* @param newTitle
*/
const updateHtmlTitle = function(newTitle) {
document.getElementsByTagName("title")[0].innerText = newTitle;
}
export {newWin, newPageWin, openDesigner, logout, closest, updateHtmlTitle}