123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- <%@ page language="java" contentType="text/html; charset=UTF-8"
- pageEncoding="UTF-8" %>
- <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
- <!DOCTYPE html>
- <html>
- <head>
- <jsp:include page="../common/common-meta-include.jsp"></jsp:include>
- <jsp:include page="../common/common-js-include.jsp"></jsp:include>
- <jsp:include page="../common/common-css-include.jsp"></jsp:include>
- <!--[if lt IE 9]>
- <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
- <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
- <![endif]-->
- <%-- <script src="https://unpkg.com/@wangeditor/editor@latest/dist/index.js"></script>
- <link href="https://unpkg.com/@wangeditor/editor@latest/dist/css/style.css" rel="stylesheet">--%>
- </head>
- <body>
- <div id="app"></div>
- <template id="template">
- <div class="layuimini-container">
- <div class="layuimini-main">
- <div class="layui-form" lay-filter="formData">
- <div class="layui-form-item">
- <input type="hidden" id="id" name="id" value="${id}">
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label required">标题</label>
- <div class="layui-input-block">
- <input name="title" v-model="data.title" lay-verify="required" lay-reqtext="请输入标题"
- autocomplete="off" class="layui-input">
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label required">内容</label>
- <div class="layui-input-block">
- <div>
- <%-- <div id="toolbar-container"></div>--%>
- <div id="content"></div>
- </div>
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label">开始日期</label>
- <div class="layui-input-block">
- <input id="beginDate" readonly="readonly" name="beginDate" v-model="data.beginDate"
- lay-reqtext="请选择开始日期" autocomplete="off" class="layui-input">
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label">结束日期</label>
- <div class="layui-input-block">
- <input id="endDate" readonly="readonly" name="endDate" v-model="data.endDate"
- lay-reqtext="请选择结束日期" autocomplete="off" class="layui-input">
- </div>
- </div>
- <div class="layui-form-item">
- <div class="layui-input-block">
- <button type="button" class="layui-btn layui-btn-normal" lay-submit lay-filter="save">保存
- </button>
- </div>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- /* document.body.onload = function () {
- /!* alert(1)
- const E = window.wangEditor
- E.createEditor({selector: '#content'})*!/
- // 或者 const editor = new E( document.getElementById('div1') )
- const { createEditor, createToolbar } = window.wangEditor
- const editorConfig = {
- placeholder: 'Type here...',
- onChange(editor) {
- const html = editor.getHtml()
- console.log('editor content', html)
- // 也可以同步到 <textarea>
- }
- }
- const editor = createEditor({
- selector: '#content',
- html: '<p><br></p >',
- config: editorConfig,
- mode: 'default', // or 'simple'
- })
- const toolbarConfig = {}
- const toolbar = createToolbar({
- editor,
- selector: '#toolbar-container',
- config: toolbarConfig,
- mode: 'default', // or 'simple'
- })
- alert(1234)
- }*/
- var tt = new Vue({
- el: "#app",
- template: "#template",
- data: {
- winH: 0,
- editor: null,
- data: {
- id: ""
- }
- },
- created() {
- },
- mounted: function () {
- this.init();
- },
- methods: {
- init: function () {
- var self = this
- this.winH = document.body.clientHeight;
- layui.laydate.render({
- elem: "#beginDate",
- theme: layDateTheme,
- done: function (data) {
- self.data.beginDate = data;
- }
- });
- layui.laydate.render({
- elem: "#endDate",
- theme: layDateTheme,
- done: function (data) {
- self.data.endDate = data;
- }
- });
- layui.form.on("submit(save)", function () {
- self.save();
- });
- /* App.common.utils.createEditor("#content", function(editor){
- self.editor = editor;
- self.getData();
- })*/
- renderEditor({
- id: "content",
- url:'',
- })
- self.getData();
- },
- getData: function () {
- var self = this;
- var id = $("#id").val();
- if (id == "" || id == null) {
- } else {
- App.postJson("/api/notice/get", {id: id}, function (res) {
- self.data = res.data;
- tinymce.activeEditor.setContent(res.data.content);
- /* self.editor.txt.html(res.data.content);*/
- // self.data.content = tinymce.get('content').getContent();
- layui.form.render();
- });
- }
- },
- save: function () {
- var self = this;
- layer.confirm("是否保存", function () {
- self.data.content = tinymce.get('content').getContent();
- /* self.data.content = self.editor.txt.html();
- $()*/
- App.postJson("/api/notice/save", self.data, function (res) {
- if (res.success) {
- self.clear()
- self.close();
- } else {
- }
- });
- });
- },
- close: function () {
- App.closeCurrentLayer();
- },
- closeWin: function () {
- window.history.back(-1);
- },
- clear: function () {
- }
- }
- });
- </script>
- </body>
- </html>
|