mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-11-10 13:00:49 +08:00
feat(notice): 我的消息与订阅设置个人域页面
This commit is contained in:
99
extend/base/admin/view/notice/mine.js
Normal file
99
extend/base/admin/view/notice/mine.js
Normal file
@@ -0,0 +1,99 @@
|
||||
$(function(){
|
||||
// HTML 转义(标题/场景等来自发送方输入,防注入)
|
||||
var escapeHtml = function(text) {
|
||||
return String(text).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,''');
|
||||
};
|
||||
|
||||
// 标题:关联 notice,通知主体被删时兜底;未读加粗强调
|
||||
var titleTemplet = function(d) {
|
||||
var notice = d.notice || {};
|
||||
if (notice.title) {
|
||||
var title = escapeHtml(notice.title);
|
||||
if (d.read_time == 0) {
|
||||
return '<strong>' + title + '</strong>';
|
||||
}
|
||||
return title;
|
||||
}
|
||||
return '<span style="color:#999">(通知已删除)#' + d.notice_id + '</span>';
|
||||
};
|
||||
|
||||
// 场景中文映射
|
||||
var sceneTemplet = function(d) {
|
||||
var notice = d.notice || {};
|
||||
var map = ua.getDataBrage('select_list_notice_scene') || {};
|
||||
var text = map[notice.scene] || notice.scene || '-';
|
||||
return escapeHtml(text);
|
||||
};
|
||||
|
||||
// 未读/已读徽章(未读行同时以加粗标题高亮)
|
||||
var readTemplet = function(d) {
|
||||
if (d.read_time == 0) {
|
||||
return '<span class="layui-badge">未读</span>';
|
||||
}
|
||||
return '<span class="layui-badge layui-bg-gray">已读</span>';
|
||||
};
|
||||
|
||||
ua.table.render({
|
||||
init: init,
|
||||
toolbar: [
|
||||
'refresh',
|
||||
[{
|
||||
text: '标记已读',
|
||||
title: '确定将勾选的消息标记为已读?',
|
||||
url: 'notice/mark_read',
|
||||
method: 'request',
|
||||
auth: 'notice/markRead',
|
||||
class: 'layui-btn layui-btn-normal layui-btn-sm',
|
||||
icon: 'fa fa-check',
|
||||
checkbox: true,
|
||||
}],
|
||||
[{
|
||||
text: '全部已读',
|
||||
title: '确定将全部站内信标记为已读?',
|
||||
url: 'notice/mark_all_read',
|
||||
method: 'request',
|
||||
auth: 'notice/markAllRead',
|
||||
class: 'layui-btn layui-btn-warm layui-btn-sm',
|
||||
icon: 'fa fa-check-square-o',
|
||||
}],
|
||||
],
|
||||
cols: [[
|
||||
{type: 'checkbox'},
|
||||
{field: 'id', title: 'ID', width: 80, search: false},
|
||||
{field: 'title', title: '标题', minWidth: 220, fieldAlias: 'notice.title', templet: titleTemplet},
|
||||
{field: 'scene', title: '场景', width: 110, align: 'center', search: 'select', searchOp: '=', selectList: ua.getDataBrage('select_list_notice_scene'), templet: sceneTemplet},
|
||||
{field: 'read_time', title: '状态', width: 80, align: 'center', search: false, templet: readTemplet},
|
||||
{field: 'create_time', title: '接收时间', width: 170, templet: ua.table.date, search: 'range'},
|
||||
{
|
||||
width: 90, title: '操作', fixed: 'right', templet: ua.table.tool,
|
||||
operat: [[
|
||||
{
|
||||
class: 'layui-btn layui-btn-primary layui-btn-xs notice-mine-read-btn',
|
||||
method: 'none',
|
||||
field: 'id',
|
||||
text: '查看',
|
||||
title: '查看消息',
|
||||
auth: 'notice/read',
|
||||
url: init.readUrl,
|
||||
}
|
||||
]]
|
||||
}
|
||||
]],
|
||||
});
|
||||
|
||||
ua.listen();
|
||||
|
||||
// 查看:弹窗打开详情,关闭后刷新列表以更新未读状态
|
||||
$(document).on('click', '.notice-mine-read-btn', function () {
|
||||
var id = $(this).attr('data-id');
|
||||
layui.layer.open({
|
||||
type: 2,
|
||||
title: '查看消息',
|
||||
area: ['760px', '560px'],
|
||||
content: ua.url(init.readUrl + '?id=' + id),
|
||||
end: function () {
|
||||
ua.table.reloadData(init.tableRenderId);
|
||||
}
|
||||
});
|
||||
});
|
||||
})
|
||||
Reference in New Issue
Block a user