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 | 72 +++++++++++++++--------- src/main/resources/templates/index.html | 6 +- src/main/resources/templates/febs/views/modules/goods/goodsUpdateNew.html | 75 ++++++++++++++++--------- 3 files changed, 96 insertions(+), 57 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 64c7ea5..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> @@ -367,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(); @@ -747,7 +763,9 @@ 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', diff --git a/src/main/resources/templates/febs/views/modules/goods/goodsUpdateNew.html b/src/main/resources/templates/febs/views/modules/goods/goodsUpdateNew.html index 71e0dda..1698083 100644 --- a/src/main/resources/templates/febs/views/modules/goods/goodsUpdateNew.html +++ b/src/main/resources/templates/febs/views/modules/goods/goodsUpdateNew.html @@ -196,11 +196,11 @@ <div class="layui-form-item"> <label class="layui-form-label febs-form-item-require">商品详情:</label> <div class="layui-input-block"> -<!-- <textarea id="lay_edit" lay-verify="goodsDetails" name="goodsDetails" class="layui-textarea"></textarea>--> - <div style="border: 1px solid #ccc;"> - <div id="toolbar-container-good-update" style="border-bottom: 1px solid #ccc;"></div> - <div id="editor-container-good-update" style="height: 300px;"></div> - </div> + <textarea id="goodsDetailsUpdate" lay-verify="content" name="goodsDetails" class="layui-textarea"></textarea> +<!-- <div style="border: 1px solid #ccc;">--> +<!-- <div id="toolbar-container-good-update" style="border-bottom: 1px solid #ccc;"></div>--> +<!-- <div id="editor-container-good-update" style="height: 300px;"></div>--> +<!-- </div>--> </div> </div> </div> @@ -410,17 +410,35 @@ elem: '#febs-form-group-date' }); + layedit.set({ //设置图片接口 + uploadImage: { + url: 'admin/goods/uploadFileBase64', //接口url + type: 'post', + } + }); + + //创建一个编辑器 + var indexUpdate = layedit.build('goodsDetailsUpdate',{ + height: 300 + }); + form.verify({ + //content富文本域中的lay-verify值 + content: function(value) { + return layedit.sync(indexUpdate); + } + }); + formSelects.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, '') - }, - } + // 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, '') + // }, + // } var category = xmSelect.render({ el: '#goods-category', @@ -797,6 +815,7 @@ "carriageAmount": goodsInfo.carriageAmount, "goodsWeight": goodsInfo.goodsWeight, "orderNumber": goodsInfo.orderNumber, + "goodsDetails": goodsInfo.goodsDetails, "thumbs": thumbs }); @@ -842,23 +861,25 @@ imgSingleBind(); imgMultiBind(); - window.editor = E.createEditor({ - html: goodsInfo.goodsDetails, - selector: '#editor-container-good-update', - config : editorConfig, - mode: 'default' - }); - - window.toolbar = E.createToolbar({ - editor, - selector: '#toolbar-container-good-update', - mode: 'default' - }); + // window.editor = E.createEditor({ + // html: goodsInfo.goodsDetails, + // selector: '#editor-container-good-update', + // config : editorConfig, + // mode: 'default' + // }); + // + // window.toolbar = E.createToolbar({ + // editor, + // selector: '#toolbar-container-good-update', + // mode: 'default' + // }); if (skus) { tableSkuData = skus; reloadTable(skus); } + + layedit.setContent(indexUpdate,goodsInfo.goodsDetails, false); } form.on('submit(goods-update-form-submit)', function (data) { @@ -875,7 +896,7 @@ data.field.delSkuId=delSku; data.field.categoryId = category.getValue('valueStr'); data.field.carriageRuleId = carriageRule.getValue('valueStr'); - data.field.goodsDetails = editor.getHtml(); + // data.field.goodsDetails = editor.getHtml(); $.ajax({ 'url': ctx + 'admin/goods/updateMallGoods', 'type': 'post', diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 505a785..d37048f 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -20,9 +20,9 @@ securityJsCode:'50d73a585f300cccf7fc2bf31d0c38c8', } </script> - <script src="https://webapi.amap.com/maps?v=1.4.15&key=e32064fc8a9dfe7af7d2d0a947b8df32&plugin=AMap.Autocomplete,AMap.PolyEditor,AMap.Geocoder,AMap.PolylineEditor"></script> - <link href="https://unpkg.com/@wangeditor/editor@5.0.1/dist/css/style.css" rel="stylesheet"> - <script src="https://unpkg.com/@wangeditor/editor@latest/dist/index.js"></script> +<!-- <script src="https://webapi.amap.com/maps?v=1.4.15&key=e32064fc8a9dfe7af7d2d0a947b8df32&plugin=AMap.Autocomplete,AMap.PolyEditor,AMap.Geocoder,AMap.PolylineEditor"></script>--> +<!-- <link href="https://unpkg.com/@wangeditor/editor@5.0.1/dist/css/style.css" rel="stylesheet">--> +<!-- <script src="https://unpkg.com/@wangeditor/editor@latest/dist/index.js"></script>--> <script src="http://gosspublic.alicdn.com/aliyun-oss-sdk-6.17.0.min.js"></script> <link rel="icon" th:href="@{febs/images/favicon.ico}" type="image/x-icon"/> </head> -- Gitblit v1.9.1