308 lines
13 KiB
JavaScript
308 lines
13 KiB
JavaScript
var example = null;
|
||
var pers = null ;
|
||
var remarkShowLength = 10;
|
||
layui.use([ 'layer' ,'form'], function() {
|
||
var layer = layui.layer;
|
||
var form = layui.form;
|
||
pers = checkPermission();
|
||
$("#searchBt").click(function(){
|
||
example.ajax.reload();
|
||
});
|
||
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 + "/OwnContract/OwnContractRecord",
|
||
"type":"get",
|
||
"data":function(d){
|
||
d.keyWord = $("#keyWord").val();
|
||
d.workId =localStorage.getItem("recordWorkId");
|
||
d.type=localStorage.getItem("recordType")
|
||
},
|
||
"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": "type","width": "10%","render": function (data, type, row) {
|
||
var type = row['type'];
|
||
var html = '';
|
||
if(type==1){
|
||
html="(非全日制)劳动合同";
|
||
}else if(type==2){
|
||
html="(管理人员)能永劳动合同";
|
||
}else if(type==3){
|
||
html="(管理人员)劳动合同";
|
||
}else if(type==4){
|
||
html="(驾驶员)劳动合同";
|
||
}else if(type==5){
|
||
html="(劳务承揽)劳动合同";
|
||
}else if(type==6){
|
||
html="(劳务派遣)劳动合同";
|
||
}else if(type==7){
|
||
html="退休返聘协议";
|
||
}else if (type==8){
|
||
html="(完成一定工作)劳动合同";
|
||
}
|
||
return html;
|
||
}},
|
||
{ "data": "signDate","width": "10%"},
|
||
{ "data": "","width": "10%","render": function (data, type, row) {
|
||
var contractId = row['contractId'];
|
||
var type = row['type'];
|
||
var idNumber = row['idNumber'];
|
||
var url = row['path'];
|
||
var contractType = row['contractType'];
|
||
var ctype="电子合同";
|
||
if(contractType==2){
|
||
ctype="纸质合同";
|
||
}
|
||
var html = '';
|
||
if(url != '' && url != null){
|
||
html += "<a style = 'color:#09A8F1;cursor: pointer' onclick = 'electronicContractView(\"" + contractId + "\",\"" + type + "\",\"" + idNumber + "\",\"" + url + "\")'>"+ctype+"</a>";
|
||
}else{
|
||
html += "<span style='color: red'>无</span>"
|
||
}
|
||
return html;
|
||
}},
|
||
{ "data": "signStartDate","width": "6%"},
|
||
{ "data": "signEndDate","width": "6%"},
|
||
{ "data": "state","width": "5%","render": function (data, type, row) {
|
||
var state = row['state'];
|
||
var isActive = row['isActive'];
|
||
var html = '';
|
||
if(state==null){
|
||
html="<a style = 'color:red;cursor: pointer'>未签署</a>";
|
||
}else if(state==0){
|
||
html="<a style = 'color:#09A8F1;cursor: pointer'>已下发</a>";
|
||
}else if(state==1 || state==3){
|
||
html="<a style = 'color:#09A8F1;cursor: pointer'>已签署</a>";
|
||
}else if(state==4){
|
||
html="<a style = 'color:red;cursor: pointer'>临期</a>";
|
||
}
|
||
if(isActive==0){
|
||
html="<a style = 'color:#F5F5F5;cursor: pointer'>失效</a>";
|
||
}
|
||
return html;
|
||
}
|
||
},
|
||
{
|
||
"data": "",
|
||
"width": "10%",
|
||
"defaultContent": "",
|
||
"orderable": false,
|
||
"render": function (data, type, row) {
|
||
var id = row['id'];
|
||
var html = '';
|
||
var contractId = row['contractId'];
|
||
var state= row['state'];
|
||
var type = row['type'];
|
||
var idNumber = row['idNumber'];
|
||
var url = row['path'];
|
||
var videourl = row['videoUrl'];
|
||
var workId = row['workId'];
|
||
if(state==0||state==null||state=='null'){
|
||
html += "<a style = 'color:red;cursor: pointer'>暂未签订</a>";
|
||
}else{
|
||
var contractType = row['contractType'];
|
||
if(contractType==2){
|
||
|
||
}else{
|
||
html += "<a style = 'color:#09A8F1;cursor: pointer' onclick = 'ContractView(\"" + contractId + "\",\"" + type + "\",\"" + idNumber + "\",\"" + videourl + "\")'>签订信息</a>";
|
||
}
|
||
}
|
||
var recordType=localStorage.getItem("recordType")
|
||
if (recordType==="1"){
|
||
html += "<a style = 'color:red;cursor: pointer' onclick = 'del(\"" + contractId + "\")'> 删除</a>";
|
||
}
|
||
return html;
|
||
}
|
||
},
|
||
],
|
||
"order": [[ 1, "desc" ],[ 2, "desc" ],[ 3, "desc" ],[ 4, "desc" ],[5, "desc"],[6, "desc"]] //在栏目列上显示排序功能
|
||
} );
|
||
}
|
||
//查看电子合同详情
|
||
function electronicContractView(id,contractType,idNumber,url){
|
||
let height = getDefaultHeight().toFixed(0) + 'px';
|
||
let width = getDefaultWidth().toFixed(0) + 'px';
|
||
localStorage.setItem("idNumber", idNumber);
|
||
localStorage.setItem("recordurl", url);
|
||
localStorage.setItem("contractId", id);
|
||
|
||
|
||
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 ContractView(id,contractType,idNumber,url){
|
||
let height = getDefaultHeight().toFixed(0) + 'px';
|
||
let width = getDefaultWidth().toFixed(0) + 'px';
|
||
localStorage.setItem("idNumber", idNumber);
|
||
localStorage.setItem("recordvideourl", url);
|
||
let layerIndex = parent.layer.open({
|
||
id: 'layer-electronicContract',
|
||
title: ['详情', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
||
type: 2,
|
||
content: 'contractDetails.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);
|
||
})
|
||
},
|
||
});
|
||
}
|
||
/**
|
||
* 新增页面 workerContractManagementRenewal.html
|
||
* */
|
||
function insertCorporations() {
|
||
var height = '85%';
|
||
var width = '85%';
|
||
var index = layer.open({
|
||
title: ['新增', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
||
type: 2,
|
||
content: 'addCorporationMag.html',
|
||
area: [width, height],
|
||
maxmin: false,
|
||
btn: ['确定', '关闭'],
|
||
yes: function (index, layero) {
|
||
var formSubmit = layer.getChildFrame('form', index);
|
||
var submited = formSubmit.find('button')[4];
|
||
// 触发点击事件,会对表单进行验证,验证成功则提交表单,失败则返回错误信息
|
||
submited.click();
|
||
// example.ajax.reload(); // 刷新页面
|
||
},
|
||
btn2: function (index, layero) {
|
||
}
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 编辑页面
|
||
*/
|
||
function edit(id) {
|
||
|
||
}
|
||
|
||
/**
|
||
* 删除
|
||
* */
|
||
function del(id) {
|
||
layer.confirm("确定删除吗?", function () {
|
||
$.ajax({
|
||
type: 'delete',
|
||
url: ctxPath + '/OwnContract/' + id,
|
||
data: {},
|
||
dataType: 'json',
|
||
success: function (data) {
|
||
if (data.resMsg == "删除成功") {
|
||
layer.alert('删除成功', {icon: 1});
|
||
setTimeout("reloading()", 2100);
|
||
} else {
|
||
layer.msg(data.resMsg, {icon: 2});
|
||
example.ajax.reload(null, false); // 刷新页面
|
||
}
|
||
}
|
||
})
|
||
})
|
||
}
|
||
|
||
//设置弹窗关闭
|
||
function reloading() {
|
||
var index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
|
||
parent.layer.close(index); //再执行关闭
|
||
window.parent.example.ajax.reload( null, false ); // 刷新页面
|
||
}
|