table.render({ elem: '#CxDataQdTjXXTab', height: 300, url: Hussar.ctxPath + '/CxData/getQdCxData', cols: [ [ {title: '序号', type: 'numbers', align: 'center', halign: 'center', hide: true}, {title: '区段', field: 'qj', align: 'center', halign: 'center',}, {title: '通道', field: 'lx', align: 'center', halign: 'center',}, {title: '超限数量', field: 'sl', align: 'center', halign: 'center'}, ], ], page: false, id: 'CxDataQdTjXXTab', even: true, limit: 20, where: { csrwId: $("#csrwId").val(), xb: '下行', isSpecial: isSpecial, }, done(res) { merge(res, "CxDataQdTjXXTab"); } })
function merge(res, id) { let data = res.data; let mergeIndex = 0; let mark = 1; let columsIndex = [2, 3];
for (let k = 0; k < columsName.length; k++) { let trArr = $("[lay-id='" + id + "']>.layui-table-box>.layui-table-body>.layui-table").find("tr"); for (let i = 1; i < res.data.length; i++) { let tdCurArr = trArr.eq(i).find("td").eq(columsIndex[k]); let tdPreArr = trArr.eq(mergeIndex).find("td").eq(columsIndex[k]); if (data[i].markId === data[i - 1].markId) { { mark += 1; tdPreArr.each(function () { $(this).attr("rowspan", mark); }); tdCurArr.each(function () { $(this).css("display", "none"); }); } else { mergeIndex = i; mark = 1; } } mergeIndex = 0; mark = 1; }
|