var example = null;
var pers = null;
$(function () {
layui.use(['layer'], function () {
var layer = layui.layer;
var form = layui.form;
});
pers = checkPermission();
init();
$("#searchBt").click(function () {
example.ajax.reload();
});
});
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 + "/salaryAppeal",
"type": "get",
"data": function (d) {
d.keyWord = $("#keyword").val();
},
"error": function (xhr, textStatus, errorThrown) {
var msg = xhr.responseText;
console.log(msg);
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);
}
}
},
"lengthMenu": [ [10, 20, 50], [10, 20, 50] ], // 设置每页显示数据量选项
"drawCallback": function() {
// alert( '表格重绘了' );
var thisDataTable = $('#dt-table').DataTable();
$(".pagination").append("
" +
"到 页" +
"确认");
//点击按钮跳转指定页数
$('#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>><'dt-table-length'l>",
"columns": [
{
width: '40px',
"orderable": false,
data: function (row, type, set, meta) {
var c = meta.settings._iDisplayStart + meta.row + 1;
return c;
}
},
{ "data": "orgName","orderable": false, "defaultContent": ""},
{ "data": "proName","orderable": false, "defaultContent": ""},
{ "data": "address","orderable": false,width: '5%', "defaultContent": ""},
{ "data": "applyUser",width: '8%', "defaultContent": ""},
{ "data": "idCard",width: '8%', "defaultContent": ""},
{ "data": "phone",width: '5%', "defaultContent": ""},
{ "data": "oweTime",width: '10%', "defaultContent": ""},
{ "data": "oweMoney",width: '5%', "defaultContent": ""},
{
"data": " ",
width: '5%',
"defaultContent": "",
"orderable": false,
"render": function (data, type, row) {
var id = row['id'];
var contractPath = row['contractPath'];
var html = '';
var photoType = 1;
if (contractPath != null && contractPath != '') {
html = '查看';
} else{
}
return html;
}
},
{
"data": " ",
width: '5%',
"defaultContent": "",
"orderable": false,
"render": function (data, type, row) {
var id = row['id'];
var attendencePath = row['attendencePath'];
var html = '';
var photoType = 2;
if (attendencePath != null && attendencePath != '') {
html = '查看';
} else{
}
return html;
}
},
{
"data": " ",
width: '5%',
"defaultContent": "",
"orderable": false,
"render": function (data, type, row) {
var id = row['id'];
var salaryPath = row['salaryPath'];
var html = '';
var photoType = 3;
if (salaryPath != null && salaryPath != '') {
html = '查看';
} else{
}
return html;
}
},
{
"data": " ",
width: '5%',
"defaultContent": "",
"orderable": false,
"render": function (data, type, row) {
var id = row['id'];
var othersPath = row['othersPath'];
var html = '';
var photoType = 4;
if (othersPath != null && othersPath != '') {
html = '查看';
} else{
}
return html;
}
},
{ "data": "appealTime",width: '5%', "defaultContent": ""},
{
"data": "",
width: '5%',
"defaultContent": "",
"orderable": false,
"render": function (data, type, row) {
var replyStatus = row['replyStatus'];
var html = '';
if (replyStatus == '已处理') {
html += '已处理'
} else{
html += '待处理'
}
return html;
},
},
{ "data": "replyContent","orderable": false,width: '5%', "defaultContent": ""},
{ "data": "replyTime",width: '5%', "defaultContent": ""},
{
"data": "",
width: '3%',
"defaultContent": "",
"orderable": false,
"render": function (data, type, row) {
var id = row['id'];
var replyStatus = row['replyStatus'];
var html = '';
if (replyStatus == '已处理') {
} else{
html += checkReply(id,"sys:wagesInfo:query", pers);
}
return html;
}
},
],
"order": [[4, "desc"], [5, "desc"],[6, "desc"],[7, "desc"],[8, "desc"], [13, "desc"], [16, "desc"]] //在栏目列上显示排序功能
});
}
function photoView(id,type) {
var title = null;
if (type == 1){
title ="合同图片"
}else if (type == 2) {
title = "考勤记录";
}else if (type == 3) {
title = "工资信息";
}else if (type == 4) {
title = "其他依据";
}
var data = {"id": id, "type": type};
$.ajax({
type: 'POST',
contentType: "application/x-www-form-urlencoded",
url: ctxPath + '/salaryAppeal/getPhoto',
contentType: "application/json; charset=utf-8",
data: JSON.stringify(data),
dataType: 'json',
success: function (data) {
localStorage.setItem("filePaths", data.path);
var height = '525px';
var width = '800px';
var index = layer.open({
title: [title, 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
type: 2,
content: './showPhoto.html',
area: [width, height],
maxmin: false,
});
}
});
}
// 回复
function checkReply(id, permission, pers) {
if (permission != "") {
if ($.inArray(permission, pers) < 0) {
return "";
}
}
var btn = $("");
return btn.prop("outerHTML");
}
// 回复
function reply(id){
var height = '400px';
var width = '500px';
var index = layer.open({
title: ['回复','color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
type: 1,
content: '*',
area: [width, height],
maxmin: false,
btn: ['确定', '关闭'],
yes: function (index, layero) {
var replyContent = $("#replyContent").val();
if(replyContent == "" || replyContent == null){
layer.msg("请填写回复消息");
$("#replyContent").focus();
return false;
}
var data = {"id" : id,"replyContent" : replyContent,"replyStatus" : "已处理"};
$.ajax({
type: 'POST',
url: ctxPath + '/salaryAppeal/updateReplyInfo',
contentType: "application/json; charset=utf-8",
data: JSON.stringify(data),
dataType: 'json',
success: function (data) {
if (data.resMsg = "回复成功") {
layer.closeAll();
layer.alert('回复成功', {icon: 1});
example.ajax.reload(); // 刷新页面
}else {
layer.closeAll();
layer.msg('回复失败', {icon: 2});
example.ajax.reload(); // 刷新页面
}
}
});
},
btn2: function (index, layero) {
}
});
}