212 lines
6.7 KiB
Plaintext
212 lines
6.7 KiB
Plaintext
|
|
let scoreParam, idNumberParam, classId, form, layer;
|
|||
|
|
|
|||
|
|
function setParams(idParam, score, idNumber) {
|
|||
|
|
scoreParam = score, idNumberParam = idNumber, classId = idParam;
|
|||
|
|
layui.use(['form', 'layer'], function () {
|
|||
|
|
layer = layui.layer;
|
|||
|
|
form = layui.form;
|
|||
|
|
getTeamPersonnel();
|
|||
|
|
form.render();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 查询
|
|||
|
|
function inquery() {
|
|||
|
|
let pattern = new RegExp("[%_<>]");
|
|||
|
|
if (pattern.test($("#notiInfo").val())) {
|
|||
|
|
$("#notiInfo").val('');
|
|||
|
|
return layer.msg('关键字查询包含特殊字符,请重新输入', {
|
|||
|
|
icon: 2,
|
|||
|
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
getTeamPersonnel();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//获取责任人
|
|||
|
|
function getTeamPersonnel() {
|
|||
|
|
let params = {
|
|||
|
|
classId: classId,
|
|||
|
|
userName: $('#keyWord').val()
|
|||
|
|
}
|
|||
|
|
$.ajax({
|
|||
|
|
headers: {
|
|||
|
|
"encrypt": sm3(JSON.stringify(params))
|
|||
|
|
},
|
|||
|
|
type: "post",
|
|||
|
|
url: dataUrl + 'proteam/pot/todayTask/getPersonList?token=' + token,
|
|||
|
|
data: params,
|
|||
|
|
success: function (result) {
|
|||
|
|
if (result.code === 200) {
|
|||
|
|
initClassTable(result.data);
|
|||
|
|
} else if (result.code === 500) {
|
|||
|
|
return layer.alert(data.msg, {icon: 2})
|
|||
|
|
} else if (result.code === 401) {
|
|||
|
|
logout(1);
|
|||
|
|
}
|
|||
|
|
}, error: function () {
|
|||
|
|
initClassTable(null);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 初始化表格数据
|
|||
|
|
function initClassTable(data) {
|
|||
|
|
let html = '<thead><tr><td><input onclick="selectAll(this.checked)" type="checkbox"></td><td>姓名</td><td>扣分</td></tr></thead>';
|
|||
|
|
html += '<tbody>'
|
|||
|
|
if (data && data.length > 0) {
|
|||
|
|
$.each(data, function (index, item) {
|
|||
|
|
if (item) {
|
|||
|
|
html += '<tr ondblclick="dbSel(this)">' +
|
|||
|
|
'<td><input onclick="sel(this.checked,this)" name="check" type="checkbox"></td>' +
|
|||
|
|
'<td idNumber="' + item.idNumber + '">' + item.userName + '</td>' +
|
|||
|
|
'<td><div class="inputDiv"><input readonly style="background-color: #f0f0f0;border: 1px solid #d9d9d9;"></div></td>' +
|
|||
|
|
'</tr>';
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
} else {
|
|||
|
|
html += '<tr><td colspan="3">暂无数据</td></tr>';
|
|||
|
|
}
|
|||
|
|
html += '</tbody>'
|
|||
|
|
$('.classTable').empty().append(html);
|
|||
|
|
checkData();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 扣分0-12
|
|||
|
|
function valcheck(num) {
|
|||
|
|
let reg = /^([0-9]|1[0-1])(\.\d{1})?$/
|
|||
|
|
if (!num.match(reg) || num === '00' || num === '0') {
|
|||
|
|
return false;
|
|||
|
|
}else {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 复选框全选
|
|||
|
|
function selectAll(selectStatus) {//传入参数(全选框的选中状态)
|
|||
|
|
//根据name属性获取到单选框的input,使用each方法循环设置所有单选框的选中状态
|
|||
|
|
if (selectStatus) {
|
|||
|
|
$("input[name='check']").each(function (i, n) {
|
|||
|
|
n.checked = true;
|
|||
|
|
$(n).parent().parent().find('td').eq(2).find('input').prop('readonly', false).removeAttr('style').val('0');
|
|||
|
|
});
|
|||
|
|
} else {
|
|||
|
|
$("input[name='check']").each(function (i, n) {
|
|||
|
|
n.checked = false;
|
|||
|
|
$(n).parent().parent().find('td').eq(2).find('input').prop('readonly', true).css({
|
|||
|
|
'background-color': '#f0f0f0',
|
|||
|
|
'border': '1px solid #d9d9d9'
|
|||
|
|
}).val('');
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//双击选中
|
|||
|
|
function dbSel(that) {
|
|||
|
|
let flag = $(that).find('input').prop("checked");
|
|||
|
|
if (flag) {
|
|||
|
|
$(that).find('input').prop("checked", false);
|
|||
|
|
$(that).find('input').prop("readonly", true).css({
|
|||
|
|
'background-color': '#f0f0f0',
|
|||
|
|
'border': '1px solid #d9d9d9'
|
|||
|
|
}).val('')
|
|||
|
|
} else {
|
|||
|
|
$(that).find('input').prop("checked", true);
|
|||
|
|
$(that).find('input').prop('readonly', false).removeAttr('style').val('0');
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 单个选中
|
|||
|
|
function sel(selectStatus, that) {
|
|||
|
|
if (selectStatus) {
|
|||
|
|
$(that).prop('checked', true);
|
|||
|
|
$(that).parent().parent().find('td').eq(2).find('input').prop('readonly', false).removeAttr('style').val('0');
|
|||
|
|
} else {
|
|||
|
|
$(that).prop('checked', false);
|
|||
|
|
$(that).parent().parent().find('td').eq(2).find('input').prop('readonly', true).css({
|
|||
|
|
'background-color': '#f0f0f0',
|
|||
|
|
'border': '1px solid #d9d9d9'
|
|||
|
|
}).val('');
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 获取复选框选中的值
|
|||
|
|
function selData() {
|
|||
|
|
let list = [];
|
|||
|
|
$("input[name='check']").each(function (i, n) {
|
|||
|
|
if (n.checked === true) {
|
|||
|
|
let id = $(n).parent().parent().find('td').eq(1).attr('idNumber');
|
|||
|
|
let name = $(n).parent().parent().find('td').eq(1).html();
|
|||
|
|
let score = $(n).parent().parent().find('td').eq(2).find('input').val();
|
|||
|
|
if (!score) {
|
|||
|
|
score = '0';
|
|||
|
|
}
|
|||
|
|
let obj = {
|
|||
|
|
'id': id,
|
|||
|
|
'name': name,
|
|||
|
|
'score': score
|
|||
|
|
};
|
|||
|
|
list.push(obj);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
return list;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 保存
|
|||
|
|
function save() {
|
|||
|
|
let id = '', name = '', score8 = '';
|
|||
|
|
let list = selData();
|
|||
|
|
if (list.length === 0) {
|
|||
|
|
return layer.msg('请选择违章人员', {icon: 7, time: 2000});
|
|||
|
|
}
|
|||
|
|
let flag = true;
|
|||
|
|
for (let i = 0; i < list.length; i++) {
|
|||
|
|
id += list[i].id + ',';
|
|||
|
|
name += list[i].name + ',';
|
|||
|
|
score8 += list[i].score + ',';
|
|||
|
|
flag = valcheck(list[i].score);
|
|||
|
|
if(!flag){
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
let index = id.lastIndexOf(",");
|
|||
|
|
let index2 = name.lastIndexOf(",");
|
|||
|
|
let index3 = score8.lastIndexOf(",");
|
|||
|
|
id = id.substring(0, index);
|
|||
|
|
name = name.substring(0, index2);
|
|||
|
|
score8 = score8.substring(0, index3);
|
|||
|
|
if(!flag){
|
|||
|
|
return layer.msg("扣分不能为0分,最大扣分不超过12分,扣分为小数,保留一位", {icon: 7})
|
|||
|
|
}else{
|
|||
|
|
closePage(1, id, name, score8);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 选中赋值
|
|||
|
|
function checkData() {
|
|||
|
|
if (idNumberParam) {
|
|||
|
|
let idNos = idNumberParam.split(',');
|
|||
|
|
let scores = scoreParam.split(',');
|
|||
|
|
$("input[name='check']").each(function (i, n) {
|
|||
|
|
var id = $(n).parent().parent().find('td').eq(1).attr('idNumber');
|
|||
|
|
idNos.forEach((o, index) => {
|
|||
|
|
if (id === o) {
|
|||
|
|
n.checked = true;
|
|||
|
|
$(n).parent().parent().find('td').eq(2).find('input').val(scores[index]);
|
|||
|
|
$(n).parent().parent().find('td').eq(2).find('input').prop('readonly', false).removeAttr('style');
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 关闭页面
|
|||
|
|
function closePage(type, id, name, score8) {
|
|||
|
|
let index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
|
|||
|
|
parent.layer.close(index); //再执行关闭
|
|||
|
|
if (type === 1) {
|
|||
|
|
parent.setViolatorsPerson(id, name, score8);
|
|||
|
|
}
|
|||
|
|
}
|