339 lines
13 KiB
JavaScript
339 lines
13 KiB
JavaScript
var example = null;
|
||
var pers = null;
|
||
var token = localStorage.getItem("token");
|
||
var ids ;
|
||
$(function () {
|
||
layui.use(['layer', 'laydate', 'form'], function () {
|
||
var layer = layui.layer;
|
||
var form = layui.form;
|
||
var laydate = layui.laydate;
|
||
pers = checkPermission();
|
||
console.log(localStorage.getItem("offIdNumber"))
|
||
init();
|
||
});
|
||
});
|
||
function init(){
|
||
example =
|
||
$('#dt-table').DataTable({
|
||
"searching": false,
|
||
"processing": true, //加载数据时显示进度状态
|
||
"serverSide" : true,
|
||
"pagingType": "full_numbers", //首页|尾页
|
||
"language": {
|
||
"url": ctxPath + "/js/plugin/datatables/Chinese.lang"
|
||
},
|
||
"ajax": {
|
||
"url" : ctxPath + "/workerDepart",
|
||
"type":"get",
|
||
"data":function(d){
|
||
d.idNumber = localStorage.getItem("offIdNumber");
|
||
},
|
||
"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");
|
||
layer.msg("token过期,请先登录", {shift: -1, time: 1000}, function(){
|
||
location.href = ctxPath + '/login.html';
|
||
});
|
||
} else if (code == 403) {
|
||
console.log("未授权:" + message);
|
||
layer.msg('未授权');
|
||
} else if (code == 500) {
|
||
console.log('系统错误:' + message);
|
||
}
|
||
}
|
||
},
|
||
"drawCallback": function() {
|
||
// alert( '表格重绘了' );
|
||
var thisDataTable = $('#dt-table').DataTable();
|
||
$(".pagination").append("<li>" +
|
||
"<a class='paginate_button' style='padding:4px;' href='#' tabindex='0'>到 <input style='margin:0px;width:40px;' id='changePage'> 页</a>" +
|
||
"<a class='paginate_button' style='margin-bottom:1px' href='#' tabindex='0' id='dataTable-btn'>确认</a></li>");
|
||
//点击按钮跳转指定页数
|
||
$('#dataTable-btn').click(function (e) {
|
||
if ($("#changePage").val() && $("#changePage").val() > 0) {
|
||
var redirectpage = $("#changePage").val() - 1;
|
||
} else {
|
||
var redirectpage = 0;
|
||
}
|
||
thisDataTable.page(redirectpage).draw( 'page' );
|
||
});
|
||
//敲击回车键跳转指定页数
|
||
$("#changePage").keypress(function (e) {
|
||
if(event.keyCode==13){
|
||
if ($("#changePage").val() && $("#changePage").val() > 0) {
|
||
var redirectpage = $("#changePage").val() - 1;
|
||
} else {
|
||
var redirectpage = 0;
|
||
}
|
||
thisDataTable.page(redirectpage).draw( 'page' );
|
||
}
|
||
});
|
||
},
|
||
"dom": "<'dt-toolbar'r>t<'dt-toolbar-footer'<'col-sm-4 col-xs-4 hidden-xs'i><'col-xs-8 col-sm-8' p v>>",
|
||
"columns": [
|
||
{
|
||
width : '5%',
|
||
"orderable": false,
|
||
data : function(row, type, set, meta) {
|
||
var c = meta.settings._iDisplayStart + meta.row + 1;
|
||
return c;
|
||
}
|
||
},
|
||
{ "data": "noticePath","width": "6%","render": function (data, type, row) {
|
||
var id = row['id'];
|
||
var html = '';
|
||
var offBook= row['noticePath'];
|
||
if(offBook==null||offBook==''){
|
||
html += "<a style = 'color:#09A8F1;cursor: pointer'>--</a>";
|
||
}else if(offBook=='线下'){
|
||
html += "<a style = 'color:#09A8F1;cursor: pointer'>线下</a>";
|
||
} else{
|
||
html += "<a onclick = 'electronicContractView(\"" + offBook + "\")' style = 'color:#09A8F1;cursor: pointer'>解除劳动合同通知书</a>";
|
||
}
|
||
return html;
|
||
}},
|
||
{ "data": "agreementPath","width": "5%","render": function (data, type, row) {
|
||
var id = row['id'];
|
||
var html = '';
|
||
var offBook= row['agreementPath'];
|
||
if(offBook==null||offBook==''){
|
||
html += "<a style = 'color:#09A8F1;cursor: pointer'>--</a>";
|
||
}else if(offBook=='线下'){
|
||
html += "<a style = 'color:#09A8F1;cursor: pointer'>线下</a>";
|
||
}else{
|
||
html += "<a onclick = 'electronicContractView(\"" + offBook + "\")' style = 'color:#09A8F1;cursor: pointer'>解除劳动合同协议书</a>";
|
||
}
|
||
return html;
|
||
}},
|
||
{ "data": "offBook","width": "5%","render": function (data, type, row) {
|
||
var id = row['id'];
|
||
var html = '';
|
||
var offBook= row['offBook'];
|
||
if(offBook==null||offBook==''){
|
||
html += "<a style = 'color:#09A8F1;cursor: pointer'>--</a>";
|
||
}else if(offBook=='线下'){
|
||
html += "<a style = 'color:#09A8F1;cursor: pointer'>线下</a>";
|
||
}else{
|
||
html += "<a onclick = 'electronicContractView(\"" + offBook + "\")' style = 'color:#09A8F1;cursor: pointer'>终止/解除劳动合同证明</a>";
|
||
}
|
||
return html;
|
||
}},
|
||
],
|
||
"order": [[ 1, "desc" ],[ 2, "desc" ],[ 3, "desc" ]]
|
||
} );
|
||
}
|
||
function electronicContractView(url){
|
||
let height = getDefaultHeight().toFixed(0) + 'px';
|
||
let width = getDefaultWidth().toFixed(0) + 'px';
|
||
localStorage.setItem("recordurl", url);
|
||
let layerIndex = parent.layer.open({
|
||
id: 'layer-electronicContract',
|
||
title: ['详情', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
||
type: 2,
|
||
content: 'ownContractView.html',
|
||
area: [width, height],
|
||
maxmin: false,
|
||
shadeClose: false, //开启遮罩关闭
|
||
shade: 0.3, //显示遮罩
|
||
move: false,
|
||
resize: false,
|
||
success:function(layero,index){
|
||
// let iframeWin = window["layui-layer-iframe" + layerIndex];
|
||
// iframeWin.setParam(url);
|
||
//var iframeWin = window[layero.find('iframe')[0]['name']];//获得iframe页的窗口对象,执行iframe页的方法:
|
||
//iframeWin.setParam(url);//调用子页面的方法,页面锁定
|
||
$(window).resize(function () {
|
||
if (autoResizeWidth) autoResizeWidth(index);
|
||
if (autoResizeHeight) autoResizeHeight(index);
|
||
})
|
||
},
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 新增页面
|
||
* */
|
||
function inserts() {
|
||
var height = '85%';
|
||
var width = '65%';
|
||
var index = layer.open({
|
||
title: ['新增', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
||
type: 2,
|
||
content: 'workerBenefitsForm.html',
|
||
area: [width, height],
|
||
maxmin: false,
|
||
btn: ['确定', '关闭'],
|
||
success: function (layero, index) {
|
||
var myIframe = window[layero.find('iframe')[0]['name']];
|
||
myIframe.getOWNReportType("");
|
||
|
||
myIframe.setWorkerId(ids);
|
||
|
||
},
|
||
yes: function (index, layero) {
|
||
var formSubmit = layer.getChildFrame('form', index);
|
||
var submited = formSubmit.find('button')[2];
|
||
// 触发点击事件,会对表单进行验证,验证成功则提交表单,失败则返回错误信息
|
||
submited.click();
|
||
// example.ajax.reload(); // 刷新页面
|
||
},
|
||
btn2: function (index, layero) {
|
||
}
|
||
});
|
||
}
|
||
|
||
//查看附件详情
|
||
function dataFileView(id) {
|
||
localStorage.setItem("id",id);
|
||
var height = '525px';
|
||
var width = '800px';
|
||
var index = layer.open({
|
||
title: ["查看", 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
||
type: 2,
|
||
content: 'workerBenefitsPhoto.html',
|
||
area: [width, height],
|
||
maxmin: false,
|
||
});
|
||
}
|
||
|
||
// 编辑按钮
|
||
function buttonEdits(id, permission, pers) {
|
||
if (permission != "") {
|
||
if ($.inArray(permission, pers) < 0) {
|
||
return "";
|
||
}
|
||
}
|
||
var btn = $("<button class='layui-btn layui-btn-xs' title='编辑' onclick='edit(\"" + id + "\")'><i class='layui-icon'></i></button>");
|
||
return btn.prop("outerHTML");
|
||
}
|
||
|
||
// 删除按钮
|
||
function buttonDel(data, permission, pers){
|
||
if(permission != ""){
|
||
if ($.inArray(permission, pers) < 0) {
|
||
return "";
|
||
}
|
||
}
|
||
var btn = $("<button class='layui-btn layui-btn-xs' title='删除' onclick='del(\"" + data +"\")'><i class='layui-icon'></i></button>");
|
||
return btn.prop("outerHTML");
|
||
}
|
||
|
||
/**
|
||
* 编辑页面
|
||
*/
|
||
function edit(id) {
|
||
$.ajax({
|
||
type: 'POST',
|
||
contentType: "application/x-www-form-urlencoded",
|
||
url: ctxPath + '/workerBenefits/getWorkerBenefitsById',
|
||
data: {"id": id},
|
||
dataType: 'json',
|
||
success: function (data) {
|
||
var height = '85%';
|
||
var width = '85%';
|
||
var index = layer.open({
|
||
title: ['修改', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
||
type: 2,
|
||
content: 'workerBenefitsForm.html',
|
||
area: [width, height],
|
||
maxmin: false,
|
||
btn: ['确定', '关闭'],
|
||
success: function (layero, index) {
|
||
var myIframe = window[layero.find('iframe')[0]['name']];
|
||
var fnc = myIframe.setData(data); //aaa()为子页面的方法
|
||
},
|
||
yes: function (index, layero) {
|
||
// 获取弹出层中的form表单元素
|
||
var formSubmit = layer.getChildFrame('form', index);
|
||
var submited = formSubmit.find('button')[2];
|
||
// 触发点击事件,会对表单进行验证,验证成功则提交表单,失败则返回错误信息
|
||
submited.click();
|
||
// example.ajax.reload(); // 刷新页面
|
||
},
|
||
btn2: function (index, layero) {
|
||
}
|
||
});
|
||
}
|
||
})
|
||
|
||
/*localStorage.setItem("id", id);
|
||
var height = getDefaultHeight().toFixed(0) + 'px';
|
||
var width = getDefaultWidth().toFixed(0) + 'px';
|
||
var layerIndex = layer.open({
|
||
id: 'layer-contract-signing-infor',
|
||
title: ['修改', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
||
content: './workerBenefitsForm.html',
|
||
area: [width, height],
|
||
type: 2,
|
||
maxmin: false,
|
||
shadeClose: false, //开启遮罩关闭
|
||
shade: 0.3, //显示遮罩
|
||
move: false,
|
||
resize: false,
|
||
btn: ['关闭'],
|
||
success:function(layero,index){
|
||
let iframeWin = window["layui-layer-iframe" + layerIndex];
|
||
iframeWin.setParam(idNumber);
|
||
$(window).resize(function () {
|
||
if (autoResizeWidth) autoResizeWidth(index);
|
||
if (autoResizeHeight) autoResizeHeight(index);
|
||
})
|
||
},
|
||
btn2: function (index, layero) {
|
||
}
|
||
});*/
|
||
}
|
||
|
||
/**
|
||
* 删除
|
||
* */
|
||
function del(id) {
|
||
layer.confirm("确定删除吗?",function () {
|
||
$.ajax({
|
||
type: 'delete',
|
||
url: ctxPath + '/workerBenefits/'+id,
|
||
data: {},
|
||
dataType: 'json',
|
||
success: function (data) {
|
||
if (data.obj == '删除成功') {
|
||
layer.alert('删除成功', {icon: 1});
|
||
example.ajax.reload(null, false); // 刷新页面
|
||
} else {
|
||
layer.msg(data.obj, {icon: 2});
|
||
example.ajax.reload(null, false); // 刷新页面
|
||
}
|
||
}
|
||
})
|
||
})
|
||
}
|
||
|
||
/**
|
||
* 获得当前时间 yyyy-MM-dd
|
||
* @returns {string}
|
||
*/
|
||
function getNowTime() {
|
||
var time = new Date();
|
||
var year = time.getFullYear();
|
||
var month = time.getMonth() + 1 >= 10 ? time.getMonth() + 1 : '0' + (time.getMonth() + 1);
|
||
var day = time.getDate() >= 10 ? time.getDate() : '0' + time.getDate();
|
||
return year + "-" + month + "-" + day;
|
||
}
|
||
|
||
/**
|
||
* 获取当月第一天
|
||
* @returns {string}
|
||
*/
|
||
function getCurrentMonthFirst() {
|
||
var date = new Date();
|
||
date.setDate(1);
|
||
var year = date.getFullYear();
|
||
var month = date.getMonth() + 1 > 10 ? date.getMonth() + 1 : '0' + (date.getMonth() + 1);
|
||
var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
|
||
return year + "-" + month + "-" + day;
|
||
} |