From 529ad9dd8d1876b57e852bc45b602ba3ccc8df2a Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Wed, 10 Apr 2024 17:19:08 +0800
Subject: [PATCH] 公告-首页公告调整

---
 src/main/resources/templates/febs/views/modules/news/newsInfoUpdate.html |   51 ++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 44 insertions(+), 7 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 cf3e101..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;
 
         //(下拉框)
@@ -101,6 +103,8 @@
                 var form = layui.form;
                 form.render();
             });
+
+            initUserValue();
         });
 
         form.render();
@@ -108,12 +112,14 @@
             elem: '#febs-form-group-date'
         });
 
+
         layedit.set({	//设置图片接口
             uploadImage: {
                 url: 'admin/goods/uploadFileBase64', //接口url
                 type: 'post',
             }
         });
+
         //创建一个编辑器
         var index = layedit.build('lay_edit',{
             height: 300
@@ -142,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('');
         });
 
 
@@ -177,12 +214,9 @@
             });
         }
 
-
-        initUserValue();
         function initUserValue() {
-            console.log(newsInfo);
             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,
@@ -191,6 +225,9 @@
                 "thumb": newsInfo.thumb,
                 "content": newsInfo.content,
             });
+            imgSingleBind();
+
+            layedit.setContent(index, newsInfo.content, false);
         }
     });
 </script>
\ No newline at end of file

--
Gitblit v1.9.1