206 lines
6.7 KiB
JavaScript
206 lines
6.7 KiB
JavaScript
|
|
let form, layer, table, tableIns,laydate;
|
|||
|
|
let pageNum = 1, limitSize = 10; // 默认第一页,分页数量为10
|
|||
|
|
let deviceTypeList = [];
|
|||
|
|
layui.use(['form', 'layer', 'table','laydate'], function () {
|
|||
|
|
form = layui.form;
|
|||
|
|
layer = layui.layer;
|
|||
|
|
table = layui.table;
|
|||
|
|
laydate = layui.laydate;
|
|||
|
|
layui.form.render();
|
|||
|
|
deviceTypeList = getDictsSelect("dev_code");
|
|||
|
|
setDictSelectValue(deviceTypeList,'devTypeCode');
|
|||
|
|
laydate.render({
|
|||
|
|
elem: '#ID-laydate-rangeLinked',
|
|||
|
|
range: ['#startTime', '#endTime'],
|
|||
|
|
rangeLinked: true // 开启日期范围选择时的区间联动标注模式 --- 2.8+ 新增
|
|||
|
|
});
|
|||
|
|
pages(1, 10, 1);
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
function pages(pageNum, pageSize, typeNum) {
|
|||
|
|
let params = getReqParams(pageNum, pageSize, typeNum);
|
|||
|
|
$.ajax({
|
|||
|
|
url: dataUrl + "/examine/getList",
|
|||
|
|
headers: {
|
|||
|
|
"token": tokens
|
|||
|
|
},
|
|||
|
|
data: params,
|
|||
|
|
type: 'POST',
|
|||
|
|
async: false,
|
|||
|
|
success: function (result) {
|
|||
|
|
console.log(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})
|
|||
|
|
}
|
|||
|
|
}, error: function (xhr) {
|
|||
|
|
error(xhr);
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
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: [10, 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: "#table_data",
|
|||
|
|
height: "full-140",
|
|||
|
|
data: dataList,
|
|||
|
|
limit: limit,
|
|||
|
|
cols: [
|
|||
|
|
[
|
|||
|
|
//表头
|
|||
|
|
{
|
|||
|
|
title: "序号", width: 80, unresize: true, align: "center",
|
|||
|
|
templet: function (d) {
|
|||
|
|
return (page - 1) * limit + d.LAY_NUM;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
{field: "customName", title: "送样单位", unresize: true, align: "center"},
|
|||
|
|
{field: "sampleTime", title: "送样时间", unresize: true, align: "center"},
|
|||
|
|
{field: "sampleDev", title: "送样设备", unresize: true, align: "center"},
|
|||
|
|
{field: "customNum", title: "送样数量", unresize: true, align: "center"},
|
|||
|
|
{field: "sampleUserName", title: "收样人", unresize: true, align: "center"},
|
|||
|
|
{field: "sampleDate", title: "收样时间", unresize: true, align: "center"},
|
|||
|
|
{field: "teamName", title: "试验班组", unresize: true, align: "center"},
|
|||
|
|
{field: "audtiStatus", title: "状态", unresize: true, align: "center"},
|
|||
|
|
{
|
|||
|
|
title: "操作", unresize: true, width: 180, align: "center",
|
|||
|
|
templet: function (d) {
|
|||
|
|
let html = '';
|
|||
|
|
html += "<a class='layui-icon layui-icon-edit' title='编辑' onclick=\"addData('" + d.id + "')\"></a>" +
|
|||
|
|
"<a class='layui-icon layui-icon-delete' title='删除' onclick=\"delData('" + d.id + "')\"></a>";
|
|||
|
|
return html;
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
],
|
|||
|
|
],
|
|||
|
|
done: function (res, curr, count) {
|
|||
|
|
layer.close(loadingMsg);
|
|||
|
|
table.resize("table_data");
|
|||
|
|
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(),
|
|||
|
|
startTime: $('#startTime').val(),
|
|||
|
|
endTime: $('#endTime').val(),
|
|||
|
|
devTypeCode : $('#devTypeCode').val(),
|
|||
|
|
};
|
|||
|
|
} else {
|
|||
|
|
obj = {
|
|||
|
|
page: '1',
|
|||
|
|
limit: '10',
|
|||
|
|
keyWord: '',
|
|||
|
|
accessType: '',
|
|||
|
|
startTime: '',
|
|||
|
|
endTime: '',
|
|||
|
|
devTypeCode : ''
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
obj = {
|
|||
|
|
encryptedData: encryptCBC(JSON.stringify(obj))
|
|||
|
|
}
|
|||
|
|
return obj;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 查询/重置
|
|||
|
|
function query() {
|
|||
|
|
let pattern = new RegExp("[%_<>]");
|
|||
|
|
if (pattern.test($("#ip").val())) {
|
|||
|
|
$("#ip").val('');
|
|||
|
|
return layer.msg('ip查询包含特殊字符,请重新输入', {
|
|||
|
|
icon: 2,
|
|||
|
|
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
pageNum = 1;
|
|||
|
|
pages(1, limitSize);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function reloadData() {
|
|||
|
|
pages(pageNum, limitSize);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 新增/修改平台用户
|
|||
|
|
function addData(id) {
|
|||
|
|
let title = '新增白名单'
|
|||
|
|
if (id) {
|
|||
|
|
title = '修改白名单';
|
|||
|
|
}
|
|||
|
|
let param = {
|
|||
|
|
'id': id
|
|||
|
|
}
|
|||
|
|
openIframe2("addOrEditWhite", title, "child/whiteForm.html", '875px', '625px', param);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function addPwdData(id) {
|
|||
|
|
let param = {
|
|||
|
|
'id': id
|
|||
|
|
}
|
|||
|
|
openIframe2("addOrEditWhite", '密码规则配置', "child/pwdRuleForm.html", '875px', '625px', param);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/*删除白名单*/
|
|||
|
|
function delData(id) {
|
|||
|
|
layer.confirm("确定删除吗?", {
|
|||
|
|
move: false
|
|||
|
|
}, function () {
|
|||
|
|
let loadingMsg = layer.msg('数据删除中,请稍候...', {icon: 16, scrollbar: false, time: 0});
|
|||
|
|
let url = dataUrl + "/sys/white/delWhite"
|
|||
|
|
let obj = {'id': id}
|
|||
|
|
let params = {
|
|||
|
|
encryptedData: encryptCBC(JSON.stringify(obj))
|
|||
|
|
}
|
|||
|
|
ajaxRequest(url, "POST", params, true, function () {
|
|||
|
|
}, function (result) {
|
|||
|
|
layer.close(loadingMsg); // 关闭提示层
|
|||
|
|
if (result.status === 200) {
|
|||
|
|
parent.layer.msg(result.msg, {icon: 1})
|
|||
|
|
query()
|
|||
|
|
} else if (result.status === 500) {
|
|||
|
|
layer.alert(result.msg, {icon: 2})
|
|||
|
|
}
|
|||
|
|
}, function (xhr) {
|
|||
|
|
layer.close(loadingMsg); // 关闭提示层
|
|||
|
|
error(xhr)
|
|||
|
|
});
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|