| | |
| | | label.error{ |
| | | position :absolute !important; |
| | | } |
| | | #preFileList{ |
| | | display: flex; |
| | | align-items: flex-start; |
| | | margin-top: 10px; |
| | | } |
| | | #postFileList{ |
| | | display: flex; |
| | | align-items: flex-start; |
| | | margin-top: 10px; |
| | | } |
| | | .file-list-item1,.file-temp1,.file-list-item2,.file-temp2{ |
| | | width: 100px; |
| | | margin-right: 10px; |
| | | } |
| | | [class^="file-list-item"] div:nth-child(1){ |
| | | width: 100%; |
| | | overflow: hidden; |
| | | position: relative; |
| | | } |
| | | [class^="file-list-item"] div:nth-child(1) img{ |
| | | width: 100px; |
| | | height: 100px; |
| | | } |
| | | [class^="file-list-item"] div:nth-child(1) .layui-badge1,.layui-badge2{ |
| | | position: absolute; |
| | | left: 2px; |
| | | top: 2px; |
| | | } |
| | | [class^="file-list-item"] div:nth-child(2){ |
| | | width: 100%; |
| | | height: 36px; |
| | | text-align: center; |
| | | line-height: 36px; |
| | | margin-top: 4px; |
| | | } |
| | | [class^="file-list-item"] div:nth-child(2) [class^="file-cancel"]{ |
| | | width: 100%; |
| | | height: 36px; |
| | | } |
| | | [class^="file-list-item"] div:nth-child(2) [class^="file-cancel"]:hover{ |
| | | background: #ED5565; |
| | | color: #fff; |
| | | } |
| | | </style> |
| | | </head> |
| | | <body class="white-bg"> |
| | |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="col-sm-6"> |
| | | <div class="form-group"> |
| | | <label class="col-sm-4 control-label">隐患来源:</label> |
| | | <div class="col-sm-8"> |
| | | <select th:field="*{dangerSrc}" class="form-control m-b" th:with="type=${@dict.getType('danger_source')}" readonly="readonly"> |
| | | <option value="" disabled>--请选择隐患来源--</option> |
| | | <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" disabled></option> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |
| | | |
| | |
| | | <div class="form-group"> |
| | | <label class="col-sm-4 control-label ">隐患名称:</label> |
| | | <div class="col-sm-8"> |
| | | <textarea th:value="*{dangerName}" class="form-control" type="text" rows="4" readonly="readonly"></textarea> |
| | | <textarea th:field="*{dangerName}" class="form-control" type="text" rows="4" readonly="readonly"></textarea> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |
| | | |
| | | <div class="row"> |
| | | <div class="col-sm-6"> |
| | | <div class="form-group"> |
| | | <label class="col-sm-4 control-label ">隐患排查方法:</label> |
| | | <div class="col-sm-8"> |
| | | <input th:value="*{remark}" class="form-control" type="text" readonly="readonly"> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div class="row"> |
| | | <div class="col-sm-6"> |
| | | <div class="form-group"> |
| | |
| | | <div class="form-group"> |
| | | <label class="col-sm-4 control-label ">隐患描述:</label> |
| | | <div class="col-sm-8"> |
| | | <textarea th:value="*{dangerDescription}" class="form-control" type="text" rows="4" readonly="readonly"></textarea> |
| | | <textarea th:field="*{dangerDescription}" class="form-control" type="text" rows="4" readonly="readonly"></textarea> |
| | | </div> |
| | | </div> |
| | | </div> |
| | |
| | | <div class="form-group"> |
| | | <label class="col-sm-4 control-label ">隐患视图:</label> |
| | | <div class="col-sm-8"> |
| | | <img style="width: 100px; height: 100px;cursor:pointer;" |
| | | <!-- <img style="width: 100px; height: 100px;cursor:pointer;"--> |
| | | <!-- title="查看图片"--> |
| | | <!-- th:src="*{preRectifyPhoto}"--> |
| | | <!-- onclick="showPicture(this.getAttribute('data-id'),'preRectifyPhoto')"--> |
| | | <!-- th:data-id="${hdcp.id}">--> |
| | | <img style="width: 100px; height: 100px;cursor:pointer;display: none" |
| | | title="查看图片" |
| | | class="allPics" |
| | | th:src="*{preRectifyPhoto}" |
| | | onclick="showPicture(this.getAttribute('data-id'),'preRectifyPhoto')" |
| | | th:data-id="${hdcp.id}"> |
| | | <div class="image-container" style="display: flex;align-items: flex-start"></div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | |
| | | <div class="form-group"> |
| | | <label class="col-sm-3 control-label is-required">验收负责人:</label> |
| | | <div class="col-sm-8"> |
| | | <input id="acceptUserName" name="acceptUserName" placeholder="选择验收负责人" class="form-control" type="text" onclick="selectAcceptUser()" maxlength="30" readonly="true" required> |
| | | <input id="acceptUserId" name="acceptUserId" type="hidden" > |
| | | <!-- <input id="acceptUserName" name="acceptUserName" placeholder="选择验收负责人" class="form-control" type="text" onclick="selectAcceptUser()" maxlength="30" readonly="true" required>--> |
| | | <!-- <input id="acceptUserId" name="acceptUserId" type="hidden" >--> |
| | | <input name="acceptUserName" th:value="*{registerUserName}" class="form-control" type="text" readonly="readonly"> |
| | | <input name="acceptUserId" th:value="*{registerUserId}" type="hidden"> |
| | | </div> |
| | | </div> |
| | | |
| | |
| | | <label class="col-sm-3 control-label is-required">隐患整改后照片:</label> |
| | | <div class="col-sm-8"> |
| | | <input name="postRectifyPhoto" id="postRectifyPhoto" type="hidden"> |
| | | <button type="button" class="layui-btn" id="postRectifyPhotoUpload">上传</button> |
| | | <div class="layui-upload-list"> |
| | | <img class="layui-upload-img" style="width: 92px; height: 92px;" id="ThumbImg"> |
| | | <p id="msgText"></p> |
| | | </div> |
| | | <!-- <button type="button" class="layui-btn" id="postRectifyPhotoUpload">上传</button>--> |
| | | <!-- <div class="layui-upload-list">--> |
| | | <!-- <img class="layui-upload-img" style="width: 92px; height: 92px;" id="ThumbImg">--> |
| | | <!-- <p id="msgText"></p>--> |
| | | <!-- </div>--> |
| | | <button type="button" class="layui-btn layui-btn-normal" id="postChooseList">选择文件(不超过3张)</button> |
| | | <button type="button" class="layui-btn" id="postUpAction">确认上传(上传后不可修改)</button> |
| | | <div id="postFileList"></div> |
| | | </div> |
| | | </div> |
| | | |
| | |
| | | <th:block th:include="include :: datetimepicker-js"/> |
| | | <th:block th:include="include :: jquery-steps-js"/> |
| | | <script type="text/javascript"> |
| | | $(document).ready(function () { |
| | | var imgsUrl = $('.allPics'); |
| | | var imageUrls = imgsUrl.attr('src') |
| | | var ids = imgsUrl.attr('data-id') |
| | | var imageContainer = document.querySelector('.image-container'); |
| | | |
| | | if(imageUrls && imageUrls !== '') { |
| | | // 将逗号分隔的字符串拆分为URL数组 |
| | | var imageUrlArray = imageUrls.split(','); |
| | | |
| | | // 遍历URL数组并创建img元素 |
| | | imageUrlArray.forEach(function (url, index) { |
| | | var img = document.createElement('img'); |
| | | img.setAttribute('src', url); |
| | | img.setAttribute('style', 'width: 100px; height: 100px; cursor: pointer;margin-right: 10px'); |
| | | img.setAttribute('title', '查看图片'); |
| | | img.setAttribute('data-id', ids); |
| | | img.addEventListener('click', function () { |
| | | // showPicture(this.getAttribute('data-id'), 'preRectifyPhoto'); |
| | | openPicture(url) |
| | | }); |
| | | imageContainer.appendChild(img); |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | function openPicture(url) { |
| | | window.open(url) |
| | | } |
| | | |
| | | /* 图片--查看 */ |
| | | function showPicture(id,type) { |
| | | var showPictureUrl = "/tr/hiddenDangerCheck/dangerBase/showPicture/{type}/{id}"; |
| | |
| | | |
| | | |
| | | <!--layui图片文件上传--> |
| | | layui.use('upload', function () { |
| | | var $ = layui.jquery |
| | | , upload = layui.upload; |
| | | |
| | | //普通图片上传 |
| | | var uploadInst = upload.render({ |
| | | elem: '#postRectifyPhotoUpload' |
| | | , url: ctx + 'tr/upload' |
| | | , before: function (obj) { |
| | | //预读本地文件示例,不支持ie8 |
| | | obj.preview(function (index, file, result) { |
| | | $('#ThumbImg').attr('src', result); //图片链接(base64) |
| | | }); |
| | | } |
| | | , done: function (res) { |
| | | //如果上传失败 |
| | | if (res.code > 0) { |
| | | return layer.msg('上传失败'); |
| | | } |
| | | //上传成功 |
| | | $('#postRectifyPhoto').val(res.imageUrl); |
| | | } |
| | | , error: function () { |
| | | //演示失败状态,并实现重传 |
| | | var msgText = $('#msgText'); |
| | | msgText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>'); |
| | | msgText.find('.demo-reload').on('click', function () { |
| | | uploadInst.upload(); |
| | | }); |
| | | // layui.use('upload', function () { |
| | | // var $ = layui.jquery |
| | | // , upload = layui.upload; |
| | | // |
| | | // //普通图片上传 |
| | | // var uploadInst = upload.render({ |
| | | // elem: '#postRectifyPhotoUpload' |
| | | // , url: ctx + 'tr/upload' |
| | | // , before: function (obj) { |
| | | // //预读本地文件示例,不支持ie8 |
| | | // obj.preview(function (index, file, result) { |
| | | // $('#ThumbImg').attr('src', result); //图片链接(base64) |
| | | // }); |
| | | // } |
| | | // , done: function (res) { |
| | | // //如果上传失败 |
| | | // if (res.code > 0) { |
| | | // return layer.msg('上传失败'); |
| | | // } |
| | | // //上传成功 |
| | | // $('#postRectifyPhoto').val(res.imageUrl); |
| | | // } |
| | | // , error: function () { |
| | | // //演示失败状态,并实现重传 |
| | | // var msgText = $('#msgText'); |
| | | // msgText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>'); |
| | | // msgText.find('.demo-reload').on('click', function () { |
| | | // uploadInst.upload(); |
| | | // }); |
| | | // } |
| | | // }); |
| | | // }); |
| | | layui.use('upload', function() { |
| | | var $ = layui.jquery; |
| | | upload = layui.upload; |
| | | var uploadList = {}; |
| | | var urls = [] |
| | | //多文件列表示例 |
| | | var postFileListDom = $('#postFileList') |
| | | var uploadListIns = upload.render({ |
| | | elem: '#postChooseList', |
| | | url: ctx + 'tr/upload' , |
| | | accept: 'file', |
| | | multiple: true, |
| | | number: 3, |
| | | auto: false, |
| | | bindAction: '#postUpAction', |
| | | choose: function(obj) { |
| | | // 展示上传按钮 |
| | | $('#postUpAction').show(); |
| | | // 将每次选择的文件追加到文件队列 |
| | | uploadList = obj.pushFile(); |
| | | const len = postFileListDom.find('.file-list-item2').length; |
| | | // 还可以上传的文件数量 |
| | | const limit = 3 - len; |
| | | var number = 0; |
| | | // 预读本地文件,如果是多文件,则会遍历。(不支持ie8/9) |
| | | obj.preview(function(index, file, result){ |
| | | if (number < limit){ |
| | | number++; |
| | | appendFile(index, file.name, result); |
| | | }else{ |
| | | deleteTempFile(index) |
| | | } |
| | | }) |
| | | }, |
| | | // before: function(obj){ |
| | | // layer.load(1); |
| | | // }, |
| | | //上传完毕回调 |
| | | //当文件全部被提交后,才触发 |
| | | allDone: function (obj) { |
| | | layer.msg("已上传 "+obj.successful+" 个文件"); |
| | | layer.closeAll('loading'); |
| | | deleteTempFile(0) |
| | | }, |
| | | done: function(res, index, upload){ |
| | | postFileListDom.find('.file-temp2').each(function () { |
| | | if (!res || res.code > 0){ |
| | | // 若上传失败,则直接移除 |
| | | return layer.msg('上传失败'); |
| | | $(this).remove(); |
| | | }else{ |
| | | $(this).removeClass('file-temp2'); |
| | | $(this).find('.file-cancel2').remove(); |
| | | $(this).find('.layui-badge2').remove(); |
| | | urls.push(res.imageUrl) |
| | | } |
| | | $('#postRectifyPhoto').val(urls.join(',')); |
| | | }) |
| | | }, |
| | | error: function(index, upload) { |
| | | var tr = postFileListDom.find('tr#upload-' + index), |
| | | tds = tr.children(); |
| | | tds.eq(1).html('<span style="color: #FF5722;">上传失败</span>'); |
| | | tds.eq(2).find('.demo-reload').removeClass('layui-hide'); //显示重传 |
| | | } |
| | | }); |
| | | |
| | | // 预览选择的文件 |
| | | function appendFile(index, name, result) { |
| | | const dom = '<div class="file-list-item2 file-temp2" data-index="'+index+'"><div><img src="'+result+'" alt="'+name+'"><span class="layui-badge2 layui-bg-blue">待上传</span></div>' + |
| | | '<div><input type="button" class="file-cancel2" value="删除"></div></div>'; |
| | | postFileListDom.append(dom); |
| | | fileCancelEvent(); |
| | | } |
| | | // 为待上传文件【取消】按钮添加点击事件 |
| | | function fileCancelEvent() { |
| | | postFileListDom.find('.file-cancel2').each(function () { |
| | | const event = $._data($(this)[0],"events"); |
| | | // 仅对未绑定事件的按钮进行绑定 |
| | | if (!event || !event["click"]){ |
| | | $(this).click(function () { |
| | | var fileDom = $(this).parent().parent(); |
| | | var index = fileDom.data('index'); |
| | | if (index){ |
| | | deleteTempFile(index); |
| | | } |
| | | fileDom.remove(); |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | // 删除待上传的文件(从文件队列中删除文件) |
| | | function deleteTempFile(index){ |
| | | if (index === 0){ |
| | | // 清空文件队列中所有数据 |
| | | for (const key in uploadList) { |
| | | delete uploadList[key]; |
| | | } |
| | | // 隐藏上传按钮 |
| | | $('#postUpAction').hide(); |
| | | }else{ |
| | | delete uploadList[index]; |
| | | var number = Object.keys(uploadList).length; |
| | | // 若上传文件队列中无数据则隐藏上传按钮 |
| | | if (number <= 0){ |
| | | $('#postUpAction').hide(); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | |
| | | </script> |