381 lines
14 KiB
JavaScript
381 lines
14 KiB
JavaScript
|
|
var example = null;
|
|||
|
|
var pers = null;
|
|||
|
|
layui.use(['layer', 'form'], function () {
|
|||
|
|
var form = layui.form;
|
|||
|
|
form.render();
|
|||
|
|
form.verify();
|
|||
|
|
// getOrg(form);
|
|||
|
|
pers = checkPermission();
|
|||
|
|
$("#searchBt").click(function () {
|
|||
|
|
example.ajax.reload();
|
|||
|
|
});
|
|||
|
|
$("#saveZipButton").click(function () {
|
|||
|
|
importExcel();
|
|||
|
|
});
|
|||
|
|
$("#checkall").change(function () {
|
|||
|
|
if ($(this).is(':checked')) {
|
|||
|
|
$('input[name="checked"]').each(function () {
|
|||
|
|
$(this).prop("checked", true);
|
|||
|
|
});
|
|||
|
|
} else {
|
|||
|
|
$('input[name="checked"]').each(function () {
|
|||
|
|
$(this).prop("checked", false);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
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 + "/Redlist",
|
|||
|
|
"type": "get",
|
|||
|
|
"data": function (d) {
|
|||
|
|
// d.orgId = $("#orgId").val();
|
|||
|
|
d.name = $("#name").val();
|
|||
|
|
d.idNumber = $("#idNumber").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": [
|
|||
|
|
{
|
|||
|
|
"data": null,
|
|||
|
|
"width": "3%",
|
|||
|
|
"bSortable": false,
|
|||
|
|
render: function (data, type, full, meta) {
|
|||
|
|
var node = '';
|
|||
|
|
var checkedStatus = data['checkedStatus'];
|
|||
|
|
node = '<input class="checkall" name="checked" value=\"' + full.idNumber + '\" type="checkbox"/>';
|
|||
|
|
if (checkedStatus == 1) {
|
|||
|
|
node = '<input class="checkall" name="checked" checked="checked" value=\"' + full.idNumber + '\" type="checkbox"/>';
|
|||
|
|
}
|
|||
|
|
return node;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
width: '2%',
|
|||
|
|
"orderable": false,
|
|||
|
|
data: function (row, type, set, meta) {
|
|||
|
|
var c = meta.settings._iDisplayStart + meta.row + 1;
|
|||
|
|
return c;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
{"data": "name", "width": "5%"},//姓名
|
|||
|
|
{"data": "idNumber", "width": "5%"},//身份证
|
|||
|
|
{"data": "post", "width": "5%"},//岗位
|
|||
|
|
{"data": "proName", "width": "5%"},//工程
|
|||
|
|
{"data": "subName", "width": "5%"},//分包商
|
|||
|
|
{"data": "phone", "width": "8%"},//联系方式
|
|||
|
|
{"data": "addTime", "width": "10%"},//报送日期
|
|||
|
|
{"data": "remark","orderable": false, "width": "10%"},//备注
|
|||
|
|
{
|
|||
|
|
"data": "",
|
|||
|
|
"width": "5%",
|
|||
|
|
"orderable": false,
|
|||
|
|
"render": function (data, type, row) {
|
|||
|
|
var id = row['idNumber'];
|
|||
|
|
var html = '';
|
|||
|
|
//详情
|
|||
|
|
html += buttonView(id, "", pers);
|
|||
|
|
html += buttonDel(id, "sys:Redlist:del", pers);
|
|||
|
|
return html;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
],
|
|||
|
|
"order": [ [2, "asc"],[3, "asc"],[4, "asc"],[5, "asc"],[6, "asc"],[7, "asc"],[8, "asc"]] //在栏目列上显示排序功能
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 新增页面
|
|||
|
|
* */
|
|||
|
|
function addRedInfo() {
|
|||
|
|
if ($.inArray("sys:Redlist:add", pers) < 0) {
|
|||
|
|
layer.msg("无添加红名单权限");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
var height = '525px';
|
|||
|
|
var width = '900px';
|
|||
|
|
var index = layer.open({
|
|||
|
|
title: ['新增', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
|||
|
|
type: 2,
|
|||
|
|
content: 'redlistForm.html',
|
|||
|
|
area: [width, height],
|
|||
|
|
maxmin: false,
|
|||
|
|
btn: ['确定', '关闭'],
|
|||
|
|
success: function (layero, index) {
|
|||
|
|
var myIframe = window[layero.find('iframe')[0]['name']];
|
|||
|
|
/* myIframe.getRedPersonList(); //aaa()为子页面的方法*/
|
|||
|
|
},
|
|||
|
|
yes: function (index, layero) {
|
|||
|
|
// 获取弹出层中的form表单元素
|
|||
|
|
var formSubmit = layer.getChildFrame('form', index);
|
|||
|
|
var submited = formSubmit.find('button')[0];
|
|||
|
|
// 触发点击事件,会对表单进行验证,验证成功则提交表单,失败则返回错误信息
|
|||
|
|
submited.click();
|
|||
|
|
example.ajax.reload(); // 刷新页面
|
|||
|
|
},
|
|||
|
|
btn2: function (index, layero) {
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 批量删除
|
|||
|
|
function delBatch() {
|
|||
|
|
if ($.inArray("sys:Redlist:del", pers) < 0) {
|
|||
|
|
layer.msg("无删除红名单权限");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
var id = null;
|
|||
|
|
var selected = []; // 选中删除的数据
|
|||
|
|
var oTable = $('#dt-table').dataTable();
|
|||
|
|
var rowcollection = oTable.$(".checkall:checked", {"page": "all"});
|
|||
|
|
rowcollection.each(function (index, elem) {
|
|||
|
|
var checkbox_value = $(elem).val();
|
|||
|
|
selected.push(checkbox_value);
|
|||
|
|
});
|
|||
|
|
if (selected.length == 0) {
|
|||
|
|
return layer.msg("请勾选要删除的数据", {icon: 2, time: 2000});
|
|||
|
|
}
|
|||
|
|
id = selected.toString();
|
|||
|
|
layer.confirm("您确定要删除选中的数据吗?", function () {
|
|||
|
|
var form = {"idNumber" : id};
|
|||
|
|
$.ajax({
|
|||
|
|
type: 'post',
|
|||
|
|
url: ctxPath + '/Redlist/deleteWorkerRed',
|
|||
|
|
contentType: "application/json; charset=utf-8",
|
|||
|
|
data: JSON.stringify(form),
|
|||
|
|
dataType: 'json',
|
|||
|
|
success: function (data) {
|
|||
|
|
if (data.resMsg == "删除成功") {
|
|||
|
|
layer.msg('删除成功', {icon: 1, time: 3000});
|
|||
|
|
example.ajax.reload(); // 刷新页面
|
|||
|
|
} else {
|
|||
|
|
layer.msg(data.resMsg, {icon: 2, time: 3000});
|
|||
|
|
example.ajax.reload(); // 刷新页面
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 点赞达标配置
|
|||
|
|
function configure() {
|
|||
|
|
if ($.inArray("sys:Redlist:config", pers) < 0) {
|
|||
|
|
layer.msg("无配置达标权限");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
var height = '375px';
|
|||
|
|
var width = '500px';
|
|||
|
|
var index = layer.open({
|
|||
|
|
title: ['点赞达标配置', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
|||
|
|
type: 2,
|
|||
|
|
content: 'configure.html',
|
|||
|
|
area: [width, height],
|
|||
|
|
maxmin: false,
|
|||
|
|
btn: ['确定', '关闭'],
|
|||
|
|
success: function (layero, index) {
|
|||
|
|
var myIframe = window[layero.find('iframe')[0]['name']];
|
|||
|
|
/* myIframe.getRedPersonList(); //aaa()为子页面的方法*/
|
|||
|
|
},
|
|||
|
|
yes: function (index, layero) {
|
|||
|
|
// 获取弹出层中的form表单元素
|
|||
|
|
var formSubmit = layer.getChildFrame('form', index);
|
|||
|
|
var submited = formSubmit.find('button')[0];
|
|||
|
|
// 触发点击事件,会对表单进行验证,验证成功则提交表单,失败则返回错误信息
|
|||
|
|
submited.click();
|
|||
|
|
example.ajax.reload(); // 刷新页面
|
|||
|
|
},
|
|||
|
|
btn2: function (index, layero) {
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 删除红名单人员
|
|||
|
|
* */
|
|||
|
|
function del(id) {
|
|||
|
|
layer.confirm("确定删除吗?", function () {
|
|||
|
|
var form = {"idNumber":id};
|
|||
|
|
$.ajax({
|
|||
|
|
type: 'post',
|
|||
|
|
url: ctxPath + '/Redlist/delRedlist',
|
|||
|
|
contentType: "application/json; charset=utf-8",
|
|||
|
|
data: JSON.stringify(form),
|
|||
|
|
dataType: 'json',
|
|||
|
|
success: function (data) {
|
|||
|
|
if (data.resMsg == "删除成功") {
|
|||
|
|
layer.alert('删除成功', {icon: 1});
|
|||
|
|
example.ajax.reload(); // 刷新页面
|
|||
|
|
} else {
|
|||
|
|
layer.msg('删除失败'+data.resMsg, {icon: 2});
|
|||
|
|
example.ajax.reload(); // 刷新页面
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 红名单历史记录查看
|
|||
|
|
function view(id,orgId) {
|
|||
|
|
localStorage.setItem("idNumbers", id);
|
|||
|
|
localStorage.setItem("orgId", orgId);
|
|||
|
|
var height = '600px';
|
|||
|
|
var width = '1200px';
|
|||
|
|
var index = layer.open({
|
|||
|
|
title: ['详情', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
|||
|
|
type: 2,
|
|||
|
|
content: './redHistory.html',
|
|||
|
|
area: [width, height],
|
|||
|
|
maxmin: false,
|
|||
|
|
success: function (layero, index) {
|
|||
|
|
var myIframe = window[layero.find('iframe')[0]['name']];
|
|||
|
|
},
|
|||
|
|
cancel: function (index, layero) {
|
|||
|
|
//取消操作,点击右上角的X
|
|||
|
|
// example.ajax.reload(); // 刷新页面
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 删除按钮
|
|||
|
|
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 buttonView(id, permission, pers) {
|
|||
|
|
if (permission != "") {
|
|||
|
|
if ($.inArray(permission, pers) < 0) {
|
|||
|
|
return "";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var orgId = $("#orgId").val();
|
|||
|
|
var btn = $("<button class='layui-btn layui-btn-xs' title='详情' onclick='view(\"" + id + "\",\""+orgId+"\")'><i class='layui-icon'></i></button>");
|
|||
|
|
return btn.prop("outerHTML");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//导入excel文件
|
|||
|
|
function importExcel() {
|
|||
|
|
if ($.inArray("sys:Redlist:import", pers) < 0) {
|
|||
|
|
layer.msg("无导入红名单权限");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
var formData = new FormData($('form')[0]);
|
|||
|
|
var name = $("#articleImageFile").val();
|
|||
|
|
if (name == null || name == "") {
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (!(name.endsWith(".xls") || name.endsWith(".xlsx") || name.endsWith(".xlsm"))) {
|
|||
|
|
layer.msg("请上传正确的Excel表格!");
|
|||
|
|
$("#articleImageFile").val("");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
formData.append("file", $("#articleImageFile")[0].files[0]);
|
|||
|
|
var idx = layer.msg('正在提交数据,请稍等...', {
|
|||
|
|
icon: 16
|
|||
|
|
, shade: 0.01
|
|||
|
|
, time: '-1'
|
|||
|
|
});
|
|||
|
|
$.ajax({
|
|||
|
|
url: ctxPath + "/Redlist/importExcel",
|
|||
|
|
type: 'POST',
|
|||
|
|
async: true,
|
|||
|
|
data: formData,
|
|||
|
|
timeout: 20000,
|
|||
|
|
// 告诉jQuery不要去处理发送的数据
|
|||
|
|
processData: false,
|
|||
|
|
// 告诉jQuery不要去设置Content-Type请求头
|
|||
|
|
contentType: false,
|
|||
|
|
success: function (data) {
|
|||
|
|
layer.close(idx);
|
|||
|
|
if(data.indexOf("导入成功") !=-1){
|
|||
|
|
layer.alert(data, {icon: 1});
|
|||
|
|
}else if(data.indexOf("导入失败") !=-1){
|
|||
|
|
layer.alert(data, {icon: 2});
|
|||
|
|
}
|
|||
|
|
example.ajax.reload(); // 刷新页面
|
|||
|
|
},
|
|||
|
|
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
|||
|
|
console.log(JSON.stringify(errorThrown));
|
|||
|
|
layer.close(idx);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
$("#articleImageFile").val("");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
function down() {
|
|||
|
|
window.location.href = ctxPath + "/download/download?filename=红名单导入模板.xlsx";
|
|||
|
|
}
|
|||
|
|
|