2025-05-20 16:19:38 +08:00
|
|
|
var pagesPathNew = getContextPathNew();
|
|
|
|
|
|
|
|
|
|
function getContextPathNew() {
|
|
|
|
|
var pathName = document.location.pathname;
|
|
|
|
|
var index = pathName.substr(1).indexOf("/");
|
|
|
|
|
var result = pathName.substr(0, index + 1);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2025-05-20 13:54:27 +08:00
|
|
|
$.ajaxSetup({
|
|
|
|
|
cache : false,
|
|
|
|
|
headers : {
|
|
|
|
|
"token" : localStorage.getItem("token")
|
|
|
|
|
},
|
|
|
|
|
error : function(xhr, textStatus, errorThrown) {
|
|
|
|
|
var msg = xhr.responseText;
|
|
|
|
|
var response = JSON.parse(msg);
|
|
|
|
|
var code = response.code;
|
|
|
|
|
var message = response.message;
|
|
|
|
|
if (code == 400) {
|
|
|
|
|
layer.msg(message);
|
|
|
|
|
} else if (code == 401) {
|
|
|
|
|
localStorage.removeItem("token");
|
2025-10-28 14:37:54 +08:00
|
|
|
location.href = contentPath+'/login.html';
|
2025-05-20 13:54:27 +08:00
|
|
|
} else if (code == 403) {
|
|
|
|
|
console.log("未授权:" + message);
|
|
|
|
|
layer.msg('未授权');
|
|
|
|
|
} else if (code == 500) {
|
|
|
|
|
layer.msg('系统错误:' + message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2025-05-20 16:19:38 +08:00
|
|
|
function buttonDel(data, permission, pers) {
|
|
|
|
|
if (permission != "") {
|
|
|
|
|
if ($.inArray(permission, pers) < 0) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-05-20 13:54:27 +08:00
|
|
|
|
2025-05-20 16:19:38 +08:00
|
|
|
var btn = $(
|
|
|
|
|
"<button class='layui-btn layui-btn-xs' title='删除' onclick='del(\"" +
|
|
|
|
|
data +
|
|
|
|
|
"\")'><i class='layui-icon'></i></button>"
|
|
|
|
|
);
|
|
|
|
|
return btn.prop("outerHTML");
|
2025-05-20 13:54:27 +08:00
|
|
|
}
|
|
|
|
|
|
2025-05-20 16:19:38 +08:00
|
|
|
function buttonEdit(href, permission, pers) {
|
|
|
|
|
if (permission != "") {
|
|
|
|
|
if ($.inArray(permission, pers) < 0) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var btn = $(
|
|
|
|
|
"<button class='layui-btn layui-btn-xs' title='编辑' onclick='window.location=\"" +
|
|
|
|
|
href +
|
|
|
|
|
"\"'><i class='layui-icon'></i></button>"
|
|
|
|
|
);
|
|
|
|
|
return btn.prop("outerHTML");
|
|
|
|
|
}
|
2025-05-20 13:54:27 +08:00
|
|
|
|
2025-05-20 16:19:38 +08:00
|
|
|
function deleteCurrentTab() {
|
|
|
|
|
var lay_id = $(parent.document)
|
|
|
|
|
.find("ul.layui-tab-title")
|
|
|
|
|
.children("li.layui-this")
|
|
|
|
|
.attr("lay-id");
|
|
|
|
|
parent.active.tabDelete(lay_id);
|
2025-05-20 13:54:27 +08:00
|
|
|
}
|