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.
 
 
 
 
 
 

283 lines
8.7 KiB

//加载语言列表
function Load_languagelist(f) {
$.get(
Page.SvrIp + "/api/select_language",
{ token: cookie.get("token") },
function (d) {
languagelist = JSON.parse(d.Data);
var html = "";
for (var _i in languagelist) {
var _d = languagelist[_i];
html += ` <option value='${_d.lang_abbr}'>${_d.skip}</option>`;
}
$("#select_language").html(html);
layui.form.render("select");
console.info(languagelist);
f();
}
);
}
function Load_element() {
layui.laydate.render({
elem: "#startTime",
type: "datetime",
});
layui.laydate.render({
elem: "#startTime2",
type: "datetime",
});
layui.laydate.render({
elem: "#endTime",
type: "datetime",
});
layui.laydate.render({
elem: "#highTime",
type: "datetime",
});
layui.laydate.render({
elem: "#lowTime",
type: "datetime",
});
layui.laydate.render({
elem: "#startTimefine",
type: "time",
});
layui.laydate.render({
elem: "#endTimefine",
type: "time",
});
$("#startTime").val(Page.formatDate(new Date()));
$("#endTime").val(Page.formatDate(new Date()));
// 服务器列表多选
layui.form.on("checkbox(realmlist)", function (data) {
var checked = $(data.elem).prop("checked");
if (data.value == 0 && checked) {
$("input[data-id='realmlist']").prop("checked", false);
} else if (data.value != 0 && checked) {
$("input[lay-filter='realmlist'][value=0]").prop("checked", false);
}
layui.form.render("checkbox");
});
layui.form.render(null, "mform");
}
function Ini_popUp(jump, link, jumpParam) {
if (popUp == "1") {
$("div[data-popup=0]").hide();
$("div[data-popup=0]").find("*[required]").removeAttr("required");
$("div[data-popup=0]").find("*[lay-verify]").removeAttr("lay-verify");
$("div[data-popup=1]").show();
$('select[name="jump"]').next().find(".layui-select-title input").click();
$('select[name="jump"]')
.next()
.find(".layui-anim")
.children(`dd[lay-value="${jump}"]`)
.click();
if (link) {
// setTimeout(() => {
// $('select[id="link"]').next().find('.layui-select-title input').click();
// $('select[id="link"]').next().find('.layui-anim').children(`dd[lay-value="${link}"]`).click();
// }, 500);
$('input[name="link"]').val(link);
} else if (jumpParam) {
// setTimeout(() => {
// $('select[id="jumpParam"]').next().find('.layui-select-title input').click();
// $('select[id="jumpParam"]').next().find('.layui-anim').children(`dd[lay-value="${jumpParam}"]`).click();
// }, 500);
$('input[name="jumpParam"]').val(jumpParam);
}
} else {
$("div[data-popup=1]").hide();
$("div[data-popup=0]").show();
}
}
//加载公告数据
function Load_noticedata() {
//新增
if (dataid == "0") {
$("input[lay-filter='realmlist'][value=0]").prop("checked", true);
$("*[data-id=popUpdiv]").show();
$("div[data-popUp=0]").hide();
$("div[data-popUp=1]").hide();
areaList = [];
customRealmlist = "";
startListTime = "";
endListTime = "";
Ini_popUp(0);
}
//编辑
else {
$.get(
Page.SvrIp + "/api/select_notice",
{
token: cookie.get("token"),
noticeId: dataid,
},
function (d) {
$('#noticeId').attr('disabled', true)
$('#noticeId').css('cursor', 'not-allowed')
var _d = d.data[0];
noticedata = _d;
console.info(_d);
for (var i in _d) {
$("#" + i).val(_d[i]);
if (i != "realmlist") {
$("input[data-id='" + i + "']").val(_d[i]);
}
}
for (var i in _d.contentList) {
addlanguage(_d.contentList[i]);
}
let str = "";
if (
_d.customRealmStr ||
(_d.areaNameList && _d.areaNameList.length > 0) ||
_d.timeParamStr != "#"
) {
str += "<span>自定义规则</span>";
console.log(_d);
if (_d.areaNameList && _d.areaNameList.length > 0) {
_d.areaNameList.forEach(function (item) {
str += `<span class="layui-badge layui-bg-green" style="margin-left: 5px;">${item}</span>`;
});
areaList = _d.areaNameList;
}
if (_d.customRealmStr) {
str += `<span class="layui-badge" style="margin-left: 5px;">${_d.customRealmStr}</span>`;
customRealmlist = _d.customRealmStr;
}
if (_d.timeParamStr && _d.timeParamStr.length > 1) {
str += `<span class="layui-badge layui-bg-cyan" style="margin-left: 5px;">${_d.timeParamStr}</span>`;
let arr = _d.timeParamStr.split("#");
startListTime = arr[0];
endListTime = arr[1];
}
str +=
'<i class="layui-icon layui-icon-close-fill" style="font-size: 20px; color: #FFB800;margin-left: 5px; cursor: pointer;" onclick="clearStr()"></i>';
}
$("#realmlistRule").html(str);
if (popUp == "1") {
$("div[data-popup=0]").hide();
$("div[data-popup=0]").find("*[required]").removeAttr("required");
$("div[data-popup=0]").find("*[lay-verify]").removeAttr("lay-verify");
$("div[data-popup=1]").show();
} else {
$("div[data-popup=1]").hide();
$("div[data-popup=0]").show();
}
var popupTypeHtml =
'<button type="button" class="layui-btn" onclick="addPopType()">增加文本栏</button>';
if (_d.popType == 0) {
popupTypeHtml += `<div class="layui-input-inline" style="width:200px">
文本栏1<input type="text" value="" class="layui-input" data-popTypeVal>
</div>
<div class="layui-input-inline" style="width:200px">
文本栏2<input type="text" value="" class="layui-input" data-popTypeVal>
</div>`
}
if (_d.popType == 2) {
$('select[name="popType"]')
.next()
.find(".layui-select-title input")
.click();
$('select[name="popType"]')
.next()
.find(".layui-anim")
.children(`dd[lay-value="${_d.popType}"]`)
.click();
popupTypeHtml += `<div class="layui-input-inline" style="width:200px">
文本栏1<input type="text" value="" class="layui-input" data-popTypeVal>
</div>
<div class="layui-input-inline" style="width:200px">
文本栏2<input type="text" value="" class="layui-input" data-popTypeVal>
</div>`
}
if (_d.popType && _d.popType == 1) {
$('select[name="popType"]')
.next()
.find(".layui-select-title input")
.click();
$('select[name="popType"]')
.next()
.find(".layui-anim")
.children(`dd[lay-value="${_d.popType}"]`)
.click();
for (var idx in _d.textParamList) {
popupTypeHtml += `<div class="layui-input-inline" style="width:200px">
文本栏${
Number(idx) + 1
}<input type="text" value="${
_d.textParamList[idx]
}" class="layui-input" data-popTypeVal>
</div>`;
}
}
$("#popType").html(popupTypeHtml);
$('input:radio[name="state"][value="' + _d.state + '"]').prop(
"checked",
true
);
$('input:radio[name="popUp"][value="' + _d.popUp + '"]').prop(
"checked",
true
);
$('input:radio[name="timetext"][value="' + _d.timetext + '"]').prop(
"checked",
true
);
$('input:radio[name="aotupop"][value="' + _d.aotupop + '"]').prop(
"checked",
true
);
$('select[name="triggertype"]')
.next()
.find(".layui-select-title input")
.click();
$('select[name="triggertype"]')
.next()
.find(".layui-anim")
.children(`dd[lay-value="${_d.triggertype}"]`)
.click();
$('select[name="type"]')
.next()
.find(".layui-select-title input")
.click();
$('select[name="type"]')
.next()
.find(".layui-anim")
.children(`dd[lay-value="${_d.type}"]`)
.click();
Ini_popUp(_d.jump, _d.link, _d.jumpParam);
//全服
if (_d.realmlist == "0") {
//选中全服
realmlistSelect.setValue([0]);
} else {
var realmlistArr = _d.realmlist.split(",");
realmlistSelect.setValue(realmlistArr);
}
layui.form.render();
}
);
}
}