未读消息提醒功能完善

This commit is contained in:
hdm 2021-11-29 23:52:40 +08:00
parent 7decfe31ab
commit 9aa3b0f8d1
10 changed files with 154 additions and 52 deletions

View File

@ -171,8 +171,8 @@ www 系统部署目录(或者子目录)
勾股OA演示地址[https://oa.gougucms.com](https://oa.gougucms.com)
<font color=red>PS为了给后面的人提供良好的演示体验体验以查看为主如果确实需要填写数据大家最好填些看似正常的数据请不要乱填数据比如1111aaa那些数据就不要乱来了。
如果大家不遵守体验规则,后期发现很多乱的数据的话,就关闭对应的填写权限了。</font>
PS为了给后面的人提供良好的演示体验体验以查看为主如果确实需要填写数据大家最好填些看似正常的数据请不要乱填数据比如1111aaa那些数据就不要乱来了。
如果大家不遵守体验规则,后期发现很多乱的数据的话,就关闭对应的填写权限了。
登录账号及密码:
~~~

View File

@ -17,9 +17,62 @@ class Index extends BaseController
{
public function index()
{
$menu = get_admin_menus();
View::assign('menu', $menu);
return View();
if (request()->isAjax()) {
$admin_id = $this->uid;
//发票待审核统计
$invoice_map_check[] = ['check_time','=',0];
$invoice_map_check[] = ['check_admin_id','=',$admin_id];
$invoice_map_check[] = ['status','=',1];
$invoice_count_check = Db::name('Invoice')->where($invoice_map_check)->count();
$statistics['invoice_html_check'] = '<a data-id="41" data-title="待审核发票" data-src="/home/invoice/index.html" class="site-menu-active"> 您有<font style="color:#FF0000">'.$invoice_count_check.'</font>条发票申请待审核</a>';
//$statistics['invoice_count_check'] = $invoice_count_check;
if($invoice_count_check==0){
$statistics['invoice_html_check'] = '';
}
//发票待开具统计
$invoice_map_open[] = ['open_time','=',0];
$invoice_map_open[] = ['open_admin_id','=',$admin_id];
$invoice_map_open[] = ['status','=',1];
$invoice_count_open = Db::name('Invoice')->where($invoice_map_open)->count();
$statistics['invoice_html_open'] = '<a data-id="41" data-title="待开具发票" data-src="/home/invoice/index.html" class="site-menu-active"> 您有<font style="color:#FF0000">'.$invoice_count_open.'</font>条发票待开具</a>';
// $statistics['invoice_count_open'] = $invoice_count_open;
if($invoice_count_open==0){
$statistics['invoice_html_open'] = '';
}
//待审核的报销统计
$expense_map_check[] = ['check_time','=',0];
$expense_map_check[] = ['check_admin_id','=',$admin_id];
$expense_map_check[] = ['status','=',1];
$expense_count_check = Db::name('Expense')->where($expense_map_check)->count();
$statistics['expense_html_check'] = '<a data-id="40" data-title="报销管理" data-src="/home/expense/index.html" class="site-menu-active"> 您有<font style="color:#FF0000">'.$expense_count_check.'</font>条报销单待审核</a>';
// $statistics['expense_count_check'] = $expense_count_check;
if($expense_count_check==0){
$statistics['expense_html_check'] = '';
}
//未读消息统计
$mail_map[] = ['to_uid','=',$admin_id];
$mail_map[] = ['is_read','=',1];
$mail_map[] = ['status','=',1];
$mail_count = Db::name('Mail')->where($mail_map)->count();
$statistics['mail_html'] = '<a data-id="27" data-title="收件箱" data-src="/home/mail/inbox.html" class="site-menu-active"> 您有<font style="color:#FF0000">'.$mail_count.'</font>条未读消息</a>';
$statistics['num_mail'] = $mail_count;
if($mail_count==0){
$statistics['mail_html'] = '';
}
foreach ($statistics as $key => $value) {
if (!$value ) unset($statistics[$key]);
}
return to_assign(0,'ok',$statistics);
}
else{
$menu = get_admin_menus();
View::assign('menu', $menu);
return View();
}
}
public function main()

View File

@ -139,7 +139,6 @@ class Mail extends BaseController
$item->from_name = Db::name('Admin')->where(['id' => $item->from_uid])->value('nickname');
$item->to_name = Db::name('Admin')->where(['id' => $item->to_uid])->value('nickname');
$item->type_title = MailList::$Type[$item->type];
$item->is_read_title = MailList::$Read[$item->is_read];
$item->mail_type_title = MailList::$MailType[$item->mail_type];
$item->delete_source_title = MailList::$Source[$item->delete_source];
$item->files = Db::name('MailFileInterfix')->where(['mid' => $item->id, 'status' => 1])->count();
@ -154,7 +153,6 @@ class Mail extends BaseController
$item->from_name = Db::name('Admin')->where(['id' => $item->from_uid])->value('nickname');
$item->to_name = Db::name('Admin')->where(['id' => $item->to_uid])->value('nickname');
$item->type_title = MailList::$Type[$item->type];
$item->is_read_title = MailList::$Read[$item->is_read];
$item->mail_type_title = MailList::$MailType[$item->mail_type];
$item->files = Db::name('MailFileInterfix')->where(['mid' => $item->id, 'status' => 1])->count();
});

View File

@ -52,9 +52,4 @@ class Mail extends Model
self::SOURCE_TWO => '同事消息',
];
public static $Read = [
self::READ_ONE => '未读',
self::READ_TWO => '已读',
];
}

View File

@ -75,6 +75,24 @@
align: 'right',
style: 'color:#1E9FFF',
width: 120,
},{
field: 'check_status',
title: '状态',
align: 'center',
width: 120,
templet:function(d){
var html='<span style="color:#FF5722">审核不通过</span>';
if(d.check_status==1){
html='<span style="color:#5FB878">报销审核中</span>';
}
else if(d.check_status==2){
html='<span style="color:#1E9FFF">审核通过</span>';
}
else if(d.check_status==3){
html='<span style="color:#FFB800">已打款</span>';
}
return html;
}
},{
field: 'admin_name',
title: '报销人',
@ -104,24 +122,6 @@
title: '录入时间',
align: 'center',
width: 150
},{
field: 'check_status',
title: '状态',
align: 'center',
width: 120,
templet:function(d){
var html='<span style="color:#FF5722">审核不通过</span>';
if(d.check_status==1){
html='<span style="color:#5FB878">报销审核中</span>';
}
else if(d.check_status==2){
html='<span style="color:#1E9FFF">审核通过</span>';
}
else if(d.check_status==3){
html='<span style="color:#FFB800">已打款</span>';
}
return html;
}
},{
field: 'check_name',
title: '审核人',

View File

@ -23,9 +23,9 @@
</li>
<li class="layui-nav-item" lay-unselect>
<a href="javascript:;" ittab-logout title="{:get_login_admin('nickname')}-点击退出登录">
<img src="{:get_login_admin('thumb')}" class="layui-nav-img"
onerror="javascript:this.src='{__IMG__}/nonepic360x360.jpg';this.onerror=null;">
<img src="{:get_login_admin('thumb')}" class="layui-nav-img" onerror="javascript:this.src='{__IMG__}/nonepic360x360.jpg';this.onerror=null;">
</a>
<div id="msgNum" class="msg-num"><a data-id="27" data-title="已收消息" data-src="/home/mail/inbox.html" class="site-menu-active" title="未读消息">0</a></div>
</li>
</ul>
</div>
@ -99,6 +99,7 @@
<!-- 脚本 -->
{block name="script"}
<script>
var msgStatus=0,isClose=0,msgNum = 0;
function init(layui) {
var layer = layui.layer;
$("[ittab-logout]").on("click", function () {
@ -119,6 +120,55 @@
});
});
};
//轮循获取消息
var getStatus = setInterval(function () {
$.ajax({
url:"{:url('home/index/index')}",
type:'post',
success:function(e){
if(e.code==0 && e.data!=''){
if(e.data.num_mail>0){
$('#msgNum').show().find('a').html(e.data.num_mail);
}
else{
$('#msgNum').hide().find('a').html(0);
}
if(isClose==0){
var html = '<ul id="messageul" style="line-height:24px;">';
$.each(e.data, function(key, value) {
if(key!='num_mail'){
html += '<li style="cursor:pointer;">'+value+'</li>';
}
});
html +='</ul>';
if(msgStatus==1){
$('#msgBox').html(html);
}else{
layer.open({
type: 1
,title:'消息提醒'
,offset: 'rb'
,area:['240px','168px']
,content: '<div id="msgBox" style="padding:10px 15px;">'+html+'</div>'
,btnAlign: 'c' //按钮居中
,shade: 0 //不显示遮罩
,success:function(){
msgStatus=1;
}
,cancel:function(){
msgStatus=0;
isClose=1;
}
});
}
}
}else{
msgStatus=0;
layer.closeAll();
}
}
})
}, 10000);
</script>
{include file="common/layui" base='base' extend="['gougucms']" callback="init" /}
{/block}

View File

@ -105,21 +105,6 @@
}
return html;
}
},{
field: 'user',
title: '申请人',
align: 'center',
width: 100
},{
field: 'department',
title: '所属部门',
align: 'center',
width: 120
},{
field: 'create_time',
title: '申请时间',
align: 'center',
width: 150
},{
field: 'invoice_status',
title: '发票状态',
@ -141,6 +126,21 @@
}
return html;
}
},{
field: 'user',
title: '申请人',
align: 'center',
width: 100
},{
field: 'department',
title: '所属部门',
align: 'center',
width: 120
},{
field: 'create_time',
title: '申请时间',
align: 'center',
width: 150
},{
field: 'check_name',
title: '审核人',

View File

@ -36,9 +36,6 @@
<script type="text/html" id="mail_type">
<span class="layui-type{{d.mail_type}}">{{d.mail_type_title}}</span>
</script>
<script type="text/html" id="is_read">
<span class="layui-type{{d.is_read}}">{{d.is_read_title}}</span>
</script>
<script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
@ -88,7 +85,13 @@
{field: 'from_name', title: '发件人', width:100,align:'center'},
{field: 'name', title: '消息主题'},
{field: 'send_time', title: '发件时间', align:'center',width:160},
{field: 'is_read_title', title: '是否已读',toolbar: '#is_read',align:'center', width:86},
{field: 'is_read', title: '是否已读',align:'center', width:86,templet:function(d){
var html='<span style="color:#FF5722">未读</span>';
if(d.is_read==2){
html='<span style="color:#5FB878">已读</span>';
}
return html;
}},
{field: 'files', title: '附件(个)',align:'center', width:86},
{field: 'right', title: '操作',fixed:'right', toolbar: '#barDemo', width:172, align:'center'}
]],

View File

@ -77,3 +77,6 @@
.layui-nav-img {width:25px;height:25px;margin-right:0;}
.layui-layout-admin .layui-footer {left:200px;height:30px;line-height:30px;background-color:#f0f0f0;font-size:12px;}
.layui-tab-content {padding:0px;}
.layui-nav .msg-num { min-width: 18px;height: 18px;position: absolute;top: -10px;right: 5px;display: none;}
.layui-nav .msg-num a {min-width: 18px; height: 18px; margin: 0; padding: 0; display: inline-block; font-size: 11px;line-height: 18px;text-align: center; background-color: #FF5722; color: #fff;border-radius: 12px; cursor: pointer;}

View File

@ -100,7 +100,7 @@ layui.define(['element'], function(exports){
})
//当点击有site-menu-active属性的标签时即左侧菜单栏中内容 ,触发点击事件
$('.site-menu-active').on('click', function() {
$('body').on('click', '.site-menu-active', function() {
var dataid = $(this);
var src=dataid.data("src"),id=dataid.data("id"),title=dataid.data("title");
//这时会判断右侧.layui-tab-title属性下的有lay-id属性的li的数目即已经打开的tab项数目