This commit is contained in:
parent
4ca72dc323
commit
d36b9d395f
|
|
@ -1,7 +1,9 @@
|
||||||
let form, layer, table, tableIns, laydate;
|
let form, layer, table, tableIns, laydate;
|
||||||
let pageNum = 1, limitSize = 10; // 默认第一页,分页数量为10
|
let pageNum = 1, limitSize = 1; // 默认第一页,分页数量为10
|
||||||
let deviceTypeList = [];
|
let deviceTypeList = [];
|
||||||
let idParam = null, statusParam = null;
|
let idParam = null, statusParam = null;
|
||||||
|
let temp_table_list = []; // 临时保存每页的所有数据
|
||||||
|
let temp_all_list = []; // 临时保存所有选中的数据
|
||||||
|
|
||||||
function setParams(params) {
|
function setParams(params) {
|
||||||
idParam = JSON.parse(params).id;
|
idParam = JSON.parse(params).id;
|
||||||
|
|
@ -19,7 +21,7 @@ function setParams(params) {
|
||||||
range: ['#startTime', '#endTime'],
|
range: ['#startTime', '#endTime'],
|
||||||
rangeLinked: true
|
rangeLinked: true
|
||||||
});
|
});
|
||||||
pages(1, 10, 1);
|
pages(1, 1, 1);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -34,7 +36,6 @@ function pages(pageNum, pageSize, typeNum) {
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
async: false,
|
async: false,
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
console.log(result);
|
|
||||||
if (result.code === 200) {
|
if (result.code === 200) {
|
||||||
if (result.data) {
|
if (result.data) {
|
||||||
initTable(result.data, result.limit, result.curr)
|
initTable(result.data, result.limit, result.curr)
|
||||||
|
|
@ -57,7 +58,7 @@ function laypages(total, page, limit) {
|
||||||
count: total,
|
count: total,
|
||||||
curr: page,
|
curr: page,
|
||||||
limit: limit,
|
limit: limit,
|
||||||
limits: [10, 20, 50, 100, 200, 500],
|
limits: [1, 20, 50, 100, 200, 500],
|
||||||
layout: ['prev', 'page', 'next', 'skip', 'count', 'limit'],
|
layout: ['prev', 'page', 'next', 'skip', 'count', 'limit'],
|
||||||
groups: 5,
|
groups: 5,
|
||||||
jump: function (obj, first) {
|
jump: function (obj, first) {
|
||||||
|
|
@ -70,22 +71,27 @@ function laypages(total, page, limit) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let flag = true;
|
||||||
|
|
||||||
/*初始化表格*/
|
/*初始化表格*/
|
||||||
function initTable(dataList, limit, page) {
|
function initTable(dataList, limit, page) {
|
||||||
let loadingMsg = layer.msg("数据加载中,请稍候...", {icon: 16, scrollbar: false, time: 0,});
|
let loadingMsg = layer.msg("数据加载中,请稍候...", {icon: 16, scrollbar: false, time: 0,});
|
||||||
tableIns = table.render({
|
tableIns = table.render({
|
||||||
elem: "#table_data",
|
elem: "#table_data",
|
||||||
id:'testData',
|
id: 'testData',
|
||||||
height: "full-140",
|
height: "full-140",
|
||||||
data: dataList,
|
data: dataList,
|
||||||
limit: limit,
|
limit: limit,
|
||||||
cols: [
|
cols: [
|
||||||
[
|
[
|
||||||
//表头
|
//表头
|
||||||
{type: 'checkbox', fixed: 'left'},
|
{
|
||||||
|
type: 'checkbox', fixed: 'left'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: "序号", width: 80, unresize: true, align: "center",
|
title: "序号", width: 80, unresize: true, align: "center",
|
||||||
templet: function (d) {
|
templet: function (d) {
|
||||||
|
console.log(d.experId)
|
||||||
return (page - 1) * limit + d.LAY_NUM;
|
return (page - 1) * limit + d.LAY_NUM;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -95,12 +101,14 @@ function initTable(dataList, limit, page) {
|
||||||
{field: "experimenter", title: "试验人员", unresize: true, align: "center"},
|
{field: "experimenter", title: "试验人员", unresize: true, align: "center"},
|
||||||
{field: "testTime", title: "试验时间", unresize: true, align: "center"},
|
{field: "testTime", title: "试验时间", unresize: true, align: "center"},
|
||||||
{field: "status", title: "状态", unresize: true, align: "center"},
|
{field: "status", title: "状态", unresize: true, align: "center"},
|
||||||
{ title: "原始记录", unresize: true, align: "center",
|
{
|
||||||
|
title: "原始记录", unresize: true, align: "center",
|
||||||
templet: function (d) {
|
templet: function (d) {
|
||||||
let html = '';
|
let html = '';
|
||||||
html += "<a title='查看' onclick=\"viewData('" + d.experId + "','"+d.devTypeCode+"')\">查看</a>";
|
html += "<a title='查看' onclick=\"viewData('" + d.experId + "','" + d.devTypeCode + "')\">查看</a>";
|
||||||
return html;
|
return html;
|
||||||
}},
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: "操作", unresize: true, width: 180, align: "center",
|
title: "操作", unresize: true, width: 180, align: "center",
|
||||||
templet: function (d) {
|
templet: function (d) {
|
||||||
|
|
@ -115,13 +123,87 @@ function initTable(dataList, limit, page) {
|
||||||
],
|
],
|
||||||
done: function (res, curr, count) {
|
done: function (res, curr, count) {
|
||||||
layer.close(loadingMsg);
|
layer.close(loadingMsg);
|
||||||
table.resize("table_data");
|
table.resize("testData");
|
||||||
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-header").css("display", "inline-block");
|
||||||
count || this.elem.next(".layui-table-view").find(".layui-table-box").css("overflow", "auto");
|
count || this.elem.next(".layui-table-view").find(".layui-table-box").css("overflow", "auto");
|
||||||
},
|
temp_table_list = res.data;
|
||||||
|
temp_table_list.forEach(function (o, i) {
|
||||||
|
if(!isCheck(o.status)){
|
||||||
|
let index = o['LAY_INDEX'];
|
||||||
|
$('.layui-table tr[data-index=' + index + '] input[type="checkbox"]').attr('disabled','disabled');
|
||||||
|
$('.layui-table tr[data-index=' + index + '] input[type="checkbox"]').next().removeClass("layui-form-checked");
|
||||||
|
$('.layui-table tr[data-index=' + index + '] input[type="checkbox"]').next().addClass("layui-disabled");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
temp_table_list.forEach(function (o, i) {
|
||||||
|
for (let j = 0; j < temp_all_list.length; j++) {
|
||||||
|
if (temp_all_list[j].experId === o.experId) {
|
||||||
|
// 这里才是真正的有效勾选
|
||||||
|
o["LAY_CHECKED"] = 'true';
|
||||||
|
// 找到对应数据改变勾选样式,呈现出选中效果
|
||||||
|
let index = o['LAY_INDEX'];
|
||||||
|
$('.layui-table tr[data-index=' + index + '] input[type="checkbox"]').prop('checked', true);
|
||||||
|
$('.layui-table tr[data-index=' + index + '] input[type="checkbox"]').next().addClass('layui-form-checked');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// 设置全选checkbox的选中状态,只有改变LAY_CHECKED的值, table.checkStatus才能抓取到选中的状态
|
||||||
|
let checkStatus = table.checkStatus('testData');
|
||||||
|
if (checkStatus.isAll) {// 是否全选
|
||||||
|
// layTableAllChoose
|
||||||
|
$('.layui-table th[data-field="0"] input[type="checkbox"]').prop('checked', true);//data-field值默认为0,如果在分页部分自定义了属性名,则需要改成对应的属性名
|
||||||
|
$('.layui-table th[data-field="0"] input[type="checkbox"]').next().addClass('layui-form-checked');//data-field值默认为0,如果在分页部分自定义了属性名,则需要改成对应的属性名
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 选中行监听(临时存储复选数据,用于列表复选框回显上一页)
|
||||||
|
table.on('checkbox(testData)', function (obj) {
|
||||||
|
if (obj.checked == true) {
|
||||||
|
if (obj.type == 'one') {
|
||||||
|
let index = checkAllList(temp_all_list, obj.data);
|
||||||
|
if (index == -1) {
|
||||||
|
temp_all_list.push(obj.data);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
temp_table_list.forEach(function (o, i) {
|
||||||
|
let index = checkAllList(temp_all_list, o);
|
||||||
|
if (index == -1 && isCheck(o.status)) {
|
||||||
|
temp_all_list.push(o);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let all_list = []; // 使用临时数组,防止删除临时选中所有的数组错乱
|
||||||
|
if (obj.type == 'one') {
|
||||||
|
temp_all_list.forEach(function (o, i) {
|
||||||
|
if (o.experId != obj.data.experId) {
|
||||||
|
all_list.push(o);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
temp_all_list.forEach(function (o, i) {
|
||||||
|
let index = checkAllList(temp_table_list, o);
|
||||||
|
if (index == -1) {
|
||||||
|
all_list.push(o);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
temp_all_list = all_list;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断数组重复
|
||||||
|
*/
|
||||||
|
function checkAllList(list, obj) {
|
||||||
|
for (let j = 0; j < list.length; j++) {
|
||||||
|
if (list[j].experId == obj.experId) {
|
||||||
|
return j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
// 获取参数
|
// 获取参数
|
||||||
function getReqParams(page, limit, type) {
|
function getReqParams(page, limit, type) {
|
||||||
|
|
@ -139,7 +221,7 @@ function getReqParams(page, limit, type) {
|
||||||
} else {
|
} else {
|
||||||
obj = {
|
obj = {
|
||||||
page: '1',
|
page: '1',
|
||||||
limit: '10',
|
limit: '1',
|
||||||
keyWord: '',
|
keyWord: '',
|
||||||
accessType: '',
|
accessType: '',
|
||||||
startTime: '',
|
startTime: '',
|
||||||
|
|
@ -173,7 +255,7 @@ function reloadData() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 原始数据查看
|
// 原始数据查看
|
||||||
function viewData(experId,devTypeCode) {
|
function viewData(experId, devTypeCode) {
|
||||||
let title = '原始记录';
|
let title = '原始记录';
|
||||||
let param = {
|
let param = {
|
||||||
'experId': experId,
|
'experId': experId,
|
||||||
|
|
@ -183,8 +265,8 @@ function viewData(experId,devTypeCode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
function passData(experId,sampleId,type){
|
function passData(experId, sampleId, type) {
|
||||||
let title = type === 1 ? '通过确认':'驳回确认';
|
let title = type === 1 ? '通过确认' : '驳回确认';
|
||||||
let param = {
|
let param = {
|
||||||
'experId': experId,
|
'experId': experId,
|
||||||
'sampleId': sampleId,
|
'sampleId': sampleId,
|
||||||
|
|
@ -194,24 +276,34 @@ function passData(experId,sampleId,type){
|
||||||
}
|
}
|
||||||
|
|
||||||
/*1.批量通过 2.批量不通过*/
|
/*1.批量通过 2.批量不通过*/
|
||||||
function batchAudit(type){
|
function batchAudit(type) {
|
||||||
const tableStatus = table.checkStatus('testData');
|
// const tableStatus = table.checkStatus('testData');
|
||||||
const size = tableStatus.data.length
|
const size = temp_all_list.length
|
||||||
if(size === 0){
|
if (size === 0) {
|
||||||
return layer.msg('未选择数据',{icon:7});
|
return layer.msg('未选择数据', {icon: 7});
|
||||||
}
|
}
|
||||||
let experIdArr = [],sampleId = null;
|
let experIdArr = [], sampleId = null;
|
||||||
$.each(tableStatus.data,function (index,item){
|
$.each(temp_all_list, function (index, item) {
|
||||||
if(index === 0){
|
if (index === 0) {
|
||||||
sampleId = item.sampleId;
|
sampleId = item.sampleId;
|
||||||
}
|
}
|
||||||
experIdArr.push(item.experId)
|
experIdArr.push(item.experId)
|
||||||
})
|
})
|
||||||
let index = layer.confirm('批量'+(type === 1 ? '通过':'不通过')+'确认前,请仔细检查数据?',{title:'操作提示',icon:7,move:false},function (){
|
let index = layer.confirm('批量' + (type === 1 ? '通过' : '不通过') + '确认前,请仔细检查数据?', {
|
||||||
|
title: '操作提示',
|
||||||
|
icon: 7,
|
||||||
|
move: false
|
||||||
|
}, function () {
|
||||||
layer.close(index);
|
layer.close(index);
|
||||||
passData(experIdArr,sampleId,type);
|
passData(experIdArr, sampleId, type);
|
||||||
})
|
})
|
||||||
console.log(tableStatus.data) // 选中行的数据
|
}
|
||||||
console.log(tableStatus.data.length) // 选中行数量,可作为是否有选中行的条件
|
|
||||||
console.log(tableStatus.isAll) // 表格是否全选
|
let checkNameArr = ['待审核','待审批']; //'待审阅',
|
||||||
|
|
||||||
|
function isCheck(value){
|
||||||
|
if (checkNameArr.indexOf(value) > -1) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -58,7 +58,7 @@ function openIframe3(id, title, content, width, height, params) {
|
||||||
iframeWin.setParams(JSON.stringify(params));
|
iframeWin.setParams(JSON.stringify(params));
|
||||||
},
|
},
|
||||||
end:function (){
|
end:function (){
|
||||||
if(id === 'auditData' || id === 'passData'){
|
if(id === 'auditData'){
|
||||||
window.reloadData();
|
window.reloadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="table-box" table-responsive style="z-index: 1;">
|
<div class="table-box" table-responsive style="z-index: 1;">
|
||||||
<table id="table_data" class="table" lay-filter="table_data"></table>
|
<table id="table_data" class="table" lay-filter="testData"></table>
|
||||||
<div id="voi-page" class="layout"></div>
|
<div id="voi-page" class="layout"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue