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.
583 lines
25 KiB
583 lines
25 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 class="layui-form-item layui-inline pull-right" style="width:300px;" id="addServerButton">
|
|
<div class="layui-inline" style="width:100px;">
|
|
<button class="layui-btn layui-btn-sm" type="button" onclick="addServer(0)">增加服务器</button>
|
|
</div>
|
|
</div> -->
|
|
</div>
|
|
<div class="row" style=" margin-left: 470PX; color : red">
|
|
<label>
|
|
提示:强制修改可编辑除realmId外的所有值,请谨慎使用
|
|
</label>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-lg-6">
|
|
<div role="tabpanel" class="tab-pane" id="send">
|
|
<div id="Datatab" ></div>
|
|
</div>
|
|
</div>
|
|
<div class="col-lg-12">
|
|
<div role="tabpanel" class="tab-pane" id="send">
|
|
<table class="layui-table" id="DatatabTwo" lay-filter="DatatabTwo" style="width:200px;"></table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script type="text/html" id="headToolbarTpl">
|
|
<div class="layui-form-item layui-inline"></div>
|
|
<button class="layui-btn layui-btn-sm" lay-event="addRow" id="addRow">新增</button>
|
|
<button class="layui-btn layui-btn-sm" lay-event="submit" id="submit" style="background-color:deepskyblue;">提交</button>
|
|
<div class ="layui-inline ">
|
|
<div class="layui-inline" style="width:100px;">服务器: {{areaNameTitle}}</div>
|
|
<div class="layui-inline" style="left:30px; width:100px;">worldId: {{worldIdTitle}}</div>
|
|
</div>
|
|
</div>
|
|
</script>
|
|
|
|
<script type="text/html" id="barDemo">
|
|
{{# if(Date.parse(new Date())/1000 - d.openTime < 24 * 3600 || d.openTime == '') { }}
|
|
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
|
|
{{# } }}
|
|
<a class="layui-btn layui-btn-xs" lay-event="power" style="background-color: blue;">强制修改</a>
|
|
{{# if(d.status == -1 && d.realmId > maxRealmId) { }}
|
|
<a class="layui-btn layui-btn-xs" lay-event="delRow" style="background-color: red;">删除</a>
|
|
{{# } }}
|
|
|
|
</script>
|
|
|
|
<script>
|
|
$(document).ready(function () {
|
|
localStorage.setItem('os-token', cookie.get("token"))
|
|
if (!Page.IsAdmin()) $('#addServerButton').hide()
|
|
});
|
|
const isMobileTerminal = () => {
|
|
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
|
navigator.userAgent
|
|
)
|
|
}
|
|
var form = layui.form;
|
|
var tableData = [];
|
|
var data = [];
|
|
|
|
function addServer(id) {
|
|
layer.open({
|
|
content: `/pages/EditServerManage.html?id=${id}`,
|
|
type: 2,
|
|
title: id == 0 ? "添加" : "修改",
|
|
area: [isMobileTerminal() ? '415px' : '1500px', '675px'],
|
|
});
|
|
}
|
|
|
|
var areaNameTitle = '未选择';
|
|
var worldIdTitle = '无';
|
|
var timeZoneTitle = 0;
|
|
var maxRealmId = 0;
|
|
var lastShowSeq = 0;
|
|
var tableId = 'DatatabTwo';
|
|
layui.table.on('toolbar(DatatabTwo)', function (obj) {
|
|
switch (obj.event) {
|
|
case 'addRow':
|
|
if (areaNameTitle == '未选择') {
|
|
layer.msg('请选择worldId', {
|
|
time: 1000 // 设置 1 秒后自动关闭
|
|
},);
|
|
return;
|
|
}
|
|
var oldDatas = layui.table.cache[tableId];
|
|
|
|
if (oldDatas[0].bigRealmId == '') {
|
|
layer.msg('请先设置上一条realm数据', {
|
|
time: 1000 // 设置 1 秒后自动关闭
|
|
},);
|
|
return;
|
|
}
|
|
|
|
var areaName = "";
|
|
for (var i = 0; i < oldDatas[0].realmName.length; i++) {
|
|
if ('0' <= (oldDatas[0].realmName)[i] && (oldDatas[0].realmName)[i] <= '9') {
|
|
break;
|
|
}
|
|
areaName += (oldDatas[0].realmName)[i];
|
|
}
|
|
var newData = {
|
|
realmId: worldIdTitle * 1000 + lastShowSeq + 1,
|
|
realmName: areaName + (parseInt(oldDatas[0].realmName.replace(areaName, "")) + 1),
|
|
bdcName: (worldIdTitle * 1000 + lastShowSeq + 1).toString(),
|
|
showSeq: parseInt((oldDatas[0].realmId + 1) % 1000),
|
|
bigRealmId: '',
|
|
logicWorldId: '',
|
|
visibleOnlyWhiteList: 0,
|
|
state: 1,
|
|
openTime: '',
|
|
visibleTime: '',
|
|
status: -1
|
|
};
|
|
lastShowSeq = newData.showSeq;
|
|
oldDatas.push(newData);
|
|
layui.table.reload(tableId, {
|
|
data: oldDatas,
|
|
})
|
|
break;
|
|
case 'submit':
|
|
var oldDatas = layui.table.cache[tableId];
|
|
var sendDatas = [];
|
|
for (var i = oldDatas.length - 1; i >= 0; i--) {
|
|
if (oldDatas[i].status == -1) {
|
|
var sendData = {}
|
|
sendData.realmId = oldDatas[i].realmId;
|
|
sendData.realmName = oldDatas[i].realmName;
|
|
sendData.areaName = areaNameTitle;
|
|
sendData.timeZoneTitle = timeZoneTitle;
|
|
sendData.worldId = worldIdTitle;
|
|
sendData.bdcName = oldDatas[i].bdcName;
|
|
sendData.state = oldDatas[i].state;
|
|
sendData.showSeq = oldDatas[i].showSeq;
|
|
sendData.logicWorldId = oldDatas[i].logicWorldId;
|
|
sendData.bigRealmId = oldDatas[i].bigRealmId;
|
|
sendData.visibleOnlyWhiteList = oldDatas[i].visibleOnlyWhiteList;
|
|
sendData.logicWorldId = oldDatas[i].logicWorldId;
|
|
sendData.openTime = Page.formatDate(oldDatas[i].openTime);
|
|
sendData.visibleTime = Page.formatDate(oldDatas[i].visibleTime);
|
|
sendData.realmId = oldDatas[i].realmId;
|
|
sendDatas.push(sendData)
|
|
}
|
|
}
|
|
|
|
console.log(sendDatas)
|
|
|
|
$.ajax({
|
|
type: "post",
|
|
url: Page.SvrIp + "/api/send_realmlist?token=" + cookie.get("token"),
|
|
data: JSON.stringify(sendDatas),
|
|
dataType: "json",
|
|
success: function (d) {
|
|
if (d.ret == 0) {
|
|
for (var i = 0; i < oldDatas.length; i++) {
|
|
oldDatas[i].status = 1;
|
|
}
|
|
layui.table.reload(tableId, {
|
|
data: oldDatas
|
|
})
|
|
}
|
|
else {
|
|
for (var i = 0; i < oldDatas.length; i++) {
|
|
oldDatas[i].status = 1;
|
|
}
|
|
|
|
for (var i = 0; i < d.data.length; i++) {
|
|
if (d.data.code != 0) {
|
|
for (var j = 0; j < oldDatas.length; j++) {
|
|
if (d.data[i].realmId == oldDatas[i].realmId) {
|
|
oldDatas[i].status = 0;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
layui.table.reload(tableId, {
|
|
data: oldDatas
|
|
})
|
|
}
|
|
alert(d.msg);
|
|
sleep(1000);
|
|
try {
|
|
$.get(Page.SvrIp + "/api/select_allrealms", {
|
|
token: cookie.get("token"),
|
|
...data.field
|
|
}, (res) => {
|
|
for (var i in res.sysdata) {
|
|
var d = res.sysdata[i];
|
|
d.issys = 1;
|
|
res.data.push(d);
|
|
}
|
|
tableData = (res.data && res.data.areaRealmList) || [];
|
|
return {
|
|
"code": res.ret, //解析接口状态
|
|
"msg": res.msg, //解析提示文本
|
|
"count": tableData.length, //解析数据长度
|
|
"data": tableData //解析数据列表
|
|
};
|
|
})
|
|
} catch {
|
|
alert("发生错误,请重试")
|
|
}
|
|
},
|
|
error: function () {
|
|
alert("保存失败");
|
|
}
|
|
});
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
});
|
|
|
|
//参数n为休眠时间,单位为毫秒:
|
|
function sleep(n) {
|
|
var start = new Date().getTime();
|
|
// console.log('休眠前:' + start);
|
|
while (true) {
|
|
if (new Date().getTime() - start > n) {
|
|
break;
|
|
}
|
|
}
|
|
// console.log('休眠后:' + new Date().getTime());
|
|
}
|
|
|
|
layui.table.on('tool(DatatabTwo)', function (obj) {
|
|
var data = obj.data; // 获得当前
|
|
var time = "";
|
|
switch (obj.event) {
|
|
case 'edit':
|
|
var oldDatas = layui.table.cache[tableId]
|
|
for (var i = 0; i < oldDatas.length; i++) {
|
|
if (oldDatas[i].realmId == data.realmId) {
|
|
|
|
data.bigRealmId = oldDatas[i].bigRealmId
|
|
data.logicWorldId = oldDatas[i].logicWorldId
|
|
|
|
if (i != oldDatas.length - 1) {
|
|
|
|
data.prebigRealmId = oldDatas[i + 1].bigRealmId
|
|
data.prelogicWorldId = oldDatas[i + 1].logicWorldId
|
|
|
|
time = Page.formatDate(oldDatas[i + 1].openTime)//.split(" ")[1]
|
|
}
|
|
else {
|
|
data.prebigRealmId = 0;
|
|
data.prelogicWorldId = 0;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
layer.open({
|
|
type: 2,
|
|
title: '编辑',
|
|
skin: 'layui-layer-molv', //样式类名,即子页面边框样式
|
|
closeBtn: 1, //要显示关闭按钮
|
|
anim: 2,
|
|
shadeClose: false, //开启遮罩
|
|
moveOut: false,
|
|
area: ['600px', '800px'],
|
|
content: '/pages/EditServer.html'
|
|
, resize: false
|
|
, maxmin: false //开启最大化最小化按钮
|
|
, success: function (layero, index) {
|
|
// 获取子页面的iframe
|
|
var iframe = window['layui-layer-iframe' + index];
|
|
// 向子页面的全局函数child传参
|
|
iframe.child(data, time);
|
|
}
|
|
});
|
|
break;
|
|
case 'power':
|
|
|
|
var oldDatas = layui.table.cache[tableId]
|
|
var time = "";
|
|
|
|
for (var i = 0; i < oldDatas.length; i++) {
|
|
if (oldDatas[i].realmId == data.realmId) {
|
|
|
|
data.bigRealmId = oldDatas[i].bigRealmId
|
|
data.logicWorldId = oldDatas[i].logicWorldId
|
|
|
|
if (i != oldDatas.length - 1) {
|
|
|
|
data.prebigRealmId = oldDatas[i + 1].bigRealmId
|
|
data.prelogicWorldId = oldDatas[i + 1].logicWorldId
|
|
|
|
time = Page.formatDate(oldDatas[i + 1].openTime)//.split(" ")[1]
|
|
}
|
|
else {
|
|
data.prebigRealmId = 0;
|
|
data.prelogicWorldId = 0;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
layer.open({
|
|
type: 2,
|
|
title: '强制修改',
|
|
skin: 'layui-layer-lan', //样式类名,即子页面边框样式
|
|
closeBtn: 1, //要显示关闭按钮
|
|
anim: 2,
|
|
shadeClose: false, //开启遮罩
|
|
moveOut: false,
|
|
area: ['600px', '800px'],
|
|
content: '/pages/PowerServer.html'
|
|
, resize: false
|
|
, maxmin: false //开启最大化最小化按钮
|
|
, success: function (layero, index) {
|
|
// 获取子页面的iframe
|
|
var iframe = window['layui-layer-iframe' + index];
|
|
// 向子页面的全局函数child传参
|
|
iframe.child(data, time);
|
|
}
|
|
});
|
|
break;
|
|
|
|
case 'delRow':
|
|
if (data.realmId != layui.table.cache[tableId][0].realmId) {
|
|
layer.msg('请先删除上一条realm数据', {
|
|
time: 1000 // 设置 1 秒后自动关闭
|
|
},);
|
|
return;
|
|
}
|
|
layer.confirm('真的删除该条数据么,[realmId: ' + data.realmId + '] ?', function (index) {
|
|
console.log(data.realmId)
|
|
console.log(layui.table.cache[tableId][0].realmId)
|
|
obj.del(); // 删除对应行(tr)的DOM结构
|
|
console.log(layui.table.cache[tableId])
|
|
var oldDatas = layui.table.cache[tableId]
|
|
console.log(oldDatas);
|
|
var newDatas = []
|
|
for (var i = 0; i < oldDatas.length - 1; i++) {
|
|
if (i == 0) {
|
|
lastShowSeq = parseInt(oldDatas[i + 1].showSeq);
|
|
}
|
|
|
|
newDatas[i] = oldDatas[i + 1]
|
|
}
|
|
layui.table.reload(tableId, {
|
|
data: newDatas,
|
|
})
|
|
layer.close(index);
|
|
// 向服务端发送删除指令
|
|
});
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
});
|
|
|
|
|
|
window.ppp = function (a) {
|
|
|
|
var oldDatas = layui.table.cache[tableId];
|
|
var realmId = a.split("||")[0]
|
|
var realmName = a.split("||")[1]
|
|
var bdcName = a.split("||")[2]
|
|
var showSeq = a.split("||")[3]
|
|
var logicWorldId = a.split("||")[4]
|
|
var bigRealmId = a.split("||")[5]
|
|
var openTime = a.split("||")[6] //+ " " + Page.formatDate(oldDatas[1].openTime).split(' ')[1]
|
|
var visibleTime = a.split("||")[7]
|
|
var status = parseInt(a.split("||")[8])
|
|
var visibleOnlyWhiteList = parseInt(a.split("||")[9])
|
|
var state = parseInt(a.split("||")[10])
|
|
|
|
console.log(visibleOnlyWhiteList)
|
|
|
|
openTime = new Date(openTime).getTime() / 1000
|
|
visibleTime = new Date(visibleTime).getTime() / 1000
|
|
|
|
for (var i = 0; i < oldDatas.length; i++) {
|
|
if (realmId == oldDatas[i].realmId) {
|
|
oldDatas[i].logicWorldId = logicWorldId;
|
|
oldDatas[i].visibleOnlyWhiteList = visibleOnlyWhiteList;
|
|
oldDatas[i].realmName = realmName;
|
|
oldDatas[i].bdcName = bdcName;
|
|
oldDatas[i].showSeq = showSeq;
|
|
oldDatas[i].bigRealmId = bigRealmId;
|
|
oldDatas[i].openTime = openTime;
|
|
oldDatas[i].visibleTime = visibleTime;
|
|
oldDatas[i].status = status;
|
|
oldDatas[i].state = state;
|
|
break;
|
|
}
|
|
}
|
|
|
|
layui.table.reload(tableId, {
|
|
data: oldDatas,
|
|
})
|
|
|
|
form.render()
|
|
}
|
|
|
|
var tableIns = layui.table.render({
|
|
elem: '#Datatab'
|
|
, height: 250
|
|
, url: Page.SvrIp + '/api/select_allrealms' //数据接口
|
|
, where: {
|
|
token: cookie.get("token")
|
|
}
|
|
, page: true
|
|
, cols: [
|
|
[
|
|
{ field: 'areaName', title: '名字', width: 80 }
|
|
,
|
|
{
|
|
field: 'timeZone', title: '时区', width: 80, templet: function (d) {
|
|
return d.timeZone || 0
|
|
}
|
|
}
|
|
,
|
|
{
|
|
field: 'worldId', title: 'worldId', width: 200, templet: function (d) {
|
|
return `<div class='layui-form'><select name="worldId" lay-filter="worldId">
|
|
<option value="">请选择一个worldId</option>
|
|
${d.worldList.map(item => {
|
|
return `<option value="${[d.areaName, item.worldId, d.timeZone]}"><a href="">worldId: ${item.worldId}</a></option>`;
|
|
}).join('')}
|
|
</select>
|
|
</div>`;
|
|
}
|
|
}
|
|
],
|
|
]
|
|
,
|
|
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);
|
|
}
|
|
|
|
tableData = (res.data && res.data.areaRealmList) || [];
|
|
return {
|
|
"code": res.ret, //解析接口状态
|
|
"msg": res.msg, //解析提示文本
|
|
"count": tableData.length, //解析数据长度
|
|
"data": tableData //解析数据列表
|
|
};
|
|
}
|
|
});
|
|
|
|
var tableInsTwo = layui.table.render({
|
|
elem: '#DatatabTwo'
|
|
, height: 600
|
|
, page: true
|
|
, toolbar: '#headToolbarTpl'
|
|
// , toolbar: '<div>服务器: 未选择</br>worldId: 无</div>'
|
|
, defaultToolbar: []
|
|
, limits: [10000]
|
|
, limit: 10000
|
|
, initSort: {
|
|
field: 'realmId',//排序字段,对应 cols 设定的各字段名
|
|
type: 'desc' //排序方式 asc: 升序、desc: 降序、null: 默认排序
|
|
}
|
|
, cols: [
|
|
[
|
|
{ field: 'realmId', title: 'realmId', width: 100 }
|
|
,
|
|
{ field: 'realmName', title: 'realmName', width: 100 }
|
|
,
|
|
{ field: 'bdcName', title: 'bdcName', width: 100 }
|
|
,
|
|
{ field: 'showSeq', title: 'showSeq', width: 100 }
|
|
,
|
|
{ field: 'state', title: 'state', width: 100 }
|
|
,
|
|
{ field: 'logicWorldId', title: 'logicWorldId', width: 100 }
|
|
,
|
|
{ field: 'bigRealmId', title: 'bigRealmId', width: 100 }
|
|
,
|
|
{
|
|
field: 'visibleOnlyWhiteList', title: 'visibleOnlyWhiteList(0-否 1-是)', width: 200,
|
|
}
|
|
,
|
|
{
|
|
field: 'openTime', title: 'openTime(开服时间)', width: 150, templet: function (d) {
|
|
if (d.openTime == null || d.openTime.length == 0) {
|
|
return '';
|
|
}
|
|
return Page.formatDate(d.openTime);
|
|
}
|
|
}
|
|
,
|
|
{
|
|
field: 'visibleTime', title: 'visibleTime(可见时间)', width: 150, templet: function (d) {
|
|
if (d.visibleTime == null || d.visibleTime.length == 0) {
|
|
return '';
|
|
}
|
|
return Page.formatDate(d.visibleTime);
|
|
}
|
|
}
|
|
,
|
|
{
|
|
field: 'status', title: '状态', width: 180, templet: function (d) {
|
|
var valstr = "";
|
|
switch (d.status) {
|
|
case -1: return "<label style=\"color: blue;height: 10px\">未提交</label>";
|
|
}
|
|
return valstr;
|
|
},
|
|
}
|
|
,
|
|
{ fixed: 'right', title: '操作', width: 200, minWidth: 150, toolbar: '#barDemo' }
|
|
]
|
|
]
|
|
, data: data
|
|
});
|
|
form.on("select(worldId)", function (data) {
|
|
if (data.value) {
|
|
console.log(data.value)
|
|
var [areaName, worldId, timeZone] = data.value.split(',');
|
|
data = tableData.find(i => i.areaName == areaName).worldList.find(i => i.worldId == worldId).realmList;
|
|
var lastWorldLength = tableData.find(i => i.areaName == areaName).worldList.length;
|
|
var realmList = tableData.find(i => i.areaName == areaName).worldList[lastWorldLength - 1].realmList;
|
|
lastShowSeq = realmList[realmList.length - 1].showSeq;
|
|
areaNameTitle = areaName;
|
|
worldIdTitle = worldId;
|
|
timeZoneTitle = timeZone;
|
|
|
|
maxRealmId = data[data.length - 1].realmId;
|
|
|
|
tableInsTwo.reload({
|
|
data
|
|
//, toolbar: `<div>服务器: ${areaName}</br>worldId: ${worldId}</div>`
|
|
, page: {
|
|
curr: 1 //重新从第 1 页开始
|
|
},
|
|
});
|
|
} else {
|
|
tableInsTwo.reload({
|
|
data: []
|
|
//, toolbar: '<div>服务器: 未选择</br>worldId: 无</div>'
|
|
});
|
|
}
|
|
});
|
|
|
|
</script>
|
|
<style>
|
|
.layui-table-cell {
|
|
overflow: visible;
|
|
}
|
|
|
|
.layui-layer-tips {
|
|
display: none
|
|
}
|
|
</style>
|
|
</body>
|
|
|
|
</html>
|