330 lines
10 KiB
HTML
330 lines
10 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en" xmlns="http://www.w3.org/1999/html">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<title>系统公告列表</title>
|
||
<link rel="stylesheet" href="../../layui-v2.8.18/layui/css/layui.css" media="all"/>
|
||
</head>
|
||
<style>
|
||
.layui-table th{
|
||
font-weight: bold;
|
||
text-align: center
|
||
}
|
||
.layui-table td{
|
||
text-align: center
|
||
}
|
||
.layui-btn-sm {
|
||
height: 35px;
|
||
line-height: 35px;
|
||
padding: 0px 10px;
|
||
font-size: 16px;
|
||
}
|
||
</style>
|
||
<body style="margin-left: 15px">
|
||
<form class="layui-form" action="" onsubmit="return false">
|
||
<div class="layui-form-item" style="margin-bottom: 0px;">
|
||
<div class="layui-inline" style="margin-top: 10px;">
|
||
<div class="layui-input-inline">
|
||
<input type="text" id="keyWord" placeholder="请输入关键字" autocomplete="off" class="layui-input">
|
||
</div>
|
||
<div class="layui-input-inline" style="width: 150px;margin-left: 18px;">
|
||
<select id="type" name="type" class="form-control input-sm">
|
||
<option value="">请选择公告类型</option>
|
||
<option value="1">升级公告</option>
|
||
<option value="2">系统通知</option>
|
||
</select>
|
||
</div>
|
||
<div class="layui-input-inline">
|
||
<div class="layui-input-inline">
|
||
<input type="text" class="layui-input" placeholder="发布时间" id="releaseTime">
|
||
</div>
|
||
</div>
|
||
<div class="layui-input-inline" style="width: 70px;margin-top: 2px">
|
||
<button id="searchBt" class="layui-btn layui-btn-sm">查询</button>
|
||
</div>
|
||
<div class="layui-input-inline" style="width: 70px;margin-top: 2px">
|
||
<button id="resetBt" class="layui-btn layui-btn-sm">重置</button>
|
||
</div>
|
||
<div class="layui-input-inline" style="width: 70px;margin-top: 2px">
|
||
<button id="addBt" class="layui-btn layui-btn-sm">新增</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
|
||
<table id="demo" lay-filter="test"></table>
|
||
|
||
<script type="text/html" id="toolsBar">
|
||
<a lay-event="view" style="color: #009688;cursor: pointer;font-size: 15px">详情</a>
|
||
<span style="font-size: 15px;"> | </span>
|
||
<a lay-event="del" style="color: #009688;cursor: pointer;font-size: 15px">删除</a>
|
||
</script>
|
||
|
||
</body>
|
||
</html>
|
||
<script src="../../js/jquery/jquery-3.6.0.js"></script>
|
||
<script src="../../layui-v2.8.18/layui/layui.js"></script>
|
||
<script type="text/javascript" src="../../js/jq.js"></script>
|
||
<script src="../../js/common_methon.js"></script>
|
||
<script type="text/javascript" src="../../js/publicJs.js"></script>
|
||
<script type="text/javascript" src="../../js/select.js"></script>
|
||
<script type="text/javascript" src="../../js/my/permission.js"></script>
|
||
<script>
|
||
layui.config({
|
||
base: '../../js/layuiModules/', // 第三方模块所在目录
|
||
version: 'v1.6.4' // 插件版本号
|
||
}).extend({
|
||
soulTable: 'notice,layNotify', // 模块
|
||
});
|
||
|
||
let form;
|
||
var table;
|
||
var notice;
|
||
var layNotify;
|
||
var laydate;
|
||
var util;
|
||
$("#resetBt").click(function(){
|
||
table.reload('menuTable', {
|
||
url: ctxPath + '/announcement/getAnnouncementList'
|
||
, method: 'post' //方式默认是get
|
||
, page: true
|
||
, where: {
|
||
keyWord: "",
|
||
type: "",
|
||
releaseTime: "",
|
||
} //设定异步数据接口的额外参数
|
||
});
|
||
$("#keyWord").val("");
|
||
getAnnouncementType(form,"");
|
||
$("#releaseTime").val("");
|
||
})
|
||
$("#searchBt").click(function(){
|
||
table.reload('menuTable', {
|
||
url: ctxPath + '/announcement/getAnnouncementList'
|
||
, method: 'post' //方式默认是get
|
||
, page: true
|
||
, where: {
|
||
keyWord: $("#keyWord").val(),
|
||
type: $("#type").val(),
|
||
releaseTime: $("#releaseTime").val(),
|
||
} //设定异步数据接口的额外参数
|
||
});
|
||
})
|
||
$("#addBt").click(function(){
|
||
localStorage.setItem("id","")
|
||
var index = layer.open({
|
||
title: ['新增', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
||
type: 2,
|
||
content: "./AnnouncementForm.html",
|
||
area: ['90%', '95%'],
|
||
maxmin: false,
|
||
});
|
||
// layerOpenFormForSencond("新增","./announcementForm.html");
|
||
})
|
||
layui.use(['laydate','util','form','table','notice', 'layNotify'],function(){
|
||
table = layui.table;
|
||
form = layui.form;
|
||
laydate = layui.laydate;
|
||
util = layui.util;
|
||
notice = layui.notice;
|
||
layNotify = layui.layNotify;
|
||
initTime();
|
||
//渲染表格
|
||
table.render({
|
||
elem: '#demo'
|
||
, url: ctxPath + '/announcement/getAnnouncementList' //数据接口
|
||
|
||
, method: 'post' //方式默认是get
|
||
, toolbar: 'default' //开启工具栏,此处显示默认图标,可以自定义模板,详见文档
|
||
, where: {} //post请求必须加where ,post请求需要的参数
|
||
, cellMinWidth: 80
|
||
, cols: [[ //表头
|
||
{
|
||
field: 'number', width:80,title: '序号', align: 'center', type: 'numbers'
|
||
}
|
||
, {
|
||
field: 'title', title: '公告标题', align: 'center', templet: d => {
|
||
return text ="<span style='cursor:pointer;' onclick='openView(\"" + d.id +"\")'>"+d.title+"</span>";
|
||
}
|
||
}
|
||
, {field: 'type', align: 'center', title: '公告类型'}
|
||
, {
|
||
field: 'acceptGroup', title: '接受群体', align: 'center', templet: d => {
|
||
return text ="<span style='cursor:pointer;' onclick='openPersonView(\"" + d.id +"\")'>"+d.acceptGroup+"</span>";
|
||
}
|
||
}
|
||
, {field: 'releasePerson', align: 'center', title: '发布人'}
|
||
, {field: 'releaseTime', align: 'center', title: '发布时间'}
|
||
, {fixed: 'right', title: '操作', align: 'center', toolbar: '#toolsBar'}
|
||
]]
|
||
, id: 'menuTable'
|
||
, page: true //开启分页
|
||
, loading: true //数据加载中。。。
|
||
, limits: [5, 10, 20] //一页选择显示3,5或10条数据
|
||
, limit: 10 //一页显示5条数据
|
||
, response: {
|
||
statusCode: 200 //规定成功的状态码,默认:0
|
||
}, parseData: function (res) { //将原始数据解析成 table 组件所规定的数据,res为从url中get到的数据
|
||
let result;
|
||
if (res.data !== '' && res.data != null && res.data !== "null") {
|
||
if (this.page.curr) {
|
||
result = res.data.slice(this.limit * (this.page.curr - 1), this.limit * this.page.curr);
|
||
} else {
|
||
result = res.data.slice(0, this.limit);
|
||
}
|
||
}
|
||
return {
|
||
"code": res.code, //解析接口状态
|
||
"msg": res.msg, //解析提示文本
|
||
"count": res.count, //解析数据长度
|
||
"data": result, //解析数据列表
|
||
};
|
||
},
|
||
toolbar: "#toolbar"
|
||
});
|
||
|
||
//监听工具条
|
||
table.on('tool(test)', function (obj) {
|
||
var data = obj.data; //当前行数据
|
||
var rowIndex = obj.index;
|
||
var layEvent = obj.event; //当前点击的事件名
|
||
if (layEvent === 'view') {
|
||
openView(data.id)
|
||
}
|
||
if (layEvent === 'del') {
|
||
var index = layer.confirm('确定要删除吗?', {
|
||
btn : [ '确定', '取消' ]
|
||
}, function() {
|
||
layer.close(index);
|
||
ajaxCommonMethod('/announcement/delAnnouncementById',{'id': data.id},"删除成功","删除失败");
|
||
});
|
||
}
|
||
});
|
||
|
||
getAnnouncementType(form,"");
|
||
})
|
||
|
||
/**
|
||
* 打开详情页面
|
||
* @param id
|
||
*/
|
||
function openView(id){
|
||
localStorage.setItem('announcementId',id);
|
||
var index = layer.open({
|
||
title: ['公告详情', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
||
type: 2,
|
||
content: './AnnouncementView.html',
|
||
area: ["90%", "95%"],
|
||
maxmin: false,
|
||
btn: ['关闭'],
|
||
});
|
||
}
|
||
function openPersonView(id){
|
||
localStorage.setItem('announcementId',id);
|
||
var index = layer.open({
|
||
title: ['公告详情', 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
|
||
type: 2,
|
||
content: './AnnouncementPersonView.html',
|
||
area: ["35%", "65%"],
|
||
maxmin: false,
|
||
btn: ['关闭'],
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 初始化发布时间选择器
|
||
*/
|
||
function initTime() {
|
||
/*
|
||
* 快捷选项
|
||
*/
|
||
// 日期
|
||
laydate.render({
|
||
elem: "#releaseTime",
|
||
shortcuts: [
|
||
{
|
||
text: "昨天",
|
||
value: function(){
|
||
var now = new Date();
|
||
now.setDate(now.getDate() - 1);
|
||
return now;
|
||
}
|
||
},
|
||
{
|
||
text: "今天",
|
||
value: function(){
|
||
return Date.now();
|
||
}
|
||
},
|
||
{
|
||
text: "明天",
|
||
value: function(){
|
||
var now = new Date();
|
||
now.setDate(now.getDate() + 1);
|
||
return now;
|
||
}
|
||
},
|
||
{
|
||
text: "上个月",
|
||
value: function(){
|
||
var now = new Date();
|
||
var month = now.getMonth() - 1;
|
||
now.setMonth(month);
|
||
// 若上个月数不匹配,则表示天数溢出
|
||
if (now.getMonth() !== month) {
|
||
now.setDate(0); // 重置天数
|
||
}
|
||
return [now];
|
||
}
|
||
},
|
||
{
|
||
text: "下个月",
|
||
value: function(){
|
||
var now = new Date();
|
||
var month = now.getMonth() + 1;
|
||
now.setMonth(month);
|
||
// 若下个月数不匹配,则表示天数溢出
|
||
if (now.getMonth() !== month) {
|
||
now.setDate(0); // 重置天数
|
||
}
|
||
return [now];
|
||
}
|
||
},
|
||
{
|
||
text: "某一天",
|
||
value: "2016-10-14"
|
||
}
|
||
]
|
||
});
|
||
}
|
||
|
||
function reloadTip(tip,message,type){
|
||
layNotify.notice({
|
||
title: tip+"提示",
|
||
type: type,
|
||
message: message
|
||
});
|
||
}
|
||
|
||
function ajaxCommonMethod(url,data,success,error){
|
||
$.ajax({
|
||
type: 'POST',
|
||
async: false, // 默认异步true,false表示同步
|
||
url: ctxPath + url,// 请求地址
|
||
contentType: "application/x-www-form-urlencoded",
|
||
dataType: 'json', // 服务器返回数据类型
|
||
data: data, //获取提交的表单字段
|
||
success: function (data) {
|
||
var resMsg = data.resMsg;
|
||
if ("数据获取成功" == resMsg) {
|
||
reloadTip("删除",success,'success');
|
||
setTimeout(function(){
|
||
window.location.reload();
|
||
}, 2000);
|
||
}else {
|
||
reloadTip("删除",error,"error");
|
||
}
|
||
}
|
||
});
|
||
}
|
||
</script> |