IntelligentRecognition/ah-jjsp-web/.svn/pristine/87/8785f0383be35097d9e17221a66...

428 lines
14 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, tableIns, idParam;
let pageNum = 1, limitSize = 15; // 默认第一页分页数量为15
layui.use(['form', 'layer', 'table'], function () {
form = layui.form;
layer = layui.layer;
table = layui.table;
pages(1, 15, 1);
$('#myModal_edit').on('show.bs.modal', centerModals);
form.on('submit(model)', function (data) {
let params = {
idNumber: $('#id').val(),
peopleStatus: data.field.peopleStatus
}
editPeopleStatusAjax(params);
return false;
});
})
function pages(pageNum, pageSize, typeNum) {
let params = getReqParams(pageNum, pageSize, typeNum);
$.ajax({
headers: {
"encrypt": sm3(JSON.stringify(params))
},
url: dataUrl + "proteam/pot/workPermit/getBackboneScoreList?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: [15, 20, 50, 100, 200, 500],
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: "#viobBasisTable",
id: "viobBasisTable",
height: "full-150",
data: dataList,
limit: limit,
cols: [
[
{
type: 'checkbox',
unresize: true,
width: 60,
align: "center",
},
//表头
{
title: "序号",
width: '100',
unresize: true,
align: "center",
templet: function (d) {
return (page - 1) * limit + d.LAY_INDEX;
}
},
{
field: "userName",
title: "姓名",
width: '235',
unresize: true,
align: "center",
sort: true
},
{
field: "idNumber",
title: "身份证号",
width: '240',
unresize: true,
align: "center",
sort: true
},
{
field: "score",
title: "考试成绩",
width: '230',
unresize: true,
align: "center",
sort: true
},
{
field: "qualified",
title: "合格状态",
width: '230',
unresize: true,
align: "center",
sort: true
},
{
field: "peopleType",
title: "人员",
width: '230',
unresize: true,
align: "center",
sort: true
},
{
field: "peopleStatus",
title: "状态",
width: '230',
unresize: true,
align: "center",
sort: true
},
{
title: "操作",
width: '300',
unresize: true,
align: "center",
templet: function (d) {
return "<a onclick=\"editData('" + d.idNumber + "','" + d.peopleStatus + "')\">编辑状态</a>" +
"<div>|</div><a onclick=\"addOrEditData('" + d.idNumber + "')\">编辑</a>" +
"<div>|</div><a onclick=\"delData('" + d.idNumber + "')\">删除</a>";
}
}
],
],
done: function (res, curr, count) {
layer.close(loadingMsg);
$(".layui-laypage-skip").css("display", "none");
table.resize("viobBasisTable");
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 + "",
userName: $("#userName").val(),
idNumber: $("#idNumber").val(),
qualified: $("#qualified").val(),
peopleStatus: $("#peopleStatus").val(),
};
} else {
obj = {
page: '1',
limit: '15',
userName: '',
idNumber: '',
qualified: '',
peopleStatus: ''
};
}
return obj;
}
// 编辑状态
function editData(idNumber, peopleStatus) {
let index = layer.open({
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,
shade: 0.1,
shadeClose: false,
content: addContent(),
area: ["550px", "330px"],
move: false,
success: function (layero, index) {
$(layero).find('#peopleStatus').val(peopleStatus)
$(layero).find('#id').val(idNumber)
layui.form.render();
}
});
}
// 编辑状态html
function addContent() {
let html = '<div class="add-form layui-form" style="padding-top: 3%">' +
'<form class="layui-form" action="#" onsubmit="return false;">' +
'<input id="id" hidden>' +
'<div class="layui-form-item" style="margin-left: 10%;">' +
'<label class="layui-form-label">状态</label>' +
'<div class="layui-inline" style="width: 255px;">' +
'<select id="peopleStatus" name="peopleStatus" class="layui-select">' +
'<option value="正常">正常</option>' +
'<option value="重点关注">重点关注</option>' +
'<option value="拉黑">拉黑</option>' +
'<option value="冻结">冻结</option>' +
'</select>' +
'</div>' +
'</div>' +
'<div class="layui-form-item" style="padding-left: 0%;margin-top: 28%;margin-left: 44%;justify-content: center;">' +
'<button type="button" class="layui-btn layui-btn-normal" lay-submit = "" lay-filter="model" id="save">确定</button>' +
'</div>' +
'</form>' +
'</div>';
layui.form.render();
return html;
}
// 编辑状态-ajax请求
function editPeopleStatusAjax(params) {
let loadingMsg = layer.msg('数据上传中,请稍候...', {icon: 16, scrollbar: false, time: 0});
$.ajax({
headers: {
"encrypt": sm3(JSON.stringify(params))
},
url: dataUrl + 'proteam/pot/workPermit/editPeopleStatus?token=' + token,
type: 'POST',
data: params,
dataType: 'json',
beforeSend: function () {
$('#save').removeClass("layui-btn-disabled").attr("disabled", true);
},
success: function (result) {
layer.close(loadingMsg); // 关闭提示层
if (result.code === 200) {
parent.layer.msg(result.msg, {icon: 1});
layer.closeAll();
reloadData();
} else if (result.code === 500) {
layer.alert(result.msg, {icon: 2})
$('#save').removeClass("layui-btn-disabled").attr("disabled", false);
} else if (result.code === 401) {
logout(1)
}
},
error: function (result) {
layer.close(loadingMsg); // 关闭提示层
layer.msg('服务异常,请稍后重试', {icon: 16, scrollbar: false, time: 2000});
$('#save').removeClass("layui-btn-disabled").attr("disabled", false);
}
});
}
/*新增/修改骨干成绩*/
function addOrEditData(id) {
let title = '新增骨干成绩';
if (id) {
title = '修改骨干成绩';
}
let layerIndex = parent.layer.open({
id: "addOrEditBackboneScore",
title: ['<div style="border-left: 3px solid #2F82FB;display: flex;align-items: center;height: 20px;padding: 0 10px;">' + title + '</div>', 'font-size:16px;background-color:#f0f0f0;display: flex;align-items: center;'],
type: 2,
maxmin: false,
content: '../dutyTask/backboneScore/backboneScoreForm.html',
area: ['664px', '544px'],
move: false,
success: function (layero, index) {
let iframeWin = parent.window["layui-layer-iframe" + layerIndex];
iframeWin.setParams(id);
}
});
}
// 批量删除
function batchDel() {
let selectData = layui.table.checkStatus('viobBasisTable').data;
console.log(selectData)
let idList = [];
if (selectData.length > 0) {
$.each(selectData,function (index,item){
idList.push(item.idNumber);
})
delData(idList.toString());
} else {
return layer.msg('请选择要删除的数据', {icon: 7, time: 2000})
}
}
/*删除骨干人员*/
function delData(id) {
layer.confirm("确定删除吗?", function () {
let loadingMsg = layer.msg('数据删除中,请稍候...', {icon: 16, scrollbar: false, time: 0});
$.ajax({
headers: {
"encrypt": sm3(JSON.stringify({
idNumbers: id
}))
},
url: dataUrl + 'proteam/pot/workPermit/delPeople?token=' + token,
data: {
idNumbers: id,
},
type: 'post',
async: true,
success: function (result) {
layer.close(loadingMsg); // 关闭提示层
if (result.code === 200) {
parent.layer.msg(result.msg, {icon: 1})
reloadData();
} else if (result.code === 500) {
parent.layer.alert(result.msg, {icon: 2})
} else if (result.code === 401) {
logout(1);
}
}, error: function () {
layer.close(loadingMsg); // 关闭提示层
layer.msg('服务异常,请稍后重试', {icon: 16, scrollbar: false, time: 2000});
}
});
})
}
/*模板下载*/
function downLoadExcelModel() {
let loadingMsg = layer.msg('模板下载中,请稍候...', {icon: 16, scrollbar: false, time: 0});
let url = dataUrl + 'proteam/pot/workPermit/downLoadExcelModel?token=' + token;
let xhr = new XMLHttpRequest();
xhr.open("get", url, true);
xhr.responseType = "blob"; // 转换流
xhr.setRequestHeader("encrypt",
sm3(JSON.stringify({})));
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 = "骨干成绩-导入模板.xls"; // 文件名
} else {
layer.msg('服务异常,请稍后重试', {icon: 16, scrollbar: false, time: 2000});
}
a.click()
window.URL.revokeObjectURL(url)
};
xhr.send();
}
function reloadData() {
pages(pageNum, limitSize)
}
// 查询
function query() {
let pattern = new RegExp("[%_<>]");
if (pattern.test($("#userName").val())) {
$("#userName").val('');
return layer.msg('姓名查询包含特殊字符,请重新输入', {
icon: 2,
time: 2000 //2秒关闭如果不配置默认是3秒
});
}
if (pattern.test($("#idNumber").val())) {
$("#idNumber").val('');
return layer.msg('身份证号查询包含特殊字符,请重新输入', {
icon: 2,
time: 2000 //2秒关闭如果不配置默认是3秒
});
}
pageNum = 1;
pages(1, limitSize)
}
/*导入*/
function chooseFile() {
$("#import-excel").trigger("click");
}
$("#import-excel").change(function () {
if ($(this).val()) {
let files = $(this)[0].files[0];
let fileType = files.name.substring(
files.name.lastIndexOf(".") + 1,
files.name.length
);
if (fileType === "xlsx" || fileType === "xls") {
excelUpload3(this, '', dataUrl + "proteam/pot/workPermit/importExcel?token=" + token)
} else {
layer.msg("仅支持上传文件格式为xlx、xlsx", {icon: 5,});
$("#import-excel").val("");
}
}
});
// 弹出模态框
function centerModals() {
$('#myModal_edit').each(function (i) {
var $clone = $(this).clone().css('display', 'block').appendTo('body');
var top = Math.round(($clone.height() - $clone.find('.modal-content').height()) / 3);
top = top > 0 ? top : 0;
$clone.remove();
$(this).find('.modal-content').css("margin-top", top);
});
};
// 关闭页面
function closePage() {
let index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
parent.layer.close(index); //再执行关闭
}