2024-07-25 11:03:20 +08:00
|
|
|
|
let form, layer, table, tableIns;
|
|
|
|
|
|
let pageNum = 1, limitSize = 10; // 默认第一页,分页数量为10
|
|
|
|
|
|
let selectedIds = []; // 存储选中项的ID
|
|
|
|
|
|
layui.use(['form', 'layer', 'table', 'laydate'], function () {
|
|
|
|
|
|
form = layui.form;
|
|
|
|
|
|
layer = layui.layer;
|
|
|
|
|
|
table = layui.table;
|
|
|
|
|
|
var laydate = layui.laydate;
|
|
|
|
|
|
// 渲染
|
|
|
|
|
|
laydate.render({
|
|
|
|
|
|
elem: '#ID-laydate-rangeLinked',
|
|
|
|
|
|
range: ['#startTime', '#endTime'],
|
|
|
|
|
|
rangeLinked: true // 开启日期范围选择时的区间联动标注模式 --- 2.8+ 新增
|
|
|
|
|
|
});
|
|
|
|
|
|
layui.form.render();
|
|
|
|
|
|
getDevSelected();
|
|
|
|
|
|
pages(1, 10, 1);
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
function pages(pageNum, pageSize, typeNum) {
|
|
|
|
|
|
let params = getReqParams(pageNum, pageSize, typeNum);
|
|
|
|
|
|
let url = dataUrl + "/primaryDatas/getList"
|
|
|
|
|
|
ajaxRequest(url, "POST", params, true, function () {
|
|
|
|
|
|
}, 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})
|
|
|
|
|
|
}
|
|
|
|
|
|
}, 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-130",
|
|
|
|
|
|
data: dataList,
|
|
|
|
|
|
limit: limit,
|
|
|
|
|
|
cols: [
|
|
|
|
|
|
[
|
|
|
|
|
|
//表头
|
|
|
|
|
|
{title: "序号", width: 80, unresize: true, align: "center",
|
|
|
|
|
|
templet: function (d) {
|
2024-07-26 18:49:55 +08:00
|
|
|
|
return (page - 1) * limit + d.LAY_NUM;
|
2024-07-25 11:03:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{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: "sampleDate", title: "收样时间", unresize: true, align: "center"},
|
|
|
|
|
|
{field: "sampleUserName", title: "收样人", unresize: true, align: "center"},
|
|
|
|
|
|
{field: "experTime", title: "试验时间", unresize: true, align: "center"},
|
|
|
|
|
|
{field: "teamName", title: "试验班组", unresize: true, align: "center"},
|
|
|
|
|
|
{title: "操作", unresize: true, width: 300, align: "center",
|
|
|
|
|
|
templet: function (d) {
|
|
|
|
|
|
return '<a href="#" style="color: blue;" onclick="testClick(\'' + d.id + '\',\''+d.customNum+'\')">查看</a>';
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
],
|
|
|
|
|
|
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");
|
|
|
|
|
|
// 每次分页完成后,根据selectedIds选中复选框
|
|
|
|
|
|
/*$.each(res.data, function(i, item){
|
|
|
|
|
|
if($.inArray(item.id, selectedIds) !== -1){
|
|
|
|
|
|
table.checkRow(item);
|
|
|
|
|
|
}
|
|
|
|
|
|
});*/
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// 监听单个复选框的选中和取消事件
|
|
|
|
|
|
table.on('checkbox(table_data)', function (obj) {
|
|
|
|
|
|
if (obj.checked) {
|
|
|
|
|
|
selectedIds.push(obj.data.id);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
var index = selectedIds.indexOf(obj.data.id);
|
|
|
|
|
|
if (index > -1) {
|
|
|
|
|
|
selectedIds.splice(index, 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
// 获取头部复选框元素
|
|
|
|
|
|
var headerCheckbox = $('input[name="layTableCheckbox"]');
|
|
|
|
|
|
|
|
|
|
|
|
// 监听头部复选框的change事件
|
|
|
|
|
|
headerCheckbox.on('change', function() {
|
|
|
|
|
|
if ($(this).is(':checked')) {
|
|
|
|
|
|
// 全选操作
|
|
|
|
|
|
table.checkAll('table_data');
|
|
|
|
|
|
selectedIds = table.cache.table_data.map(function(item) {
|
|
|
|
|
|
return item.id;
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 全不选操作
|
|
|
|
|
|
table.uncheckAll('table_data');
|
|
|
|
|
|
selectedIds = [];
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取参数
|
|
|
|
|
|
function getReqParams(page, limit, type) {
|
|
|
|
|
|
let obj = {};
|
|
|
|
|
|
if (!type) {
|
|
|
|
|
|
obj = {
|
|
|
|
|
|
page: page + "",
|
|
|
|
|
|
limit: limit + "",
|
|
|
|
|
|
devTypeCode: $('#devId').val(),
|
|
|
|
|
|
keyWord: $('#keyWord').val(),
|
|
|
|
|
|
sampleUserName: $('#sampleUserName').val(),
|
|
|
|
|
|
startTime: $('#startTime').val(),
|
|
|
|
|
|
endTime: $('#endTime').val(),
|
|
|
|
|
|
};
|
|
|
|
|
|
} else {
|
|
|
|
|
|
obj = {
|
|
|
|
|
|
page: '1',
|
|
|
|
|
|
limit: '10',
|
|
|
|
|
|
devTypeCode: '',
|
|
|
|
|
|
keyWord: '',
|
|
|
|
|
|
sampleUserName: '',
|
|
|
|
|
|
startTime: '',
|
|
|
|
|
|
endTime:''
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
obj={
|
|
|
|
|
|
encryptedData:encryptCBC(JSON.stringify(obj))
|
|
|
|
|
|
}
|
|
|
|
|
|
return obj;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 查询/重置
|
|
|
|
|
|
function query() {
|
|
|
|
|
|
pageNum = 1;
|
|
|
|
|
|
pages(1, limitSize);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function reloadData() {
|
|
|
|
|
|
pages(pageNum, limitSize);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 试验标准新增、修改
|
|
|
|
|
|
function testClick(id,customNum) {
|
2024-07-26 11:20:28 +08:00
|
|
|
|
let title = '试验详细信息'
|
2024-07-25 11:03:20 +08:00
|
|
|
|
let param = {
|
|
|
|
|
|
'id': id,
|
|
|
|
|
|
'customNum':customNum
|
|
|
|
|
|
}
|
|
|
|
|
|
openIframeMax("primaryDataList", title, "child/primaryDataList.html", '100%', '100%', param);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getDevSelected() {
|
|
|
|
|
|
let url = dataUrl + '/sys/select/getDicts';
|
|
|
|
|
|
let obj = {
|
|
|
|
|
|
'code':"dev_code"
|
|
|
|
|
|
}
|
|
|
|
|
|
let params = {
|
|
|
|
|
|
encryptedData: encryptCBC(JSON.stringify(obj))
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ajaxRequest(url, "POST", params, true, function () {
|
|
|
|
|
|
}, function (result) {
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
|
|
|
setSelectValue(result.data, 'devId');
|
|
|
|
|
|
// return result.data
|
|
|
|
|
|
} else {
|
|
|
|
|
|
layer.alert(result.msg, {icon: 2})
|
|
|
|
|
|
}
|
|
|
|
|
|
}, function (xhr) {
|
|
|
|
|
|
error(xhr)
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*下拉选表单赋值*/
|
|
|
|
|
|
function setSelectValue(list, selectName) {
|
|
|
|
|
|
let html = '<option value="" selected>请选设备类型</option>';
|
|
|
|
|
|
$.each(list, function (index, item) {
|
|
|
|
|
|
html += '<option value="' + item.value + '">' + item.name + '</option>';
|
|
|
|
|
|
})
|
|
|
|
|
|
$('#' + selectName).empty().append(html);
|
|
|
|
|
|
layui.form.render();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function commitCheckTestData(){
|
|
|
|
|
|
console.log(selectedIds);
|
|
|
|
|
|
let url = dataUrl + '/experimental/commitCheckTestData';
|
|
|
|
|
|
let obj = {
|
|
|
|
|
|
'ids':selectedIds
|
|
|
|
|
|
}
|
|
|
|
|
|
let params = {
|
|
|
|
|
|
encryptedData: encryptCBC(JSON.stringify(obj))
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ajaxRequest(url, "POST", params, true, function () {
|
|
|
|
|
|
}, function (result) {
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
|
|
|
console.log("数据",result.data)
|
|
|
|
|
|
// return result.data
|
|
|
|
|
|
} else {
|
|
|
|
|
|
layer.alert(result.msg, {icon: 2})
|
|
|
|
|
|
}
|
|
|
|
|
|
}, function (xhr) {
|
|
|
|
|
|
error(xhr)
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|