文件

186 行
7.8 KiB
HTML
可执行文件

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<!--[1.1.96]-->
<link rel="stylesheet" href="__PUBLIC__/layuiadmin/style/admin.css">
<div class="layui-fluid" id="LAY-app-message">
<div class="layui-card">
<div class="layui-tab layui-tab-brief">
<ul class="layui-tab-title">
<if condition="$nored neq null">
<li class="layui-this">消息通知<span class="layui-badge" id="noread" data-noread="{$nored}">{$nored}</span></li>
<else />
<li class="layui-this">消息通知</li>
</if>
</ul>
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">
<div class="LAY-app-message-btns" style="margin-bottom: 10px;">
<if condition="$authArr['noticeDelete'] eq true">
<button class="layui-btn layui-btn-primary layui-btn-sm" data-type="all" data-events="del">删除</button>
</if>
<if condition="$authArr['flagRead'] eq true">
<button class="layui-btn layui-btn-primary layui-btn-sm" data-type="all" data-events="ready">标记已读</button>
</if>
<if condition="$authArr['allRead'] eq true">
<button class="layui-btn layui-btn-primary layui-btn-sm" data-type="all" data-events="readyAll">全部已读</button>
</if>
</div>
<table id="LAY-app-message-all" lay-filter="LAY-app-message-all"></table>
</div>
</div>
</div>
</div>
</div>
<script type="text/html" id="showimg">
{{# if(d.type== 1){}}
{{d.describe}}
{{# }}}
{{# if(d.type== 2){}}
<img src="{{ d.describe}}">
{{# }}}
</script>
<script type="text/html" id="barDemo">
<a class="layui-btn layui-btn-warm layui-btn-sm" lay-event="edit">回复</a>
</script>
<script>
layui.config({
base: '__PUBLIC__/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index','table'],function () {
var $ = layui.jquery,layer = layui.layer,table = layui.table;
var DISABLED = 'layui-btn-disabled'
//区分各选项卡中的表格
,tabs = {
all: {
text: '消息通知'
,id: 'LAY-app-message-all'
}
};
//全部消息
table.render({
elem: '#LAY-app-message-all'
,url: "{:U('Super/WorkMessage/getadmin')}"
,method:'post'
,page: true
,cols: [[
{type: 'checkbox', fixed: 'left'}
,{field: 'number', title: '工单编号',align: 'center', style: 'width:20%;'}
,{field: 'describe', title: '消息内容',align: 'center',style: 'width:44%;',templet:'#showimg',}
,{field: 'addtime', title: '时间',align: 'center',style: 'width:17%;',templet: '<div>{{ layui.util.timeAgo(d.addtime) }}</div>'}
,{field: 'state', title: '状态',align: 'center',style: 'width:7%;',}
,{fixed: 'right',title: '操作',align: 'center',toolbar: '#barDemo',style: 'width:12%;'}
]]
,skin: 'line'
,done:function (res, curr, count) {
hoverOpenImg();
}
});
function hoverOpenImg() {
var img_show = null; // tips提示
$('td img').hover(function () {
// alert($(this).attr('src'));
var img = "<img class='img_msg' src='" + $(this).attr('src') + "' style='width:365px;' />";
img_show = layer.tips(img, this, {
tips: [2, '#F0F0F0']
, time: 40000
, area: ['30%','30%']
});
}, function () {
layer.close(img_show);
});
$('td img').attr('style', 'max-width:90px;max-height:30px');
}
// 全部
table.on('tool(LAY-app-message-all)', function(obj) {
var data = obj.data;
if (obj.event === 'edit') {
window.location.href="{:U('Work/detail')}?id=" + data.number;
}
})
//事件处理
var events = {
del: function(othis, type){
var thisTabs = tabs[type]
,checkStatus = table.checkStatus(thisTabs.id)
,data = checkStatus.data; //获得选中的数据
if(data.length === 0) return layer.msg('请先选择要删除的消息');
layer.confirm('确定删除选中的数据吗?', function(){
var chooseIds = [];
for (var i=0;i<data.length;i++){
chooseIds += data[i].id+",";
}
noticePost("{:U('Super/WorkMessage/noticeDelete')}",{ids:chooseIds},thisTabs.id,1)
});
}
,ready: function(othis, type){
var thisTabs = tabs[type]
,checkStatus = table.checkStatus(thisTabs.id)
,data = checkStatus.data; //获得选中的数据
if(data.length === 0) return layer.msg('请先选择要标记的消息');
var chooseIds = [];
for (var i=0;i<data.length;i++){
chooseIds += data[i].id+",";
}
layer.confirm("确认此消息已读,同编号的消息会一起变更!!!",{title:"警告",icon:7},function () {
noticePost("{:U('Super/WorkMessage/flagRead')}",{ids:chooseIds},thisTabs.id,2)
})
}
,readyAll: function(othis, type){
var thisTabs = tabs[type];
layer.confirm("确认要全部标记为已读吗",{title:"警告",icon:7},function () {
noticePost("{:U('Super/WorkMessage/allRead')}","",thisTabs.id,3)
})
}
};
$('.LAY-app-message-btns .layui-btn').on('click', function(){
var othis = $(this)
,thisEvent = othis.data('events')
,type = othis.data('type');
events[thisEvent] && events[thisEvent].call(this, othis, type);
});
/**
*
* @param url 请求地址
* @param postData 请求参数
* @param tableid 表格id(用来重载表格)
* @param type 为2时 需要操作未读消息数据 为3时 重置未读消息为0
*/
function noticePost(url,postData,tableid,type) {
$.ajax({
url:url,
type:"post",
data:postData,
success:function (res) {
if (res.status == 0){
if (type == 1){
$("#noread").text(res.num);
$("#noread").attr("data-noread",res.num);
}else if (type == 2){
$("#noread").text(res.num);
$("#noread").attr("data-noread",res.num);
}else if (type == 3){
$("#noread").text("0");
$("#noread").attr("data-noread","0");
}
layer.msg(res.msg,{time:1000},function () {
table.reload(tableid); //刷新表格
})
}else {
layer.msg(res.msg)
}
}
})
}
});
</script>