let table, form, layer, laydate, util, user = getUser(); let type = 0; let pageNum = 1, limitSize = 50; $(function () { layui.config({ base: "../../js/layui/", //此处路径请自行处理, 可以使用绝对路径 }).extend({ formSelects: 'formSelects-v4' }).use(['layer', 'laydate', 'formSelects', 'form', 'table', 'util'], function () { layer = layui.layer; form = layui.form; laydate = layui.laydate; table = layui.table; formSelects = layui.formSelects; util = layui.util; form.render(); setTable(table); getOrgSelect(); getSelectParams(); getEarlyNum(); pages(1, 50, type); util.event('lay-active', { query: function () { pages(1, limitSize, type); }, reset: function () { $('#workManager').val(''); $('#bidName').val(''); formSelects.value('regulatory', []); formSelects.value('riskLevel', []); form.render(); pages(1, limitSize, type); }, export: function () { exportData(); } }); $('li').click(function () { if (type !== this.value) { changItem(this, $(this).parent(), 'checkBtn'); type = this.value; console.log(type); $('#workManager').val(""); $('#bidName').val(''); formSelects.value('regulatory', []); formSelects.value('riskLevel', []); pages(1, 50, type) } }); table.on("rowDouble(table)", function (res) { let obj = res.data; console.log(res); if (obj.type !== '2' && obj.type !== '3') { openRemotePatrol(obj.classId, obj.puid, obj.tCode, obj.twCode, obj.tdCode, obj.passWay, obj.bidCode); } }); }); }); function pages(pageNum, pageSize, type) { let params = getReqParams(pageNum, pageSize); $.ajax({ headers: { "encrypt": sm3(JSON.stringify(params)) }, url: dataUrl + "proteam/pot/early/" + urlLis[type] + "?token=" + token, data: params, type: 'POST', async: false, success: function (result) { console.log(result); if (result.code === 200) { if (result.rows) { initTable(result.rows, limitSize, pageNum) laypages(result.total, pageNum, limitSize) } } else if (result.code === 500) { layer.alert(result.msg, {icon: 2}) } else if (result.code === 401) { logout(1); } }, error: function () { } }); } function test(){ let params = getReqParams(1, 50); $.ajax({ headers: { "encrypt": sm3(JSON.stringify(params)) }, url: dataUrl + "proteam/pot/early/getTodayWarnInfo?token=" + token, data: params, type: 'POST', async: false, success: function (result) { console.log("test"); console.log(result); }, error: function () { } }); } 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: [30,50,100], layout: ['prev', 'page', 'next', 'skip', 'count', 'limit'], groups: 5, jump: function (obj, first) { if (!first) { pageNum = obj.curr; limitSize = obj.limit; console.log("type=="+type) pages(obj.curr, obj.limit, type); } } }); }) } function initTable(dataList, limit, page) { table.set({ limit: limit, data: dataList, cols: [setTableCols(page, limit, type)] }); table.render(); } /*** * * @param page * @param limit * @returns {{currentUserOrgId, riskLevel, currentUserId: string, org, pageSize: string, isSup, proName: (*|string|jQuery), type: string, pageNum: string, fzrName: (*|string|jQuery)}} */ function getReqParams(page, limit) { return { pageNum: page + "", pageSize: limit + "", org: formSelects.value('regulatory', 'val').toString(), riskLevel: formSelects.value('riskLevel', 'val').toString(), proName: $('#bidName').val(), fzrName: $('#workManager').val(), currentUserId: user.userId + "", isSup: user.isSup, currentUserOrgId: user.orgId, type: type + "" }; } function reloadTable(type){ pages(1, 50, type); } /** * 改变按钮样式 * @param dom dom * @param parentDom 父类Dom * @param css 样式名称 */ function changItem(dom, parentDom, css) { let item = $(dom); if (!item.hasClass(css)) { $.each(parentDom.children(), function (index, item) { $(item).removeClass(css); }); } item.addClass(css); } //组织机构下拉选 function getOrgSelect() { let keys = []; $.ajax({ headers: { "encrypt": sm3(JSON.stringify({})) }, url: dataUrl + 'proteam/pot/team/getOrgSelected' + '?token=' + token, type: 'post', success: function (data) { $.each(data.data, function (index, item) { let temp = { "name": item.name, "value": item.code }; keys.push(temp); }) formSelects.data('regulatory', 'local', { arr: keys }); form.render(); } }); } /* 风险等级赋值 */ function getSelectParams() { let keys = []; $.ajax({ headers: { "encrypt": sm3(JSON.stringify({ code: 'risk_level' })) }, url: dataUrl + 'proteam/pot/team/getSelectParams' + '?token=' + token, type: 'post', data: { code: 'risk_level' }, success: function (data) { let html = ''; $.each(data.data, function (index, item) { let temp = { "name": item.value, "value": item.key }; keys.push(temp); }) formSelects.data('riskLevel', 'local', { arr: keys }); form.render(); } }); } let arr = ["今日无施工", "新进班组", "七日无施工", "人数变化大", "工序变化", "重点关注", "球机异常", '球机信号','作业类型'] //导出 function exportData() { let loadingMsg = layer.msg("数据导出中,请稍候...", {icon: 16, scrollbar: false, time: 0,}); let url = dataUrl + "proteam/pot/early/exportToExcel?" + setData(getReqParams(pageNum, limitSize)) + '&token=' + token; let xhr = new XMLHttpRequest(); let a = document.createElement("a"); xhr.open("get", url, true); xhr.responseType = "blob"; // 转换流 xhr.setRequestHeader("encrypt", sm3(JSON.stringify( getReqParams(pageNum, limitSize) ))); xhr.onload = function () { layer.close(loadingMsg); if (this.status === 200) { let url = window.URL.createObjectURL(new Blob([this.response])) let link = document.createElement('a') link.style.display = 'none' link.href = url link.setAttribute('download', arr[type] + timestamp() + ".xlsx") document.body.appendChild(link) link.click() // 释放URL对象所占资源 window.URL.revokeObjectURL(url) // 用完即删 document.body.removeChild(link) } else { layer.msg("数据发生异常,请稍后重试", {icon: 16, scrollbar: false, time: 2000}); } }; xhr.send(); } function openRemotePatrol(id, puid, tCode, twCode, tdCode, passWay, bidNo) { if (user.isSup !== '3') { addSuper(id, "1"); } let layerIndex = layer.open({ id: "remotePatrol", title: false, type: 2, maxmin: false, content: '../dutyTask/remotePatrol/remotePatrol.html', area: ['100%', '100%'], closeBtn: 0, success: function (layero, index) { let iframeWin = window["layui-layer-iframe" + layerIndex]; iframeWin.setParams(id, puid, tCode, twCode, tdCode, passWay, user.isSup, 2, bidNo); }, end: function () { if (user.isSup !== '3') { addSuper(id, "2"); } } }); } /*添加督查时间*/ function addSuper(classId, type) { let params = { classId: classId, type: type } $.ajax({ headers: { "encrypt": sm3(JSON.stringify(params)) }, url: dataUrl + 'proteam/pot/supervision/insertSupervision?token=' + token, data: params, type: 'POST', async: true, success: function (result) { }, error: function () { } }); }