let table, form, laypage, tableIns, rightPopup, util, formSelects, user = getUser(); let pageNum = 1, limitSize = 30; let searchList = [ {'titleName': '工程名称', 'titleCode': 'bidName', 'isChecked': true, 'type': 'select'}, {'titleName': '工程状态', 'titleCode': 'proStatus', 'isChecked': true, 'type': 'select'}, {'titleName': '工程类型', 'titleCode': 'proType', 'isChecked': true, 'type': 'select'}, {'titleName': '关键字', 'titleCode': 'keyWord', 'isChecked': false, 'type': 'input'}]; $(function () { layui.config({ base: "../../js/layui/", //此处路径请自行处理, 可以使用绝对路径 }).extend({ rightPopup: "rightPopup", rightPopup2: "rightPopup2", formSelects: 'formSelects-v4' }).use(["form", "laypage", "formSelects", "table", "rightPopup", "rightPopup2", 'util'], function () { form = layui.form; //只有执行了这一步,部分表单元素才会自动修饰成功 table = layui.table; laypage = layui.laypage; rightPopup = layui.rightPopup2; util = layui.util; formSelects = layui.formSelects; util.event('lay-active', { query: function () { pages(1, limitSize); getBasicInfoData(); }, reset: function () { $("#proStatus").val('00'); $('#proType').val('00'); $('#isStop').val('00'); $('#voltage').val('00'); $('#jlManage').val(''); $("#owerManager").val(''); $("#consManage").val(''); $("#keyWord").val(''); formSelects.value('bidName', []); formSelects.value('buildUnit', []); form.render(); pages(1, limitSize); getBasicInfoData(); }, export: function () { exportData(); }, openMore: function () { openMoreOption(); } }); getOrgSelect(); getProStatus(); /*getSelectParams();*/ getIsStop(); getProType(); getVoltage(); getBasicInfoData(); pages(1, 30, 1); getProject(); layui.form.render(); $('#myModal_edit').on('show.bs.modal', centerModals); table.on("rowDouble(proTable)", function (res) { viewData(res.data.bidCode); }); table.on('tool(proTable)', function (obj) { console.log(obj.event); console.log(obj.data.bidCode); var bidCode=obj.data.bidCode; switch (obj.event) { case 'team': openWorkTeam(bidCode) break; case 'tClass': openClassMetting(1, bidCode); break; case 'yClass': openClassMetting(2, bidCode); break; default: break; } }) } ); }); /* 班组详情跳转 */ function openWorkTeam(bidCode) { let layerIndex = layer.open({ id: "workTeam", title: false, type: 2, maxmin: false, content: 'child/workTeam.html', area: ['100%', '100%'], move: false, closeBtn: 0, success: function (layero, index) { let iframeWin = window["layui-layer-iframe" + layerIndex]; iframeWin.setParams(bidCode); } }); } /* *站班会 * 详情 */ function openClassMetting(type, id) { let layerIndex = layer.open({ id: "workTeam", title: false, type: 2, maxmin: false, content: 'classMetting.html', area: ['100%', '100%'], move: false, closeBtn: 0, success: function (layero, index) { let iframeWin = window["layui-layer-iframe" + layerIndex]; iframeWin.setParams(type, id); } }); } /** * * @param pageNum * @param pageSize */ function pages(pageNum, pageSize) { let params = getReqParams(pageNum, pageSize); $.ajax({ headers: { "encrypt": sm3(JSON.stringify(params)) }, url: dataUrl + 'proteam/pot/newPro/getProList?token=' + token, data: params, type: 'POST', async: false, success: function (result) { if (result.code === 200) { console.log(result); if (result.rows) { initTable(result.rows, limitSize, pageNum) laypages(result.total, pageNum, limitSize); resetContent(); } } else if (result.code === 500) { layer.alert(result.msg, {icon: 2}) } else if (result.code === 401) { logout(); } }, 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; pages(obj.curr, obj.limit, null); } } }); }) } // 在建工程、今日实施作业工、二级风险、三级风险、四级风险、五级风险、施工班组、施工人员数量 function getBasicInfoData() { $.ajax({ headers: { "encryp+t": sm3(JSON.stringify({ params: encrypt(JSON.stringify({ currentUserId: user.userId, isSup: user.isSup, currentUserOrgId: user.orgId, buildUnit: formSelects.value('buildUnit', 'val').toString(), bidCode: formSelects.value('bidName', 'val').toString(), status: isEmpty($("#proStatus").val()) ? "" : $('#proStatus').val(), singleType: isEmpty($('#proType').val()) ? "" : $('#proType').val(), })) })) }, url: dataUrl + "proteam/pot/newPro/getBasicInfoData?token=" + token, type: "POST", dataType: "JSON", data: { params: encrypt(JSON.stringify({ currentUserId: user.userId, isSup: user.isSup, currentUserOrgId: user.orgId, buildUnit: formSelects.value('buildUnit', 'val').toString(), bidCode: formSelects.value('bidName', 'val').toString(), status: isEmpty($("#proStatus").val()) ? "" : $('#proStatus').val(), singleType: isEmpty($('#proType').val()) ? "" : $('#proType').val(), })) }, success: function (data) { let obj = data.data; if (obj) { $("#underConst_num").html(obj.zjNum); $("#impWork_num").html(obj.ssNum); $("#twoRiskNum").html(obj.ejfxNum); $("#threeRiskNum").html(obj.sjfxNum); $("#fourRiskNum").html(obj.fffNum); $("#fiveRiskNum").html(obj.wjfxNum); $("#team_num").html(obj.teamNum); $("#team_person_num").html(obj.sgNum); } } }); } function initTable(dataList, limit, page) { tableIns = table.render({ elem: "#proTable", id: "proTable", height: "full-175", data: dataList, limit: limit, cols: [ [ //表头 { title: "序号", width: 80, unresize: true, align: "center", fixed: 'left', templet: function (d) { return (page - 1) * limit + d.LAY_INDEX; } }, { field: "orgName", title: "建管单位", width: 200, unresize: false, align: "center", sort: true, fixed: 'left' }, { field: "bidName", title: "工程名称", width: 200, unresize: false, align: "center", sort: true, fixed: 'left', }, { field: "teamNum", title: "施工班组总数", width: 200, unresize: false, event: 'team', sort: true, align: "center", templet: function (d) { return "" + d.teamNum + ""; } }, { field: "tzNum", title: "当日站班会/施工人数", width: 240, unresize: false, event: 'tClass', sort: true, align: "center", templet: function (d) { return "" + d.tzNum + ""; } }, { field: "yzNum", title: "昨日站班会/施工人数", width: 240, unresize: false, event: 'yClass', sort: true, align: "center", templet: function (d) { return "" + d.yzNum + ""; } }, {field: "ejfxNum", title: "当日二级风险数", width: 200, unresize: false, sort: true, align: "center",}, {field: "sjfxNum", title: "当日三级风险数", width: 200, unresize: false, sort: true, align: "center",}, {field: "fffNum", title: "当日四级风险数", width: 200, unresize: false, sort: true, align: "center",}, {field: "wjfxNum", title: "当日五级风险数", width: 200, unresize: false, sort: true, align: "center",}, {field: "jdDw", title: "监理单位", width: 200, unresize: false, align: "center", sort: true,}, {field: "sgDw", title: "施工单位", width: 200, unresize: false, align: "center", sort: true,}, {field: "wzNum", title: "违章数", width: 200, unresize: false, align: "center", sort: true}, {field: "state", title: "工程状态", width: 200, unresize: false, align: "center", sort: true, templet: function (d) { if(d.state=='01'){ return '待建' }else if(d.state=='02'){ return '在施' }else if(d.state=='03'){ return '停工' }else if(d.state=='04'){ return '投产' }else{ return '待建' } } }, {field: "proDetailType", title: "工程类型", width: 200, unresize: false, align: "center", sort: true,}, {field: "yzxmjl", title: "业主项目经理", width: 200, unresize: false, sort: true, align: "center",}, {field: "zjlgcs", title: "总监理工程师", width: 200, unresize: false, sort: true, align: "center",}, {field: "sgxmjl", title: "施工项目经理", width: 200, unresize: false, sort: true, align: "center",}, ], ], done: function (res, curr, count) { $(".layui-laypage-skip").css("display", "none"); $(".layui-table-main tr").each(function (index, val) { $($(".layui-table-fixed-r tr")[index + 1]).css("height", $(val).height()); }); } }); } // 获取参数 function getReqParams(page, limit) { console.log($('#proType').val()) return { pageNum: page + "", pageSize: limit + "", buildUnit: formSelects.value('buildUnit', 'val').toString(), bidCode: formSelects.value('bidName', 'val').toString(), status: isEmpty($("#proStatus").val()) ? "" : $('#proStatus').val(), proDetailType: isEmpty($('#proType').val()) ? "" : $('#proType').val(), keyWord: isEmpty($("#keyWord").val()) ? "" : $("#keyWord").val(), currentUserId: user.userId + "", isSup: user.isSup, currentUserOrgId: user.orgId }; } //导出 function exportData() { let loadingMsg = layer.msg("数据导出中,请稍候...", {icon: 16, scrollbar: false, time: 0,}); let url = dataUrl + "proteam/pot/newPro/exportProData?" + 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', "工程列表.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 viewData(data) { rightPopup.rightPopupLayer("../../html/projectInformation/child/projectDetailsDetail.html", data); } //组织机构下拉选 function getOrgSelect() { let keys = []; $.ajax({ headers: { "encrypt": sm3(JSON.stringify({})) }, url: dataUrl + 'proteam/pot/team/getOrgSelected' + '?token=' + token, type: 'post', success: function (data) { console.log(data); $.each(data.data, function (index, item) { let temp = { "name": item.name, "value": item.code }; keys.push(temp); }) formSelects.data('buildUnit', 'local', { arr: keys }); form.render(); } }); } function getProject() { let keys = []; $("#bidName").empty(); Ajax().post({ headers: { "encrypt": sm3(JSON.stringify({ currentUserId: user.userId, isSup: user.isSup, currentUserOrgId: user.orgId })) }, url: dataUrl + 'proteam/pot/newPro/getProjectSelect', data: { currentUserId: user.userId, isSup: user.isSup, currentUserOrgId: user.orgId }, success: function (data) { let obj = data.data; $.each(obj, function (index, item) { keys.push({ "name": item.proName, "value": item.proCode }); }); formSelects.data('bidName', 'local', { arr: keys }); formSelects.btns('bidName',['remove']) form.render(); } }); } //工程状态下拉选 function getProStatus() { let obj = [{ code: '01', name: '待建' }, { code: '02', name: '在施' },{ code: '03', name: '停工' }, { code: '04', name: '投产' }]; let html = ''; $.each(obj, function (index, item) { html += ''; }) $('#proStatus').empty().append(html); form.render(); } function getIsStop() { let obj = [{ code: 1, name: '是' }, { code: 0, name: '否' }]; let html = ''; $.each(obj, function (index, item) { html += ''; }) $('#isStop').empty().append(html); form.render(); } //工程状态下拉选 function getProType() { let obj = [ {code: '1', name: '变电站' }, {code: '2', name: '架空线' }, {code: '3', name: '架空线切改' }, {code: '4', name: '电缆' }, {code: '5', name: '电缆切改' }, {code: '6', name: '开关站' }, {code: '7', name: '间隔' }, {code: '9', name: '通信光缆' }, {code: '10', name: '通信站' }, {code: '11', name: '混合线路' }, {code: '12', name: '换流站' }, {code: '13', name: '串补站' }, {code: '19', name: '间隔' }, {code: '21', name: '水下电缆' }, {code: '22', name: '水下电缆切改' }, {code: '23', name: '混合线路' }, {code: '24', name: '静止无功补偿工程' }, {code: '25', name: '调相机工程' }, {code: '26', name: '安全稳定控制工程' } ]; let html = ''; $.each(obj, function (index, item) { html += ''; }) $('#proType').empty().append(html); form.render(); } function getVoltage() { let obj = [{ code: '110(66)kV', name: '110(66)kV' }, { code: '220kV', name: '220kV' }, { code: '35kV', name: '35kV' }, { code: '500KV', name: '500KV' }] ; let html = ''; $.each(obj, function (index, item) { html += ''; }) $('#voltage').empty().append(html); form.render(); } // 关闭页面 function closePage(type) { if (type === 1) { let index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引 parent.layer.close(index); //再执行关闭 } else if (type === 2) { layer.closeAll(); } } // 展开/收起 function isShow(type) { if (type === 1) { $("#basic-info").slideLeftHide(); setTimeout(() => { $("#show").removeAttr("style"); }, 510); $(".basic-info-box").animate({backgroundColor: "#fff"}, "500"); } else if (type === 2) { $("#show").css("display", "none"); $(".basic-info-box").animate({backgroundColor: "#EEF5FF"}, "500"); $("#basic-info").slideLeftShow(); } } // 弹出模态框 function centerModals() { $('#myModal_edit').each(function (i) { var $clone = $(this).clone().css('display', 'block').appendTo('body'); var top = Math.round(($clone.height() - $clone.find('.modal-content').height()) / 3); top = top > 0 ? top : 0; $clone.remove(); $(this).find('.modal-content').css("margin-top", top); }); } /*更多选项*/ function openMoreOption() { let width = getMoreWidth().toFixed(0) + "px"; let height = getMoreHeight().toFixed(0) + "px"; let layerIndex = layer.open({ id: "moreOption", title: ['
选择查询条件
', 'font-size:16px;background-color:#f0f0f0;display: flex;align-items: center;'], type: 1, maxmin: false, content: setOptionHtml(), area: [width, height], move: false, shade: 0.1, success: function (layero, index) { layui.form.render(); $(window).resize(function () { if (autoMoreResizeWidth) autoMoreResizeWidth(index); if (autoMoreResizeHeight) autoMoreResizeHeight(index); }); }, }); } /*更多选项赋值*/ function setOptionHtml() { let html = '
'; let cent = ''; $.each(searchList, function (index, item) { if (item.isChecked) { cent += '
' } else { cent += '
' } }) html += '
' + cent + '
' html += '
' + '' + '' + '
' return html; } /*确定更多选项*/ function sureOption() { let formList = []; $('input[type=checkbox]').each(function (index) { let html = ''; searchList[index].isChecked = $(this).prop("checked") if ($(this).prop("checked")) { formList.push(setOptionForm(searchList[index])) } }) setFormHtml(formList); layer.closeAll() } /*给表单内容*/ function setFormHtml(data) { $('.more-search-box').removeAttr('style') let html = '', cent = '', cent2 = '', item = $('.option-form .layui-form-item'); clearBasicForm(); $('.two-item').css('height', '0') if (data.length > 0 && data.length <= 3) { $.each(data, function (index, item) { html += item; }) $('.buildUnit').after(html); } else if (data.length > 3) { $.each(data, function (index, item) { if (index <= 2) { html += item; } else if (index > 2) { cent += item; } }) clearBasicForm(); $('.buildUnit').after(html); if (cent != '') { $('.two-item').css('height', '50px').append(cent) } } if (data.length <= 3) { $('.table-box').css('height', 'calc(100% - 300px)') tableIns.getthat().fullHeightGap = '180' } else if (data.length > 3 && data.length <= 8) { tableIns.getthat().fullHeightGap = '225' $('.table-box').css('height', 'calc(100% - 300px)') } form.render(); tableIns.resize(); getOrgSelect(); getProStatus(); getProType(); getVoltage(); getIsStop(); getProject(); } /*设置更多选项表单*/ function setOptionForm(item) { let html = ''; if (item.type === 'select') { html = '
' + '' + '
' + '' + '
' + '
' } else { html = '
' + '' + '
' + '' + '
' + '
' } return html; } /*清空表单的内容*/ function clearBasicForm() { console.log(2); let obj = $('.layui-form-item .layui-inline'); obj.each(function () { if ($(this).hasClass('buildUnit') || $(this).hasClass('btns')) { } else { let classAttr = $(this).attr('class'); obj.remove('.' + classAttr.substring(classAttr.indexOf(' ') + 1, classAttr.length)); } }) } // 重置页面样式 function resetContent() { if ($('.layui-input-inline').length <= 4) { $('.table-box').css('height', 'calc(100% - 300px)') tableIns.getthat().fullHeightGap = '180' } else if ($('.layui-input-inline').length > 4 && $('.layui-input-inline').length <= 10) { $('.table-box').css('height', 'calc(100% - 300px)') tableIns.getthat().fullHeightGap = '225' } else if ($('.layui-input-inline').length === 11) { $('.table-box').css('height', 'calc(100% - 300px)') tableIns.getthat().fullHeightGap = '220' } tableIns.resize(); }