You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

330 lines
13 KiB

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<!--#include file="/widget/head.html"-->
<!--#include file="/widget/email-tail.html"-->
<style>
.layui-table-cell {
height: auto;
}
</style>
</head>
<body class="layui-layout-body" layadmin-themealias="default">
<div id="wrapper">
<!-- Navigation -->
<!--#include file="/widget/nav.html"-->
<div id="page-wrapper" class="layui-body layadmin-tabsbody-item layui-show layui-fluid layui-row layui-col-space15">
<div class="layui-card" id="card-page-wrapper">
<div class="row">
<div class="col-lg-12">
<h2 class="page-header">公告管理</h2>
</div>
</div>
<div style="width:1400px;">
<div role="tabpanel" class="tab-pane" id="send">
<div class="layui-form">
<!--<div class="layui-form-item layui-inline" style="width:400px;">
<label class="layui-form-label" style="width: 120px;">开始时间</label>
<div class="layui-inline" style="width:220px;">
<input type="text" name="title" id="stadate" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline" style="width:400px;">
<label class="layui-form-label" style="width: 120px;">结束时间</label>
<div class="layui-inline" style="width:220px;">
<input type="text" name="title" id="enddate" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-form-item layui-inline" style="width:100px;">
<div class="layui-inline" style="width:100px;">
<button class="layui-btn" type="button" id="query">查询</button>
</div>
</div>-->
<div class="layui-form-item layui-inline" style="width:300px;">
<div class="layui-inline" style="width:100px;">
<button class="layui-btn" type="button" onclick="opennotice(0,0)">添加公告</button>
</div>
<div class="layui-inline" style="width:100px;">
<button class="layui-btn" type="button" onclick="opennotice(0,1)">添加拍脸图</button>
</div>
</div>
<!--<div class="layui-form-item layui-inline" style="width:100px;">
<div class="layui-inline" style="width:100px;">
<button class="layui-btn" type="button" onclick="sendnotice(0)">推送所有公告</button>
</div>
</div>-->
</div>
<div class="layui-tab" lay-filter="filterTab">
<ul class="layui-tab-title">
<li class="layui-this">公告</li>
<li>拍脸图</li>
</ul>
<div class="layui-tab-content">
<div id="Datatab" style="width:1000px;"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script id="btn" type="text/template">
{{# if(d.issys==1){ }}
<span> execl内置公告<br/>无法修改删除 </span>
{{# } else { }}
<input type="button" class="layui-btn layui-btn-xs" value="编辑" onclick="opennotice({{d.noticeId}},{{d.popUp}})"/>
<input type="button" class="layui-btn layui-btn-xs" value="删除"
onclick="delnotice({{ d.noticeId}},'{{d.title}}')"/>
{{# if(d.state == 0) { }}
<input type="button" class="layui-btn layui-btn-xs" value="开启"
onclick="toggleNotice({{ d.noticeId}},'1','{{d.popUp}}')"/>
{{# } else { }}
<input type="button" class="layui-btn layui-btn-xs layui-btn-warm" value="禁用"
onclick="toggleNotice({{ d.noticeId}},'0','{{d.popUp}}')"/>
{{# } }}
{{# } }}
</script>
<script id="picimgtemp" type="text/template">
<div style="width:100px;height:auto;">
{{# if(d.contentList && d.contentList.find(item => item.language == 'en')){ }}
<img style="width:auto; height:100px;cursor:pointer; "
src="{{d.contentList.find(item => item.language == 'en').pic}}" onclick="openimg(this);"/>
{{# } }}
</div>
</script>
<script id="iconimgtemp" type="text/template">
<div style="width:100px;height:100px;">
<img style="width: auto; height: 100px;" src="{{d.icon}}"/>
</div>
</script>
<script>
var element = layui.element;
var noticeList = [[], []];
var tableIns;
window.noticeIndex = 0;
function delnotice(id, text) {
if (confirm("确定删除《" + text + "》公告吗?")) {
$.get(Page.SvrIp + "/api/del_notice", {
token: cookie.get("token"),
noticeId: id
}, function (data) {
if (data.ret == 0) {
alert(data.msg);
location.reload();
}
});
}
}
function toggleNotice(id, state, type) {
if (confirm(`确定${state == 0 ? '关闭' : '开启'}该公告吗`)) {
$.get(Page.SvrIp + "/api/ban_notice", {
token: cookie.get("token"),
noticeId: id,
state,
type
}, function (data) {
if (data.ret == 0) {
layer.msg(data.msg);
tableIns.reload({
url: Page.SvrIp + '/api/select_notice' //数据接口
, where: {
token: cookie.get("token"),
popUp: window.noticeIndex
}
});
}
});
}
}
function openimg(t) {
var src = $(t).attr("src");
layer.open({
content: " <img style='width: auto;max-width:1800px; height: 450px;' src=" + src + " />",
type: 1,
title: false,
shade: false,
closeBtn: 2,
area: ['auto', '450px']
});
$(".layui-layer.layui-layer-page,.layui-layer-content").css("background-color", "transparent");
}
function opennotice(id, t) {
var title = "";
if (id == 0) {
title = "添加";
} else {
title = "编辑";
}
if (t == 0) {
title += "公告";
} else {
title += "拍脸图";
}
layer.open({
content: `/pages/EditNotice.html?id=${id}&t=${t}`,
type: 2,
title: title,
area: ['1350px', '870px']
});
}
function ShowNoticeDay(id) {
layer.open({
content: '/pages/ShowNoticeDay.html?id=' + id,
type: 2,
title: `ID ${id} 显示计划`,
area: ['1050px', '870px']
});
}
$(function () {
var _d = new Date();
layui.laydate.render({
elem: '#stadate',
value: _d.getFullYear() + "-" + (_d.getMonth() + 1) + "-" + _d.getDate()
});
layui.laydate.render({
elem: '#enddate',
value: _d.getFullYear() + "-" + (_d.getMonth() + 1) + "-" + _d.getDate()
});
$("#query").click(function () {
tableIns.reload({
where: {
token: cookie.get("token"),
startDate: $("#stadate").val(),
endDate: $("#enddate").val()
}
});
});
//var args = initPage('已封');
tableIns = layui.table.render({
id: 'tableIns',
elem: '#Datatab'
, url: Page.SvrIp + '/api/select_notice' //数据接口
, where: {
token: cookie.get("token"),
popUp: window.noticeIndex
//startDate: $("#stadate").val(),
//endDate: $("#enddate").val()
}
, page: true
, cols: [[
{field: 'noticeId', title: 'noticeId', width: 90}
, {
field: 'popUp', title: '类型', width: 80, templet: function (d) {
return d.popUp == 1 ? "<label style='color:blue;'> 拍脸图</label>" : " <label style='color:crimson;'>公告 </label>";
}
}
, {
field: 'state', title: '状态', width: 60, templet: function (d) {
return d.state == 1 ? "启用" : "<label style='color: red;'>禁用</label>";
}
}
, {
field: 'triggertype', title: '触发时间', width: 90, templet: function (d) {
var valstr = "";
if (d.triggertype == 0) {
switch (d.valid) {
case -1:
valstr = "未开始";
break;
case 0:
valstr = "有效期内";
break;
case 1:
valstr = "<label style='color: red;'>已过期</label>";
break;
}
}
switch (d.triggertype) {
case 0:
default:
return "固定时间<br/>" + valstr;
break;
case 1:
return "开服时间<br/> <input type='button' class='layui-btn layui-btn-xs' value='显示计划' onclick='ShowNoticeDay(" + d.noticeId + ")'/>";
break;
}
}
}
, {field: 'sort', title: '排序', width: 60}
, {
field: 'startTime', title: '开始时间', width: 160, templet: function (d) {
if (d.triggertype == "1") {
return `开服推迟时间<br/>${d.openserverstartday}${d.openserverstarttime}`;
}
return d.startTime;
}
}
, {
field: 'endTime', title: '结束时间', width: 160, templet: function (d) {
if (d.triggertype == "1") {
return `持续显示<br/>${d.openserverendday}${d.openserverendtime}<br/>间隔天数${d.intervaldays}`;
}
return d.endTime;
}
}
, {
field: 'realmlist', title: '区服', width: 120, templet: function (d) {
if (d.realmlist == "0") {
return "全服";
}
if (d.areaNameList.length > 0 || d.customRealmStr || d.timeParamStr !== '#') {
return "自定义规则";
}
return d.realmlist;
}
}
//, { field: 'title', title: '标题', width: 160 }
//, { field: 'content', title: '显示内容', width: 160 }
, {field: 'pic', title: '图片', width: 130, templet: "#picimgtemp"}
, {field: '*', title: '编辑', width: 170, templet: "#btn"}
]]
, done: function (res, cur, count) {
if (window.noticeIndex == 0) {
$(".layui-table-box").find("[data-field='pic']").css("display", "none");
}
}
, parseData: function (res) { //res 即为原始返回的数据
if (res.ret == 1) {
location.href = "/pages/login.html";
}
for (var i in res.sysdata) {
var d = res.sysdata[i];
d.issys = 1;
res.data.push(d);
}
return {
"code": res.ret, //解析接口状态
"msg": res.msg, //解析提示文本
"count": res.count, //解析数据长度
"data": res.data //解析数据列表
};
}
});
element.on('tab(filterTab)', function (data) {
window.noticeIndex = data.index;
tableIns.reload({
url: Page.SvrIp + '/api/select_notice' //数据接口
, where: {
token: cookie.get("token"),
popUp: window.noticeIndex
}
});
})
});
</script>
</body>
</html>