HnRealNameBmwWeb/js/work/person/safeguardingAppealList.js

303 lines
12 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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("<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>><'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 = '<span style = "color:#35B3F1;cursor: pointer" onclick="photoView(\''+id +'\',\''+photoType+'\')">查看</span>';
} 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 = '<span style = "color:#35B3F1;cursor: pointer" onclick="photoView(\''+id +'\',\''+photoType+'\')">查看</span>';
} 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 = '<span style = "color:#35B3F1;cursor: pointer" onclick="photoView(\''+id +'\',\''+photoType+'\')">查看</span>';
} 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 = '<span style = "color:#35B3F1;cursor: pointer" onclick="photoView(\''+id +'\',\''+photoType+'\')">查看</span>';
} 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 += '<span style="color: #00B83F">已处理</span>'
} else{
html += '<span style="color: #ff0000">待处理</span>'
}
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 = $("<button class='layui-btn layui-btn-xs' title='回复' onclick='reply(\""+id+"\")'><i class='layui-icon'>&#xe642;</i></button>");
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: '<span style="color: red; float: left ;margin-top: 5%;margin-left: 9%">*</span><textarea id="replyContent" style="margin-top: 5%;height: 150px;" rows="5" cols="50" placeholder="填写相关回复消息"></textarea>',
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) {
}
});
}