Переглянути джерело

卡种信息 使用规则修改富文本

hanfucheng 5 місяців тому
батько
коміт
c3df41e802

+ 46 - 6
qmjszx-admin/src/main/resources/templates/information/add.html

@@ -62,19 +62,20 @@
             </div>
             <div class="col-xs-12">
                 <div class="form-group">
-                    <label class="col-sm-3 control-label is-required">使用规则:</label>
+                    <label class="col-sm-3 control-label is-required">状态:</label>
                     <div class="col-sm-8">
-                        <input name="notes" class="form-control" type="text" maxlength="255" required>
+                        <select name="state" class="form-control" th:with="type=${@dict.getType('sys_job_status')}" required>
+                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
+                        </select>
                     </div>
                 </div>
             </div>
             <div class="col-xs-12">
                 <div class="form-group">
-                    <label class="col-sm-3 control-label is-required">状态:</label>
+                    <label class="col-sm-3 control-label is-required">使用规则:</label>
                     <div class="col-sm-8">
-                        <select name="state" class="form-control" th:with="type=${@dict.getType('sys_job_status')}" required>
-                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
-                        </select>
+                        <input name="notes" class="form-control" type="hidden" maxlength="255" required>
+                        <div class="summernote" id = "notes"></div>
                     </div>
                 </div>
             </div>
@@ -82,6 +83,8 @@
     </div>
     <th:block th:include="include :: footer" />
     <th:block th:include="include :: datetimepicker-js" />
+    <th:block th:include="include :: summernote-js"/>
+    <th:block th:include="include :: summernote-css"/>
     <script th:inline="javascript">
         var prefix = ctx + "information"
         $("#form-information-add").validate({
@@ -99,6 +102,43 @@
             minView: "month",
             autoclose: true
         });
+
+        $(function () {
+            $('.summernote').summernote({
+                lang: 'zh-CN',
+                dialogsInBody: true,
+                height: 150,
+                callbacks: {
+                    onChange: function (contents, $edittable) {
+                        $("input[name='" + this.id + "']").val(contents);
+                    },
+                    onImageUpload: function (files) {
+                        var obj = this;
+                        var data = new FormData();
+                        data.append("file", files[0]);
+                        $.ajax({
+                            type: "post",
+                            url: ctx + "common/upload",
+                            data: data,
+                            cache: false,
+                            contentType: false,
+                            processData: false,
+                            dataType: 'json',
+                            success: function (result) {
+                                if (result.code == web_status.SUCCESS) {
+                                    $('#' + obj.id).summernote('insertImage', result.url);
+                                } else {
+                                    $.modal.alertError(result.msg);
+                                }
+                            },
+                            error: function (error) {
+                                $.modal.alertWarning("图片上传失败。");
+                            }
+                        });
+                    }
+                }
+            });
+        });
     </script>
 </body>
 </html>

+ 51 - 6
qmjszx-admin/src/main/resources/templates/information/edit.html

@@ -63,19 +63,20 @@
             </div>
             <div class="col-xs-12">
                 <div class="form-group">
-                    <label class="col-sm-3 control-label is-required">使用规则:</label>
+                    <label class="col-sm-3 control-label is-required">状态:</label>
                     <div class="col-sm-8">
-                        <input name="notes" th:field="*{notes}" class="form-control" type="text" maxlength="255">
+                        <select name="state" class="form-control" th:with="type=${@dict.getType('sys_job_status')}">
+                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{state}"></option>
+                        </select>
                     </div>
                 </div>
             </div>
             <div class="col-xs-12">
                 <div class="form-group">
-                    <label class="col-sm-3 control-label is-required">状态:</label>
+                    <label class="col-sm-3 control-label is-required">使用规则:</label>
                     <div class="col-sm-8">
-                        <select name="state" class="form-control" th:with="type=${@dict.getType('sys_job_status')}">
-                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{state}"></option>
-                        </select>
+                        <input name="notes" th:field="*{notes}" class="form-control" type="hidden" maxlength="255">
+                        <div class="summernote" id="notes"></div>
                     </div>
                 </div>
             </div>
@@ -83,6 +84,8 @@
     </div>
     <th:block th:include="include :: footer" />
     <th:block th:include="include :: datetimepicker-js" />
+    <th:block th:include="include :: summernote-js"/>
+    <th:block th:include="include :: summernote-css"/>
     <script th:inline="javascript">
         var prefix = ctx + "information";
         $("#form-information-edit").validate({
@@ -100,6 +103,48 @@
             minView: "month",
             autoclose: true
         });
+
+        $(function() {
+            $('.summernote').each(function(i) {
+                console.log($('#' + this.id))
+                $('#' + this.id).summernote({
+                    lang: 'zh-CN',
+                    dialogsInBody: true,
+                    height: 200,
+                    callbacks: {
+                        onChange: function(contents, $edittable) {
+                            $("input[name='" + this.id + "']").val(contents);
+                        },
+                        onImageUpload: function(files) {
+                            var obj = this;
+                            var data = new FormData();
+                            data.append("file", files[0]);
+                            $.ajax({
+                                type: "post",
+                                url: ctx + "common/upload",
+                                data: data,
+                                cache: false,
+                                contentType: false,
+                                processData: false,
+                                dataType: 'json',
+                                success: function(result) {
+                                    if (result.code == web_status.SUCCESS) {
+                                        $('#' + obj.id).summernote('insertImage', result.url);
+                                    } else {
+                                        $.modal.alertError(result.msg);
+                                    }
+                                },
+                                error: function(error) {
+                                    $.modal.alertWarning("图片上传失败。");
+                                }
+                            });
+                        }
+                    }
+                });
+                var content = $("input[name='" + this.id + "']").val();
+                $('#' + this.id).summernote('code', content);
+            })
+        });
     </script>
 </body>
 </html>

+ 0 - 4
qmjszx-admin/src/main/resources/templates/information/information.html

@@ -111,10 +111,6 @@
                     title: '有效期'
                 },
                 {
-                    field: 'notes',
-                    title: '使用规则'
-                },
-                {
                     field: 'state',
                     title: '状态',
                     formatter: function (value, row, index) {