IntelligentRecognition/ah-jjsp-web/.svn/pristine/78/784584ed91f1b6c200b05d0f0fb...

288 lines
9.1 KiB
Plaintext
Raw Permalink 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.

let form, layer, table, user = getUser();
let pageNum = 1, limitSize = 30; // 默认第一页分页数量为15
layui.use(['form', 'layer', 'table'], function () {
form = layui.form;
layer = layui.layer;
table = layui.table;
pages(1, 30, 1);
})
function pages(pageNum, pageSize, typeNum) {
let params = getReqParams(pageNum, pageSize, typeNum);
$.ajax({
headers: {
"encrypt": sm3(JSON.stringify(params))
},
url: dataUrl + "proteam/pot/admittedPerson/getAdmittedPersonList?token=" + token,
data: params,
type: 'POST',
async: false,
success: function (result) {
if (result.code === 200) {
if (result.data) {
initTable(result.data, result.limit, result.curr)
laypages(result.count, result.curr, result.limit)
}
} else if (result.code === 500) {
layer.alert(result.msg, {icon: 2})
} else if (result.code === 401) {
logout(1);
}
}, error: function () {
}
});
}
function laypages(total, page, limit) {
layui.use(['laypage'], function () {
let laypage = layui.laypage;
laypage.render({
elem: 'voi-page',
count: total,
curr: page,
limit: limit,
limits: [30,50,100],
layout: ['prev', 'page', 'next', 'skip', 'count', 'limit'],
groups: 5,
jump: function (obj, first) {
if (!first) {
pageNum = obj.curr, limitSize = obj.limit;
pages(obj.curr, obj.limit, null);
}
}
});
})
}
/*初始化表格*/
function initTable(dataList, limit, page) {
let loadingMsg = layer.msg("数据加载中,请稍候...", {icon: 16, scrollbar: false, time: 0,});
tableIns = table.render({
elem: "#dutyStatisticTable",
height: "full-120",
data: dataList,
limit: limit,
cols: [
[
//表头
{
title: "序号",
width: 80,
unresize: true,
align: "center",
templet: function (d) {
return (page - 1) * limit + d.LAY_INDEX;
}
},
{
field: "userName",
title: "姓名",
unresize: true,
align: "center",
sort: true
},
{
field: "sex",
title: "性别",
unresize: true,
align: "center",
sort: true
},
{
field: "mz",
title: "民族",
unresize: true,
align: "center",
sort: true
},
{
field: "idNumber",
title: "身份证号",
unresize: true,
align: "center",
sort: true
},
{
field: "szr",
title: "三种人身份",
unresize: true,
align: "center",
sort: true
},
{
field: "zrCityName",
title: "准入地市名称",
unresize: true,
align: "center",
sort: true
},
{
title: "操作",
width: 140,
unresize: false,
sort: true,
align: "center",
templet: function (d) {
return '<div style="width: 80px;height: 80px;line-height:80px;cursor: pointer;color: #2F82FB" ' +
'onclick="openImg(\'' + d.id + '\')"><span>资质图片</span></div>';
}
},
],
],
done: function (res, curr, count) {
layer.close(loadingMsg);
table.resize("dutyStatisticTable");
count || this.elem.next(".layui-table-view").find(".layui-table-header").css("display", "inline-block");
count || this.elem.next(".layui-table-view").find(".layui-table-box").css("overflow", "auto");
},
});
}
// 获取参数
function getReqParams(page, limit, type) {
let obj = {};
if (!type) {
obj = {
page: page + "",
limit: limit + "",
keyWord: $("#keyWord").val()
};
} else {
obj = {
page: '1',
limit: '30',
keyWord: ''
};
}
return obj;
}
/*导出*/
function exportData() {
let checkUser = $("#checkUser").val(),
createTime = $("#createTime").val(),
currentUserId = user.userId + '',
isSup = user.isSup;
let loadingMsg = layer.msg("数据导出中,请稍候...", {icon: 16, scrollbar: false, time: 0,});
let url = dataUrl + "proteam/pot/dutyStatistics/exportData?checkUser=" + checkUser + "&createTime="
+ createTime + "&currentUserId=" + currentUserId + "&isSup=" + isSup + "&token=" + token;
let xhr = new XMLHttpRequest();
xhr.open("get", url, true);
xhr.responseType = "blob"; // 转换流
xhr.setRequestHeader("encrypt",
sm3(JSON.stringify({
checkUser: checkUser,
createTime: createTime,
currentUserId: currentUserId,
isSup: isSup,
})));
xhr.onload = function () {
layer.close(loadingMsg);
if (this.status === 200) {
let blob = this.response;
var a = document.createElement("a");
var url = window.URL.createObjectURL(blob);
a.href = url;
a.download = "值班统计" + getNowDate() + ".xlsx"; // 文件名
} else {
layer.msg("数据发生异常,请稍后重试", {icon: 16, scrollbar: false, time: 2000});
}
a.click();
window.URL.revokeObjectURL(url);
};
xhr.send();
}
// 查询/重置
function query() {
let pattern = new RegExp("[%_<>]");
if (pattern.test($("#checkUser").val())) {
$("#checkUser").val('');
return layer.msg('值班员查询包含特殊字符,请重新输入', {
icon: 2,
time: 2000 //2秒关闭如果不配置默认是3秒
});
}
pageNum = 1;
pages(1, limitSize);
}
/*人员照片*/
function openImg(id) {
let width = getChooseWidth().toFixed(0) + "px";
let height = getChooseHeight().toFixed(0) + "px";
let layerIndex = layer.open({
id: "voiImg",
title: ['<div style="border-left: 3px solid #2F82FB;display: flex;align-items: center;height: 20px;padding: 0 10px;">资质照片</div>', 'font-size:16px;background-color:#f0f0f0;display: flex;align-items: center;'],
type: 1,
maxmin: false,
content: setHtml(id),
area: [width, height],
move: false,
shade: 0.1,
success: function (layero, index) {
let viewer = new Viewer(document.getElementById('main-box'), {
url: 'data-original',
show: function () {
viewer.update();
}
});
$(window).resize(function () {
if (autoChooseResizeWidth) autoChooseResizeWidth(index);
if (autoChooseResizeHeight) autoChooseResizeHeight(index);
});
},
});
}
function setHtml(id) {
let imgList = getSGRYImgListAjax(id);
let html = '<div id="main-box" class="layout">';
if(imgList.length > 0){
$.each(imgList, function (index, item) {
let path = '../../img/notPhoto.png';
if(item.base64Url){
path = item.base64Url;
html += '<div class="person-img layout"><img src="' + path + '" data-original = "' + path + '"><p>'+item.imgType+'</p></div>'
}else{
html += '<div class="person-img layout"><img src="' + path + '" data-original = "' + path + '"><p>'+item.imgType+'</p></div>'
}
})
}
html += '</div>';
return html;
}
// 获取人员相关的照片
function getSGRYImgListAjax(id) {
let imgList = [];
$.ajax({
headers: {
"encrypt": sm3(JSON.stringify({
id: id
}))
},
url: dataUrl + 'proteam/pot/admittedPerson/getSGRYImgList?token=' + token,
data: {
id: id
},
type: 'POST',
async: false,
success: function (result) {
console.log(result)
if (result.code === 200) {
if (result.data) {
imgList = result.data;
}
} else if (result.code === 500) {
layer.alert(result.msg, {icon: 2})
} else if (result.code === 401) {
logout(1);
}
}
});
return imgList;
}