142 lines
3.8 KiB
Plaintext
142 lines
3.8 KiB
Plaintext
|
|
let voiTypeIdParam,form, layer;
|
|||
|
|
function setParams(voiTypeId){
|
|||
|
|
voiTypeIdParam = voiTypeId;
|
|||
|
|
layui.use(['form', 'layer'], function () {
|
|||
|
|
layer = layui.layer;
|
|||
|
|
form = layui.form;
|
|||
|
|
getVioInfoList();
|
|||
|
|
form.render();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 查询
|
|||
|
|
function inquery() {
|
|||
|
|
let pattern = new RegExp("[%_<>]");
|
|||
|
|
if (pattern.test($("#notiInfo").val())) {
|
|||
|
|
$("#notiInfo").val('');
|
|||
|
|
return layer.msg('关键字查询包含特殊字符,请重新输入', {
|
|||
|
|
icon: 2,
|
|||
|
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
getVioInfoList();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//获取违章依据
|
|||
|
|
function getVioInfoList() {
|
|||
|
|
let params = {
|
|||
|
|
vioTypeId: voiTypeIdParam,
|
|||
|
|
notiInfo: $('#notiInfo').val()
|
|||
|
|
}
|
|||
|
|
$.ajax({
|
|||
|
|
headers: {
|
|||
|
|
"encrypt": sm3(JSON.stringify(params))
|
|||
|
|
},
|
|||
|
|
type: "post",
|
|||
|
|
url: dataUrl + 'proteam/pot/todayTask/getVioInfoList?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></tr></thead>';
|
|||
|
|
html += '<tbody>'
|
|||
|
|
if (data !== null && data.length > 0) {
|
|||
|
|
data.forEach((item, index) => {
|
|||
|
|
html += '<tr ondblclick="dbSel(this)">' +
|
|||
|
|
'<td><input onclick="sel(this.checked,this)" name="check" type="checkbox"></td>' +
|
|||
|
|
'<td id="' + item.id + '">' + item.notiInfo + '</td>' +
|
|||
|
|
'</tr>';
|
|||
|
|
});
|
|||
|
|
} else {
|
|||
|
|
html += '<tr><td colspan="2">暂无数据</td></tr>';
|
|||
|
|
}
|
|||
|
|
html += '</tbody>'
|
|||
|
|
$('.classTable').empty().append(html);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 复选框全选
|
|||
|
|
function selectAll(selectStatus) {//传入参数(全选框的选中状态)
|
|||
|
|
//根据name属性获取到单选框的input,使用each方法循环设置所有单选框的选中状态
|
|||
|
|
if (selectStatus) {
|
|||
|
|
$("input[name='check']").each(function (i, n) {
|
|||
|
|
n.checked = true;
|
|||
|
|
});
|
|||
|
|
} else {
|
|||
|
|
$("input[name='check']").each(function (i, n) {
|
|||
|
|
n.checked = false;
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//双击选中
|
|||
|
|
function dbSel(that){
|
|||
|
|
let flag = $(that).find('input').prop("checked");
|
|||
|
|
if(flag){
|
|||
|
|
$(that).find('input').prop("checked",false);
|
|||
|
|
}else{
|
|||
|
|
$(that).find('input').prop("checked",true);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 单个选中
|
|||
|
|
function sel(selectStatus, that) {
|
|||
|
|
if (selectStatus) {
|
|||
|
|
$(that).prop('checked', true);
|
|||
|
|
} else {
|
|||
|
|
$(that).prop('checked', false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 获取复选框选中的值
|
|||
|
|
function selData() {
|
|||
|
|
let list = [];
|
|||
|
|
$("input[name='check']").each(function (i, n) {
|
|||
|
|
if (n.checked === true) {
|
|||
|
|
let name = $(n).parent().parent().find('td').eq(1).html();
|
|||
|
|
let obj = {
|
|||
|
|
'name': name,
|
|||
|
|
};
|
|||
|
|
list.push(obj);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
return list;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 保存
|
|||
|
|
function save() {
|
|||
|
|
let name = '';
|
|||
|
|
let list = selData();
|
|||
|
|
if (list.length === 0) {
|
|||
|
|
return layer.msg('请选择违章依据', {icon: 7});
|
|||
|
|
}
|
|||
|
|
list.forEach((item, index) => {
|
|||
|
|
name += item.name + ';';
|
|||
|
|
});
|
|||
|
|
let index2 = name.lastIndexOf(";");
|
|||
|
|
name = name.substring(0, index2);
|
|||
|
|
closePage(1,name);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 关闭页面
|
|||
|
|
function closePage(type,name) {
|
|||
|
|
let index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
|
|||
|
|
parent.layer.close(index); //再执行关闭
|
|||
|
|
if (type === 1) {
|
|||
|
|
parent.setVioInfo(name);
|
|||
|
|
}
|
|||
|
|
}
|