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

332 lines
12 KiB
JavaScript
Raw Normal View History

2025-11-27 16:55:35 +08:00
var example = null;
var pers = null;
var proId = localStorage.getItem("proId");
var trueProId = localStorage.getItem("trueProId");
layui.use(['layer', 'laydate', 'form'], function () {
var layer = layui.layer;
var laydate = layui.laydate;
var form = layui.form;
pers = checkPermission();
$("#searchBt").click(function () {
example.ajax.reload();
});
getSubPro(form,proId)
});
/**
* 推送引入标段工程概念需要重新查工程
* @param form
* @param orgId
*/
function getSubPro(form,proId) {
$("#proId").html("");
$.ajax({
type: 'post',
url: ctxPath + '/infoPushs/getSubPro',
data: {
proId: proId
},
async: false,
dataType:"json",
success: function (data) {
var html = '';
for (var i = 0; i < data.length; i++) {
html += '<option value="' + data[i].id + '">' + data[i].name + '</option>';
}
$("#proId").html(html);
form.render('select');
init();
},
error: function (err) {
console.log("获取工程下拉列表出错:", err);
}
});
}
function init() {
example =
$('#dt-table').DataTable({
"sort": false,
"searching": false,
"processing": true, //加载数据时显示进度状态
"serverSide": true,
"language": {
2025-12-02 14:22:34 +08:00
"url": contentPath + "/js/plugin/datatables/Chinese.lang"
2025-11-27 16:55:35 +08:00
},
"ajax": {
"url": ctxPath + "/infoPushs/selectWorkerContract",
"type": "post",
"data": function (d) {
d.proId = $("#proId").val();
d.conPush = $("#conPush").val();
d.keyWord = $("#keyWord").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": "name",width: '6%'},
{"data": "idNumber",width: '8%'},
{"data": "proName",width: '10%'},
{
"data": "",
"defaultContent": "",width: '5%',
"orderable": false,
"render": function (data, type, row) {
var conStatus = row['conStatus'];
var html = '';
if (conStatus == '0') {
html += '<span style="color:#f7a00a;">未签署</span>';
} else if (conStatus == '1') {
html += '<span style="color:green">已签署</span>';
}else{
html += '<span style="color:red"></span>';
}
return html;
}
},
{
"data": "",
"defaultContent": "",width: '5%',
"orderable": false,
"render": function (data, type, row) {
var conPush = row['conPush'];
var html = '';
if (conPush == '0') {
html += '<span style="color:#f7a00a;">未推送</span>';
} else if (conPush == '1') {
html += '<span style="color:green">已推送</span>';
} else if (conPush == '2') {
html += '<span style="color:red">推送失败</span>';
}else{
html += '<span style="color:red"></span>';
}
return html;
}
},
{"data": "conPushTime",width: '8%'},
{
"data": "",
"defaultContent": "",width: '5%',
"orderable": false,
"render": function (data, type, row) {
var conPush = row['conPush'];
var idNumber = row['idNumber'];
var html = '';
let proId = $("#proId").val();;
html += buttonConPush(idNumber,proId, conPush, "", pers); // 合同推送
return html;
}
},
],
"order": [[0, "desc"], [1, "asc"]] //在栏目列上显示排序功能
});
}
function oneConPush(idNumber,proId,comPush) {
if(comPush !== '1'){
$.ajax({
type: 'post',
url: ctxPath + '/contractPush/selectContractPushList',
data: {
idCard:idNumber,
projectId:proId
},
dataType: 'json',
success: function (data) {
alert(data.obj);
example.ajax.reload();
}
})
}else{
layer.msg("已经推送成功,不能重复推送");
}
}
// 合同推送
function buttonConPush(idNumber, proId, comPush, permission, pers) {
if (permission != "") {
if ($.inArray(permission, pers) < 0) {
return "";
}
}
var btn = $("<button class='layui-btn layui-btn-xs' title='合同推送' onclick='oneConPush(\"" + idNumber + "\",\"" + proId + "\",\""+comPush+"\")'>合同推送</button>");
return btn.prop("outerHTML");
}
// 批量推送
function pushAll() {
var idNumber = [];
var proId = [];
var oTable = $('#dt-table').dataTable();
var rowcollection = oTable.$(".checkall:checked", {"page": "all"});
rowcollection.each(function (index, elem) {
var checkbox_value = $(elem).val();
var strArr = checkbox_value.split(",");
idNumber.push(strArr[0]);
proId.push(strArr[1]);
});
if (idNumber.length == 0) {
return layer.msg("请勾选要批量推送的数据", {icon: 2, time: 2000});
}else{
$.ajax({
type: 'post',
url: ctxPath + '/attendancePush/',
traditional:true,
data: {
idNumberList:idNumber,
currentDayList:proId
},
dataType: 'json',
success: function (data) {
}
})
}
}
/**
* 获得当前时间 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;
}
/**
* 获取分公司
* */
function getCompanys(orgId) {
$("#orgId").empty();
$.ajax({
type: 'POST',
url: ctxPath + '/WorkRecord/getCompanys',
data: {},
dataType: 'json',
success: function (data) {
if(data.length>0){
var str = '<option selected value="">请选择分公司</option>';
for(var i = 0; i < data.length; i++) {
if(orgId == data[i].id) {
str += '<option selected value=\'' + data[i].id + '\'>' + data[i].name + '</option>';
} else {
str += '<option value=\'' + data[i].id + '\'>' + data[i].name + '</option>';
}
}
$("#orgId").append(str);
layui.form.render('select'); //这里就是我们要渲染的地方了
}
}
})
}
/**
* 获取工程
* */
function getProject(orgId) {
$("#proId").empty();
$.ajax({
type: 'POST',
url: ctxPath + '/WorkRecord/getProject',
data: {
"comId":orgId,
},
dataType: 'json',
success: function (data) {
if(data.length>0){
var str = '<option selected value="">请选择工程</option>';
for(var i = 0; i < data.length; i++) {
str += '<option value=\'' + data[i].id + '\'>' + data[i].name + '</option>';
}
$("#proId").append(str);
layui.form.render('select'); //这里就是我们要渲染的地方了
}
}
})
}