feat: 增加后台消息模板
This commit is contained in:
181
app/admin/controller/system/AdminNotice.php
Normal file
181
app/admin/controller/system/AdminNotice.php
Normal file
@@ -0,0 +1,181 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | swiftAdmin 极速开发框架 [基于ThinkPHP6开发]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2020-2030 http://www.swiftadmin.net
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | swiftAdmin.net High Speed Development Framework
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: meystack <coolsec@foxmail.com> Apache 2.0 License Code
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace app\admin\controller\system;
|
||||||
|
|
||||||
|
use app\admin\enums\AdminNoticeEnum;
|
||||||
|
use app\admin\service\AdminNoticeService;
|
||||||
|
use app\AdminController;
|
||||||
|
use app\common\exception\OperateException;
|
||||||
|
use app\common\model\system\AdminNotice as AdminNoticeModel;
|
||||||
|
use app\common\model\system\Admin as AdminModel;
|
||||||
|
use Exception;
|
||||||
|
use support\Response;
|
||||||
|
use think\db\exception\DataNotFoundException;
|
||||||
|
use think\db\exception\DbException;
|
||||||
|
use think\db\exception\ModelNotFoundException;
|
||||||
|
|
||||||
|
class AdminNotice extends AdminController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 消息类型
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public array $msgType = [
|
||||||
|
'notice' => '通知',
|
||||||
|
'message' => '消息',
|
||||||
|
'todo' => '待办',
|
||||||
|
];
|
||||||
|
|
||||||
|
// 初始化函数
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->model = new AdminNoticeModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取资源列表
|
||||||
|
* @return Response
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function index(): Response
|
||||||
|
{
|
||||||
|
if (request()->isAjax()) {
|
||||||
|
list($count, $list) = AdminNoticeService::dataList(get_admin_id());
|
||||||
|
return $this->success('查询成功', null, $list, $count);
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('/system/admin_notice/index', [
|
||||||
|
'msgType' => $this->msgType,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息模板
|
||||||
|
* @return Response
|
||||||
|
* @throws DataNotFoundException
|
||||||
|
* @throws DbException
|
||||||
|
* @throws ModelNotFoundException
|
||||||
|
*/
|
||||||
|
public function bells(): Response
|
||||||
|
{
|
||||||
|
list($count, $list) = AdminNoticeService::bells(get_admin_id());
|
||||||
|
return view('/system/admin_notice/bells', [
|
||||||
|
'list' => $list,
|
||||||
|
'count' => $count
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取消息列表
|
||||||
|
* @return Response
|
||||||
|
* @throws DbException
|
||||||
|
*/
|
||||||
|
public function getBells(): Response
|
||||||
|
{
|
||||||
|
$data = AdminNoticeService::getBells(get_admin_id());
|
||||||
|
return $this->success('获取成功', '/', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 阅读消息
|
||||||
|
* @return Response
|
||||||
|
* @throws OperateException
|
||||||
|
*/
|
||||||
|
public function read(): Response
|
||||||
|
{
|
||||||
|
$id = request()->get('id', 0);
|
||||||
|
$detail = AdminNoticeService::getDetail($id, get_admin_id());
|
||||||
|
return view('/system/admin_notice/' . $detail['type'], [
|
||||||
|
'detail' => $detail
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送消息
|
||||||
|
* @return Response
|
||||||
|
* @throws DataNotFoundException
|
||||||
|
* @throws DbException
|
||||||
|
* @throws ModelNotFoundException
|
||||||
|
* @throws OperateException
|
||||||
|
*/
|
||||||
|
public function add(): Response
|
||||||
|
{
|
||||||
|
if (request()->isPost()) {
|
||||||
|
$post = request()->post();
|
||||||
|
$post['send_id'] = get_admin_id();
|
||||||
|
$post['type'] = AdminNoticeEnum::MESSAGE;
|
||||||
|
$post['send_ip'] = request()->getRealIp();
|
||||||
|
$post['create_time'] = time();
|
||||||
|
validate(\app\common\validate\system\AdminNotice::class)->check($post);
|
||||||
|
AdminNoticeService::add($post);
|
||||||
|
return $this->success('发送成功');
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('/system/admin_notice/add', [
|
||||||
|
'adminList' => AdminModel::select()->toArray(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清空消息
|
||||||
|
* @return Response
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function clear(): Response
|
||||||
|
{
|
||||||
|
$type = input('type', AdminNoticeEnum::NOTICE);
|
||||||
|
$where[] = ['type', '=', $type];
|
||||||
|
$where[] = ['admin_id', '=', get_admin_id()];
|
||||||
|
$where[] = ['status', '=', AdminNoticeEnum::STATUS_READ];
|
||||||
|
try {
|
||||||
|
AdminNoticeModel::where($where)->delete();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return $this->error('清空失败');
|
||||||
|
}
|
||||||
|
return $this->success('清空成功');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全部消息已读
|
||||||
|
* @return Response
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function readAll(): Response
|
||||||
|
{
|
||||||
|
$type = input('type', AdminNoticeEnum::NOTICE);
|
||||||
|
$where[] = ['type', '=', $type];
|
||||||
|
$where[] = ['admin_id', '=', get_admin_id()];
|
||||||
|
$where[] = ['status', '=', AdminNoticeEnum::STATUS_UNREAD];
|
||||||
|
try {
|
||||||
|
AdminNoticeModel::where($where)->update(['status' => 1]);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return $this->error('操作失败');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->success('全部已读成功');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除消息
|
||||||
|
* @return Response
|
||||||
|
* @throws OperateException
|
||||||
|
*/
|
||||||
|
public function del(): Response
|
||||||
|
{
|
||||||
|
$id = request()->get('id', 0);
|
||||||
|
AdminNoticeService::delete($id, get_admin_id());
|
||||||
|
return $this->success('删除成功');
|
||||||
|
}
|
||||||
|
}
|
||||||
258
app/admin/view/system/admin_notice/bells.html
Normal file
258
app/admin/view/system/admin_notice/bells.html
Normal file
@@ -0,0 +1,258 @@
|
|||||||
|
<include file="/public/header" />
|
||||||
|
<link href="__STATICADMIN__css/message.css" rel="stylesheet" type="text/css" />
|
||||||
|
<div class="layui-tab layui-tab-brief" >
|
||||||
|
|
||||||
|
<ul class="layui-tab-title" style="text-align: center;">
|
||||||
|
<li class="layui-this" id="msg" >{:__('通知')}({$count['notice']})</li>
|
||||||
|
<li>{:__('私信')}({$count['message']})</li>
|
||||||
|
<li>{:__('待办')}({$count['todo']})</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div class="layui-tab-content" style="padding: 5px 0px;">
|
||||||
|
<div class="layui-tab-item layui-show">
|
||||||
|
<ul id="notice" class="layui-instant-list" >
|
||||||
|
<volist name="list['notice']" id="vo">
|
||||||
|
<a data-id="{$vo.id}" data-type="notice" class="layui-instant-list-item active_{$vo.status}" href="javascript:;">
|
||||||
|
<img class="layui-instant-item-icon" src="__ADMINIMAGES__message.png">
|
||||||
|
<div class="layui-instant-item-right">
|
||||||
|
<h2 class="layui-instant-item-title">{$vo.title}</h2>
|
||||||
|
<p class="layui-instant-item-text">{$vo.create_time}</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</volist>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<!-- // 列表为空 -->
|
||||||
|
<div class="layui-instant-list-empty" <empty name="$list['notice']"> style="display:black;" <else/> style="display:none;" </empty> >
|
||||||
|
<img src="__ADMINIMAGES__noting.png"><div>{:__('没有通知')}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- // 底部操作 -->
|
||||||
|
<notempty name="$list['notice']">
|
||||||
|
<div class="layui-instant-footer">
|
||||||
|
<a href="javascript:;" class="instant-clear" data-type="notice">{:__('清空通知')}</a>
|
||||||
|
<span>|</span>
|
||||||
|
<a href="javascript:;" class="instant-reads" data-type="notice">{:__('全部已读')}</a>
|
||||||
|
</div>
|
||||||
|
</notempty>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-tab-item">
|
||||||
|
|
||||||
|
<ul id="message" class="layui-instant-list" >
|
||||||
|
<volist name="list['message']" id="vo">
|
||||||
|
<a data-id="{$vo.id}" data-type="message" class="layui-instant-list-item active_{$vo.status}" href="javascript:;">
|
||||||
|
<img class="layui-instant-item-icon" src="{$vo.face|default='__ADMINIMAGES__head.png'}" >
|
||||||
|
<div class="layui-instant-item-right">
|
||||||
|
<h2 class="layui-instant-item-title">{$vo.title}</h2>
|
||||||
|
<p class="layui-instant-item-text">{$vo.create_time}</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</volist>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<!-- // 列表为空 -->
|
||||||
|
<div class="layui-instant-list-empty" <empty name="$list['message']"> style="display:black;" <else/> style="display:none;" </empty> >
|
||||||
|
<img src="__ADMINIMAGES__noting.png"><div>{:__('没有私信')}</div>
|
||||||
|
</div>
|
||||||
|
<notempty name="$list['message']">
|
||||||
|
<div class="layui-instant-footer">
|
||||||
|
<a href="javascript:;" class="instant-clear" data-type="message">{:__('清空私信')}</a>
|
||||||
|
<span>|</span>
|
||||||
|
<a href="javascript:;" class="instant-reads" data-type="message">{:__('全部已读')}</a>
|
||||||
|
</div>
|
||||||
|
</notempty>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-tab-item">
|
||||||
|
<ul id="todo" class="layui-instant-list" >
|
||||||
|
<volist name="list['todo']" id="vo">
|
||||||
|
<a data-id="{$vo.id}" data-type="todo" class="layui-instant-list-item active_{$vo.status}" href="javascript:;">
|
||||||
|
<div class="layui-instant-item-right">
|
||||||
|
<eq name="$vo['status']" value="0">
|
||||||
|
<span class="layui-badge pull-right">{:__('待完成')}</span>
|
||||||
|
<else/>
|
||||||
|
<eq name="$vo['status']" value="3">
|
||||||
|
<span class="layui-badge layui-bg-green pull-right">{:__('进行中')}</span>
|
||||||
|
<else/>
|
||||||
|
<span class="layui-badge layui-bg-gray pull-right">{:__('已完成')}</span>
|
||||||
|
</eq>
|
||||||
|
</eq>
|
||||||
|
<h2 class="layui-instant-item-title">{$vo.title}</h2>
|
||||||
|
<p class="layui-instant-item-text">{$vo.create_time}</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</volist>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<!-- // 列表为空 -->
|
||||||
|
<div class="layui-instant-list-empty" <empty name="$list['todo']"> style="display:black;" <else/> style="display:none;" </empty> >
|
||||||
|
<img src="__ADMINIMAGES__noting.png"><div>{:__('没有待办')}</div>
|
||||||
|
</div>
|
||||||
|
<notempty name="$list['todo']">
|
||||||
|
<div class="layui-instant-footer">
|
||||||
|
<a href="javascript:;" class="instant-clear" data-type="todo">{:__('清空待办')}</a>
|
||||||
|
<span>|</span>
|
||||||
|
<a href="javascript:;" class="instant-reads" data-type="todo">{:__('全部完成')}</a>
|
||||||
|
</div>
|
||||||
|
</notempty>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<include file="/public/footer" />
|
||||||
|
|
||||||
|
<script>
|
||||||
|
layui.use(['element'], function () {
|
||||||
|
let $ = layui.jquery;
|
||||||
|
let layer = layui.layer;
|
||||||
|
let flow = layui.flow;
|
||||||
|
let instantItem = {
|
||||||
|
notice: {
|
||||||
|
title: '我的通知',
|
||||||
|
anim: 2,
|
||||||
|
},
|
||||||
|
message: {
|
||||||
|
title: '我的私信',
|
||||||
|
anim: 0,
|
||||||
|
},
|
||||||
|
todo: {
|
||||||
|
title: '我的待办',
|
||||||
|
anim: 0,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// 执行通知流加载
|
||||||
|
$.each(instantItem, function (index, type) {
|
||||||
|
flow.load({
|
||||||
|
elem: '#' + index,
|
||||||
|
done: function (page, next) {
|
||||||
|
let list = [];
|
||||||
|
let url = "{:url('/system/AdminNotice/getBells')}?type=" + index + "&page=" + page;
|
||||||
|
$.get(url, function (res) {
|
||||||
|
let data = res.data;
|
||||||
|
if (page >= 2) {
|
||||||
|
layui.each(data.data, function (key, item) {
|
||||||
|
let html = '';
|
||||||
|
switch (index) {
|
||||||
|
case 'notice':
|
||||||
|
html += '<a data-id="' + item.id + '" data-type="notice" class="layui-instant-list-item active_' + item.status + '" href="javascript:;">';
|
||||||
|
html += '<img class="layui-instant-item-icon" src="__ADMINIMAGES__message.png">';
|
||||||
|
html += '<div class="layui-instant-item-right">';
|
||||||
|
html += '<h2 class="layui-instant-item-title">' + item.title + '</h2>';
|
||||||
|
html += '<p class="layui-instant-item-text">' + item.create_time + '</p>';
|
||||||
|
html += '</div>';
|
||||||
|
html += '</a>';
|
||||||
|
break;
|
||||||
|
case 'message':
|
||||||
|
html += '<a data-id="' + item.id + '" data-type="message" class="layui-instant-list-item active_' + item.status + '" href="javascript:;">';
|
||||||
|
html += '<img class="layui-instant-item-icon" src="' + item.face + '">';
|
||||||
|
html += '<div class="layui-instant-item-right">';
|
||||||
|
html += '<h2 class="layui-instant-item-title">' + item.title + '</h2>';
|
||||||
|
html += '<p class="layui-instant-item-text">' + item.create_time + '</p>';
|
||||||
|
html += '</div>';
|
||||||
|
html += '</a>';
|
||||||
|
break;
|
||||||
|
case 'todo':
|
||||||
|
html += '<a data-id="' + item.id + '" data-type="todo" class="layui-instant-list-item active_' + item.status + '" href="javascript:;">';
|
||||||
|
html += '<div class="layui-instant-item-right">';
|
||||||
|
if (item.status === 0) {
|
||||||
|
html += '<span class="layui-badge pull-right">待完成</span>';
|
||||||
|
} else if (item.status === 3) {
|
||||||
|
html += '<span class="layui-badge layui-bg-green pull-right">进行中</span>';
|
||||||
|
} else {
|
||||||
|
html += '<span class="layui-badge layui-bg-gray pull-right">已完成</span>';
|
||||||
|
}
|
||||||
|
html += '<h2 class="layui-instant-item-title">' + item.title + '</h2>';
|
||||||
|
html += '<p class="layui-instant-item-text">' + item.create_time + '</p>';
|
||||||
|
html += '</div>';
|
||||||
|
html += '</a>';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
list.push(html);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
next(list.join(''), page < data.last_page);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 打开新窗口
|
||||||
|
$('.layui-instant-list').on('click', '.layui-instant-list-item', function () {
|
||||||
|
|
||||||
|
let that = this;
|
||||||
|
$(that).addClass('active_open');
|
||||||
|
$(that).removeClass('active_0').addClass('active_1');
|
||||||
|
let id = $(that).attr('data-id');
|
||||||
|
let type = $(that).attr('data-type');
|
||||||
|
let openURL = "{:url('/system/AdminNotice/read')}?type=" + type + "&id=" + id;
|
||||||
|
|
||||||
|
parent.layer.open({
|
||||||
|
id: type + id,
|
||||||
|
type: 2,
|
||||||
|
title: instantItem[type].title,
|
||||||
|
shade: 0,
|
||||||
|
maxmin: true,
|
||||||
|
isOutAnim: false,
|
||||||
|
area: ['38%', '41%'],
|
||||||
|
content: [openURL, 'no'],
|
||||||
|
success: function (layero, index) {
|
||||||
|
$('body').on('click', '.active_open', function (e) {
|
||||||
|
parent.layer.close(index);
|
||||||
|
$(that).removeClass('active_open');
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 清空消息点击事件
|
||||||
|
$('.instant-clear').click(function (obj) {
|
||||||
|
var that = $(this), type = that.data('type');
|
||||||
|
var findElem = $('#' + type);
|
||||||
|
|
||||||
|
// 删除元素
|
||||||
|
that.parent().prev().prev().remove();
|
||||||
|
that.parent().prev().show();
|
||||||
|
that.parent().remove();
|
||||||
|
// 替换标题
|
||||||
|
findElem.text(findElem.text().replace(/\([^\)]*\)/,''));
|
||||||
|
// 执行AJAX请求...
|
||||||
|
$.ajax({
|
||||||
|
url: "{:url('/system/AdminNotice/clear')}",
|
||||||
|
type: 'post',
|
||||||
|
data: {type: type},
|
||||||
|
success: function (res) {
|
||||||
|
if (res.code === 200) {
|
||||||
|
layer.msg(res.msg);
|
||||||
|
} else {
|
||||||
|
layer.error(res.msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 一键已读
|
||||||
|
$('.instant-reads').click(function (obj) {
|
||||||
|
var that = $(this), type = that.data('type');
|
||||||
|
// 执行AJAX请求...
|
||||||
|
$.ajax({
|
||||||
|
url: "{:url('/system/AdminNotice/readAll')}",
|
||||||
|
type: 'post',
|
||||||
|
data: {type: type},
|
||||||
|
success: function (res) {
|
||||||
|
if (res.code === 200) {
|
||||||
|
layer.msg(res.msg);
|
||||||
|
$('.layui-instant-list-item').removeClass('active_0').addClass('active_1');
|
||||||
|
} else {
|
||||||
|
layer.error(res.msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
180
app/admin/view/system/admin_notice/index.html
Normal file
180
app/admin/view/system/admin_notice/index.html
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
<include file="/public/header"/>
|
||||||
|
<!--<link href="__STATICADMIN__css/message.css" rel="stylesheet" type="text/css" />-->
|
||||||
|
<style>
|
||||||
|
#msgType {
|
||||||
|
padding-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#msgType li {
|
||||||
|
border-radius: 3px;
|
||||||
|
cursor: pointer;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
padding: 8px 8px 8px 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#msgType li i {
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#msgType li.active, #msgType li:hover {
|
||||||
|
color: #1890ff;
|
||||||
|
background-color: #e6f7ff;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class="layui-fluid">
|
||||||
|
<div class="layui-row layui-col-space15">
|
||||||
|
<div class="layui-col-md2">
|
||||||
|
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-card-header layadmin-card-header-auto">
|
||||||
|
<h5>{:__('我的信箱')}</h5>
|
||||||
|
</div>
|
||||||
|
<div id="msgType" class="layui-card-body">
|
||||||
|
<li class="active" data-event="todo">
|
||||||
|
<i class="layui-icon fa-tags"></i>
|
||||||
|
<span>待办项</span>
|
||||||
|
</li>
|
||||||
|
<li data-event="send">
|
||||||
|
<i class="layui-icon fa-rocket"></i>
|
||||||
|
<span>已发送</span>
|
||||||
|
</li>
|
||||||
|
<li data-event="notice">
|
||||||
|
<i class="layui-icon fa-volume-up"></i>
|
||||||
|
<span>系统通知</span>
|
||||||
|
</li>
|
||||||
|
<li data-event="message">
|
||||||
|
<i class="layui-icon fa-comment"></i>
|
||||||
|
<span>我的私信</span>
|
||||||
|
</li>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-col-md10">
|
||||||
|
<!-- // 展示数据 -->
|
||||||
|
<div class="layui-card">
|
||||||
|
<!-- // 默认操作按钮 -->
|
||||||
|
<div class="layui-card-header layadmin-card-header-auto ">
|
||||||
|
<div class="layui-form">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
|
||||||
|
<div class="layui-inline">
|
||||||
|
<div class="layui-input-inline ">
|
||||||
|
<input name="title" class="layui-input" type="text"
|
||||||
|
placeholder="{:__('请输入消息标题')}"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-inline">
|
||||||
|
<!-- // 默认搜索 -->
|
||||||
|
<button class="layui-btn icon-btn" lay-filter="formSearch" lay-submit><i
|
||||||
|
class="layui-icon layui-icon-search"></i>{:__('搜索')}
|
||||||
|
</button>
|
||||||
|
<!-- // 打开添加页面 -->
|
||||||
|
<button class="layui-btn icon-btn" lay-open="" data-title="{:__('发送私信')}"
|
||||||
|
data-area="36%,39%" data-url="{:url('system/AdminNotice/add')}">
|
||||||
|
<i class="layui-icon layui-icon-add-1"></i>{:__('发私信')}
|
||||||
|
</button>
|
||||||
|
<button class="layui-btn layui-btn-danger" lay-batch data-table="lay-tableList"
|
||||||
|
data-url="/user/batchMessage?type=read">{:__('全部已读')}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- // 创建数据实例 -->
|
||||||
|
<table id="lay-tableList" lay-filter="lay-tableList"></table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- // 列表编辑框 -->
|
||||||
|
<script type="text/html" id="tableBar">
|
||||||
|
<a class="layui-table-text" data-title="{:__('查看')}" data-url="{:url('/system/AdminNotice/read')}?id={{d.id}}"
|
||||||
|
data-area="39%,46%" lay-event="edit">{:__('查看')}</a>
|
||||||
|
<div class="layui-divider layui-divider-vertical"></div>
|
||||||
|
<a class="layui-table-text" data-url="{:url('/system/AdminNotice/del')}?id={{d.id}}" lay-event="del">{:__('删除')}</a>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/html" id="setRowChecked">
|
||||||
|
<div class="layui-btn-container ">
|
||||||
|
<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="all">{:__('全部')}</button>
|
||||||
|
<button class="layui-btn layui-btn-primary layui-btn-xs" lay-event="1">{:__('已读')}</button>
|
||||||
|
<button class="layui-btn layui-btn-primary layui-btn-xs" lay-event="0">{:__('未读')}</button>
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<include file="/public/footer"/>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
layui.use(['table', 'jquery',], function () {
|
||||||
|
let $ = layui.jquery;
|
||||||
|
let table = layui.table; // 表格
|
||||||
|
|
||||||
|
// 定义表格URL
|
||||||
|
let tableURL = "{:url('/system/AdminNotice/index')}";
|
||||||
|
|
||||||
|
// 基础表格
|
||||||
|
table.render({
|
||||||
|
elem: "#lay-tableList"
|
||||||
|
, url: tableURL
|
||||||
|
, page: true
|
||||||
|
, toolbar: '#setRowChecked'
|
||||||
|
, cols: [[
|
||||||
|
{type: 'checkbox'},
|
||||||
|
{
|
||||||
|
field: 'title', align: 'left', templet: function (e) {
|
||||||
|
let title = '<a class="layui-table-text';
|
||||||
|
title += '" lay-open data-title="查看消息" data-url="{:url(\'/system/AdminNotice/read\')}?id=' + e.id + '" data-area="600px, 390px" >';
|
||||||
|
if (e.status === 0) {
|
||||||
|
title += '<i class="layui-icon fa-envelope"></i> ';
|
||||||
|
} else {
|
||||||
|
title += '<i class="layui-icon fa-envelope-o"></i> ';
|
||||||
|
}
|
||||||
|
title += e.title;
|
||||||
|
title += '</a>';
|
||||||
|
return title;
|
||||||
|
}, title: '{:__("标题")}'
|
||||||
|
},
|
||||||
|
{field: 'send_ip', align: 'center', width: 180, title: '{:__("发送者 IP")}'},
|
||||||
|
{field: 'create_time', align: 'center', width: 180, title: '{:__("创建时间")}'},
|
||||||
|
{align: 'center', toolbar: '#tableBar', width: 160, title: '{:__("操作")}'},
|
||||||
|
]]
|
||||||
|
})
|
||||||
|
|
||||||
|
$('#msgType li').click(function () {
|
||||||
|
let event = $(this).data('event');
|
||||||
|
table.reloadData('lay-tableList', {
|
||||||
|
where: {type: event}
|
||||||
|
}, true);
|
||||||
|
$(this).addClass('active').siblings().removeClass('active');
|
||||||
|
});
|
||||||
|
|
||||||
|
// 列表双击
|
||||||
|
table.on('rowDouble(lay-tableList)', function (obj) {
|
||||||
|
let data = obj.data;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 头工具栏事件
|
||||||
|
table.on('toolbar(lay-tableList)', function (obj) {
|
||||||
|
let checkBtn = null;
|
||||||
|
switch (obj.event) {
|
||||||
|
case 'all':
|
||||||
|
case '0':
|
||||||
|
case '1':
|
||||||
|
checkBtn = $(this);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
table.reloadData('lay-tableList', {
|
||||||
|
where: {status: obj.event}
|
||||||
|
},true);
|
||||||
|
$('.layui-btn-container .layui-btn').removeClass('layui-btn-normal').addClass('layui-btn-primary');
|
||||||
|
$(checkBtn).removeClass('layui-btn-primary').addClass('layui-btn-normal');
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
56
app/admin/view/system/admin_notice/message.html
Normal file
56
app/admin/view/system/admin_notice/message.html
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
<include file="/public/header"/>
|
||||||
|
<link href="__STATICADMIN__css/message.css" rel="stylesheet" type="text/css"/>
|
||||||
|
<div id="adminNotice" class="layui-fluid">
|
||||||
|
<div class="layui-card layui-panel">
|
||||||
|
<div class="layui-card-body">
|
||||||
|
<div class="layui-title borderNone">
|
||||||
|
<div class="title" style="display: inline-block">发送者:<span>
|
||||||
|
<img src="{$detail.face|default=''}" class="face" width="20"> </span>
|
||||||
|
{$detail.nickname|default='隐藏用户'}
|
||||||
|
</div>
|
||||||
|
<div class="time layui-fr"><i class="layui-icon fa-clock-o"></i> {$detail.create_time}</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-message">{$detail.content|raw}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-footer">
|
||||||
|
<if ($detail[
|
||||||
|
'send_id'] != $AdminLogin['id'])>
|
||||||
|
<button type="button" class="layui-btn layui-btn-normal" lay-open data-title="回复私信" data-url="#replyForms"
|
||||||
|
data-area="500px,350px">回复
|
||||||
|
</button>
|
||||||
|
</if>
|
||||||
|
<button type="button" class="layui-btn layui-btn-danger" sa-event="closeDialog">关闭</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/html" id="replyForms">
|
||||||
|
<div class="layui-fluid layui-bg-white">
|
||||||
|
<form action="{:url('/system/AdminNotice/add')}" class="layui-form">
|
||||||
|
<input type="text" name="admin_id" value="{$detail.send_id}" hidden>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label"><span style="color: red; ">* </span>{:__('标题')}</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
|
||||||
|
<input type="text" name="title" class="layui-input" lay-verify="required" value=""
|
||||||
|
placeholder="请输入私信标题">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="layui-form-label"><span style="color: red; ">* </span>{:__('回复内容')}</label>
|
||||||
|
<div class="layui-input-block">
|
||||||
|
<textarea name="content" class="layui-textarea"
|
||||||
|
placeholder="请输入私信内容"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-footer layui-form-item layui-center ">
|
||||||
|
<button class="layui-btn layui-btn-primary" type="button" sa-event="closePageDialog">{:__('取消')}
|
||||||
|
</button>
|
||||||
|
<button class="layui-btn" lay-filter="submitPage" lay-submit>{:__('提交')}</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<include file="/public/footer"/>
|
||||||
19
app/admin/view/system/admin_notice/notice.html
Normal file
19
app/admin/view/system/admin_notice/notice.html
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<include file="/public/header" />
|
||||||
|
<link href="__STATICADMIN__css/message.css" rel="stylesheet" type="text/css" />
|
||||||
|
<div id="adminNotice" class="layui-fluid">
|
||||||
|
<div class="layui-card">
|
||||||
|
<div class="layui-title">
|
||||||
|
<div class="title">标题:{$detail.title}</div>
|
||||||
|
<div class="time">时间:{$detail.create_time}</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-message">{$detail.content|raw}</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-instructions">
|
||||||
|
<p>本消息属系统通知,来源于业务流程管理系统,请勿回复</p>
|
||||||
|
<p>在系统使用过程中,如果有问题请联系网站运维组:## </p>
|
||||||
|
</div>
|
||||||
|
<div class="layui-footer">
|
||||||
|
<button type="button" class="layui-btn layui-btn-danger" sa-event="closeDialog" >关闭</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<include file="/public/footer" />
|
||||||
23
app/admin/view/system/admin_notice/todo.html
Normal file
23
app/admin/view/system/admin_notice/todo.html
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<include file="/public/header"/>
|
||||||
|
<link href="__STATICADMIN__css/message.css" rel="stylesheet" type="text/css"/>
|
||||||
|
<div id="adminTodo" class="layui-card">
|
||||||
|
<div class="layui-card-body">
|
||||||
|
<div class="layui-panel">
|
||||||
|
<div class="layui-card-header">
|
||||||
|
<div class="title">{$detail.title}</div>
|
||||||
|
<div class="time"><span class="times">任务创建于:</span>{$detail.create_time}</div>
|
||||||
|
</div>
|
||||||
|
<div class="layui-todo">{$detail.content|raw}</div>
|
||||||
|
<div class="layui-banner">
|
||||||
|
<p>本消息属系统工作流待办流程管理</p>
|
||||||
|
<p>在系统使用过程中,如果有问题请联系网站运维组 </p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layui-footer">
|
||||||
|
<button type="button" class="layui-btn layui-btn-danger" sa-event="closeDialog">确认</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<include file="/public/footer"/>
|
||||||
73
app/common/validate/system/AdminNotice.php
Normal file
73
app/common/validate/system/AdminNotice.php
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
declare (strict_types=1);
|
||||||
|
|
||||||
|
namespace app\common\validate\system;
|
||||||
|
|
||||||
|
use app\admin\enums\AdminNoticeEnum;
|
||||||
|
use think\Validate;
|
||||||
|
use app\common\model\system\Admin as AdminModel;
|
||||||
|
|
||||||
|
class AdminNotice extends Validate
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 定义验证规则
|
||||||
|
* 格式:'字段名' => ['规则1','规则2'...]
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $rule = [
|
||||||
|
'admin_id' => 'require|checkUser',
|
||||||
|
'send_id' => 'checkReceive',
|
||||||
|
'type' => 'require',
|
||||||
|
'content' => 'require',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定义错误信息
|
||||||
|
* 格式:'字段名.规则名' => '错误信息'
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $message = [
|
||||||
|
'admin_id.require' => '请选择用户',
|
||||||
|
'admin_id.checkUser' => '用户不存在',
|
||||||
|
'type.require' => '请选择消息类型',
|
||||||
|
'content.require' => '消息内容不能为空',
|
||||||
|
'send_id.checkReceive' => '不能给自己发送消息',
|
||||||
|
];
|
||||||
|
|
||||||
|
// 测试验证场景
|
||||||
|
protected $scene = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证用户组权限
|
||||||
|
* @param $value
|
||||||
|
* @param $rule
|
||||||
|
* @param $data
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function checkUser($value, $rule, $data): bool
|
||||||
|
{
|
||||||
|
$result = AdminModel::where('id', $value)->findOrEmpty()->toArray();
|
||||||
|
if (empty($result)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $value
|
||||||
|
* @param $rule
|
||||||
|
* @param $data
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function checkReceive($value, $rule, $data): bool
|
||||||
|
{
|
||||||
|
if ($data['type'] == AdminNoticeEnum::MESSAGE && $value == $data['admin_id']) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user