Commit 74aa8ffb by naan1993

增加富文本编辑器

parent 2b3b3cf9
...@@ -66,6 +66,7 @@ public class NoticeController extends BaseController { ...@@ -66,6 +66,7 @@ public class NoticeController extends BaseController {
public String noticeUpdate(@PathVariable Integer noticeId, Model model) { public String noticeUpdate(@PathVariable Integer noticeId, Model model) {
Notice notice = this.noticeMapper.selectById(noticeId); Notice notice = this.noticeMapper.selectById(noticeId);
model.addAttribute("notice",notice); model.addAttribute("notice",notice);
LogObjectHolder.me().set(notice);
return PREFIX + "notice_edit.html"; return PREFIX + "notice_edit.html";
} }
......
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-1 control-label">内容</label> <label class="col-sm-1 control-label">内容</label>
<div class="col-sm-11"> <div class="col-sm-11">
<textarea class="form-control" id="content" name="content" type="text" style="height: 150px;"></textarea> <div id="editor" class="editorHeight">
</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -33,5 +34,6 @@ ...@@ -33,5 +34,6 @@
</div> </div>
</div> </div>
<script type="text/javascript" src="${ctxPath}/static/js/plugins/wangEditor/wangEditor.js"></script>
<script src="${ctxPath}/static/modular/system/notice/notice_info.js"></script> <script src="${ctxPath}/static/modular/system/notice/notice_info.js"></script>
@} @}
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<div class="form-horizontal" id="noticeInfoForm"> <div class="form-horizontal" id="noticeInfoForm">
<input type="hidden" id="id" value="${notice.id}"> <input type="hidden" id="id" value="${notice.id}">
<input type="hidden" id="contentVal" value="${notice.content}">
<div class="row"> <div class="row">
<div class="col-sm-12"> <div class="col-sm-12">
...@@ -17,7 +18,8 @@ ...@@ -17,7 +18,8 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-1 control-label">内容</label> <label class="col-sm-1 control-label">内容</label>
<div class="col-sm-11"> <div class="col-sm-11">
<textarea class="form-control" id="content" name="content" type="text" style="height: 150px;">${notice.content}</textarea> <div id="editor" class="editorHeight">
</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -30,8 +32,8 @@ ...@@ -30,8 +32,8 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<script type="text/javascript" src="${ctxPath}/static/js/plugins/wangEditor/wangEditor.js"></script>
<script src="${ctxPath}/static/modular/system/notice/notice_info.js"></script> <script src="${ctxPath}/static/modular/system/notice/notice_info.js"></script>
@} @}
...@@ -54,4 +54,8 @@ ...@@ -54,4 +54,8 @@
} }
.dept-tree { .dept-tree {
padding:10px padding:10px
}
.editorHeight{
height: 170px;
} }
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
* 初始化通知详情对话框 * 初始化通知详情对话框
*/ */
var NoticeInfoDlg = { var NoticeInfoDlg = {
noticeInfoData : {}, noticeInfoData: {},
editor: null,
validateFields: { validateFields: {
title: { title: {
validators: { validators: {
...@@ -10,13 +11,6 @@ var NoticeInfoDlg = { ...@@ -10,13 +11,6 @@ var NoticeInfoDlg = {
message: '标题不能为空' message: '标题不能为空'
} }
} }
},
content: {
validators: {
notEmpty: {
message: '内容不能为空'
}
}
} }
} }
}; };
...@@ -24,7 +18,7 @@ var NoticeInfoDlg = { ...@@ -24,7 +18,7 @@ var NoticeInfoDlg = {
/** /**
* 清除数据 * 清除数据
*/ */
NoticeInfoDlg.clearData = function() { NoticeInfoDlg.clearData = function () {
this.noticeInfoData = {}; this.noticeInfoData = {};
} }
...@@ -34,7 +28,7 @@ NoticeInfoDlg.clearData = function() { ...@@ -34,7 +28,7 @@ NoticeInfoDlg.clearData = function() {
* @param key 数据的名称 * @param key 数据的名称
* @param val 数据的具体值 * @param val 数据的具体值
*/ */
NoticeInfoDlg.set = function(key, val) { NoticeInfoDlg.set = function (key, val) {
this.noticeInfoData[key] = (typeof value == "undefined") ? $("#" + key).val() : value; this.noticeInfoData[key] = (typeof value == "undefined") ? $("#" + key).val() : value;
return this; return this;
} }
...@@ -45,22 +39,23 @@ NoticeInfoDlg.set = function(key, val) { ...@@ -45,22 +39,23 @@ NoticeInfoDlg.set = function(key, val) {
* @param key 数据的名称 * @param key 数据的名称
* @param val 数据的具体值 * @param val 数据的具体值
*/ */
NoticeInfoDlg.get = function(key) { NoticeInfoDlg.get = function (key) {
return $("#" + key).val(); return $("#" + key).val();
} }
/** /**
* 关闭此对话框 * 关闭此对话框
*/ */
NoticeInfoDlg.close = function() { NoticeInfoDlg.close = function () {
parent.layer.close(window.parent.Notice.layerIndex); parent.layer.close(window.parent.Notice.layerIndex);
} }
/** /**
* 收集数据 * 收集数据
*/ */
NoticeInfoDlg.collectData = function() { NoticeInfoDlg.collectData = function () {
this.set('id').set('title').set('content'); this.noticeInfoData['content'] = NoticeInfoDlg.editor.txt.text();
this.set('id').set('title');
} }
/** /**
...@@ -75,7 +70,7 @@ NoticeInfoDlg.validate = function () { ...@@ -75,7 +70,7 @@ NoticeInfoDlg.validate = function () {
/** /**
* 提交添加 * 提交添加
*/ */
NoticeInfoDlg.addSubmit = function() { NoticeInfoDlg.addSubmit = function () {
this.clearData(); this.clearData();
this.collectData(); this.collectData();
...@@ -85,11 +80,11 @@ NoticeInfoDlg.addSubmit = function() { ...@@ -85,11 +80,11 @@ NoticeInfoDlg.addSubmit = function() {
} }
//提交信息 //提交信息
var ajax = new $ax(Feng.ctxPath + "/notice/add", function(data){ var ajax = new $ax(Feng.ctxPath + "/notice/add", function (data) {
Feng.success("添加成功!"); Feng.success("添加成功!");
window.parent.Notice.table.refresh(); window.parent.Notice.table.refresh();
NoticeInfoDlg.close(); NoticeInfoDlg.close();
},function(data){ }, function (data) {
Feng.error("添加失败!" + data.responseJSON.message + "!"); Feng.error("添加失败!" + data.responseJSON.message + "!");
}); });
ajax.set(this.noticeInfoData); ajax.set(this.noticeInfoData);
...@@ -99,7 +94,7 @@ NoticeInfoDlg.addSubmit = function() { ...@@ -99,7 +94,7 @@ NoticeInfoDlg.addSubmit = function() {
/** /**
* 提交修改 * 提交修改
*/ */
NoticeInfoDlg.editSubmit = function() { NoticeInfoDlg.editSubmit = function () {
this.clearData(); this.clearData();
this.collectData(); this.collectData();
...@@ -109,17 +104,24 @@ NoticeInfoDlg.editSubmit = function() { ...@@ -109,17 +104,24 @@ NoticeInfoDlg.editSubmit = function() {
} }
//提交信息 //提交信息
var ajax = new $ax(Feng.ctxPath + "/notice/update", function(data){ var ajax = new $ax(Feng.ctxPath + "/notice/update", function (data) {
Feng.success("修改成功!"); Feng.success("修改成功!");
window.parent.Notice.table.refresh(); window.parent.Notice.table.refresh();
NoticeInfoDlg.close(); NoticeInfoDlg.close();
},function(data){ }, function (data) {
Feng.error("修改失败!" + data.responseJSON.message + "!"); Feng.error("修改失败!" + data.responseJSON.message + "!");
}); });
ajax.set(this.noticeInfoData); ajax.set(this.noticeInfoData);
ajax.start(); ajax.start();
} }
$(function() { $(function () {
Feng.initValidator("noticeInfoForm", NoticeInfoDlg.validateFields); Feng.initValidator("noticeInfoForm", NoticeInfoDlg.validateFields);
//初始化编辑器
var E = window.wangEditor;
var editor = new E('#editor');
editor.create();
editor.txt.html($("#contentVal").val());
NoticeInfoDlg.editor = editor;
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment