266 lines
8.1 KiB
Plaintext
266 lines
8.1 KiB
Plaintext
|
|
let table, form, layer, util;
|
|||
|
|
let teamId = ''
|
|||
|
|
let pageNum = 1, limitSize = 30; // 默认第一页,分页数量为10
|
|||
|
|
function setForm(obj) {
|
|||
|
|
console.log(obj);
|
|||
|
|
teamId = obj;
|
|||
|
|
$(function () {
|
|||
|
|
layui.use(['layer', 'form', 'table', 'util'], function () {
|
|||
|
|
layer = layui.layer;
|
|||
|
|
form = layui.form;
|
|||
|
|
table = layui.table;
|
|||
|
|
form.render();
|
|||
|
|
util = layui.util;
|
|||
|
|
util.event('lay-active', {
|
|||
|
|
query: function () {
|
|||
|
|
pages(1, limitSize);
|
|||
|
|
},
|
|||
|
|
reset: function () {
|
|||
|
|
$('#keyword').val('');
|
|||
|
|
$('#name').val('');
|
|||
|
|
$('#card').val('');
|
|||
|
|
$('#type').val('');
|
|||
|
|
form.render();
|
|||
|
|
pages(1, limitSize);
|
|||
|
|
},
|
|||
|
|
export: function () {
|
|||
|
|
exportData();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
getSelectParams();
|
|||
|
|
pages(1, 30, 1);
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
function pages(pageNum, pageSize) {
|
|||
|
|
let params = getReqParams(pageNum, pageSize);
|
|||
|
|
$.ajax({
|
|||
|
|
headers: {
|
|||
|
|
"encrypt": sm3(JSON.stringify(params))
|
|||
|
|
},
|
|||
|
|
url: dataUrl + "proteam/pot/team/getTeamPeople?token=" + token,
|
|||
|
|
data: params,
|
|||
|
|
type: 'POST',
|
|||
|
|
async: false,
|
|||
|
|
success: function (result) {
|
|||
|
|
if (result.code === 200) {
|
|||
|
|
if (result.rows) {
|
|||
|
|
initTable(result.rows, limitSize, pageNum)
|
|||
|
|
laypages(result.total, pageNum, limitSize)
|
|||
|
|
}
|
|||
|
|
} 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) {
|
|||
|
|
table.render({
|
|||
|
|
elem: "#personnelTable",
|
|||
|
|
id: "personnelTable",
|
|||
|
|
height: "full-130",
|
|||
|
|
data: dataList,
|
|||
|
|
cols: [
|
|||
|
|
[//表头
|
|||
|
|
{
|
|||
|
|
field: "number",
|
|||
|
|
type: "numbers",
|
|||
|
|
title: "序号",
|
|||
|
|
width: 100,
|
|||
|
|
unresize: true,
|
|||
|
|
sort: true,
|
|||
|
|
align: "center",
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: "teamName",
|
|||
|
|
title: "班组名称",
|
|||
|
|
unresize: true,
|
|||
|
|
sort: true,
|
|||
|
|
minWidth: 80,
|
|||
|
|
align: "center"
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: 'type',
|
|||
|
|
title: "工种",
|
|||
|
|
unresize: true,
|
|||
|
|
sort: true,
|
|||
|
|
minWidth: 80,
|
|||
|
|
align: "center"
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: "name",
|
|||
|
|
title: "姓名",
|
|||
|
|
minWidth: 80,
|
|||
|
|
unresize: true,
|
|||
|
|
sort: true,
|
|||
|
|
align: "center"
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: "age",
|
|||
|
|
title: "年龄",
|
|||
|
|
unresize: true,
|
|||
|
|
sort: true,
|
|||
|
|
minWidth: 80,
|
|||
|
|
align: "center"
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: "photo",
|
|||
|
|
title: "照片",
|
|||
|
|
unresize: true,
|
|||
|
|
sort: true,
|
|||
|
|
minWidth: 100,
|
|||
|
|
align: "center",
|
|||
|
|
templet: function (d) {
|
|||
|
|
if (!isEmpty(d.photo)) {
|
|||
|
|
return '<img src=' + d.photo + ' width="50px" height="50px" alt=""/>'
|
|||
|
|
|
|||
|
|
} else {
|
|||
|
|
return '<img src="../../../img/peopleSign.png" width="50px" height="50px" alt=""/>'
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: "card",
|
|||
|
|
title: "身份证号",
|
|||
|
|
unresize: true,
|
|||
|
|
sort: true,
|
|||
|
|
minWidth: 200,
|
|||
|
|
align: "center"
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
{
|
|||
|
|
field: "achievement",
|
|||
|
|
title: "考试准入成绩",
|
|||
|
|
unresize: true,
|
|||
|
|
sort: true,
|
|||
|
|
minWidth: 100,
|
|||
|
|
align: "center"
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: "examination",
|
|||
|
|
title: "体检",
|
|||
|
|
unresize: true,
|
|||
|
|
sort: true,
|
|||
|
|
minWidth: 80,
|
|||
|
|
align: "center"
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: "insurance",
|
|||
|
|
title: "保险",
|
|||
|
|
unresize: true,
|
|||
|
|
sort: true,
|
|||
|
|
minWidth: 80,
|
|||
|
|
align: 'center'
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
{
|
|||
|
|
field: "points",
|
|||
|
|
title: "累计扣分",
|
|||
|
|
unresize: true,
|
|||
|
|
sort: true,
|
|||
|
|
minWidth: 80,
|
|||
|
|
align: 'center'
|
|||
|
|
}
|
|||
|
|
],
|
|||
|
|
],
|
|||
|
|
limit: limit
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
// 获取参数
|
|||
|
|
function getReqParams(page, limit) {
|
|||
|
|
let obj = {
|
|||
|
|
pageNum: page + "",
|
|||
|
|
pageSize: limit + "",
|
|||
|
|
teamId: teamId+"",
|
|||
|
|
keyWord: $('#keyword').val(),
|
|||
|
|
name: $('#name').val(),
|
|||
|
|
card: $('#card').val(),
|
|||
|
|
type: transformNull($('#type').val())
|
|||
|
|
};
|
|||
|
|
return obj;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//导出
|
|||
|
|
function exportData() {
|
|||
|
|
let loadingMsg = layer.msg("数据导出中,请稍候...", {icon: 16, scrollbar: false, time: 0,});
|
|||
|
|
let url = dataUrl + "proteam/pot/team/exportTeamPeopleData?" + setData(getReqParams(pageNum, limitSize)) + '&token=' + token;
|
|||
|
|
let xhr = new XMLHttpRequest();
|
|||
|
|
xhr.open("get", url, true);
|
|||
|
|
xhr.responseType = "blob"; // 转换流
|
|||
|
|
xhr.setRequestHeader("encrypt",
|
|||
|
|
sm3(JSON.stringify(
|
|||
|
|
getReqParams(pageNum, limitSize)
|
|||
|
|
)));
|
|||
|
|
xhr.onload = function () {
|
|||
|
|
layer.close(loadingMsg);
|
|||
|
|
if (this.status === 200) {
|
|||
|
|
let url = window.URL.createObjectURL(new Blob([this.response]))
|
|||
|
|
let link = document.createElement('a')
|
|||
|
|
link.style.display = 'none'
|
|||
|
|
link.href = url
|
|||
|
|
link.setAttribute('download', "班组人员信息.xlsx")
|
|||
|
|
document.body.appendChild(link)
|
|||
|
|
link.click()
|
|||
|
|
// 释放URL对象所占资源
|
|||
|
|
window.URL.revokeObjectURL(url)
|
|||
|
|
// 用完即删
|
|||
|
|
document.body.removeChild(link)
|
|||
|
|
} else {
|
|||
|
|
layer.msg("数据发生异常,请稍后重试", {icon: 16, scrollbar: false, time: 2000});
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
xhr.send();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//组织机构下拉选
|
|||
|
|
function getSelectParams() {
|
|||
|
|
$.ajax({
|
|||
|
|
headers: {
|
|||
|
|
"encrypt": sm3(JSON.stringify({
|
|||
|
|
code: 'people_type'
|
|||
|
|
}))
|
|||
|
|
},
|
|||
|
|
url: dataUrl + 'proteam/pot/team/getSelectParams' + '?token=' + token,
|
|||
|
|
type: 'post',
|
|||
|
|
data: {
|
|||
|
|
code: 'people_type'
|
|||
|
|
},
|
|||
|
|
success: function (data) {
|
|||
|
|
let html = '<option value="" selected>全部</option>';
|
|||
|
|
$.each(data.data, function (index, item) {
|
|||
|
|
html += '<option value="' + item.key + '">' + item.value + '</option>';
|
|||
|
|
})
|
|||
|
|
$('#type').empty().append(html);
|
|||
|
|
form.render();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|