From 48b659deb5ca926eadd792ef92e1115190a53352 Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Mon, 18 Dec 2023 15:36:47 +0800
Subject: [PATCH] 富文本改造

---
 src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html |  119 ++++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 92 insertions(+), 27 deletions(-)

diff --git a/src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html b/src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html
index 10c3e1f..e85810a 100644
--- a/src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html
+++ b/src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html
@@ -173,11 +173,11 @@
                                         <div class="layui-form-item">
                                             <label class="layui-form-label febs-form-item-require">商品详情:</label>
                                             <div class="layui-input-block">
-<!--                                                <textarea id="goodsDetailEdit" lay-verify="goodsDetails" name = "goodsDetails" class="layui-textarea"></textarea>-->
-                                                <div style="border: 1px solid #ccc;">
-                                                    <div id="toolbar-container-good-add" style="border-bottom: 1px solid #ccc;"></div>
-                                                    <div id="editor-container-good-add" style="height: 450px;"></div>
-                                                </div>
+                                                <textarea id="goodsDetailEditAdd" lay-verify="content" name = "goodsDetails" class="layui-textarea"></textarea>
+<!--                                                <div style="border: 1px solid #ccc;">-->
+<!--                                                    <div id="toolbar-container-good-add" style="border-bottom: 1px solid #ccc;"></div>-->
+<!--                                                    <div id="editor-container-good-add" style="height: 450px;"></div>-->
+<!--                                                </div>-->
                                             </div>
                                         </div>
                                     </div>
@@ -253,6 +253,16 @@
                                                 <label class="layui-form-label febs-form-item-require">邮费模板:</label>
                                                 <div class="layui-input-block">
                                                     <div id="carriage-rule"></div>
+                                                </div>
+                                            </div>
+                                        </div>
+
+                                        <blockquote class="layui-elem-quote blue-border">优惠卷设置</blockquote>
+                                        <div class="layui-form-item coupon-rule">
+                                            <div class="layui-col-lg6">
+                                                <label class="layui-form-label">优惠卷:</label>
+                                                <div class="layui-input-block">
+                                                    <div id="coupon-rule"></div>
                                                 </div>
                                             </div>
                                         </div>
@@ -357,30 +367,46 @@
 
         form.render();
 
-        var E = window.wangEditor;
-        const editorConfig = { MENU_CONF: {} };
-        editorConfig.MENU_CONF['uploadImage'] = {
-            server: '/admin/goods/uploadFileBase64',
-            fieldName : "file",
-            customInsert(res, insertFn) {
-                insertFn(res.data.src, res.data.title, '')
-            },
-        }
-
-        const editor = E.createEditor({
-            selector: '#editor-container-good-add',
-            config : editorConfig,
-            mode: 'default'
-        });
-
-        const toolbar = E.createToolbar({
-            editor,
-            selector: '#toolbar-container-good-add',
-            mode: 'default'
-        });
+        // var E = window.wangEditor;
+        // const editorConfig = { MENU_CONF: {} };
+        // editorConfig.MENU_CONF['uploadImage'] = {
+        //     server: '/admin/goods/uploadFileBase64',
+        //     fieldName : "file",
+        //     customInsert(res, insertFn) {
+        //         insertFn(res.data.src, res.data.title, '')
+        //     },
+        // }
+        //
+        // const editor = E.createEditor({
+        //     selector: '#editor-container-good-add',
+        //     config : editorConfig,
+        //     mode: 'default'
+        // });
+        //
+        // const toolbar = E.createToolbar({
+        //     editor,
+        //     selector: '#toolbar-container-good-add',
+        //     mode: 'default'
+        // });
 
         laydate.render({
             elem: '#febs-form-group-date'
+        });
+        layedit.set({	//设置图片接口
+            uploadImage: {
+                url: 'admin/goods/uploadFileBase64', //接口url
+                type: 'post',
+            }
+        });
+        //创建一个编辑器
+        var indexAdd = layedit.build('goodsDetailEditAdd',{
+            height: 300
+        });
+        form.verify({
+            //content富文本域中的lay-verify值
+            content: function(value) {
+                return layedit.sync(indexAdd);
+            }
         });
 
         formSelects.render();
@@ -395,6 +421,8 @@
             iconfont: {
                 parent: 'hidden',
             },
+            tips: '请选择',
+            filterable: true,
             radio: true,
             clickClose: true,
             tree: {
@@ -434,6 +462,33 @@
 
         febs.get(ctx + 'admin/goods/carriageRuleTree', null, function(res) {
             carriageRule.update({
+                data : res.data,
+                autoRow: true,
+            });
+        })
+
+        var couponRule = xmSelect.render({
+            el: '#coupon-rule',
+            language: 'zn',
+            prop : {
+                value : 'id',
+                children : 'child'
+            },
+            iconfont: {
+                parent: 'hidden',
+            },
+            // radio: true,
+            clickClose: true,
+            tree: {
+                show: true,
+                //非严格模式
+                strict: false,
+            },
+            data: []
+        })
+
+        febs.get(ctx + 'admin/goods/couponTreeSet', null, function(res) {
+            couponRule.update({
                 data : res.data,
                 autoRow: true,
             });
@@ -697,10 +752,20 @@
 
         form.on('submit(goods-add-form-submit)', function (data) {
             data.field.goodsType = 1;
+            let couponRuleList = couponRule.getValue();
+            if (couponRuleList.length > 0) {
+                var couponIds = [];
+                layui.each(couponRuleList, function (key, item) {
+                    couponIds.push(item.id)
+                });
+                data.field.couponIds=couponIds;
+            }
             data.field.addMallGoodsSkuDtos = tableSkuData;
             data.field.categoryId = category.getValue('valueStr');
             data.field.carriageRuleId = carriageRule.getValue('valueStr');
-            data.field.goodsDetails = editor.getHtml();
+            // let content = layedit.getContent();
+            // alert(content);
+            // data.field.goodsDetails = content;
             $.ajax({
                 'url':ctx + 'admin/goods/addMallGoods',
                 'type':'post',

--
Gitblit v1.9.1