From 3d9854e8ce419e7d8c415ff51ba58836efec8aca Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Fri, 13 May 2022 18:06:22 +0800
Subject: [PATCH] fix newsInfo

---
 src/main/java/cc/mrbird/febs/mall/vo/AdminMallNewsInfoVo.java                 |    4 
 src/main/resources/templates/febs/views/modules/news/newsInfoList.html        |   27 +-
 src/main/java/cc/mrbird/febs/mall/service/impl/MallNewsInfoServiceImpl.java   |   71 +++--
 src/main/resources/mapper/modules/MallNewsInfoMapper.xml                      |    2 
 src/main/resources/templates/febs/views/modules/news/newsInfoUpdate-bak.html  |  121 ++++++++++
 src/main/java/cc/mrbird/febs/mall/dto/MallNewsInfoDto.java                    |    6 
 src/main/java/cc/mrbird/febs/mall/entity/MallNewsInfo.java                    |    6 
 src/main/java/cc/mrbird/febs/mall/controller/AdminNewsInfoController.java     |    7 
 src/main/resources/templates/febs/views/modules/news/newsInfoAdd.html         |  120 ++++++++--
 src/main/java/cc/mrbird/febs/mall/service/IMallNewsInfoService.java           |    4 
 src/main/resources/templates/febs/views/modules/news/newsInfoUpdate.html      |  149 +++++++++---
 src/main/resources/templates/febs/views/modules/news/newsInfoUpdate-bak2.html |  203 ++++++++++++++++
 12 files changed, 616 insertions(+), 104 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/mall/controller/AdminNewsInfoController.java b/src/main/java/cc/mrbird/febs/mall/controller/AdminNewsInfoController.java
index 877b8e2..f09959a 100644
--- a/src/main/java/cc/mrbird/febs/mall/controller/AdminNewsInfoController.java
+++ b/src/main/java/cc/mrbird/febs/mall/controller/AdminNewsInfoController.java
@@ -16,6 +16,7 @@
 import javax.management.Query;
 import javax.validation.Valid;
 import javax.validation.constraints.NotNull;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -84,4 +85,10 @@
         return new FebsResponse().success().message("新增成功");
     }
 
+    @GetMapping(value = "findAllCategoryList")
+    public FebsResponse findAllCategoryList() {
+        List<MallNewsCategory> categories = mallNewsInfoService.findAllCategory();
+        return new FebsResponse().success().data(categories);
+    }
+
 }
diff --git a/src/main/java/cc/mrbird/febs/mall/dto/MallNewsInfoDto.java b/src/main/java/cc/mrbird/febs/mall/dto/MallNewsInfoDto.java
index 4994bc9..f363987 100644
--- a/src/main/java/cc/mrbird/febs/mall/dto/MallNewsInfoDto.java
+++ b/src/main/java/cc/mrbird/febs/mall/dto/MallNewsInfoDto.java
@@ -19,4 +19,10 @@
      */
     private Integer type;
 
+    private String videoUrl;
+
+    private String thumb;
+
+    private String categoryId;
+
 }
diff --git a/src/main/java/cc/mrbird/febs/mall/entity/MallNewsInfo.java b/src/main/java/cc/mrbird/febs/mall/entity/MallNewsInfo.java
index 0f35b95..54f98af 100644
--- a/src/main/java/cc/mrbird/febs/mall/entity/MallNewsInfo.java
+++ b/src/main/java/cc/mrbird/febs/mall/entity/MallNewsInfo.java
@@ -22,4 +22,10 @@
      * 1-文章2-跳转到产品
      */
     private Integer type;
+
+    private String videoUrl;
+
+    private String thumb;
+
+    private Long categoryId;
 }
diff --git a/src/main/java/cc/mrbird/febs/mall/service/IMallNewsInfoService.java b/src/main/java/cc/mrbird/febs/mall/service/IMallNewsInfoService.java
index 27812ec..0e42280 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/IMallNewsInfoService.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/IMallNewsInfoService.java
@@ -9,6 +9,8 @@
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 public interface IMallNewsInfoService extends IService<MallNewsInfo> {
 
     IPage<AdminMallNewsInfoVo> getNewInfoList(MallNewsInfo mallNewsInfo, QueryRequest request);
@@ -26,4 +28,6 @@
     void addOrModifyNewsCategory(MallNewsCategory mallNewsCategory);
 
     MallNewsCategory findNewsCategoryById(Long id);
+
+    List<MallNewsCategory> findAllCategory();
 }
diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/MallNewsInfoServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/MallNewsInfoServiceImpl.java
index eb93f7e..a8daf2a 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/impl/MallNewsInfoServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/impl/MallNewsInfoServiceImpl.java
@@ -9,6 +9,7 @@
 import cc.mrbird.febs.mall.mapper.MallNewsInfoMapper;
 import cc.mrbird.febs.mall.service.IMallNewsInfoService;
 import cc.mrbird.febs.mall.vo.AdminMallNewsInfoVo;
+import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -16,6 +17,8 @@
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
+
+import java.util.List;
 
 /**
  * @author wzy
@@ -37,20 +40,23 @@
 
     @Override
     public FebsResponse addNewsInfo(MallNewsInfoDto mallNewsInfoDto) {
-        Integer type = mallNewsInfoDto.getType();
-        if(type == 2){
-            Long goodsId = mallNewsInfoDto.getGoodsId()==null?0L:mallNewsInfoDto.getGoodsId();
-            if(goodsId == 0L){
-                return new FebsResponse().fail().message("请选择跳转的产品");
-            }
-        }
+//        Integer type = mallNewsInfoDto.getType();
+//        if(type == 2){
+//            Long goodsId = mallNewsInfoDto.getGoodsId()==null?0L:mallNewsInfoDto.getGoodsId();
+//            if(goodsId == 0L){
+//                return new FebsResponse().fail().message("请选择跳转的产品");
+//            }
+//        }
+//        MallNewsInfo mallNewsInfo = new MallNewsInfo();
+//        mallNewsInfo.setTitle(mallNewsInfoDto.getTitle());
+//        mallNewsInfo.setContent(mallNewsInfoDto.getContent());
+//        mallNewsInfo.setType(mallNewsInfoDto.getType());
+//        if(mallNewsInfoDto.getType() == 2){
+//            mallNewsInfo.setTargetId(mallNewsInfoDto.getGoodsId());
+//        }
+
         MallNewsInfo mallNewsInfo = new MallNewsInfo();
-        mallNewsInfo.setTitle(mallNewsInfoDto.getTitle());
-        mallNewsInfo.setContent(mallNewsInfoDto.getContent());
-        mallNewsInfo.setType(mallNewsInfoDto.getType());
-        if(mallNewsInfoDto.getType() == 2){
-            mallNewsInfo.setTargetId(mallNewsInfoDto.getGoodsId());
-        }
+        BeanUtil.copyProperties(mallNewsInfoDto, mallNewsInfo);
         this.baseMapper.insert(mallNewsInfo);
         return new FebsResponse().success();
     }
@@ -71,22 +77,26 @@
         if(ObjectUtil.isEmpty(mallNewsInfoBefore)){
             return new FebsResponse().fail().message("系统繁忙,请刷新页面重试");
         }
-        Integer type = mallNewsInfoDto.getType();
-        if(type == 2){
-            Long goodsId = mallNewsInfoDto.getGoodsId()==null?0L:mallNewsInfoDto.getGoodsId();
-            if(goodsId == 0L){
-                return new FebsResponse().fail().message("请选择跳转的产品");
-            }
-        }
+//        Integer type = mallNewsInfoDto.getType();
+//        if(type == 2){
+//            Long goodsId = mallNewsInfoDto.getGoodsId()==null?0L:mallNewsInfoDto.getGoodsId();
+//            if(goodsId == 0L){
+//                return new FebsResponse().fail().message("请选择跳转的产品");
+//            }
+//        }
+//        MallNewsInfo mallNewsInfo = new MallNewsInfo();
+//        mallNewsInfo.setTitle(mallNewsInfoDto.getTitle());
+//        mallNewsInfo.setContent(mallNewsInfoDto.getContent());
+//        mallNewsInfo.setType(mallNewsInfoDto.getType());
+//        if(mallNewsInfoDto.getType() == 2){
+//            mallNewsInfo.setTargetId(mallNewsInfoDto.getGoodsId());
+//        }
+//        this.baseMapper.insert(mallNewsInfo);
+//        this.baseMapper.deleteById(mallNewsInfoDto.getId());
+
         MallNewsInfo mallNewsInfo = new MallNewsInfo();
-        mallNewsInfo.setTitle(mallNewsInfoDto.getTitle());
-        mallNewsInfo.setContent(mallNewsInfoDto.getContent());
-        mallNewsInfo.setType(mallNewsInfoDto.getType());
-        if(mallNewsInfoDto.getType() == 2){
-            mallNewsInfo.setTargetId(mallNewsInfoDto.getGoodsId());
-        }
-        this.baseMapper.insert(mallNewsInfo);
-        this.baseMapper.deleteById(mallNewsInfoDto.getId());
+        BeanUtil.copyProperties(mallNewsInfoDto, mallNewsInfo);
+        this.baseMapper.updateById(mallNewsInfo);
         return new FebsResponse().success();
     }
 
@@ -114,4 +124,9 @@
     public MallNewsCategory findNewsCategoryById(Long id) {
         return mallNewsCategoryMapper.selectById(id);
     }
+
+    @Override
+    public List<MallNewsCategory> findAllCategory() {
+        return mallNewsCategoryMapper.selectList(null);
+    }
 }
diff --git a/src/main/java/cc/mrbird/febs/mall/vo/AdminMallNewsInfoVo.java b/src/main/java/cc/mrbird/febs/mall/vo/AdminMallNewsInfoVo.java
index 4061448..44b193a 100644
--- a/src/main/java/cc/mrbird/febs/mall/vo/AdminMallNewsInfoVo.java
+++ b/src/main/java/cc/mrbird/febs/mall/vo/AdminMallNewsInfoVo.java
@@ -16,6 +16,8 @@
 
     private String content;
 
+    private String thumb;
+
     private Long targetId;
 
     private String targetName;
@@ -27,4 +29,6 @@
      * 1-文章2-跳转到产品
      */
     private Integer type;
+
+    private String categoryName;
 }
diff --git a/src/main/resources/mapper/modules/MallNewsInfoMapper.xml b/src/main/resources/mapper/modules/MallNewsInfoMapper.xml
index 186ff7e..ebb2b60 100644
--- a/src/main/resources/mapper/modules/MallNewsInfoMapper.xml
+++ b/src/main/resources/mapper/modules/MallNewsInfoMapper.xml
@@ -5,9 +5,11 @@
     <select id="getNewInfoListInPage" resultType="cc.mrbird.febs.mall.vo.AdminMallNewsInfoVo">
         SELECT
                a.*,
+               c.title categoryName,
                b.goods_name targetName
         FROM mall_news_info a
         left join mall_goods b on a.target_id = b.id
+        left join mall_news_category c on a.category_id=c.id
         group by a.id
         order by a.CREATED_TIME desc
     </select>
diff --git a/src/main/resources/templates/febs/views/modules/news/newsInfoAdd.html b/src/main/resources/templates/febs/views/modules/news/newsInfoAdd.html
index ff64d30..8c361ee 100644
--- a/src/main/resources/templates/febs/views/modules/news/newsInfoAdd.html
+++ b/src/main/resources/templates/febs/views/modules/news/newsInfoAdd.html
@@ -25,29 +25,44 @@
         <div class="layui-form-item">
             <label class="layui-form-label febs-form-item-require">标题:</label>
             <div class="layui-input-block">
-                <input type="text" name="title" lay-verify="required" autocomplete="off" class="layui-input" >
+                <input type="text" name="title" autocomplete="off" class="layui-input" >
             </div>
         </div>
         <div class="layui-form-item">
-            <label class="layui-form-label febs-form-item-require">内容:</label>
+            <label class="layui-form-label febs-form-item-require">分类:</label>
             <div class="layui-input-block">
-                <input type="text" name="content" lay-verify="required" autocomplete="off" class="layui-input" >
-            </div>
-        </div>
-        <div class="layui-form-item">
-            <label class="layui-form-label febs-form-item-require">类型:</label>
-            <div class="layui-input-block">
-                <input type="radio" name="type" value="1" title="文章" checked="">
-                <input type="radio" name="type" value="2" title="跳转到产品">
+                <select name="categoryId" class="news-category" id="news-category" >
+                    <option value="">请选择</option>
+                </select>
             </div>
         </div>
 
-        <div class="layui-col-lg6">
-            <label class="layui-form-label">绑定产品:</label>
+        <div class="layui-form-item">
+            <label class="layui-form-label">视频:</label>
             <div class="layui-input-block">
-                <select name="goodsId" class="newsInfo-add-goods" id="goodsSelect" >
-                    <option value="">请选择</option>
-                </select>
+                <button type="button" class="layui-btn upload" id="upload" style="background-color: #009688; margin-bottom: 2px">上传文件</button>
+                <input type="text" name="videoUrl" autocomplete="off" value="" id="videoUrl" class="layui-input" readonly>
+            </div>
+        </div>
+
+        <div class="layui-form-item">
+            <label class="layui-form-label">缩略图:</label>
+            <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>
+                </blockquote>
+                <div class="febs-hide">
+                    <input type="text" id="thumb"  name="thumb" autocomplete="off" class="layui-input" readonly>
+                </div>
+            </div>
+        </div>
+
+        <div class="layui-form-item">
+            <label class="layui-form-label febs-form-item-require">内容:</label>
+            <div class="layui-input-block">
+                <textarea id="lay_edit" name = "content" lay-verify="content" class="layui-textarea"></textarea>
             </div>
         </div>
         <div class="layui-form-item febs-hide">
@@ -57,27 +72,26 @@
 </div>
 
 <script data-th-inline="javascript">
-    layui.use(['febs', 'form', 'formSelects', 'validate', 'treeSelect', 'eleTree', 'laydate'], function () {
+    layui.use(['febs', 'form', 'formSelects', 'validate', 'treeSelect', 'eleTree','layedit', 'laydate', 'upload'], function () {
         var $ = layui.$,
             febs = layui.febs,
             layer = layui.layer,
+            upload = layui.upload,
             formSelects = layui.formSelects,
-            treeSelect = layui.treeSelect,
             form = layui.form,
             laydate = layui.laydate,
-            eleTree = layui.eleTree,
+            layedit = layui.layedit,
             $view = $('#newsInfo-add'),
             validate = layui.validate;
 
         //(下拉框)
-        $.get(ctx + 'admin/goods/goods/allTree', function (data) {
-            for (var k in data)
-            {
-                $(".newsInfo-add-goods").append("<option value='" + data[k].goodsId + "'>" + data[k].goodsName + "</option>");
+        $.get(ctx + 'admin/news/findAllCategoryList', function (data) {
+            var arr = data.data;
+            for (let i = 0; i < arr.length; i++) {
+                $(".news-category").append("<option value='" + arr[i].id + "'>" + arr[i].title + "</option>");
             }
             layui.use('form', function () {
                 var form = layui.form;
-                // $("#goodsSelect").val(mailGoodsUpdate.categoryId)
                 form.render();
             });
         });
@@ -87,8 +101,24 @@
             elem: '#febs-form-group-date'
         });
 
-        formSelects.render();
+        layedit.set({	//设置图片接口
+            uploadImage: {
+                url: 'admin/goods/uploadFileBase64', //接口url
+                type: 'post',
+            }
+        });
+        //创建一个编辑器
+        var index = layedit.build('lay_edit',{
+            height: 300
+        });
+        form.verify({
+            //content富文本域中的lay-verify值
+            content: function(value) {
+                return layedit.sync(index);
+            }
+        });
 
+        formSelects.render();
         form.on('submit(newsInfo-add-form-submit)', function (data) {
             febs.post(ctx + 'admin/news/addNewsInfo', data.field, function () {
                 layer.closeAll();
@@ -97,5 +127,47 @@
             });
             return false;
         });
+
+        upload.render({
+            elem: '#imageUpload'
+            ,url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口
+            ,multiple: false
+            ,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">')
+                });
+            }
+            ,done: function(res){
+                $("#thumb").val(res.data.src);
+            }
+        });
+
+
+        bindUpload();
+        function bindUpload() {
+            upload.render({
+                elem: '.upload'
+                ,url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口
+                ,accept: 'file'
+                ,before: function(obj){
+                    layer.msg('上传中', {icon: 16, time: 0});
+                }
+                ,done: function(res){
+                    var item = this.item;
+                    //如果上传失败
+                    if(res.code !== 0){
+                        return layer.msg('上传失败');
+                    }
+
+                    // $(item).parent().prev().find('input').val(res.data[0]);
+                    $("#videoUrl").val(res.data.src);
+                    layer.msg('上传完毕', {icon: 1});
+                }
+                ,error: function(err){
+                    return layer.msg('上传失败');
+                }
+            });
+        }
     });
 </script>
\ No newline at end of file
diff --git a/src/main/resources/templates/febs/views/modules/news/newsInfoList.html b/src/main/resources/templates/febs/views/modules/news/newsInfoList.html
index 7675466..6b584bf 100644
--- a/src/main/resources/templates/febs/views/modules/news/newsInfoList.html
+++ b/src/main/resources/templates/febs/views/modules/news/newsInfoList.html
@@ -24,6 +24,11 @@
         </div>
     </div>
 </div>
+<style>
+    .layui-table-cell {
+        height: auto;
+    }
+</style>
 <!-- 表格操作栏 start -->
 <script type="text/html" id="user-option">
     <span shiro:lacksPermission="user:view,user:update,user:delete">
@@ -61,7 +66,7 @@
                 febs.modal.open('编辑', 'modules/news/newsInfoUpdate/' + data.id, {
                     btn: ['提交', '取消'],
                     yes: function (index, layero) {
-                        $('#systemPay-update').find('#submit').trigger('click');
+                        $('#newsInfo-update').find('#submit').trigger('click');
                     },
                     btn2: function () {
                         layer.closeAll();
@@ -114,24 +119,16 @@
                 url: ctx + 'admin/news/getNewInfoList',
                 cols: [[
                     {field: 'title', title: '标题', minWidth: 120,align:'center'},
-                    {field: 'content', title: '内容', minWidth: 120,align:'center'},
-                    {field: 'createdTime', title: '创建时间', minWidth: 120,align:'center'},
-                    {field: 'type', title: '类型',
+                    {field: 'categoryName', title: '分类', minWidth: 120,align:'center'},
+                    {field: 'thumb', title: '缩略图',
                         templet: function (d) {
-                            if(d.type === 1){
-                                return '<span>文章</span>'
-                            }else if(d.type === 2){
-                                return '<span>跳转到产品</span>'
-                            }else{
-                                return ''
-                            }
-                        }, minWidth: 100,align:'center'},
-                    {field: 'targetId', title: '跳转到目标ID', minWidth: 200,align:'center'},
-                    {field: 'targetName', title: '跳转到目标', minWidth: 200,align:'center'},
+                            return '<a lay-event="seeImgThumb"><img id="seeImgThumb'+d.id+'" src="'+d.thumb+'" alt=""></a>';
+                        }, minWidth: 150,align:'center'},
+                    {field: 'createdTime', title: '创建时间', minWidth: 120,align:'center'},
                     {title: '操作',
                         templet: function (d) {
                             return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="newsInfoUpdate" shiro:hasPermission="user:update">编辑</button>'
-                                +'<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="delNewsInfo" shiro:hasPermission="user:update">删除</button>'
+                                +'<button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delNewsInfo" shiro:hasPermission="user:update">删除</button>'
                         },minWidth: 300,align:'center'}
                 ]]
             });
diff --git a/src/main/resources/templates/febs/views/modules/news/newsInfoUpdate-bak.html b/src/main/resources/templates/febs/views/modules/news/newsInfoUpdate-bak.html
new file mode 100644
index 0000000..0513465
--- /dev/null
+++ b/src/main/resources/templates/febs/views/modules/news/newsInfoUpdate-bak.html
@@ -0,0 +1,121 @@
+<style>
+    #newsInfo-update {
+        padding: 20px 25px 25px 0;
+    }
+
+    #newsInfo-update .layui-treeSelect .ztree li a, .ztree li span {
+        margin: 0 0 2px 3px !important;
+    }
+    #newsInfo-update #data-permission-tree-block {
+        border: 1px solid #eee;
+        border-radius: 2px;
+        padding: 3px 0;
+    }
+    #newsInfo-update .layui-treeSelect .ztree li span.button.switch {
+        top: 1px;
+        left: 3px;
+    }
+    #newsInfo-update img{
+        max-width:100px
+    }
+
+</style>
+<div class="layui-fluid" id="newsInfo-update">
+    <form class="layui-form" action="" lay-filter="newsInfo-update-form">
+        <div class="layui-form-item febs-hide">
+            <label class="layui-form-label febs-form-item-require">id:</label>
+            <div class="layui-input-block">
+                <input type="text" name="id" data-th-value="${newsInfo.id}">
+            </div>
+        </div>
+        <div class="layui-form-item">
+            <label class="layui-form-label febs-form-item-require">标题:</label>
+            <div class="layui-input-block">
+                <input type="text" name="title" lay-verify="required" autocomplete="off" class="layui-input" >
+            </div>
+        </div>
+        <div class="layui-form-item">
+            <label class="layui-form-label febs-form-item-require">内容:</label>
+            <div class="layui-input-block">
+                <input type="text" name="content" lay-verify="required" autocomplete="off" class="layui-input" >
+            </div>
+        </div>
+        <div class="layui-form-item">
+            <label class="layui-form-label febs-form-item-require">类型:</label>
+            <div class="layui-input-block">
+                <input type="radio" name="type" value="1" title="文章" checked="">
+                <input type="radio" name="type" value="2" title="跳转到产品">
+            </div>
+        </div>
+
+        <div class="layui-col-lg6">
+            <label class="layui-form-label">绑定产品:</label>
+            <div class="layui-input-block">
+                <select name="goodsId" class="newsInfo-update-goods" id="goodsSelectUpdate" >
+                    <option value="">请选择</option>
+                </select>
+            </div>
+        </div>
+        <div class="layui-form-item febs-hide">
+            <button class="layui-btn" lay-submit="" lay-filter="newsInfo-update-form-submit" id="submit"></button>
+        </div>
+    </form>
+</div>
+
+<script data-th-inline="javascript">
+    layui.use(['febs', 'form', 'formSelects', 'validate', 'treeSelect', 'eleTree', 'laydate'], function () {
+        var $ = layui.$,
+            febs = layui.febs,
+            layer = layui.layer,
+            formSelects = layui.formSelects,
+            treeSelect = layui.treeSelect,
+            form = layui.form,
+            laydate = layui.laydate,
+            eleTree = layui.eleTree,
+            newsInfo = [[${newsInfo}]],
+            $view = $('#newsInfo-update'),
+            validate = layui.validate;
+
+        //(下拉框)
+        $.get(ctx + 'admin/goods/goods/allTree', function (data) {
+            for (var k in data)
+            {
+                $(".newsInfo-update-goods").append("<option value='" + data[k].goodsId + "'>" + data[k].goodsName + "</option>");
+            }
+            layui.use('form', function () {
+                var form = layui.form;
+                $("#goodsSelectUpdate").val(newsInfo.targetId)
+                form.render();
+            });
+        });
+
+        form.render();
+        laydate.render({
+            elem: '#febs-form-group-date'
+        });
+
+        formSelects.render();
+
+
+        initUserValue();
+
+        function initUserValue() {
+            form.val("newsInfo-update-form", {
+                "id": newsInfo.id,
+                "targetId": newsInfo.targetId,
+                "title": newsInfo.title,
+                "content": newsInfo.content,
+                "type": newsInfo.type
+            });
+        }
+
+        form.on('submit(newsInfo-update-form-submit)', function (data) {
+            febs.post(ctx + 'admin/news/updateNewsInfo', data.field, function () {
+                layer.closeAll();
+                febs.alert.success('操作成功');
+                $('#febs-newInfo').find('#reset').click();
+            });
+            return false;
+        });
+    });
+</script>
\ No newline at end of file
diff --git a/src/main/resources/templates/febs/views/modules/news/newsInfoUpdate-bak2.html b/src/main/resources/templates/febs/views/modules/news/newsInfoUpdate-bak2.html
new file mode 100644
index 0000000..0709d28
--- /dev/null
+++ b/src/main/resources/templates/febs/views/modules/news/newsInfoUpdate-bak2.html
@@ -0,0 +1,203 @@
+<style>
+    #newsInfo-update {
+        padding: 20px 25px 25px 0;
+    }
+
+    #newsInfo-update .layui-treeSelect .ztree li a, .ztree li span {
+        margin: 0 0 2px 3px !important;
+    }
+
+    #newsInfo-update #data-permission-tree-block {
+        border: 1px solid #eee;
+        border-radius: 2px;
+        padding: 3px 0;
+    }
+
+    #newsInfo-update .layui-treeSelect .ztree li span.button.switch {
+        top: 1px;
+        left: 3px;
+    }
+
+    #newsInfo-update img {
+        max-width: 100px
+    }
+
+</style>
+<div className="layui-fluid" id="newsInfo-update">
+    <form className="layui-form" action="" lay-filter="newsInfo-update-form">
+        <div class="layui-form-item febs-hide">
+            <label class="layui-form-label febs-form-item-require">id:</label>
+            <div class="layui-input-block">
+                <input type="text" name="id" data-th-value="${newsInfo.id}">
+            </div>
+        </div>
+        <div className="layui-form-item">
+            <label className="layui-form-label febs-form-item-require">标题:</label>
+            <div className="layui-input-block">
+                <input type="text" name="title" autoComplete="off" className="layui-input">
+            </div>
+        </div>
+        <div className="layui-form-item">
+            <label className="layui-form-label febs-form-item-require">分类:</label>
+            <div className="layui-input-block">
+                <select name="categoryId" className="news-category" id="news-category">
+                    <option value="">请选择</option>
+                </select>
+            </div>
+        </div>
+
+        <div className="layui-form-item">
+            <label className="layui-form-label">视频:</label>
+            <div className="layui-input-block">
+                <button type="button" className="layui-btn upload" id="upload"
+                        style="background-color: #009688; margin-bottom: 2px">上传文件
+                </button>
+                <input type="text" name="videoUrl" autoComplete="off" value="" id="videoUrl" className="layui-input"
+                       readOnly>
+            </div>
+        </div>
+
+        <div className="layui-form-item">
+            <label className="layui-form-label">缩略图:</label>
+            <div className="layui-input-block">
+                <button type="button" className="layui-btn" id="imageUpload"
+                        style="background-color: #009688; margin-bottom: 2px">图片上传
+                </button>
+                <blockquote className="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
+                    <div className=" layui-upload-list view-images" id="thumbImage">
+                    </div>
+                </blockquote>
+                <div className="febs-hide">
+                    <input type="text" id="thumb" name="thumb" autoComplete="off" className="layui-input" readOnly>
+                </div>
+            </div>
+        </div>
+
+        <div className="layui-form-item">
+            <label className="layui-form-label febs-form-item-require">内容:</label>
+            <div className="layui-input-block">
+                <textarea id="lay_edit" name="content" lay-verify="content" className="layui-textarea"></textarea>
+            </div>
+        </div>
+        <div className="layui-form-item febs-hide">
+            <button className="layui-btn" lay-submit="" lay-filter="newsInfo-update-form-submit" id="submit"></button>
+        </div>
+    </form>
+</div>
+
+<script data-th-inline="javascript">
+    layui.use(['febs', 'form', 'formSelects', 'validate', 'treeSelect', 'eleTree', 'layedit', 'laydate', 'upload'], function () {
+        var $ = layui.$,
+            febs = layui.febs,
+            layer = layui.layer,
+            upload = layui.upload,
+            formSelects = layui.formSelects,
+            form = layui.form,
+            laydate = layui.laydate,
+            layedit = layui.layedit,
+            newsInfo = [[${newsInfo}]],
+            $view = $('#newsInfo-update'),
+            validate = layui.validate;
+
+        //(下拉框)
+        $.get(ctx + 'admin/news/findAllCategoryList', function (data) {
+            var arr = data.data;
+            for (let i = 0; i < arr.length; i++) {
+                $(".news-category").append("<option value='" + arr[i].id + "'>" + arr[i].title + "</option>");
+            }
+            layui.use('form', function () {
+                var form = layui.form;
+                form.render();
+            });
+        });
+
+        form.render();
+        laydate.render({
+            elem: '#febs-form-group-date'
+        });
+
+        layedit.set({	//设置图片接口
+            uploadImage: {
+                url: 'admin/goods/uploadFileBase64', //接口url
+                type: 'post',
+            }
+        });
+        //创建一个编辑器
+        var index = layedit.build('lay_edit', {
+            height: 300
+        });
+        form.verify({
+            //content富文本域中的lay-verify值
+            content: function (value) {
+                return layedit.sync(index);
+            }
+        });
+
+        formSelects.render();
+        form.on('submit(newsInfo-update-form-submit)', function (data) {
+            febs.post(ctx + 'admin/news/updateNewsInfo', data.field, function () {
+                layer.closeAll();
+                febs.alert.success('操作成功');
+                $('#febs-newInfo').find('#reset').click();
+            });
+            return false;
+        });
+
+        upload.render({
+            elem: '#imageUpload'
+            , url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口
+            , multiple: false
+            , 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">')
+                });
+            }
+            , done: function (res) {
+                $("#thumb").val(res.data.src);
+            }
+        });
+
+
+        bindUpload();
+
+        function bindUpload() {
+            upload.render({
+                elem: '.upload'
+                , url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口
+                , accept: 'file'
+                , before: function (obj) {
+                    layer.msg('上传中', {icon: 16, time: 0});
+                }
+                , done: function (res) {
+                    var item = this.item;
+                    //如果上传失败
+                    if (res.code !== 0) {
+                        return layer.msg('上传失败');
+                    }
+
+                    // $(item).parent().prev().find('input').val(res.data[0]);
+                    $("#videoUrl").val(res.data.src);
+                    layer.msg('上传完毕', {icon: 1});
+                }
+                , error: function (err) {
+                    return layer.msg('上传失败');
+                }
+            });
+        }
+
+        initUserValue();
+        function initUserValue() {
+            var thumb = newsInfo.thumb;
+            $('#thumbImage').html('<img src="' + thumb + '" alt="" class="layui-upload-img" style="width: 100px">')
+            form.val("newsInfo-update-form", {
+                "id": newsInfo.id,
+                "categoryId": newsInfo.categoryId,
+                "title": newsInfo.title,
+                "videoUrl": newsInfo.videoUrl,
+                "thumb": newsInfo.thumb,
+                "content": newsInfo.content,
+            });
+        }
+    });
+</script>
\ No newline at end of file
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 0513465..cf3e101 100644
--- a/src/main/resources/templates/febs/views/modules/news/newsInfoUpdate.html
+++ b/src/main/resources/templates/febs/views/modules/news/newsInfoUpdate.html
@@ -31,29 +31,44 @@
         <div class="layui-form-item">
             <label class="layui-form-label febs-form-item-require">标题:</label>
             <div class="layui-input-block">
-                <input type="text" name="title" lay-verify="required" autocomplete="off" class="layui-input" >
+                <input type="text" name="title" autocomplete="off" class="layui-input" >
             </div>
         </div>
         <div class="layui-form-item">
-            <label class="layui-form-label febs-form-item-require">内容:</label>
+            <label class="layui-form-label febs-form-item-require">分类:</label>
             <div class="layui-input-block">
-                <input type="text" name="content" lay-verify="required" autocomplete="off" class="layui-input" >
-            </div>
-        </div>
-        <div class="layui-form-item">
-            <label class="layui-form-label febs-form-item-require">类型:</label>
-            <div class="layui-input-block">
-                <input type="radio" name="type" value="1" title="文章" checked="">
-                <input type="radio" name="type" value="2" title="跳转到产品">
+                <select name="categoryId" class="news-category" id="news-category" >
+                    <option value="">请选择</option>
+                </select>
             </div>
         </div>
 
-        <div class="layui-col-lg6">
-            <label class="layui-form-label">绑定产品:</label>
+        <div class="layui-form-item">
+            <label class="layui-form-label">视频:</label>
             <div class="layui-input-block">
-                <select name="goodsId" class="newsInfo-update-goods" id="goodsSelectUpdate" >
-                    <option value="">请选择</option>
-                </select>
+                <button type="button" class="layui-btn upload" id="upload" style="background-color: #009688; margin-bottom: 2px">上传文件</button>
+                <input type="text" name="videoUrl" autocomplete="off" value="" id="videoUrl" class="layui-input" readonly>
+            </div>
+        </div>
+
+        <div class="layui-form-item">
+            <label class="layui-form-label">缩略图:</label>
+            <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>
+                </blockquote>
+                <div class="febs-hide">
+                    <input type="text" id="thumb"  name="thumb" autocomplete="off" class="layui-input" readonly>
+                </div>
+            </div>
+        </div>
+
+        <div class="layui-form-item">
+            <label class="layui-form-label febs-form-item-require">内容:</label>
+            <div class="layui-input-block">
+                <textarea id="lay_edit" name = "content" lay-verify="content" class="layui-textarea"></textarea>
             </div>
         </div>
         <div class="layui-form-item febs-hide">
@@ -63,28 +78,27 @@
 </div>
 
 <script data-th-inline="javascript">
-    layui.use(['febs', 'form', 'formSelects', 'validate', 'treeSelect', 'eleTree', 'laydate'], function () {
+    layui.use(['febs', 'form', 'formSelects', 'validate', 'treeSelect', 'eleTree','layedit', 'laydate', 'upload'], function () {
         var $ = layui.$,
             febs = layui.febs,
             layer = layui.layer,
+            upload = layui.upload,
             formSelects = layui.formSelects,
-            treeSelect = layui.treeSelect,
             form = layui.form,
             laydate = layui.laydate,
-            eleTree = layui.eleTree,
+            layedit = layui.layedit,
             newsInfo = [[${newsInfo}]],
             $view = $('#newsInfo-update'),
             validate = layui.validate;
 
         //(下拉框)
-        $.get(ctx + 'admin/goods/goods/allTree', function (data) {
-            for (var k in data)
-            {
-                $(".newsInfo-update-goods").append("<option value='" + data[k].goodsId + "'>" + data[k].goodsName + "</option>");
+        $.get(ctx + 'admin/news/findAllCategoryList', function (data) {
+            var arr = data.data;
+            for (let i = 0; i < arr.length; i++) {
+                $(".news-category").append("<option value='" + arr[i].id + "'>" + arr[i].title + "</option>");
             }
             layui.use('form', function () {
                 var form = layui.form;
-                $("#goodsSelectUpdate").val(newsInfo.targetId)
                 form.render();
             });
         });
@@ -94,21 +108,24 @@
             elem: '#febs-form-group-date'
         });
 
+        layedit.set({	//设置图片接口
+            uploadImage: {
+                url: 'admin/goods/uploadFileBase64', //接口url
+                type: 'post',
+            }
+        });
+        //创建一个编辑器
+        var index = layedit.build('lay_edit',{
+            height: 300
+        });
+        form.verify({
+            //content富文本域中的lay-verify值
+            content: function(value) {
+                return layedit.sync(index);
+            }
+        });
+
         formSelects.render();
-
-
-        initUserValue();
-
-        function initUserValue() {
-            form.val("newsInfo-update-form", {
-                "id": newsInfo.id,
-                "targetId": newsInfo.targetId,
-                "title": newsInfo.title,
-                "content": newsInfo.content,
-                "type": newsInfo.type
-            });
-        }
-
         form.on('submit(newsInfo-update-form-submit)', function (data) {
             febs.post(ctx + 'admin/news/updateNewsInfo', data.field, function () {
                 layer.closeAll();
@@ -117,5 +134,63 @@
             });
             return false;
         });
+
+        upload.render({
+            elem: '#imageUpload'
+            ,url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口
+            ,multiple: false
+            ,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">')
+                });
+            }
+            ,done: function(res){
+                $("#thumb").val(res.data.src);
+            }
+        });
+
+
+        bindUpload();
+        function bindUpload() {
+            upload.render({
+                elem: '.upload'
+                ,url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口
+                ,accept: 'file'
+                ,before: function(obj){
+                    layer.msg('上传中', {icon: 16, time: 0});
+                }
+                ,done: function(res){
+                    var item = this.item;
+                    //如果上传失败
+                    if(res.code !== 0){
+                        return layer.msg('上传失败');
+                    }
+
+                    // $(item).parent().prev().find('input').val(res.data[0]);
+                    $("#videoUrl").val(res.data.src);
+                    layer.msg('上传完毕', {icon: 1});
+                }
+                ,error: function(err){
+                    return layer.msg('上传失败');
+                }
+            });
+        }
+
+
+        initUserValue();
+        function initUserValue() {
+            console.log(newsInfo);
+            var thumb = newsInfo.thumb;
+            $('#thumbImage').html('<img src="' + thumb + '" alt="" class="layui-upload-img" style="width: 100px">')
+            form.val("newsInfo-update-form", {
+                "id": newsInfo.id,
+                "categoryId": newsInfo.categoryId,
+                "title": newsInfo.title,
+                "videoUrl": newsInfo.videoUrl,
+                "thumb": newsInfo.thumb,
+                "content": newsInfo.content,
+            });
+        }
     });
 </script>
\ No newline at end of file

--
Gitblit v1.9.1