let pageNum = 1, limitSize = 10; let pageNum2 = 1, limitSize2 = 10; // 查询/重置 function queryTable(type) { if (type === 1) { pages(1, limitSize, false, 1); } else { pages(1, limitSize2, false, 2); } } function pages(pageNum, pageSize, typeNum, operType) { let params = getReqParams(pageNum, pageSize, typeNum, operType); $.ajax({ url: dataUrl + 'proteam/pot/workPermit/getWorkPermitAndXhList?token=' + token, data: params, type: 'POST', async: false, success: function (result) { if (result.code === 200) { if (result.data) { initTable(result.data, result.limit, result.curr, operType) laypages(result.count, result.curr, result.limit, operType) } } else if (result.code === 500) { layer.msg(result.msg, { icon: 2 }) } else if (result.code === 401) { logout(1); } }, error: function () { } }); } function laypages(total, page, limit, operType) { layui.use(['laypage'], function () { let laypage = layui.laypage; laypage.render({ elem: operType === 1 ? 'voi-page' : 'voi-page2', count: total, curr: page, limit: limit, limits: [10,30, 50, 100], layout: ['page', 'count', 'limit'], groups: 5, jump: function (obj, first) { if (!first) { if (operType === 1) { pageNum = obj.curr, limitSize = obj.limit; } else { pageNum2 = obj.curr, limitSize2 = obj.limit; } pages(obj.curr, obj.limit, null, operType); } } }); }) } /*初始化表格*/ function initTable(dataList, limit, page, operType) { tableIns = table.render({ elem: operType === 1 ? "#dataTable" : "#dataTable2", height: $(window).height() / 3.6, data: dataList, id: operType === 1 ? "dataTable" : "dataTable2", cols: [ setColTable(limit, page, operType) ], limit: limit, done: function (res, curr, count) { if (res.data && res.data.length > 0) { if (parseInt(selType) === operType) { // 渲染完成后选中第一行 $(".layui-table-body tr[data-index='0']").addClass('layui-table-checked'); $(".layui-table-body tr[data-index='0']").find('.layui-table-box input[type="checkbox"]').prop('checked', true); setData(res.data[0], operType); // 移除选中数据 let tableId = operType === 1 ? 'dataTable2' : 'dataTable' let tableElem = $('#' + tableId).next('.layui-table-view'); tableElem.find('.layui-table-body tr').removeClass('layui-table-checked'); } } else { if (parseInt(selType) === operType) { setNoData(); } } }, }); table.on('row(' + (operType === 1 ? "dataTable" : "dataTable2") + ')', function (obj) { // 移除选中数据 let tableId = operType === 1 ? 'dataTable2' : 'dataTable' let tableElem = $('#' + tableId).next('.layui-table-view'); tableElem.find('.layui-table-body tr').removeClass('layui-table-checked'); // 重新选中数据 var data = obj.data; // 获取当前行数据 // 标注当前点击行的选中状态 obj.setRowChecked({ type: 'radio' // radio 单选模式;checkbox 复选模式 }); setData(data, operType); }); } // 选中数据 function setData(data, operType) { $('#indexIframe').removeAttr('style'); $('#no-ticket-file').css('display', 'none'); $('#essCondition-box').removeAttr('style') $('#permitTable tbody tr:nth-child(1)').css('background-color', '#a1bbf3') selObj = data; status = data.status; ticketNo = data.ticketNo; ticketId = data.ticketId; bidNo = data.bidNo; if (operType === 1) { selType = '1'; } else { selType = '2'; } setEssConditionData(); } function setNoData() { selObj = null, status = '', ticketNo = '', ticketId = '', bidNo = ''; $('#essCondition-box').css('display', 'none'); $('#indexIframe').css('display', 'none'); $('#no-ticket-file').removeAttr('style'); } function setColTable(limit, page, operType) { if (operType === 1) { return [ //表头 { title: "序号", width: '10%', unresize: false, align: "center", templet: function (d) { return (page - 1) * limit + d.LAY_NUM; } }, { field: "projectName", title: "工程名称", width: '23%', sort: false, unresize: false, align: "center", style: "word-break: break-all;", }, { field: "ticketNo", title: "作业票编号", width: '30%', sort: false, unresize: false, align: "center", style: "word-break: break-all;", }, { field: "riskLevel", title: "风险等级", width: '10%', sort: false, unresize: false, align: "center", templet: function (d) { return setRiskLevelColor(d.riskLevel); } }, { field: "workManager", title: "班组长", width: '15%', unresize: false, sort: false, align: "center", }, { field: "status", title: "状态", width: '12%', unresize: false, sort: false, align: "center", } ]; } else { return [ //表头 { title: "序号", width: '8%', unresize: false, align: "center", templet: function (d) { return (page - 1) * limit + d.LAY_NUM; } }, { field: "projectName", title: "工程名称", width: '18%', sort: false, unresize: false, align: "center", style: "word-break: break-all;", }, { field: "ticketNo", title: "作业票编号", width: '27%', sort: false, unresize: false, align: "center", style: "word-break: break-all;", }, { field: "riskLevel", title: "风险等级", width: '8%', sort: false, unresize: false, align: "center", templet: function (d) { return setRiskLevelColor(d.riskLevel); } }, { field: "workManager", title: "班组长", width: '13%', unresize: false, sort: false, align: "center", }, { title: "作业票状态", width: '12.5%', unresize: false, sort: false, align: "center", templet: function (d) { return '已结束'; } }, { title: "销号状态", field: "status", width: '11.5%', unresize: false, sort: false, align: "center", }, ]; } } // 获取参数 function getReqParams(page, limit, type, operType) { let obj = {}; if (!type) { obj = { page: page + "", limit: limit + "", status: operType === 1 ? $('#permitStatus').val() : $('#consumptionStatus').val(), type: operType, orgList:operType === 1 ? formSelects.value('buildCode', 'val'):formSelects.value('buildCode2', 'val'), projectName:operType === 1 ? $('#proName').val().trim():$('#proName2').val().trim(), currentUserId: user.userId + '', isSup: user.isSup, currentUserOrgId: user.orgId }; } else { obj = { page: page, limit: limit, status: operType === 1 ? $('#permitStatus').val() : $('#consumptionStatus').val(), type: operType, orgList:operType === 1 ? formSelects.value('buildCode', 'val'):formSelects.value('buildCode2', 'val'), projectName:operType === 1 ? $('#proName').val().trim():$('#proName2').val().trim(), currentUserId: user.userId + '', isSup: user.isSup, currentUserOrgId: user.orgId }; } return obj; }