2025-11-27 16:55:35 +08:00
|
|
|
|
var example = null;
|
|
|
|
|
|
var pers = null;
|
|
|
|
|
|
var layer = null;
|
|
|
|
|
|
var form = null;
|
|
|
|
|
|
$(function () {
|
|
|
|
|
|
layui.use(['layer', 'form'], function () {
|
|
|
|
|
|
layer = layui.layer;
|
|
|
|
|
|
form = layui.form;
|
|
|
|
|
|
getProject(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": {
|
2025-12-09 18:44:29 +08:00
|
|
|
|
"url": "../../../../js/plugin/datatables/Chinese.lang"
|
2025-11-27 16:55:35 +08:00
|
|
|
|
},
|
|
|
|
|
|
"ajax": {
|
2025-12-09 18:44:29 +08:00
|
|
|
|
"url": smz_ht_url + "/dataCount/getContractTeamList",
|
2025-11-27 16:55:35 +08:00
|
|
|
|
"type": "POST",
|
|
|
|
|
|
"data": function (d) {
|
|
|
|
|
|
d.proId = $("#proId").val();
|
|
|
|
|
|
d.contractCode = $("#contractCode").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 () {
|
2025-12-09 18:44:29 +08:00
|
|
|
|
location.href = smz_ht_url + '/login.html';
|
2025-11-27 16:55:35 +08:00
|
|
|
|
});
|
|
|
|
|
|
} 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": "contractCode","orderable": false,'width': '160px'},
|
|
|
|
|
|
{"data": "proName","orderable": false,'width': '150px'},
|
|
|
|
|
|
{"data": "contractAmount","orderable": false,'width': '140px'},
|
|
|
|
|
|
{"data": "totalNum","orderable": false,'width': '140px'},
|
|
|
|
|
|
{"data": "gxNum","orderable": false,'width': '190px',},
|
|
|
|
|
|
{"data": "attDayNum","orderable": false,'width': '150px'},
|
|
|
|
|
|
{
|
|
|
|
|
|
"data": "",
|
|
|
|
|
|
'width': '200px',
|
|
|
|
|
|
"defaultContent": "",
|
|
|
|
|
|
"orderable": false,
|
|
|
|
|
|
"render": function (data, type, row) {
|
|
|
|
|
|
var id = row['id'];
|
|
|
|
|
|
var proId = row['proId'];
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
html += buttonView(id,proId, "", pers);
|
|
|
|
|
|
return html;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
"order": [] //在栏目列上显示排序功能
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查看
|
|
|
|
|
|
* */
|
|
|
|
|
|
function contractView(id,proId) {
|
2025-12-13 17:44:14 +08:00
|
|
|
|
var height = '97.5%';
|
|
|
|
|
|
var width = '97.5%';
|
2025-11-27 16:55:35 +08:00
|
|
|
|
var index = layer.open({
|
|
|
|
|
|
title: ['小包干合同详情','color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
|
|
|
|
|
type: 2,
|
|
|
|
|
|
content: 'contractStatView.html',
|
|
|
|
|
|
area: [width, height],
|
|
|
|
|
|
maxmin: false,
|
|
|
|
|
|
btn: ['关闭'],
|
|
|
|
|
|
success: function (layero, index) {
|
|
|
|
|
|
// 延迟执行,确保 iframe 完全加载
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
var iframe = layero.find("iframe")[0]
|
|
|
|
|
|
if (iframe && iframe.contentWindow && iframe.contentWindow.receiveParamsContract) {
|
|
|
|
|
|
iframe.contentWindow.receiveParamsContract({
|
|
|
|
|
|
id: id,
|
|
|
|
|
|
proId: proId,
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}, 100)
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 详情按钮
|
|
|
|
|
|
function buttonView(id,proId,permission, pers) {
|
|
|
|
|
|
if (permission != "") {
|
|
|
|
|
|
if ($.inArray(permission, pers) < 0) {
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-12-13 17:44:14 +08:00
|
|
|
|
var btn = $("<button class='layui-btn layui-btn-xs' title='详情' onclick='contractView(\""+id+"\",\""+proId+"\")' style='background-color: transparent;color: #009688;'>详情</button>");
|
2025-11-27 16:55:35 +08:00
|
|
|
|
return btn.prop("outerHTML");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function resetContract() {
|
|
|
|
|
|
$('#proId').val('');
|
|
|
|
|
|
$('#contractCode').val('');
|
|
|
|
|
|
// 重新渲染 select 下拉框
|
|
|
|
|
|
layui.form.render("select");
|
|
|
|
|
|
example.ajax.reload();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 导出
|
|
|
|
|
|
*/
|
|
|
|
|
|
function exportBtnOutContract() {
|
|
|
|
|
|
var proId = $("#proId").val();
|
|
|
|
|
|
var contractCode = $("#contractCode").val();
|
2025-12-05 15:39:43 +08:00
|
|
|
|
var token = localStorage.getItem("smz-token");
|
2025-11-27 16:55:35 +08:00
|
|
|
|
var loadingMsg = layer.msg('下载中,请稍候...', {icon: 16, scrollbar: false, time: 0});
|
2025-12-09 18:44:29 +08:00
|
|
|
|
var url = smz_ht_url + "/dataCount/downloadContractTeamExcel?proId=" + proId + "&contractCode=" + contractCode + "&token=" + token;
|
2025-11-27 16:55:35 +08:00
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
|
|
xhr.open("get", url, true);
|
|
|
|
|
|
xhr.responseType = "blob"; // 转换流
|
|
|
|
|
|
xhr.onload = function () {
|
|
|
|
|
|
layer.close(loadingMsg);
|
|
|
|
|
|
if (this.status === 200) {
|
|
|
|
|
|
var blob = this.response;
|
|
|
|
|
|
var a = document.createElement("a");
|
|
|
|
|
|
var url = window.URL.createObjectURL(blob);
|
|
|
|
|
|
a.href = url;
|
|
|
|
|
|
a.download = "合同班组.xlsx"; // 文件名
|
|
|
|
|
|
}else {
|
|
|
|
|
|
layer.msg('发生异常,请稍后重试', {icon: 16, scrollbar: false, time: 2000});
|
|
|
|
|
|
}
|
|
|
|
|
|
a.click()
|
|
|
|
|
|
window.URL.revokeObjectURL(url)
|
|
|
|
|
|
};
|
|
|
|
|
|
xhr.send();
|
2025-12-13 17:44:14 +08:00
|
|
|
|
}
|