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.
 
 
 
 
 
 

150 lines
5.4 KiB

//添加语言
function addlanguage(data) {
//数据初始化添加
if (data) {
layui.element.tabAdd('demo', {
title: languagelist.filter(f => f.lang_abbr == data.language)[0].skip
, content: template("languagetemp", data)
, id: data.language
});
layui.element.tabChange('demo', data.language);
}
//手动添加
else {
var data1 = layui.form.val("mform").select_language;
if ($("li[lay-id=" + data1 + "]").length != 0) {
alert(data1 + "语言已添加!");
return;
}
layui.element.tabAdd('demo', {
title: $("#select_language").find("option:selected").text()
, content: template("languagetemp", {
language: data1,
id: 0
})
, id: data1
});
layui.element.tabChange('demo', data1);
}
layui.form.render();
Ini_popUp();
}
function Del_notice(del) {
var id;
if (del instanceof Array) {
id = del.join(',');
} else {
id = del;
}
$.get(Page.SvrIp + "/api/del_notice", {
token: cookie.get("token"),
id: id
}, function (data) {
console.info(data);
});
}
//保存公告
function Sub_notice() {
//监听提交
layui.form.on('submit(formDemo)', function (data) {
var contentList = [];
$("#tab-content .layui-tab-item").each(function (i, e) {
contentList.push({
language: $(e).find("[data-id='language']").val() ? $(e).find("[data-id='language']").val() : "",
content: $(e).find("[data-id='content']").val() ? $(e).find("[data-id='content']").val() : "",
title: $(e).find("[data-id='title']").val() ? $(e).find("[data-id='title']").val() : "",
icon: $(e).find("[data-id='icon']").val() ? $(e).find("[data-id='icon']").val() : "",
pic: $(e).find("[data-id='pic']").val() ? $(e).find("[data-id='pic']").val() : "",
id: $(e).find("[data-id='id']").val() ? $(e).find("[data-id='id']").val() : ""
});
});
if (contentList.length == 0) {
alert("至少添加一种语言!");
return false;
}
//此处进行差异化查找
if (dataid != "0") {
//删除编辑时删掉的id
var dellist = noticedata.contentList.filter(x => !contentList.find(y => y.id == x.id)).map(y => y.id);
console.info(dellist);
if (dellist.length!=0) {
Del_notice(dellist);
}
}
if(data.field.triggertype == 1) {
data.field.endTimeDay = data.field.endTimeDay1;
data.field.Intervaldays = data.field.Intervaldays1;
}
if(data.field.triggertype == 2) {
data.field.endTimeDay = data.field.endTimeDay2;
data.field.Intervaldays = data.field.Intervaldays2;
}
delete data.field.pic;
delete data.field.icon;
delete data.field.content;
delete data.field.title;
delete data.field.id;
delete data.field.language;
delete data.field.endTimeDay1;
delete data.field.Intervaldays1;
delete data.field.endTimeDay2;
delete data.field.Intervaldays2;
data.field.contentList = contentList;
data.field.popUp = popUp;
data.field.areaNameList = areaList;
data.field.customRealmStr = customRealmlist;
data.field.timeParamStr = startListTime + '#' + endListTime;
var _realmlist = realmlistSelect.getValue('value');
_realmlist.sort((a, b) => a - b);
data.field.realmlist = _realmlist.join(',');
if((data.field.areaNameList.length > 0 || data.field.customRealmStr) && data.field.realmlist == '0') {
data.field.realmlist = ''
}
console.log(_realmlist, 222)
var _textParamList = $("input[data-popTypeVal]");
var textParamList = [];
_textParamList.each(function (i, e) {
textParamList.push($(e).val());
});
data.field.textParamList = textParamList;
if(popUp == 1 && (!data.field.link || data.field.jump != 1)) data.field.link = '';
if(popUp == 1 && (!data.field.jumpParam || data.field.jump == 1)) data.field.jumpParam = 0;
console.info(data.field);
$.ajax({
type: "post",
url: Page.SvrIp + "/api/update_notice?token=" + cookie.get("token"),
data: JSON.stringify(data.field),
/* contentType: 'application/json',*/
dataType: "json",
success: function (d) {
if (d.ret == 0) {
alert(d.msg);
parent.layer.close(parent.layer.getFrameIndex(window.name));
parent.layui.table.reload('tableIns', {
url: Page.SvrIp+'/api/select_notice' //数据接口
, where: {
token: cookie.get("token"),
popUp: parent.noticeIndex
}
});
// parent.location.reload();
}
else {
layer.msg(d.msg);
}
},
error: function () {
alert("保存失败");
}
});
return false;
});
}