Commit 74aa8ffb by naan1993

增加富文本编辑器

parent 2b3b3cf9
......@@ -66,6 +66,7 @@ public class NoticeController extends BaseController {
public String noticeUpdate(@PathVariable Integer noticeId, Model model) {
Notice notice = this.noticeMapper.selectById(noticeId);
model.addAttribute("notice",notice);
LogObjectHolder.me().set(notice);
return PREFIX + "notice_edit.html";
}
......
......@@ -17,7 +17,8 @@
<div class="form-group">
<label class="col-sm-1 control-label">内容</label>
<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>
......@@ -33,5 +34,6 @@
</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>
@}
......@@ -4,6 +4,7 @@
<div class="form-horizontal" id="noticeInfoForm">
<input type="hidden" id="id" value="${notice.id}">
<input type="hidden" id="contentVal" value="${notice.content}">
<div class="row">
<div class="col-sm-12">
......@@ -17,7 +18,8 @@
<div class="form-group">
<label class="col-sm-1 control-label">内容</label>
<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>
......@@ -30,8 +32,8 @@
</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>
@}
......@@ -55,3 +55,7 @@
.dept-tree {
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 @@
* 初始化通知详情对话框
*/
var NoticeInfoDlg = {
noticeInfoData : {},
noticeInfoData: {},
editor: null,
validateFields: {
title: {
validators: {
......@@ -10,13 +11,6 @@ var NoticeInfoDlg = {
message: '标题不能为空'
}
}
},
content: {
validators: {
notEmpty: {
message: '内容不能为空'
}
}
}
}
};
......@@ -24,7 +18,7 @@ var NoticeInfoDlg = {
/**
* 清除数据
*/
NoticeInfoDlg.clearData = function() {
NoticeInfoDlg.clearData = function () {
this.noticeInfoData = {};
}
......@@ -34,7 +28,7 @@ NoticeInfoDlg.clearData = function() {
* @param key 数据的名称
* @param val 数据的具体值
*/
NoticeInfoDlg.set = function(key, val) {
NoticeInfoDlg.set = function (key, val) {
this.noticeInfoData[key] = (typeof value == "undefined") ? $("#" + key).val() : value;
return this;
}
......@@ -45,22 +39,23 @@ NoticeInfoDlg.set = function(key, val) {
* @param key 数据的名称
* @param val 数据的具体值
*/
NoticeInfoDlg.get = function(key) {
NoticeInfoDlg.get = function (key) {
return $("#" + key).val();
}
/**
* 关闭此对话框
*/
NoticeInfoDlg.close = function() {
NoticeInfoDlg.close = function () {
parent.layer.close(window.parent.Notice.layerIndex);
}
/**
* 收集数据
*/
NoticeInfoDlg.collectData = function() {
this.set('id').set('title').set('content');
NoticeInfoDlg.collectData = function () {
this.noticeInfoData['content'] = NoticeInfoDlg.editor.txt.text();
this.set('id').set('title');
}
/**
......@@ -75,7 +70,7 @@ NoticeInfoDlg.validate = function () {
/**
* 提交添加
*/
NoticeInfoDlg.addSubmit = function() {
NoticeInfoDlg.addSubmit = function () {
this.clearData();
this.collectData();
......@@ -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("添加成功!");
window.parent.Notice.table.refresh();
NoticeInfoDlg.close();
},function(data){
}, function (data) {
Feng.error("添加失败!" + data.responseJSON.message + "!");
});
ajax.set(this.noticeInfoData);
......@@ -99,7 +94,7 @@ NoticeInfoDlg.addSubmit = function() {
/**
* 提交修改
*/
NoticeInfoDlg.editSubmit = function() {
NoticeInfoDlg.editSubmit = function () {
this.clearData();
this.collectData();
......@@ -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("修改成功!");
window.parent.Notice.table.refresh();
NoticeInfoDlg.close();
},function(data){
}, function (data) {
Feng.error("修改失败!" + data.responseJSON.message + "!");
});
ajax.set(this.noticeInfoData);
ajax.start();
}
$(function() {
$(function () {
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