hn_cloud_web/smz-web/js/work/push/infoPush.js

446 lines
16 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', 'laydate', 'form'], function () {
var layer = layui.layer;
var laydate = layui.laydate;
var form = layui.form;
getOrg(form);
var orgId = $("#orgId").val();
getGroupPro(form, orgId);
form.on('select(orgId)', function (data) {
getGroupPro(form, data.value);
});
pers = checkPermission();
init();
$("#searchBt").click(function () {
example.ajax.reload();
});
$("#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);
});
}
});
});
})
function init() {
example =
$('#dt-table').DataTable({
"sort": false,
"searching": false,
"processing": true, //加载数据时显示进度状态
"serverSide": true,
"language": {
"url": contentPath + "/js/plugin/datatables/Chinese.lang"
},
"ajax": {
"url": ctxPath + "/infoPushs/selectInfo",
"type": "post",
"data": function (d) {
d.orgId = $("#orgId").val();
d.proId = $("#proId").val();
d.proPushStatus = $("#proPushStatus").val();
},
"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() {
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":"3%",
// "data": null,
// "bSortable": false,
// render: function (data, type, full, meta) {
// var node = '';
// var checkedStatus = data['checkedStatus'];
// node = '<input class="checkall" name="checked" value=\"' + full.idNumber + ',' + full.proId + '\" type="checkbox"/>';
// if (checkedStatus == 1) {
// node = '<input class="checkall" name="checked" checked="checked" value=\"' + full.idNumber + ',' + full.proId + '\" type="checkbox"/>';
// }
// return node;
// }
// },
{
width: '3%',
data: function (row, type, set, meta) {
var c = meta.settings._iDisplayStart + meta.row + 1;
return c;
}
},
{"data": "proName",width: '10%'},
{
"data": "",
"defaultContent": "",width: '5%',
"orderable": false,
"render": function (data, type, row) {
var onJobNum = row['onJobNum'];
var intactOnJobNum = row['intactOnJobNum'];
var html = '';
html = '<a onclick="onJobView(\''+row['proId']+'\',\'1\',\'\')">'+ onJobNum+'/'+intactOnJobNum +'</a>';
return html;
}
},
{
"data": "",
"defaultContent": "",width: '5%',
"orderable": false,
"render": function (data, type, row) {
var notOnJobNum = row['notOnJobNum'];
var intactNotOnJobNum = row['intactNotOnJobNum'];
var html = '';
html = '<a onclick="onJobView(\''+row['proId']+'\',\'0\',\'1\')">'+ notOnJobNum+'/'+intactNotOnJobNum +'</a>';
return html;
}
},
{
"data": "",
"defaultContent": "",width: '5%',
"orderable": false,
"render": function (data, type, row) {
var onJobPushNum = row['onJobPushNum'];
var notOnJobPushNum = row['notOnJobPushNum'];
var html = '';
html = '<a onclick="onJobView(\''+row['proId']+'\',\'\',\'1\')">'+ onJobPushNum+'/'+notOnJobPushNum +'</a>';
return html;
}
},
{
"data": "",
"defaultContent": "",width: '5%',
"orderable": false,
"render": function (data, type, row) {
var intactContractNum = row['intactContractNum'];
var contractPushNum = row['contractPushNum'];
var html = '';
html = '<a onclick="contractPushView(\''+row['proId']+'\')">'+ intactContractNum+'/'+contractPushNum +'</a>';
return html;
}
},
{
"data": "",
"defaultContent": "",width: '6%',
"orderable": false,
"render": function (data, type, row) {
var pushAll = row['pushAll'];
var attendanceAll = row['attendanceAll'];
var attendancePush = row['attendancePush'];
var html = '';
html = '<a onclick="attendancePushView(\''+row['proId']+'\')">' + pushAll + '/' + attendanceAll + '/' + attendancePush + '</a>';
return html;
}
},
{
"data": "",
"defaultContent": "",width: '4%',
"orderable": false,
"render": function (data, type, row) {
var proPushStatus = row['proPushStatus'];
var html = '';
if (proPushStatus == '0') {
html += '<span style="color:#f7a00a;">未推送</span>';
}else if (proPushStatus == '1') {
html += '<span style="color:green">推送成功</span>';
}else if (proPushStatus == '2') {
html += '<span style="color:red">推送失败</span>';
}else{
html += '<span style="color:red"></span>';
}
return html;
}
},
{
"data": "",
"defaultContent": "",width: '5%',
"orderable": false,
"render": function (data, type, row) {
var proId = row['proId'];
var proPushStatus = row['proPushStatus'];
var isMultiple = row['isMultiple'];
var proOldId = row['proOldId'];
if(proOldId != null && proOldId !="" && proOldId !="null"){
proId = proOldId;
}
var html = '';
let subProId = proId.split(",");
let trueProId = proId;
if(subProId.length>1){
trueProId = subProId[isMultiple-1] ;
}
html += buttonProPush(trueProId, proPushStatus, "sys:infoPush:pro", pers);//工程推送
html += buttonAttPush(row['proId'], proPushStatus, "sys:infoPush:attendance", pers);//
if(proPushStatus == '1'){
html += toRstUi(trueProId);//工程推送
}
return html;
}
},
],
"order": [[0, "desc"], [1, "asc"]] //在栏目列上显示排序功能
});
}
function toRstUi(proId) {
var btn = $("<button class='layui-btn layui-btn-xs' title='人社厅页面' onclick='initRstUi(\"" + proId + "\")'>人社厅页面</button>");
return btn.prop("outerHTML");
}
function initRstUi(proId) {
$.ajax({
type: 'POST',
url: ctxPath + '/infoPushs/showRst',
data:{proId: proId},
dataType: "json",
success: function(data) {
if(data.res=="1"){
var height = '800px';
var width = '1600px';
var index = top.layer.open({
title: false,
type: 2,
content: data.obj,
area: [width, height],
maxmin: false
});
}
},
error: function(e) {
console.log("e", e);
}
});
}
/**
* 单个工程推送
* */
function funProPush(proId,proPushStatus) {
if(proPushStatus != '1'){
$.ajax({
type: 'post',
url: ctxPath + '/projectPush/selectProjectPush',
data: {
proId:proId
},
dataType: 'json',
success: function (data) {
layer.alert(data.obj);
example.ajax.reload();
}
});
}else{
layer.msg("已经推送成功,不能重复推送");
}
}
// 单个工程推送
function buttonProPush(proId, proPushStatus, permission, pers) {
if (permission != "") {
if ($.inArray(permission, pers) < 0) {
return "";
}
}
var btn = $("<button class='layui-btn layui-btn-xs' title='工程推送' onclick='funProPush(\"" + proId + "\",\""+proPushStatus+"\")'>工程推送</button>");
return btn.prop("outerHTML");
}
function buttonAttPush(proId, proPushStatus, permission, pers) {
if (permission != "") {
if ($.inArray(permission, pers) < 0) {
return "";
}
}
var btn = $("<button class='layui-btn layui-btn-xs' title='当日考勤推送' onclick='funAttPush(\"" + proId + "\")'>当日考勤推送</button>");
return btn.prop("outerHTML");
}
function funAttPush(proId) {
var date = getNowTime();
$.ajax({
type: 'post',
url: ctxPath + '/attPush/selectAttendancePush',
data: {
proId : proId,
currentDay : date
},
dataType: 'json',
success: function (data) {
layer.alert(data.obj);
}
});
}
/**
* 获取当日时间
*/
function getNowTime() {
var nowDate = new Date();
var year = nowDate.getFullYear();
var month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() + 1) :
nowDate.getMonth() + 1;
var day = nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate.getDate();
var h =nowDate.getHours();
var m=nowDate.getMinutes();
var s=nowDate.getSeconds();
var dateStr = year + "-" + month + "-" + day;
return dateStr;
}
/**
* 在职/离职人员页面
* 在职/离职人员推送数量页面
* einStatus 在职 or 离职
* isEinPush 是否已推送
* */
function onJobView(proId,einStatus,isEinPush) {
localStorage.setItem("proId", proId);
localStorage.setItem("einStatus", einStatus);
localStorage.setItem("isEinPush", isEinPush);
var index = layer.open({
title: true,
title:["人员信息推送"],
type: 2,
content: './onJobInfoPush.html',
area: ['80%', '96%'],
maxmin: false
});
}
/**
* 合同推送页面
* */
function contractPushView(proId) {
localStorage.setItem("proId", proId);
var index = layer.open({
title: true,
title:["合同信息推送"],
type: 2,
content: './contractInfoPush.html',
area: ['80%', '96%'],
maxmin: false
});
}
/**
* 考勤推送页面
* */
function attendancePushView(proId) {
layer.msg("详情页面开发中。。。");
// localStorage.setItem("proId", proId);
// var index = layer.open({
// title: true,
// title:["合同信息推送"],
// type: 2,
// content: './contractInfoPush.html',
// area: ['80%', '96%'],
// maxmin: 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;
}
/**
* 推送引入标段工程概念,需要重新查工程
* @param form
* @param orgId
*/
function getGroupPro(form,orgId) {
$("#proId").html("");
$.ajax({
type: 'post',
url: ctxPath + '/infoPushs/getGroupPro',
data: {
companyId: orgId
},
async: false,
success: function (data) {
var html = '<option value="">--请选择工程--</option>';
for (var i = 0; i < data.length; i++) {
html += '<option value="' + data[i].id + '">' + data[i].name + '</option>';
}
$("#proId").html(html);
form.render('select');
},
error: function (err) {
console.log("获取工程下拉列表出错:", err);
}
});
}