2025-11-27 16:55:35 +08:00
|
|
|
|
let urlIds=new Array();
|
|
|
|
|
|
initMenu();
|
|
|
|
|
|
var table;
|
|
|
|
|
|
var layer;
|
|
|
|
|
|
var laydate;
|
2025-12-05 15:39:43 +08:00
|
|
|
|
token = localStorage.getItem("smz-token")
|
2025-11-27 16:55:35 +08:00
|
|
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
|
|
|
|
const resizer = document.getElementById('resizer');
|
|
|
|
|
|
const sidebar = document.getElementById('admin-side');
|
|
|
|
|
|
const navbar = document.getElementById('admin-navbar-side');
|
|
|
|
|
|
const menu = document.getElementById('menu');
|
|
|
|
|
|
const mainContent = document.getElementById('admin-body');
|
|
|
|
|
|
|
|
|
|
|
|
let isDragging = false;
|
|
|
|
|
|
|
|
|
|
|
|
resizer.addEventListener('mousedown', function (e) {
|
|
|
|
|
|
isDragging = true;
|
|
|
|
|
|
document.body.style.cursor = 'ew-resize';
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
document.addEventListener('mousemove', function (e) {
|
|
|
|
|
|
if (!isDragging) return;
|
|
|
|
|
|
|
|
|
|
|
|
// 设置最小宽度为 200px,最大为 500px
|
|
|
|
|
|
const minWidth = 200;
|
|
|
|
|
|
const maxWidth = 500;
|
|
|
|
|
|
const newWidth = Math.min(Math.max(e.clientX, minWidth), maxWidth);
|
|
|
|
|
|
|
|
|
|
|
|
requestAnimationFrame(() => {
|
|
|
|
|
|
sidebar.style.width = newWidth + 'px';
|
|
|
|
|
|
navbar.style.width = newWidth + 'px';
|
|
|
|
|
|
menu.style.width = newWidth + 'px';
|
|
|
|
|
|
mainContent.style.left = (newWidth + 5) + 'px'; // 加上分割线宽度
|
|
|
|
|
|
resizer.style.left = newWidth + 'px';
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
document.addEventListener('mouseup', function () {
|
|
|
|
|
|
isDragging = false;
|
|
|
|
|
|
document.body.style.cursor = 'default';
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// 禁止拖拽时选中文字
|
|
|
|
|
|
resizer.addEventListener('selectstart', function (e) {
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$(function () {
|
|
|
|
|
|
layui.use(['layer', 'laydate', 'form','table'], function () {
|
|
|
|
|
|
layer = layui.layer;
|
|
|
|
|
|
var form = layui.form;
|
|
|
|
|
|
table=layui.table;
|
|
|
|
|
|
laydate=layui.laydate;
|
|
|
|
|
|
openlinqi();
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
function initMenu(){
|
2025-12-02 18:30:53 +08:00
|
|
|
|
$.ajax({
|
2025-11-27 16:55:35 +08:00
|
|
|
|
url: ctxPath + "/permissions/current",
|
2025-12-02 18:30:53 +08:00
|
|
|
|
type:"get",
|
2025-11-27 16:55:35 +08:00
|
|
|
|
async:false,
|
|
|
|
|
|
success:function(data){
|
|
|
|
|
|
if(!$.isArray(data)){
|
|
|
|
|
|
location.href=ctxPath + '/login.html';
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
var menu = $("#menu");
|
|
|
|
|
|
$.each(data, function(i,item){
|
|
|
|
|
|
var a = $("<a href='javascript:;'></a>");
|
2025-12-02 18:30:53 +08:00
|
|
|
|
|
2025-11-27 16:55:35 +08:00
|
|
|
|
var css = item.css;
|
|
|
|
|
|
if(css!=null && css!=""){
|
|
|
|
|
|
a.append("<i aria-hidden='true' class='fa " + css +"'></i>");
|
|
|
|
|
|
}
|
|
|
|
|
|
a.append("<cite title='"+item.name+"'>"+item.name+"</cite>");
|
|
|
|
|
|
a.attr("lay-id", item.id);
|
|
|
|
|
|
urlIds.push(item.id);
|
|
|
|
|
|
var href = item.href;
|
|
|
|
|
|
if(href != null && href != ""){
|
|
|
|
|
|
a.attr("data-url", href);
|
|
|
|
|
|
}
|
2025-12-02 18:30:53 +08:00
|
|
|
|
|
2025-11-27 16:55:35 +08:00
|
|
|
|
var li = $("<li class='layui-nav-item'></li>");
|
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
|
li.addClass("layui-nav-itemed");
|
|
|
|
|
|
}
|
|
|
|
|
|
li.append(a);
|
|
|
|
|
|
menu.append(li);
|
2025-12-02 18:30:53 +08:00
|
|
|
|
|
2025-11-27 16:55:35 +08:00
|
|
|
|
//多级菜单
|
|
|
|
|
|
setChild(li, item.child)
|
|
|
|
|
|
localStorage.setItem("uelData",urlIds.join("@"));
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
function openlinqi(){
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
|
type: 'get',
|
|
|
|
|
|
contentType: "application/x-www-form-urlencoded",
|
|
|
|
|
|
url: ctxPath + '/OwnContract/getOwnContractByState',
|
|
|
|
|
|
data: {"year":"","name":"","idNumber":"","hourPay":"","monthPay":""},
|
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
|
success: function (data) {
|
|
|
|
|
|
console.log("plan",data)
|
|
|
|
|
|
if(data.data!=null&&data.data.length>0){
|
|
|
|
|
|
//renewalView()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
function renewalView() {
|
|
|
|
|
|
var height = '90%';
|
|
|
|
|
|
var width = '70%';
|
|
|
|
|
|
var index = layer.open({
|
|
|
|
|
|
title: ['临期续签','color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
|
|
|
|
|
type: 2,
|
|
|
|
|
|
content: './pages/work/ownPerson/workerContractManagementRenewal.html',
|
|
|
|
|
|
area: [width, height],
|
|
|
|
|
|
maxmin: false,
|
|
|
|
|
|
success:function(layero,index){
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
function setChild(parentElement, child){
|
|
|
|
|
|
if(child != null && child.length > 0){
|
|
|
|
|
|
$.each(child, function(j,item2){
|
|
|
|
|
|
var ca = $("<a href='javascript:;'></a>");
|
|
|
|
|
|
ca.attr("data-url", item2.href);
|
|
|
|
|
|
ca.attr("lay-id", item2.id);
|
|
|
|
|
|
urlIds.push(item2.id)
|
|
|
|
|
|
var css2 = item2.css;
|
|
|
|
|
|
if(css2!=null && css2!=""){
|
|
|
|
|
|
ca.append("<i aria-hidden='true' class='fa " + css2 +"'></i>");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ca.append("<cite title='"+item2.name+"'>"+item2.name+"</cite>");
|
|
|
|
|
|
|
|
|
|
|
|
var dd = $("<dd></dd>");
|
|
|
|
|
|
dd.append(ca);
|
|
|
|
|
|
|
|
|
|
|
|
var dl = $("<dl class='layui-nav-child'></dl>");
|
|
|
|
|
|
dl.append(dd);
|
|
|
|
|
|
|
|
|
|
|
|
parentElement.append(dl);
|
|
|
|
|
|
|
|
|
|
|
|
// 递归
|
|
|
|
|
|
setChild(dd, item2.child);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 登陆用户头像昵称
|
|
|
|
|
|
showLoginInfo();
|
|
|
|
|
|
function showLoginInfo(){
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
|
type : 'post',
|
|
|
|
|
|
url : ctxPath + '/users/current',
|
|
|
|
|
|
// async : false,
|
|
|
|
|
|
success : function(data) {
|
|
|
|
|
|
$(".admin-header-user span").text(data.nickname);
|
2025-12-02 18:30:53 +08:00
|
|
|
|
|
2025-11-27 16:55:35 +08:00
|
|
|
|
var pro = window.location.protocol;
|
|
|
|
|
|
var host = window.location.host;
|
|
|
|
|
|
var domain = pro + "//" + host;
|
2025-12-02 18:30:53 +08:00
|
|
|
|
|
2025-11-27 16:55:35 +08:00
|
|
|
|
var sex = data.sex;
|
|
|
|
|
|
var url = data.headImgUrl;
|
|
|
|
|
|
if(url == null || url == ""){
|
|
|
|
|
|
if(sex == 1){
|
2025-12-02 18:30:53 +08:00
|
|
|
|
url = contentPath + "/img/avatars/sunny.png";
|
2025-11-27 16:55:35 +08:00
|
|
|
|
} else {
|
2025-12-02 18:30:53 +08:00
|
|
|
|
url = contentPath + "/img/avatars/1.png";
|
2025-11-27 16:55:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
// url = ctxPath + "/img/avatars/login.png";
|
|
|
|
|
|
url = domain + url;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
url = domain + "/statics" + url;
|
|
|
|
|
|
}
|
|
|
|
|
|
var img = $(".admin-header-user img");
|
|
|
|
|
|
img.attr("src", url);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function logout(){
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
|
type : 'get',
|
|
|
|
|
|
url : ctxPath + '/logout',
|
|
|
|
|
|
success : function(data) {
|
|
|
|
|
|
localStorage.removeItem("token");
|
|
|
|
|
|
location.href= ctxPath + '/login.html';
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var active;
|
|
|
|
|
|
var element ;
|
|
|
|
|
|
|
|
|
|
|
|
layui.use(['layer', 'element'], function() {
|
|
|
|
|
|
var $ = layui.jquery,
|
|
|
|
|
|
layer = layui.layer;
|
|
|
|
|
|
element = layui.element; //导航的hover效果、二级菜单等功能,需要依赖element模块
|
|
|
|
|
|
element.on('nav(demo)', function(elem){
|
|
|
|
|
|
//layer.msg(elem.text());
|
|
|
|
|
|
});
|
2025-12-02 18:30:53 +08:00
|
|
|
|
|
|
|
|
|
|
//触发事件
|
|
|
|
|
|
active = {
|
2025-11-27 16:55:35 +08:00
|
|
|
|
tabAdd: function(obj){
|
|
|
|
|
|
var lay_id = $(this).attr("lay-id");
|
|
|
|
|
|
var title = $(this).html() + '<i class="layui-icon" data-id="' + lay_id + '"></i>';
|
2025-12-02 18:30:53 +08:00
|
|
|
|
//新增一个Tab项
|
|
|
|
|
|
element.tabAdd('admin-tab', {
|
2025-11-27 16:55:35 +08:00
|
|
|
|
title: title,
|
|
|
|
|
|
content: '<iframe src="' + $(this).attr('data-url') + '"></iframe>',
|
|
|
|
|
|
id: lay_id
|
2025-12-02 18:30:53 +08:00
|
|
|
|
});
|
|
|
|
|
|
element.tabChange("admin-tab", lay_id);
|
|
|
|
|
|
},
|
2025-11-27 16:55:35 +08:00
|
|
|
|
tabDelete: function(lay_id){
|
|
|
|
|
|
element.tabDelete("admin-tab", lay_id);
|
|
|
|
|
|
},
|
|
|
|
|
|
tabChange: function(lay_id){
|
|
|
|
|
|
element.tabChange('admin-tab', lay_id);
|
2025-12-02 18:30:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
//添加tab
|
|
|
|
|
|
$(document).on('click','a',function(){
|
2025-11-27 16:55:35 +08:00
|
|
|
|
if(!$(this)[0].hasAttribute('data-url') || $(this).attr('data-url')===''){
|
2025-12-02 18:30:53 +08:00
|
|
|
|
return;
|
2025-11-27 16:55:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
var tabs = $(".layui-tab-title").children();
|
|
|
|
|
|
var lay_id = $(this).attr("lay-id");
|
|
|
|
|
|
|
|
|
|
|
|
for(var i = 0; i < tabs.length; i++) {
|
2025-12-02 18:30:53 +08:00
|
|
|
|
if($(tabs).eq(i).attr("lay-id") == lay_id) {
|
2025-11-27 16:55:35 +08:00
|
|
|
|
active.tabChange(lay_id);
|
2025-12-02 18:30:53 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
active["tabAdd"].call(this);
|
|
|
|
|
|
resize();
|
2025-11-27 16:55:35 +08:00
|
|
|
|
});
|
2025-12-02 18:30:53 +08:00
|
|
|
|
|
2025-11-27 16:55:35 +08:00
|
|
|
|
$(window).on('resize', function() {
|
2025-12-02 18:30:53 +08:00
|
|
|
|
var $content = $('.admin-nav-card .layui-tab-content');
|
|
|
|
|
|
$content.height($(this).height() - 147);
|
|
|
|
|
|
$content.find('iframe').each(function() {
|
|
|
|
|
|
$(this).height($content.height());
|
|
|
|
|
|
});
|
|
|
|
|
|
}).resize();
|
|
|
|
|
|
|
|
|
|
|
|
//toggle左侧菜单
|
2025-11-27 16:55:35 +08:00
|
|
|
|
$('.admin-side-toggle').on('click', function() {
|
2025-12-02 18:30:53 +08:00
|
|
|
|
var sideWidth = $('#admin-side').width();
|
|
|
|
|
|
if(sideWidth === 300) {
|
|
|
|
|
|
$('#admin-body').animate({
|
|
|
|
|
|
left: '0'
|
|
|
|
|
|
});
|
|
|
|
|
|
$('#admin-footer').animate({
|
|
|
|
|
|
left: '0'
|
|
|
|
|
|
});
|
|
|
|
|
|
$('#admin-side').animate({
|
|
|
|
|
|
width: '0'
|
2025-11-27 16:55:35 +08:00
|
|
|
|
});
|
2025-12-02 18:30:53 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
$('#admin-body').animate({
|
|
|
|
|
|
left: '300px'
|
|
|
|
|
|
});
|
|
|
|
|
|
$('#admin-footer').animate({
|
|
|
|
|
|
left: '300px'
|
|
|
|
|
|
});
|
|
|
|
|
|
$('#admin-side').animate({
|
|
|
|
|
|
width: '300px'
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2025-11-27 16:55:35 +08:00
|
|
|
|
});
|
2025-12-02 18:30:53 +08:00
|
|
|
|
|
2025-11-27 16:55:35 +08:00
|
|
|
|
//手机设备的简单适配
|
|
|
|
|
|
var treeMobile = $('.site-tree-mobile'),
|
|
|
|
|
|
shadeMobile = $('.site-mobile-shade');
|
|
|
|
|
|
treeMobile.on('click', function () {
|
|
|
|
|
|
$('body').addClass('site-mobile');
|
|
|
|
|
|
});
|
|
|
|
|
|
shadeMobile.on('click', function () {
|
|
|
|
|
|
$('body').removeClass('site-mobile');
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 打开新页面
|
|
|
|
|
|
* @param url
|
|
|
|
|
|
* @param lay_id
|
|
|
|
|
|
* @param title
|
|
|
|
|
|
*/
|
|
|
|
|
|
function parentOpen(url,lay_id,title){
|
|
|
|
|
|
const isContained = urlIds.includes(lay_id);
|
|
|
|
|
|
if(!isContained){
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($(".layui-tab-title li[lay-id='" + lay_id + "']").length > 0) {
|
|
|
|
|
|
active.tabChange(lay_id);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
element.tabAdd('admin-tab', {
|
|
|
|
|
|
title: title,
|
2025-12-05 15:39:43 +08:00
|
|
|
|
content: '<iframe src="' + url+'?token='+localStorage.getItem("smz-token") + '"></iframe>',
|
2025-11-27 16:55:35 +08:00
|
|
|
|
id: lay_id
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
element.tabChange("admin-tab", lay_id);
|
|
|
|
|
|
resize();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//iframe自适应
|
|
|
|
|
|
function resize(){
|
|
|
|
|
|
var $content = $('.admin-nav-card .layui-tab-content');
|
|
|
|
|
|
$content.height($(this).height() - 147);
|
|
|
|
|
|
$content.find('iframe').each(function() {
|
|
|
|
|
|
$(this).height($content.height());
|
|
|
|
|
|
});
|
2025-12-02 18:30:53 +08:00
|
|
|
|
}
|