679 lines
27 KiB
JavaScript
679 lines
27 KiB
JavaScript
var example = null;
|
||
var pers = null;
|
||
var layer,form;
|
||
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": {
|
||
"url": ctxPath + "/js/plugin/datatables/Chinese.lang"
|
||
},
|
||
'scrollY': 'calc(100vh - 150px)',
|
||
'scroller': true,
|
||
'scrollCollapse':true,
|
||
"ajax": {
|
||
"url": ctxPath + "/contract",
|
||
"type": "get",
|
||
"data": function (d) {
|
||
d.proId = $("#proId").val();
|
||
d.keyWord = $("#keyWord").val();
|
||
d.contractStatus = $("#contractStatus").val();
|
||
d.isSmallBag = $("#isSmallBag").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": "proName","width":"15%",},
|
||
{"data": "name"},
|
||
{"data": "idNumber"},
|
||
{
|
||
"data": "",
|
||
"defaultContent": "",
|
||
"orderable": false,
|
||
"render": function (data, type, row) {
|
||
var postName = row['postName'];
|
||
var html = '';
|
||
if(postName != '' && postName != null){
|
||
html += "<span style = 'cursor: pointer'>" + postName + "</span>";
|
||
}else{
|
||
html += "<span style='color: red'>无</span>"
|
||
}
|
||
return html;
|
||
}
|
||
},
|
||
|
||
{
|
||
"data": "wageCriterion",
|
||
"defaultContent": "",
|
||
"orderable": false,
|
||
"render": function (data, type, row) {
|
||
var wageCriterion = row['wageCriterion'];
|
||
var html = '';
|
||
if(wageCriterion != '' && wageCriterion != null){
|
||
html += "<span style = 'cursor: pointer'>" + wageCriterion + "</span>";
|
||
}else{
|
||
html += "<span style='color: red'>无</span>"
|
||
}
|
||
return html;
|
||
}
|
||
},
|
||
|
||
{
|
||
"data": "achievementsMoney",
|
||
"defaultContent": "",
|
||
"orderable": false,
|
||
"render": function (data, type, row) {
|
||
var achievementsMoney = row['achievementsMoney'];
|
||
var html = '';
|
||
if(achievementsMoney != '' && achievementsMoney != null){
|
||
html += "<span style = 'cursor: pointer'>" + achievementsMoney + "</span>";
|
||
}else{
|
||
html += "<span style='color: red'>无</span>"
|
||
}
|
||
return html;
|
||
}
|
||
},
|
||
|
||
{
|
||
"data": "effectDate",
|
||
"defaultContent": "",
|
||
"orderable": false,
|
||
"render": function (data, type, row) {
|
||
var effectDate = row['effectDate'];
|
||
|
||
var html = '';
|
||
if(effectDate != '' && effectDate != null){
|
||
html += "<span style = 'cursor: pointer'>" + effectDate + "</span>";
|
||
}else{
|
||
html += "<span style='color: red'>无</span>"
|
||
}
|
||
return html;
|
||
}
|
||
},
|
||
// {
|
||
// "data": "",
|
||
// "defaultContent": "",
|
||
// "orderable": false,
|
||
// "render": function (data, type, row) {
|
||
// var contractCode = row['contractCode'];
|
||
//
|
||
// var html = '';
|
||
// if(contractCode != '' && contractCode != null){
|
||
// html += "<span style = 'cursor: pointer'>" + contractCode + "</span>";
|
||
// }else{
|
||
// html += "<span style='color: red'>无</span>"
|
||
// }
|
||
// return html;
|
||
// }
|
||
// },
|
||
{
|
||
"data": "",
|
||
"defaultContent": "",
|
||
"orderable": false,
|
||
"render": function (data, type, row) {
|
||
var id = row['id'];
|
||
var contractType = row['contractType'];
|
||
var url = row['url'];
|
||
|
||
var html = '';
|
||
if(contractType != '' && contractType != null){
|
||
html += "<span style = 'cursor: pointer'>" + contractType + "</span>";
|
||
}else{
|
||
html += "<span style='color: red'>无</span>"
|
||
}
|
||
return html;
|
||
}
|
||
},
|
||
{
|
||
"data": "",
|
||
"defaultContent": "",
|
||
"orderable": false,
|
||
"render": function (data, type, row) {
|
||
var id = row['id'];
|
||
var contractType = row['contractType'];
|
||
var idNumber = row['idNumber'];
|
||
var url = row['url'];
|
||
var num = row['num'];
|
||
var html = '';
|
||
if(contractType != '' && contractType != null){
|
||
if(contractType === '纸质合同'){
|
||
html += "<a style = 'color:#09A8F1;cursor: pointer' onclick = 'electronicContractView(\"" + id + "\",\"" + contractType + "\",\"" + idNumber + "\",\"" + url + "\")'>" + num + "</a>";
|
||
}else if(contractType === '电子合同'){
|
||
html += "<a style = 'color:#09A8F1;cursor: pointer' onclick = 'electronicContractView(\"" + id + "\",\"" + contractType + "\",\"" + idNumber + "\",\"" + url + "\")'>点击预览</a>";
|
||
}
|
||
}else{
|
||
html += "<span style='color: red'>无</span>"
|
||
}
|
||
return html;
|
||
}
|
||
},
|
||
|
||
{
|
||
"data": "",
|
||
"defaultContent": "",
|
||
"orderable": false,
|
||
"render": function (data, type, row) {
|
||
var id = row['id'];
|
||
var idNumber = row['idNumber'];
|
||
var jkcnsPath = row['jkcnsPath'];
|
||
var urls = row['urls'];
|
||
var aqcnsPath = row['aqcnsPath'];
|
||
var aqgzsPath = row['aqgzsPath'];
|
||
|
||
var num = 0;
|
||
if(jkcnsPath !="" && jkcnsPath !="null" && jkcnsPath !=null){
|
||
num += 1
|
||
}
|
||
if(urls !="" && urls !="null" && urls !=null){
|
||
num += 1
|
||
}
|
||
if(aqcnsPath !="" && aqcnsPath !="null" && aqcnsPath !=null){
|
||
num += 1
|
||
}
|
||
if(aqgzsPath !="" && aqgzsPath !="null" && aqgzsPath !=null && jkcnsPath !="" && jkcnsPath !="null" && jkcnsPath !=null){
|
||
num += 1
|
||
}
|
||
var html = '';
|
||
if(num != '' && num != null){
|
||
html += "<a style = 'color:#09A8F1;cursor: pointer' onclick = 'acceptanceView(\"" + id + "\",\"" + idNumber + "\")'>" + num + "</a>";
|
||
}else{
|
||
html += "<span style='color: red'>无</span>"
|
||
}
|
||
return html;
|
||
}
|
||
},
|
||
{
|
||
"data": "",
|
||
"defaultContent": "",
|
||
"orderable": false,
|
||
"render": function (data, type, row) {
|
||
var stauts = row['stauts'];
|
||
var miurInsurance = row['miurInsurance'];
|
||
var color;
|
||
// if(miurInsurance == "纸质合同"){
|
||
// stauts = "已签订";
|
||
// }
|
||
if(stauts == "已签订"){
|
||
color = '#9BCB6F';
|
||
}else if(stauts == "未签订"){
|
||
color = '#DD365D';
|
||
}else if(stauts == "待审核"){
|
||
color = '#F7B669';
|
||
}else if(stauts == "待签署"){
|
||
color = '#F7B669';
|
||
}else if(stauts== "无数据"){
|
||
color = '#F7001D';
|
||
}
|
||
var html = "<span style='color:" + color + "'>" + stauts + "</span>";
|
||
return html;
|
||
}
|
||
},
|
||
{
|
||
"data": "",
|
||
"defaultContent": "",
|
||
"orderable": false,
|
||
"render": function (data, type, row) {
|
||
var id = row['id'];
|
||
var idNumber = row['idNumber'];
|
||
var contractType = row['contractType'];
|
||
var status = row['stauts'];
|
||
var proId = row['proId'];
|
||
var html = '';
|
||
if(status != '无数据' && status != '未签订' && status != null){
|
||
//存在但重新上传,合同见证上传
|
||
// html += uploadContractWitness(idNumber,id,proId,"", pers);
|
||
//详情页面
|
||
// html += particularsContractWitness(idNumber,"", pers);
|
||
//纸质合同可以删除
|
||
// if(contractType!="电子合同"){
|
||
// html += buttonDel(idNumber,id,"", pers);
|
||
// }
|
||
}
|
||
if(status == '未签订' && (contractType == '' || contractType == null)){
|
||
//不存在,上传新的合同见证上传
|
||
// html += uploadContractWitness(idNumber,id,proId,"", pers);
|
||
}
|
||
if(status !== '未签订' && status != '无数据' && status != null ){
|
||
html += particularsContractWitness(idNumber,"", pers);
|
||
}
|
||
return html;
|
||
}
|
||
},
|
||
],
|
||
"fnInitComplete":function () {
|
||
// 防止页面闪烁
|
||
$('.table').css('display','');
|
||
//自动调整列宽(自适应)
|
||
let table = $('#dt-table').DataTable();
|
||
table.columns.adjust().draw();
|
||
},
|
||
"order": [[1, "desc"],[2, "desc"],[3, "desc"]] //在栏目列上显示排序功能
|
||
});
|
||
}
|
||
//查看电子合同详情
|
||
function electronicContractView(id,contractType,idNumber,url){
|
||
let height = getDefaultHeight().toFixed(0) + 'px';
|
||
let width = getDefaultWidth().toFixed(0) + 'px';
|
||
localStorage.setItem("idNumber", idNumber);
|
||
localStorage.setItem("url", url);
|
||
localStorage.setItem("id", id);
|
||
if(contractType=="电子合同"){
|
||
var index = layer.open({
|
||
title: ["查看", 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
||
type: 2,
|
||
content: 'contractTypeView.html',
|
||
area: [width, height],
|
||
maxmin: false,
|
||
});
|
||
}else{
|
||
let layerIndex = layer.open({
|
||
id: 'layer-contract-signing-detail',
|
||
title: ['合同见证', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
||
type: 2,
|
||
content: 'contractPhoto.html',
|
||
area: [width, height],
|
||
maxmin: false,
|
||
shadeClose: false, //开启遮罩关闭
|
||
shade: 0.3, //显示遮罩
|
||
move: false,
|
||
resize: false,
|
||
success:function(layero,index){
|
||
let iframeWin = window["layui-layer-iframe" + layerIndex];
|
||
iframeWin.setParam(id,idNumber);
|
||
$(window).resize(function () {
|
||
if (autoResizeWidth) autoResizeWidth(index);
|
||
if (autoResizeHeight) autoResizeHeight(index);
|
||
})
|
||
},
|
||
});
|
||
}
|
||
}
|
||
|
||
function acceptanceView(id,idNumber) {
|
||
localStorage.setItem("id",id);
|
||
localStorage.setItem("idNumber",idNumber);
|
||
let height ="80%";
|
||
let width = "80%";
|
||
var index = layer.open({
|
||
title: ["查看", 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
||
type: 2,
|
||
content: 'acceptanceView.html',
|
||
area: [width, height],
|
||
maxmin: false,
|
||
});
|
||
}
|
||
|
||
|
||
|
||
//详情页面
|
||
function particularsContractWitness(idNumber, permission, pers){
|
||
if (permission != "") {
|
||
if ($.inArray(permission, pers) < 0) {
|
||
return "";
|
||
}
|
||
}
|
||
var btn = $("<button class='layui-btn layui-btn-xs' title='合同签订信息' onclick='particularsContractWitnessPage(\""+idNumber+"\")'>合同签订信息</button>");
|
||
return btn.prop("outerHTML");
|
||
}
|
||
|
||
//合同签订信息
|
||
function particularsContractWitnessPage(idNumber) {
|
||
localStorage.setItem("idNumber", idNumber);
|
||
let height = getDefaultHeight().toFixed(0) + 'px';
|
||
let width = getDefaultWidth().toFixed(0) + 'px';
|
||
var layerIndex = layer.open({
|
||
id: 'layer-contract-signing-infor',
|
||
title: ['合同签订信息', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
||
content: './contractSingletonList.html',
|
||
area: [width, height],
|
||
type: 2,
|
||
maxmin: false,
|
||
shadeClose: false, //开启遮罩关闭
|
||
shade: 0.3, //显示遮罩
|
||
move: false,
|
||
resize: false,
|
||
btn: ['关闭'],
|
||
success:function(layero,index){
|
||
let iframeWin = window["layui-layer-iframe" + layerIndex];
|
||
iframeWin.setParam(idNumber);
|
||
$(window).resize(function () {
|
||
if (autoResizeWidth) autoResizeWidth(index);
|
||
if (autoResizeHeight) autoResizeHeight(index);
|
||
})
|
||
},
|
||
btn2: function (index, layero) {
|
||
}
|
||
});
|
||
}
|
||
|
||
//合同见证上传
|
||
function uploadContractWitness(idNumber, id,proId, permission, pers){
|
||
if (permission != "") {
|
||
if ($.inArray(permission, pers) < 0) {
|
||
return "";
|
||
}
|
||
}
|
||
var btn = $("<button class='layui-btn layui-btn-xs' title='合同见证上传' onclick='uploadContractWitnessView(\""+idNumber+"\",\""+id+"\",\""+proId+"\")'>合同见证上传</button>");
|
||
return btn.prop("outerHTML");
|
||
}
|
||
|
||
// 合同见证上传
|
||
function uploadContractWitnessView(idNumber,id,proId) {
|
||
// 前台生成合同见证id
|
||
let contractId = getUuid();
|
||
//以前有合同,则须通过id删除,并添加新的。无合同删除用-1
|
||
if(id!==null && id!=='null'){
|
||
let confirm = layer.confirm("合同见证已存在,是否删除然并重新上传?",{shade:0},function () {
|
||
openContractWitnessFormHtml(idNumber,id,proId,contractId);
|
||
})
|
||
}else{
|
||
openContractWitnessFormHtml(idNumber,id,proId,contractId);
|
||
}
|
||
}
|
||
|
||
function openContractWitnessFormHtml(idNumber,id,proId,contractId) {
|
||
let height = getDefaultHeight2().toFixed(0) + 'px';
|
||
let width = getDefaultWidth2().toFixed(0) + 'px';
|
||
let layerIndex = layer.open({
|
||
title: false,
|
||
type: 1,
|
||
id: 'layer-choose-checker',
|
||
maxmin: false,
|
||
shade: 0.1,
|
||
shadeClose: false, //开启遮罩关闭
|
||
content: chooseSignTypeHtml(idNumber,id,proId,contractId),
|
||
area: [width, height],
|
||
move: false,
|
||
success: function (layero, index) {
|
||
$(window).resize(function () {
|
||
if (autoResizeWidth2) {
|
||
autoResizeWidth2(index);
|
||
}
|
||
if (autoResizeHeight2) {
|
||
autoResizeHeight2(index);
|
||
}
|
||
})
|
||
},
|
||
cancel : function() {
|
||
layer.closeAll();
|
||
}
|
||
});
|
||
}
|
||
|
||
function chooseSignTypeHtml(idNumber,id,proId,contractId) {
|
||
return '<div style="width: 100%;height: 100%;display: flex;align-items: center;justify-content: space-between;flex-direction: column;padding: 15%;">' +
|
||
'<p style="font-size: 23px;font-weight: bold;">请选择签订的合同模板</p>' +
|
||
'<a style="font-size: 23px;font-weight: bold;color: #2AAAF0;text-decoration: underline;cursor: pointer;" onclick="choosePersonnelType(1,\''+idNumber+'\',\''+id+'\',\''+proId+'\',\''+contractId+'\')">附件1-1-劳动合同书(普通人员)</a>' +
|
||
'<a style="font-size: 23px;font-weight: bold;color: #2AAAF0;text-decoration: underline;cursor: pointer;" onclick="choosePersonnelType(2,\''+idNumber+'\',\''+id+'\',\''+proId+'\',\''+contractId+'\')">附件1-2-劳动合同书(班组长)</a>' +
|
||
'</div>';
|
||
}
|
||
|
||
// 1、普通人员;2班组长
|
||
function choosePersonnelType(value,idNumber,id,proId,contractId) {
|
||
let title = '合同见证上传(普通人员)';
|
||
if(value === 2){
|
||
title = '合同见证上传(班组长)';
|
||
}
|
||
let height = getDefaultHeight().toFixed(0) + 'px';
|
||
let width = getDefaultWidth().toFixed(0) + 'px';
|
||
let layerIndex = layer.open({
|
||
id: 'layer_Personnel_add',
|
||
title: [title, 'color:#3A81AD;font-size:22px;background-color:#eee;'],
|
||
type: 2,
|
||
content: 'contractWitnessForm.html',
|
||
area: [width, height],
|
||
maxmin: false,
|
||
shadeClose: false, //开启遮罩关闭
|
||
shade: 0.3, //显示遮罩
|
||
move: false,
|
||
resize: false,
|
||
success: function (layero, index) {
|
||
let iframeWin = window["layui-layer-iframe" + layerIndex];
|
||
iframeWin.setParam(value,idNumber,id === 'null' ? '-1':id,proId,contractId);
|
||
$(window).resize(function () {
|
||
if (autoResizeWidth) {
|
||
autoResizeWidth(index);
|
||
}
|
||
if (autoResizeHeight) {
|
||
autoResizeHeight(index);
|
||
}
|
||
})
|
||
},
|
||
cancel : function() {
|
||
layer.closeAll();
|
||
}
|
||
});
|
||
}
|
||
|
||
// 删除按钮
|
||
function buttonDel(idNumber,id, permission, pers){
|
||
|
||
if(permission != ""){
|
||
if ($.inArray(permission, pers) < 0) {
|
||
return "";
|
||
}
|
||
}
|
||
var btn = $("<button class='layui-btn layui-btn-xs' title='删除' onclick='del(\"" + idNumber +"\",\""+id+"\")'><i class='layui-icon'></i></button>");
|
||
return btn.prop("outerHTML");
|
||
}
|
||
|
||
/**
|
||
* 删除用户
|
||
* */
|
||
function del(idNumber,id) {
|
||
layer.confirm("确定删除吗?",function () {
|
||
$.ajax({
|
||
type: 'post',
|
||
url: ctxPath + '/contract/delContract',
|
||
data: {idNumber:idNumber,delId:id},
|
||
dataType: 'json',
|
||
success: function (data) {
|
||
if (data.resMsg == "删除成功") {
|
||
layer.alert('删除成功', {icon: 1});
|
||
example.ajax.reload(); // 刷新页面
|
||
} else {
|
||
layer.msg("删除失败", {icon: 2});
|
||
example.ajax.reload(); // 刷新页面
|
||
}
|
||
}
|
||
})
|
||
})
|
||
}
|
||
|
||
function getUuid() {
|
||
var s = [];
|
||
var hexDigits = "0123456789abcdef";
|
||
for (var i = 0; i < 36; i++) {
|
||
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
|
||
}
|
||
s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
|
||
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
|
||
s[8] = s[13] = s[18] = s[23] = "-";
|
||
var rep = "-";
|
||
var uuid = s.join("").replace(new RegExp(rep,'gm'),'');
|
||
return uuid;
|
||
}
|
||
|
||
// 子页面调用的刷新父页面方法
|
||
function reloadData() {
|
||
example.ajax.reload( null, false);
|
||
}
|
||
|
||
//合同见证上传
|
||
// function uploadContractWitnessView(idNumber,id) {
|
||
// var contractId = getUuid();
|
||
// //以前有合同,则须通过id删除,并添加新的。无合同删除用-1
|
||
// if(id!==null && id!=='null'){
|
||
// let confirm = layer.confirm("合同见证已存在,是否删除然并重新上传?",function () {
|
||
// localStorage.setItem("idNumber", idNumber);
|
||
// localStorage.setItem("delId", id);
|
||
// localStorage.setItem("contractId", contractId);
|
||
// layer.close(confirm);
|
||
// var height = '700px';
|
||
// var width = '1300px';
|
||
// var index = layer.open({
|
||
// title: ['合同见证上传','color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
||
// type: 2,
|
||
// content: 'contractSignUploadFrom.html',
|
||
// area: [width, height],
|
||
// maxmin: false
|
||
// });
|
||
// })
|
||
// }else{
|
||
// localStorage.setItem("idNumber", idNumber);
|
||
// localStorage.setItem("delId", "-1");
|
||
// localStorage.setItem("contractId", contractId);
|
||
// var height = '700px';
|
||
// var width = '1300px';
|
||
// var index = layer.open({
|
||
// title: ['合同见证上传','color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
||
// type: 2,
|
||
// content: 'contractSignUploadFrom.html',
|
||
// area: [width, height],
|
||
// maxmin: false
|
||
// });
|
||
// }
|
||
//
|
||
//
|
||
//
|
||
// }
|
||
|
||
/**
|
||
* 导出数据
|
||
*/
|
||
function exportBtns() {
|
||
var token = localStorage.getItem("token");
|
||
var proId = $("#proId").val();
|
||
var keyWord = $("#keyWord").val();
|
||
var contractStatus = $("#contractStatus").val();
|
||
var index = top.layer.msg('数据较多,请稍等。。。', {
|
||
icon: 4,
|
||
time: 5000 //2秒关闭(如果不配置,默认是3秒)
|
||
});
|
||
window.location.href = ctxPath + "/contract/exportList?keyWord=" + keyWord + "&contractStatus=" + contractStatus +
|
||
"&proId=" + proId +"&token=" + token;
|
||
}
|
||
|
||
/**
|
||
* 下载
|
||
*/
|
||
var BATCH_SIZE = 5; // 每次下载的文件数量
|
||
var DELAY_TIME = 1000; // 批次之间的延迟时间(毫秒)
|
||
function downloads() {
|
||
var token = localStorage.getItem("token");
|
||
var proId = $("#proId").val();
|
||
var keyWord = $("#keyWord").val();
|
||
var contractStatus = $("#contractStatus").val();
|
||
var loadingMsg = layer.msg('下载中,请稍候...', {icon: 16, scrollbar: false, time: 0});
|
||
$.ajax({
|
||
type: 'post',
|
||
url: ctxPath + '/contract/downloadsPDF',
|
||
data: {proId:proId,keyWord:keyWord,contractStatus:contractStatus},
|
||
dataType: 'json',
|
||
success: function (data) {
|
||
// console.log(data);
|
||
if (data.resMsg == "数据获取成功") {
|
||
var data = data.obj.data;
|
||
|
||
|
||
downloadBatch(data, 0, BATCH_SIZE);
|
||
|
||
// layer.alert('数据获取成功', {icon: 1});
|
||
// example.ajax.reload(); // 刷新页面
|
||
} else {
|
||
layer.msg(data.resMsg, {icon: 2});
|
||
example.ajax.reload(); // 刷新页面
|
||
}
|
||
layer.close(loadingMsg);
|
||
}, error: function (err) {
|
||
layer.close(loadingMsg);
|
||
layer.msg("数据获取失败", {icon: 2});
|
||
console.log("err", err);
|
||
}
|
||
})
|
||
}
|
||
|
||
function downloadBatch(data, startIndex, endIndex) {
|
||
for (var i = startIndex; i < endIndex && i < data.length; i++) {
|
||
if (data[i].contractType === '电子合同') {
|
||
setParamPDFs(data[i].url, data[i].name);
|
||
}
|
||
}
|
||
// 如果还有更多文件需要下载,设置下一个批次的延迟
|
||
if (endIndex < data.length) {
|
||
setTimeout(function() {
|
||
downloadBatch(data, endIndex, endIndex + BATCH_SIZE);
|
||
}, DELAY_TIME);
|
||
}
|
||
}
|