let form, laydate, flow, layer, rightPopup; let pageNum = 1, pageSize = 15; // 图片定义分页 let pageNum2 = 1, pageSize2 = 2; // 列表定义分页 let queryType = 1; // 默认图片 function setParams(obj) { layui.config({ base: "../../js/layui-v2.9.14/layui/", //此处路径请自行处理, 可以使用绝对路径 }).extend({ rightPopup: "rightPopup2", }).use(["form", 'laydate', 'flow', 'layer', 'rightPopup'], function () { form = layui.form; laydate = layui.laydate; flow = layui.flow; layer = layui.layer; rightPopup = layui.rightPopup; dataFlow(); }); } /**数据流加载*/ function dataFlow() { flow.load({ elem: '#ID-flow-demo', // 流加载容器 scrollElem: '#ID-flow-demo', // 滚动条所在元素,一般不用填,此处只是演示需要。 end: '数据加载完毕', direction: 'bottom', done: function (page, next) { // 执行下一页的回调 pageNum = page; let lis = []; let returnData = loadData(); if (returnData != null) { if (queryType === 1) { // 图片 lis = initImgData(returnData.data.list) } else { // 列表 lis = initListData(returnData.data.list) } next(lis.join(''), page < returnData.data.total / (queryType === 1 ? pageSize : pageSize2)); if (queryType === 1) { $('.img-info').on('mouseenter', function () { this.querySelector('.hidden-actions').style.display = 'block'; }); $('.img-info').on('mouseleave', function () { this.querySelector('.hidden-actions').style.display = 'none'; }); } else { $('.img-data').on('mouseenter', function () { this.querySelector('.hidden-actions2').style.display = 'block'; }); $('.img-data').on('mouseleave', function () { this.querySelector('.hidden-actions2').style.display = 'none'; }); } } } }); } /**加载图片数据*/ function loadData() { let returnData = null; let url = dataUrl + "/backstage/synthesisQuery/getImgList" let obj = {} if (queryType === 1) { // 图片 obj = { pageNum: pageNum, pageSize: pageSize, queryType: queryType } } else { // 列表 obj = { pageNum: pageNum2, pageSize: pageSize2, queryType: queryType } } let params = { encryptedData: encryptCBC(JSON.stringify(obj)) } ajaxRequest(url, "POST", params, false, function () { }, function (result) { if (result.status === 200) { console.log(result) returnData = result; } else { layer.msg(result.msg, {icon: 2}) } }, function (xhr) { error(xhr) }); return returnData; } /**渲染图片*/ function initImgData(list) { let htmlArr = []; if (list && list.length > 0) { $.each(list, function (index, item) { htmlArr.push("
" + "
\n" + " " + "
" + "
" + "

" + item.uploadTime + "

" + "

" + item.uploadTypeName + "

" + "
" + "
" + "

" + item.sourceTypeName + "

" + setCollectData(item) + "
" + "
" + "
" + "
" + "
" + setCollectImg(item) + "
" + "
"); }) } return htmlArr; // 设置收藏按钮 function setCollectImg(item) { if (item.collectStatus === '0') { return "
" + ""; } else { return "" + "
"; } } // 设置收藏图标 function setCollectData(item) { if (item.collectStatus === '1') { return ""; } return ""; } } /**1.图片 2.列表*/ function changeType(that, type) { if (type === 1) { $(that).attr('src', '../../img/synthesisQuery/photo_check.png'); $(that).next().attr('src', '../../img/synthesisQuery/list.png'); } else { $(that).attr('src', '../../img/synthesisQuery/list_check.png'); $(that).prev().attr('src', '../../img/synthesisQuery/photo.png'); } queryType = type; pageNum = 1; pageNum2 = 1; $('#ID-flow-demo').empty(); dataFlow(); } /*图片类型查询*/ function queryByType(that, type) { $('.type-num').each(function () { $(this).removeClass('type-num-check'); }) $(that).addClass('type-num-check'); } /**渲染列表图片*/ function initListData(list) { let htmlArr = []; if (list && list.length > 0) { $.each(list, function (index, item) { let html = "
" + "
" + "

" + item.uploadTime + "

" + "

" + item.uploadTypeName + "

" + "
" + setBasicInfo(item) + "
" console.log(html) htmlArr.push(html); }) } return htmlArr; /**设置安全违章\质量检测\安全措施落实\协调照片\重要事项及宣传类*/ function setBasicInfo(item) { let html = ''; if (item.uploadType === '1') { // 安全违章 html += "
" + "

违章地点:

" + "

" + item.id + "

" + "
" + "
" + "

违章描述:

" + "

施工人员未正确佩戴安全帽,存在安全隐患

" + "
" + "
" + setImgData() + "
" + setRectData(item); } else if (item.uploadType === '2') { // 质量检测 html += "
" + "

检查地点

" + "

工地 A 区施工现场 3 号楼

" + "
" + "
" + "

检查描述:

" + "

施工人员未正确佩戴安全帽,存在安全隐患

" + "
" + "
" + setImgData() + "
" + setRectData(item); } else if (item.uploadType === '3') { // 安全措施落实 html += "
" + "

检查地点

" + "

工地 A 区施工现场 3 号楼

" + "
" + "
" + "

检查描述:

" + "

施工人员未正确佩戴安全帽,存在安全隐患

" + "
" + "
" + setImgData() + "
"; } else if (item.uploadType === '4') { // 协调照片 html += "
" + "

建设前描述

" + "

工地 A 区施工现场 3 号楼

" + "
" + "
" + setImgData() + "
" + "
" + "

建设中描述:

" + "

施工人员未正确佩戴安全帽,存在安全隐患

" + "
" + "
" + setImgData() + "
" + "
" + "

恢复后描述:

" + "

施工人员未正确佩戴安全帽,存在安全隐患

" + "
" + "
" + setImgData() + "
"; } else if (item.uploadType === '5') { // 重要事项及宣传类 html += "
" + "

标题

" + "

工地 A 区施工现场 3 号楼

" + "
" + "
" + "

内容:

" + "

施工人员未正确佩戴安全帽,存在安全隐患

" + "
" + "
" + setImgData() + "
"; } return html; function setImgData() { let list = [{compressFilePath: '../../img/synthesisQuery/7.jpg'}, {compressFilePath: '../../img/synthesisQuery/7.jpg'}, {compressFilePath: '../../img/synthesisQuery/7.jpg'}, {compressFilePath: '../../img/synthesisQuery/7.jpg'}, {compressFilePath: '../../img/synthesisQuery/7.jpg'}, {compressFilePath: '../../img/synthesisQuery/7.jpg'}]; let cent = ''; $.each(list, function (index, item) { cent += "
" + "" + "
" + "
" + "
" + "
" + setCollectImg(item) + "
" + "
"; }) return cent; } /**设置整改数据*/ function setRectData(item) { let cent2 = ''; if (item.rectStatus === '1') { // 已整改 cent2 += "
" + "

整改说明:

" + "

施工人员已进行安全教育

" + "
" + "
" + setImgData() + "
"; } return cent2; } } // 设置收藏按钮 function setCollectImg(item) { if (item.collectStatus === '0') { return "
" + ""; } else { return "" + "
"; } } } /**放大*/ function viewImg(item) { layer.photos({ shade: 0.5, footer: false, photos: { "title": "图片预览", "start": 0, "data": [ { "pid": 1, "src": "../../img/synthesisQuery/7.jpg", } ] }, }); } /**放大*/ function imgDownLoad(item) { alert(item.id) } /**水印下载*/ function waterImgDownLoad(item) { alert(item.id) } /**收藏*/ function collectImg(that, item, type) { if (type === 0) { // 收藏 $(that).next().removeAttr("style"); $(that).css({'display': 'none'}) $(that).parent().parent().prev().find('img').eq(0).removeAttr('style') } else if (type === 1) { // 取消收藏 $(that).prev().removeAttr("style"); $(that).css({'display': 'none'}); $(that).parent().parent().prev().find('img').eq(0).css({'display': 'none'}) } } /**高级筛选*/ function highSearch() { rightPopup.rightPopupLayer("../../pages/synthesisQuery/highSearchForm.html", JSON.stringify({}), ["50%", "100%"]); }