From 5ff0dc65650b3ad7b94c2f289c45fc86d6d12dca Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Tue, 17 May 2022 18:43:31 +0800 Subject: [PATCH] fix goods editor --- src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html | 78 ++++++++++++++++++++++++++------------ 1 files changed, 53 insertions(+), 25 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 18b2c15..5cbc964 100644 --- a/src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html +++ b/src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html @@ -142,7 +142,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> +<!-- <textarea id="goodsDetailEdit" lay-verify="goodsDetails" name = "goodsDetails" class="layui-textarea"></textarea>--> + <div style="border: 1px solid #ccc;"> + <div id="toolbar-container" style="border-bottom: 1px solid #ccc;"></div> + <div id="editor-container" style="height: 450px;"></div> + </div> </div> </div> </div> @@ -254,6 +258,29 @@ element = layui.element; 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', + config : editorConfig, + mode: 'default' + }); + + const toolbar = E.createToolbar({ + editor, + selector: '#toolbar-container', + mode: 'default' + }); + laydate.render({ elem: '#febs-form-group-date' }); @@ -466,37 +493,38 @@ } }); - layedit.set({ //设置图片接口 - uploadImage: { - url: 'admin/goods/uploadFileBase64', //接口url - type: 'post', - } - }); - //创建一个编辑器 - var index = layedit.build('goodsDetailEdit', { height: '300px', }); - //提交时把值同步到文本域中 - form.verify({ - //content富文本域中的lay-verify值 - goodsDetails: function(value) { - return layedit.sync(index); - } - }); + // layedit.set({ //设置图片接口 + // uploadImage: { + // url: 'admin/goods/uploadFileBase64', //接口url + // type: 'post', + // } + // }); + // //创建一个编辑器 + // var index = layedit.build('goodsDetailEdit', { height: '300px', }); + // //提交时把值同步到文本域中 + // form.verify({ + // //content富文本域中的lay-verify值 + // goodsDetails: function(value) { + // return layedit.sync(index); + // } + // }); - upload.render({ - elem: '#skuImg'+index - ,url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口 - ,done: function(res){ - febs.alert.success(res.data.src); - $('#imageUrls' + index).attr('src', res.data.src); - $('#skuImage'+ index).val(res.data.src); - } - }); + // upload.render({ + // elem: '#skuImg'+index + // ,url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口 + // ,done: function(res){ + // febs.alert.success(res.data.src); + // $('#imageUrls' + index).attr('src', res.data.src); + // $('#skuImage'+ index).val(res.data.src); + // } + // }); form.on('submit(goods-add-form-submit)', function (data) { data.field.goodsType = 1; data.field.addMallGoodsSkuDtos = tableSkuData; data.field.categoryId = category.getValue('valueStr'); + data.field.goodsDetails = editor.getHtml(); $.ajax({ 'url':ctx + 'admin/goods/addMallGoods', 'type':'post', -- Gitblit v1.9.1