Commit 517ac553 by fengshuonan

完善通知页面

parent fc88e441
......@@ -15,6 +15,7 @@
*/
package cn.stylefeng.guns.modular.system.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.stylefeng.guns.core.common.annotion.BussinessLog;
import cn.stylefeng.guns.core.common.constant.dictmap.NoticeMap;
import cn.stylefeng.guns.core.common.constant.factory.ConstantFactory;
......@@ -76,7 +77,7 @@ public class NoticeController extends BaseController {
@RequestMapping("/notice_update/{noticeId}")
public String noticeUpdate(@PathVariable Long noticeId, Model model) {
Notice notice = this.noticeService.selectById(noticeId);
model.addAttribute("notice", notice);
model.addAllAttributes(BeanUtil.beanToMap(notice));
LogObjectHolder.me().set(notice);
return PREFIX + "notice_edit.html";
}
......
......@@ -49,7 +49,7 @@ public class NoticeWrapper extends BaseControllerWrapper {
@Override
protected void wrapTheMap(Map<String, Object> map) {
Long creater = (Long) map.get("creater");
Long creater = (Long) map.get("createUser");
map.put("createrName", ConstantFactory.me().getUserNameById(creater));
}
}
@layout("/common/_container.html"){
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>通知管理</h5>
</div>
<div class="ibox-content">
<div class="row row-lg">
<div class="col-sm-12">
@layout("/common/_container.html",{plugins:["table","layer","sweet-alert"],js:["/assets/modular/system/notice/notice.js"]}){
<div class="row" id="noticePage">
<div class="col-lg-12">
<div class="card card-outline-theme m-b-10">
<div class="card-body">
<div class="form-horizontal">
<div class="form-body">
<div class="row">
<div class="col-sm-3">
<#NameCon id="condition" name="名称" />
<div class="col-md-3">
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">通知名称</div>
</div>
<input v-model="condition" type="text" class="form-control" placeholder="通知名称" autocomplete="off">
</div>
</div>
<div class="col-sm-3">
<#button name="搜索" icon="fa-search" clickFun="Notice.search()"/>
<div class="col-md-3">
<div class="input-group condition-button">
<div class="input-group-btn condition-button">
<button type="button" id="check-minutes"
class="btn btn-info waves-effect waves-light condition-button-width" onclick="Notice.search()">查询
</button>
</div>
</div>
</div>
</div>
<div class="hidden-xs" id="NoticeTableToolbar" role="group">
@if(shiro.hasPermission("/notice/add")){
<#button name="添加" icon="fa-plus" clickFun="Notice.openAddNotice()"/>
@}
@if(shiro.hasPermission("/notice/update")){
<#button name="修改" icon="fa-plus" clickFun="Notice.openNoticeDetail()" space="true"/>
@}
@if(shiro.hasPermission("/notice/delete")){
<#button name="删除" icon="fa-plus" clickFun="Notice.delete()" space="true"/>
@}
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="card card-outline-theme m-b-0">
<div class="card-body p-t-0 p-b-0">
<div class="form-horizontal">
<div class="form-actions">
<div class="row">
<div class="col-lg-12">
<div class="card m-b-0 p-b-0">
<div class="hidden-xs" id="NoticeTableToolbar" role="group">
@if(shiro.hasPermission("/notice/add")){
<button type="button" class="btn btn-primary waves-effect" onclick="Notice.openAddNotice()">
<i class="fa fa-plus"></i>&nbsp;添加
</button>
@}
@if(shiro.hasPermission("/notice/update")){
<button type="button" class="btn btn-primary waves-effect m-l-5" onclick="Notice.openNoticeDetail()">
<i class="fa fa-edit"></i>&nbsp;修改
</button>
@}
@if(shiro.hasPermission("/notice/delete")){
<button type="button" class="btn btn-primary waves-effect m-l-5" onclick="Notice.delete()">
<i class="fa fa-remove"></i>&nbsp;删除
</button>
@}
</div>
<#table id="NoticeTable"/>
</div>
</div>
</div>
<#table id="NoticeTable"/>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="${ctxPath}/static/modular/system/notice/notice.js"></script>
@}
@layout("/common/_container.html"){
<div class="ibox float-e-margins">
<div class="ibox-content">
<div class="form-horizontal" id="noticeInfoForm">
<input type="hidden" id="id" value="">
<div class="row">
<div class="col-sm-12">
<div class="form-group">
<label class="col-sm-1 control-label">标题</label>
<div class="col-sm-11">
<input class="form-control" id="title" name="title" type="text">
</div>
@layout("/common/_dialog.html",{plugins:["sweet-alert","layer"],js:["/assets/modular/system/notice/notice_add.js"]}){
<div class="container-fluid">
<form id="noticeForm" \@submit="submitForm">
<div class="row">
<div class="col-12">
<div class="form-group">
<h5>标题 <span class="text-danger">*</span></h5>
<div class="controls">
<input v-model="title" type="text" class="form-control">
</div>
<div class="form-group">
<label class="col-sm-1 control-label">内容</label>
<div class="col-sm-11">
<div id="editor" class="editorHeight">
</div>
</div>
</div>
<div class="form-group">
<h5>内容 <span class="text-danger">*</span></h5>
<div class="controls">
<input v-model="content" type="text" class="form-control">
</div>
</div>
</div>
<div class="row btn-group-m-t">
<div class="col-sm-10">
<#button btnCss="info" name="提交" id="ensure" icon="fa-check" clickFun="NoticeInfoDlg.addSubmit()"/>
<#button btnCss="danger" name="取消" id="cancel" icon="fa-eraser" clickFun="NoticeInfoDlg.close()"/>
</div>
<div class="row">
<div class="col-6">
<div class="text-xs-right">
<button class="btn btn-info normal-button-width" \@click="ensure">提交</button>
<button class="btn btn-inverse normal-button-width m-l-10" \@click="close">取消</button>
</div>
</div>
</div>
</div>
</form>
</div>
<script type="text/javascript" src="//unpkg.com/wangeditor/release/wangEditor.min.js"></script>
<script src="${ctxPath}/static/modular/system/notice/notice_info.js"></script>
@}
@}
\ No newline at end of file
@layout("/common/_container.html"){
<div class="ibox float-e-margins">
<div class="ibox-content">
<div class="form-horizontal" id="noticeInfoForm">
@layout("/common/_dialog.html",{plugins:["sweet-alert","layer"],js:["/assets/modular/system/notice/notice_edit.js"]}){
<div class="container-fluid">
<form id="noticeForm" \@submit="submitForm">
<input type="hidden" id="id" value="${notice.id}">
<input type="hidden" id="contentVal" value='${notice.content}'>
<input id="noticeId" value="${noticeId}" type="hidden" class="form-control">
<div class="row">
<div class="col-sm-12">
<div class="form-group">
<label class="col-sm-1 control-label">标题</label>
<div class="col-sm-11">
<input class="form-control" id="title" name="title" type="text" value="${notice.title}">
</div>
<div class="row">
<div class="col-12">
<div class="form-group">
<h5>标题 <span class="text-danger">*</span></h5>
<div class="controls">
<input v-model="title" id="title" value="${title}" type="text" class="form-control">
</div>
<div class="form-group">
<label class="col-sm-1 control-label">内容</label>
<div class="col-sm-11">
<div id="editor" class="editorHeight">
</div>
</div>
</div>
<div class="form-group">
<h5>内容 <span class="text-danger">*</span></h5>
<div class="controls">
<input v-model="content" id="content" value="${content}" type="text" class="form-control">
</div>
</div>
</div>
<div class="row btn-group-m-t">
<div class="col-sm-10">
<#button btnCss="info" name="提交" id="ensure" icon="fa-check" clickFun="NoticeInfoDlg.editSubmit()"/>
<#button btnCss="danger" name="取消" id="cancel" icon="fa-eraser" clickFun="NoticeInfoDlg.close()"/>
</div>
<div class="row">
<div class="col-6">
<div class="text-xs-right">
<button class="btn btn-info normal-button-width" \@click="ensure">提交</button>
<button class="btn btn-inverse normal-button-width m-l-10" \@click="close">取消</button>
</div>
</div>
</div>
</div>
</form>
</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>
@}
@}
\ No newline at end of file
......@@ -5,7 +5,10 @@ var Notice = {
id: "NoticeTable", //表格id
seItem: null, //选中的条目
table: null,
layerIndex: -1
layerIndex: -1,
condition: {
condition: ""
}
};
/**
......@@ -14,11 +17,11 @@ var Notice = {
Notice.initColumn = function () {
return [
{field: 'selectItem', radio: true},
{title: 'id', field: 'id', visible: false, align: 'center', valign: 'middle'},
{title: 'id', field: 'noticeId', visible: false, align: 'center', valign: 'middle'},
{title: '标题', field: 'title', align: 'center', valign: 'middle', sortable: true},
{title: '内容', field: 'content', align: 'center', valign: 'middle', sortable: true},
{title: '发布者', field: 'createrName', align: 'center', valign: 'middle', sortable: true},
{title: '创建时间', field: 'createtime', align: 'center', valign: 'middle', sortable: true}
{title: '创建时间', field: 'createTime', align: 'center', valign: 'middle', sortable: true}
];
};
......@@ -62,7 +65,7 @@ Notice.openNoticeDetail = function () {
area: ['800px', '420px'], //宽高
fix: false, //不固定
maxmin: true,
content: Feng.ctxPath + '/notice/notice_update/' + Notice.seItem.id
content: Feng.ctxPath + '/notice/notice_update/' + Notice.seItem.noticeId
});
this.layerIndex = index;
}
......@@ -74,14 +77,14 @@ Notice.openNoticeDetail = function () {
Notice.delete = function () {
if (this.check()) {
var operation = function(){
var operation = function () {
var ajax = new $ax(Feng.ctxPath + "/notice/delete", function (data) {
Feng.success("删除成功!");
Notice.table.refresh();
}, function (data) {
Feng.error("删除失败!" + data.responseJSON.message + "!");
});
ajax.set("noticeId", Notice.seItem.id);
ajax.set("noticeId", Notice.seItem.noticeId);
ajax.start();
};
......@@ -94,11 +97,17 @@ Notice.delete = function () {
*/
Notice.search = function () {
var queryData = {};
queryData['condition'] = $("#condition").val();
queryData['condition'] = Notice.condition.condition;
Notice.table.refresh({query: queryData});
};
$(function () {
Notice.app = new Vue({
el: '#noticePage',
data: Notice.condition
});
var defaultColunms = Notice.initColumn();
var table = new BSTable(Notice.id, "/notice/list", defaultColunms);
table.setPaginationType("client");
......
/**
* 角色详情对话框(可用于添加和修改对话框)
*/
var NoticeAddDlg = {
editor: null,
data: {
title: "",
content: ""
}
};
/**
* 关闭此对话框
*/
NoticeAddDlg.close = function () {
parent.layer.close(window.parent.Notice.layerIndex);
};
/**
* 验证表单
*/
NoticeAddDlg.validateForm = function () {
var data = NoticeAddDlg.data;
if (!data.title) {
return "请输入标题";
}
if (!data.content) {
return "请输入内容";
}
return true;
};
/**
* 提交添加角色
*/
NoticeAddDlg.addSubmit = function () {
var ajax = new $ax(Feng.ctxPath + "/notice/add", function (data) {
parent.Feng.success("添加成功!");
window.parent.Notice.table.refresh();
parent.layer.close(window.parent.Notice.layerIndex);
}, function (data) {
parent.Feng.error("添加失败!" + data.responseJSON.message + "!");
});
ajax.set(NoticeAddDlg.data);
ajax.start();
};
$(function () {
NoticeAddDlg.app = new Vue({
el: '#noticeForm',
data: NoticeAddDlg.data,
methods: {
submitForm: function (e) {
e.preventDefault();
},
ensure: function () {
var result = NoticeAddDlg.validateForm();
if (result === true) {
NoticeAddDlg.addSubmit();
} else {
Feng.alert(result);
}
},
close: function () {
NoticeAddDlg.close();
}
}
});
});
/**
* 角色详情对话框(可用于添加和修改对话框)
*/
var NoticeEditDlg = {
editor: null,
data: {
noticeId: $("#noticeId").val(),
title: $("#title").val(),
content: $("#content").val()
}
};
/**
* 关闭此对话框
*/
NoticeEditDlg.close = function () {
parent.layer.close(window.parent.Notice.layerIndex);
};
/**
* 验证表单
*/
NoticeEditDlg.validateForm = function () {
var data = NoticeEditDlg.data;
if (!data.title) {
return "请输入标题";
}
if (!data.content) {
return "请输入内容";
}
return true;
};
/**
* 提交添加角色
*/
NoticeEditDlg.editSubmit = function () {
var ajax = new $ax(Feng.ctxPath + "/notice/update", function (data) {
parent.Feng.success("修改成功!");
window.parent.Notice.table.refresh();
parent.layer.close(window.parent.Notice.layerIndex);
}, function (data) {
parent.Feng.error("修改失败!" + data.responseJSON.message + "!");
});
ajax.set(NoticeEditDlg.data);
ajax.start();
};
$(function () {
NoticeEditDlg.app = new Vue({
el: '#noticeForm',
data: NoticeEditDlg.data,
methods: {
submitForm: function (e) {
e.preventDefault();
},
ensure: function () {
var result = NoticeEditDlg.validateForm();
if (result === true) {
NoticeEditDlg.editSubmit();
} else {
Feng.alert(result);
}
},
close: function () {
NoticeEditDlg.close();
}
}
});
});
/**
* 初始化通知详情对话框
*/
var NoticeInfoDlg = {
noticeInfoData: {},
editor: null,
validateFields: {
title: {
validators: {
notEmpty: {
message: '标题不能为空'
}
}
}
}
};
/**
* 清除数据
*/
NoticeInfoDlg.clearData = function () {
this.noticeInfoData = {};
}
/**
* 设置对话框中的数据
*
* @param key 数据的名称
* @param val 数据的具体值
*/
NoticeInfoDlg.set = function (key, value) {
this.noticeInfoData[key] = (typeof value == "undefined") ? $("#" + key).val() : value;
return this;
}
/**
* 设置对话框中的数据
*
* @param key 数据的名称
* @param val 数据的具体值
*/
NoticeInfoDlg.get = function (key) {
return $("#" + key).val();
}
/**
* 关闭此对话框
*/
NoticeInfoDlg.close = function () {
parent.layer.close(window.parent.Notice.layerIndex);
}
/**
* 收集数据
*/
NoticeInfoDlg.collectData = function () {
this.noticeInfoData['content'] = NoticeInfoDlg.editor.txt.html();
this.set('id').set('title');
}
/**
* 验证数据是否为空
*/
NoticeInfoDlg.validate = function () {
$('#noticeInfoForm').data("bootstrapValidator").resetForm();
$('#noticeInfoForm').bootstrapValidator('validate');
return $("#noticeInfoForm").data('bootstrapValidator').isValid();
};
/**
* 提交添加
*/
NoticeInfoDlg.addSubmit = function () {
this.clearData();
this.collectData();
if (!this.validate()) {
return;
}
//提交信息
var ajax = new $ax(Feng.ctxPath + "/notice/add", function (data) {
Feng.success("添加成功!");
window.parent.Notice.table.refresh();
NoticeInfoDlg.close();
}, function (data) {
Feng.error("添加失败!" + data.responseJSON.message + "!");
});
ajax.set(this.noticeInfoData);
ajax.start();
}
/**
* 提交修改
*/
NoticeInfoDlg.editSubmit = function () {
this.clearData();
this.collectData();
if (!this.validate()) {
return;
}
//提交信息
var ajax = new $ax(Feng.ctxPath + "/notice/update", function (data) {
Feng.success("修改成功!");
window.parent.Notice.table.refresh();
NoticeInfoDlg.close();
}, function (data) {
Feng.error("修改失败!" + data.responseJSON.message + "!");
});
ajax.set(this.noticeInfoData);
ajax.start();
}
$(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