From 105eb6748372c92c9c0c69aa503074b9419e0515 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Tue, 28 Sep 2021 15:08:27 +0800
Subject: [PATCH] 20210927

---
 src/main/resources/templates/febs/views/modules/goods/goodsUpdate.html    |  234 ++++++++++++++++++++++++++++++++++++++++++++++
 src/main/java/cc/mrbird/febs/mall/controller/ViewMallGoodsController.java |   14 ++
 src/main/resources/templates/febs/views/modules/goods/goodsList.html      |   13 ++
 3 files changed, 260 insertions(+), 1 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/mall/controller/ViewMallGoodsController.java b/src/main/java/cc/mrbird/febs/mall/controller/ViewMallGoodsController.java
index 766269e..bcec09e 100644
--- a/src/main/java/cc/mrbird/febs/mall/controller/ViewMallGoodsController.java
+++ b/src/main/java/cc/mrbird/febs/mall/controller/ViewMallGoodsController.java
@@ -65,4 +65,18 @@
         model.addAttribute("mailGoodsDetail", data);
         return FebsUtil.view("modules/goods/detailGoods");
     }
+
+    /**
+     * 商品-编辑-详情
+     * @param id
+     * @param model
+     * @return
+     */
+    @GetMapping("goodsUpdate/{id}")
+    @RequiresPermissions("goodsUpdate:update")
+    public String goodsUpdate(@PathVariable long id, Model model) {
+        AdminMailGoodsDetailVo data = mallGoodsService.getMallGoodsInfoById(id);
+        model.addAttribute("mailGoodsUpdate", data);
+        return FebsUtil.view("modules/goods/goodsUpdate");
+    }
 }
diff --git a/src/main/resources/templates/febs/views/modules/goods/goodsList.html b/src/main/resources/templates/febs/views/modules/goods/goodsList.html
index 260c7ac..e9f4442 100644
--- a/src/main/resources/templates/febs/views/modules/goods/goodsList.html
+++ b/src/main/resources/templates/febs/views/modules/goods/goodsList.html
@@ -98,6 +98,17 @@
                     maxmin: true,
                 });
             }
+            if (layEvent === 'goodsUpdate') {
+                febs.modal.open('编辑', 'modules/goods/goodsUpdate/' + data.id, {
+                    btn: ['提交', '取消'],
+                    yes: function (index, layero) {
+                        $('#goods-update').find('#submit').trigger('click');
+                    },
+                    btn2: function () {
+                        layer.closeAll();
+                    }
+                });
+            }
             if (layEvent === 'seeImgThumb') {
                 var t = $view.find('#seeImgThumb'+data.id+'');
                 //页面层
@@ -196,7 +207,7 @@
                             }else{
                                 return '<button class="layui-btn layui-btn-normal layui-btn-xs febs-bg-green" lay-event="upGoods" shiro:hasPermission="user:update">上架</button>'
                                 + '<button class="layui-btn layui-btn-normal layui-btn-xs febs-bg-red" lay-event="delGoods" shiro:hasPermission="user:update">删除</button>'
-                                + '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="updateGoods" shiro:hasPermission="user:update">编辑</button>'
+                                + '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="goodsUpdate" shiro:hasPermission="user:update">编辑</button>'
 
                             }
                         },minWidth: 300,align:'center'}
diff --git a/src/main/resources/templates/febs/views/modules/goods/goodsUpdate.html b/src/main/resources/templates/febs/views/modules/goods/goodsUpdate.html
new file mode 100644
index 0000000..5e66e5b
--- /dev/null
+++ b/src/main/resources/templates/febs/views/modules/goods/goodsUpdate.html
@@ -0,0 +1,234 @@
+<style>
+    #goods-update {
+        padding: 20px 25px 25px 0;
+    }
+
+    #goods-update .layui-treeSelect .ztree li a, .ztree li span {
+        margin: 0 0 2px 3px !important;
+    }
+    #goods-update #data-permission-tree-block {
+        border: 1px solid #eee;
+        border-radius: 2px;
+        padding: 3px 0;
+    }
+    #user-add .layui-treeSelect .ztree li span.button.switch {
+        top: 1px;
+        left: 3px;
+    }
+
+</style>
+<div class="layui-fluid" id="goods-update">
+    <form class="layui-form" action="" lay-filter="goods-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">
+            </div>
+        </div>
+        <div class="layui-row layui-col-space10 layui-form-item">
+            <div class="layui-col-lg6">
+                <label class="layui-form-label febs-form-item-require">商品名称:</label>
+                <div class="layui-input-block">
+                    <input type="text" name="goodsName" class="layui-input" readonly>
+                </div>
+            </div>
+            <div class="layui-col-lg6">
+                <label class="layui-form-label febs-form-item-require">商品编号:</label>
+                <div class="layui-input-block">
+                    <input type="text" name="goodsNo" class="layui-input" readonly>
+                </div>
+            </div>
+        </div>
+        <div class="layui-row layui-col-space10 layui-form-item">
+            <div class="layui-col-lg6">
+                <label class="layui-form-label febs-form-item-require">所属分类:</label>
+                <div class="layui-input-block">
+                    <select name="parentId" class="categary-goods-update-category" id="categarySelect" readonly>
+                        <option value="">请选择</option>
+                    </select>
+                </div>
+            </div>
+            <div class="layui-col-lg6">
+                <label class="layui-form-label febs-form-item-require">单位:</label>
+                <div class="layui-input-block">
+                    <input type="text" name="unit" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
+                </div>
+            </div>
+        </div>
+        <div class="layui-row layui-col-space10 layui-form-item">
+            <div class="layui-col-lg6">
+                <label class="layui-form-label febs-form-item-require">原价:</label>
+                <div class="layui-input-block">
+                    <input type="text" name="originalPrice" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
+                </div>
+            </div>
+            <div class="layui-col-lg6">
+                <label class="layui-form-label febs-form-item-require">现价:</label>
+                <div class="layui-input-block">
+                    <input type="text" name="presentPrice" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
+                </div>
+            </div>
+        </div>
+        <div class="layui-form-item">
+            <label class="layui-form-label">商品介绍:</label>
+            <div class="layui-input-block">
+                <input type="text" name="goodsIntrodution" autocomplete="off" class="layui-input" >
+            </div>
+        </div>
+        <!--        <div class="layui-row layui-col-space10 layui-form-item">-->
+        <!--            <div class="layui-col-lg6">-->
+        <!--                <label class="layui-form-label">规格:</label>-->
+        <!--                <div class="layui-input-block">-->
+        <!--                    <input type="text" name="addMallGoodsSkuDtos" autocomplete="off" class="layui-input" id="attrName">-->
+        <!--                </div>-->
+        <!--            </div>-->
+        <!--            <div class="layui-col-lg6">-->
+        <!--                <button type="button" class="layui-btn layui-btn-normal layui-btn-xs" id="test3" >添加</button>-->
+        <!--            </div>-->
+        <!--        </div>-->
+        <div id="attrWrap"></div>
+        <div class="layui-form-item">
+            <label class="layui-form-label">缩略图链接:</label>
+            <div class="layui-input-block">
+                <img alt="缩略图" data-th-src="${mailGoodsUpdate.thumb}"  style="width: 100px">
+            </div>
+        </div>
+        <div class="layui-form-item">
+            <label class="layui-form-label">商品详情:</label>
+            <div class="layui-input-block">
+                <textarea id="lay_edit" lay-verify="goodsDetails" name = "goodsDetails" class="layui-textarea">[[${mailGoodsUpdate.goodsDetails}]]</textarea>
+            </div>
+        </div>
+        <div class="layui-row layui-col-space10 layui-form-item">
+            <div class="layui-col-lg6">
+                <label class="layui-form-label">是否热卖:</label>
+                <div class="layui-input-block">
+                    <input type="radio" name="isHot" value="1" title="是" >
+                    <input type="radio" name="isHot" value="2" title="否" checked="">
+                </div>
+            </div>
+        </div>
+    </form>
+</div>
+
+<script data-th-inline="javascript">
+    layui.use(['febs', 'form', 'formSelects', 'validate', 'treeSelect', 'eleTree','layedit'], function () {
+        var $ = layui.$,
+            febs = layui.febs,
+            layer = layui.layer,
+            formSelects = layui.formSelects,
+            treeSelect = layui.treeSelect,
+            form = layui.form,
+            eleTree = layui.eleTree,
+            mailGoodsUpdate = [[${mailGoodsUpdate}]],
+            $view = $('#goods-update'),
+            validate = layui.validate,
+            layedit = layui.layedit,
+            _deptTree;
+
+        form.render();
+
+        //(下拉框)
+        $.get(ctx + 'admin/goodsCategory/categorys/allTree', function (data) {
+            for (var k in data)
+            {
+                $(".categary-goods-update-category").append("<option value='" + data[k].parentId + "'>" + data[k].name + "</option>");
+            }
+            layui.use('form', function () {
+                var form = layui.form;
+                $("#categarySelect").val(mailGoodsUpdate.categoryId)
+                form.render();
+            });
+        });
+
+        layedit.set({	//设置图片接口
+            uploadImage: {
+                url: 'admin/goods/uploadFileBase64', //接口url
+                type: 'post',
+            }
+        });
+        //创建一个编辑器
+        var index = layedit.build('lay_edit',{
+            height: 300
+        });
+        //提交时把值同步到文本域中
+        form.verify({
+            //content富文本域中的lay-verify值
+            goodsDetails: function(value) {
+                return layedit.sync(index);
+            }
+        });
+
+        initUserValue();
+
+        function appendSku(sku,skuIndex){
+            var index = skuIndex;
+            let attrNameVal = sku.skuName;
+            let stockVal = sku.stock;
+            let skuVolume = sku.skuVolume;
+            let originalPrice = sku.originalPrice;
+            let presentPrice = sku.presentPrice;
+            let skuImage = sku.skuImage;
+            $('#attrWrap').append(`
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">规格详情:</label>
+                        <div class="layui-input-block layui-form-item item">
+                            <div style="float:left" >
+                                <div>
+                                    <input type="text" class="layui-input" value="` + attrNameVal + `" readonly >
+                                </div>
+                            </div>
+                            <div  style="float:left" >
+                                <div>
+                                    <img class="layui-upload-img" src="` + skuImage + `" style="width: 100px" readonly>
+                                </div>
+                            </div>
+                            <div style="float:left" >
+                                <div>
+                                    <input type="text" value="` + stockVal + `" placeholder="库存" autocomplete="off" class="layui-input" readonly>
+                                </div>
+                            </div>
+                            <div style="float:left" >
+                                <div>
+                                    <input type="text" value="` + skuVolume + `" placeholder="销售数量" autocomplete="off" class="layui-input" readonly>
+                                </div>
+                            </div>
+                            <div style="float:left" >
+                                <div>
+                                    <input type="text" value="` + originalPrice + `" placeholder="原价" autocomplete="off" class="layui-input" readonly>
+                                </div>
+                            </div>
+                            <div style="float:left" >
+                                <div>
+                                    <input type="text" value="` + presentPrice + `" placeholder="现价" autocomplete="off" class="layui-input" readonly>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+            `)
+        }
+
+        function initUserValue() {
+            var skuIndex = 0;
+            let skuLength = mailGoodsUpdate.mailGoodsSkuDetailVo.length;
+            for(var skuIndex = 0; skuIndex < skuLength; skuIndex++){
+                appendSku(mailGoodsUpdate.mailGoodsSkuDetailVo[skuIndex],skuIndex);
+            }
+
+            form.val("goods-update-form", {
+                "id": mailGoodsUpdate.id,
+                "goodsNo": mailGoodsUpdate.goodsNo,
+                "categoryId": mailGoodsUpdate.categoryId,
+                "mailGoodsSkuDetailVo": mailGoodsUpdate.mailGoodsSkuDetailVo,
+                "unit": mailGoodsUpdate.unit,
+                "originalPrice": mailGoodsUpdate.originalPrice,
+                "presentPrice": mailGoodsUpdate.presentPrice,
+                "goodsIntrodution": mailGoodsUpdate.goodsIntrodution,
+                "thumb": mailGoodsUpdate.thumb,
+                "goodsDetails": mailGoodsUpdate.goodsDetails,
+                "isHot": mailGoodsUpdate.isHot,
+                "goodsName": mailGoodsUpdate.goodsName
+            });
+        }
+    });
+</script>
\ No newline at end of file

--
Gitblit v1.9.1