From 632c48891cb0d9df96c96792adb6517a0cd43226 Mon Sep 17 00:00:00 2001 From: xiaoyong931011 <15274802129@163.com> Date: Thu, 16 Jun 2022 16:36:08 +0800 Subject: [PATCH] 20220528 --- src/main/resources/templates/febs/views/modules/news/newsInfoUpdate.html | 42 ++++++++++++++++++++++++++++++++++++++---- 1 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/main/resources/templates/febs/views/modules/news/newsInfoUpdate.html b/src/main/resources/templates/febs/views/modules/news/newsInfoUpdate.html index b272524..4261a16 100644 --- a/src/main/resources/templates/febs/views/modules/news/newsInfoUpdate.html +++ b/src/main/resources/templates/febs/views/modules/news/newsInfoUpdate.html @@ -47,6 +47,7 @@ <label class="layui-form-label">视频:</label> <div class="layui-input-block"> <button type="button" class="layui-btn upload" id="upload" style="background-color: #009688; margin-bottom: 2px">上传文件</button> + <button type="button" class="layui-btn layui-btn-danger" id="uploadDel" style="margin-bottom: 2px">删除</button> <input type="text" name="videoUrl" autocomplete="off" value="" id="videoUrl" class="layui-input" readonly> </div> </div> @@ -56,9 +57,9 @@ <div class="layui-input-block"> <button type="button" class="layui-btn" id="imageUpload" style="background-color: #009688; margin-bottom: 2px">图片上传</button> <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;"> - <div class=" layui-upload-list view-images" id="thumbImage"> - </div> + <div class="layui-upload-list" id="thumbImage"></div> </blockquote> + <div class="layui-word-aux">双击图片删除</div> <div class="febs-hide"> <input type="text" id="thumb" name="thumb" autocomplete="off" class="layui-input" readonly> </div> @@ -89,6 +90,7 @@ layedit = layui.layedit, newsInfo = [[${newsInfo}]], $view = $('#newsInfo-update'), + $uploadDel = $view.find('#uploadDel'), validate = layui.validate; //(下拉框) @@ -146,12 +148,43 @@ ,before: function(obj){ //预读本地文件示例,不支持ie8 obj.preview(function(index, file, result){ - $('#thumbImage').html('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img" style="width: 100px">') + if ($("#thumb").val()) { + $('#thumbImage').html('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img new-image" style="width: 130px">') + } else { + $('#thumbImage').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img new-image" style="width: 130px">') + } + // $('#thumbImage').html('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img new-image" style="width: 100px">') }); } ,done: function(res){ $("#thumb").val(res.data.src); + + imgUnBind(".new-image"); + imgSingleBind(); } + }); + + function imgUnBind(className) { + $(className).each(function() { + $(this).unbind('dblclick'); + }) + } + + function imgSingleBind() { + $(".new-image").each(function(index, element) { + $(this).on("dblclick", function() { + var imgThumb = $(".new-image")[index]; + $(imgThumb).remove(); + $("#thumb").val(""); + + imgUnBind(".new-image"); + imgSingleBind(); + }); + }) + } + + $uploadDel.on('click', function () { + $("#videoUrl").val(''); }); @@ -183,7 +216,7 @@ function initUserValue() { var thumb = newsInfo.thumb; - $('#thumbImage').html('<img src="' + thumb + '" alt="" class="layui-upload-img" style="width: 100px">') + $('#thumbImage').html('<img src="' + thumb + '" alt="" class="layui-upload-img new-image" style="width: 100px">') form.val("newsInfo-update-form", { "id": newsInfo.id, "categoryId": newsInfo.categoryId, @@ -192,6 +225,7 @@ "thumb": newsInfo.thumb, "content": newsInfo.content, }); + imgSingleBind(); layedit.setContent(index, newsInfo.content, false); } -- Gitblit v1.9.1