// 刷新数据 function switchhotel() { try { Gethotel(); } catch (e) { console.log(e) } } // 刷新数据 function Gethotel() { MyPost("/Home/Privacy", { title: "刷新中..." }, function (res) { if (res.IsSuccess) { toastr.success(res.Result) } else { try { toastr.error(res.Result) } catch (e) { console.log(e) } } }, function (errorText) { toastr.error("网络繁忙~") }); } let SelHotelSwal = null; //选择酒店 function SelHotel(type, group = 0) { if (type == 0) { toastr.error("没有酒店权限~"); return; } getgroupstr(0) } function getgroupstr(group, search = "") { let selhotel = 0; let str = JSON.parse(Cookies.get("historyItems") || "[]") ; if (search.length > 0) { // 如果存在就移除之前的 然后添加到末尾 str = str.filter(function (x){ return x != search; }) str.unshift(search); if (str.length > 5) { str.length = 5; } Cookies.set('historyItems', JSON.stringify(str), { expires: 7, path: window.location.pathname }); } MyPost('/Api/GetGroup', { isSwal: false, data: { group: Number(group), search} }, function (res) { if (SelHotelSwal == null) { SelHotelSwal = Swal.fire({ title: '', html: res, customClass: 'swal-wide', onClose: (res) => { SelHotelSwal = null;}, showConfirmButton: false, allowOutsideClick: true, showCancelButton: false, preConfirm: function (x) { // 选择了酒店 let sel = $("#ifm").contents().find("#hidden").val(); if (sel == "") { toastr.error("未选择任何酒店信息~") } else { MyPost("/Api/Sel", { title: "切换中...", data: { id: sel } }, function (res) { if (res.IsSuccess) { location.reload(); //location.href = "/"; } else { try { toastr.error(res.Result || "切换失败~") } catch (e) { console.log(e) } } }, function (errorText) { toastr.error("网络繁忙~") }); } } }) } else { $('.swal-wide').html(res); } // 添加搜素历史 for (var i of str ){ $(".history_list").append(`
  • ` + i + `
  • `) } // 点击历史 的搜素时候赋值并收起历史 $(".history_list li").click((e) => { $('#searchtext').val($(e.currentTarget).text()) $('.history_list').mouseout(); }); // 用于判断是否 在触摸历史记录区域 在触摸时候不会隐藏 // 主要原因是因为点击历史区域时是先触发input的fouout 事件 然后区域隐藏 然后就是不会触发点击事件了 let ismovehos = false; $('#searchtext').focusout( (e) => { if (!ismovehos) { $('.history_list').hide(); } } ); $('#searchtext').focus( (e) => { $('.history_list').show(); } ); $('.history_list').mouseout(() => { ismovehos = false; if (!$('#searchtext').is(':focus')) { $('.history_list').hide(); } }) $('.history_list').mousemove(() => { ismovehos = true; $('.history_list').show(); }); //添加搜索事件 $("#search").click((e) => { getgroupstr(group, $("#searchtext").val()); }); $("#searchtext").prop('type', 'text'); // 添加酒店组点击事件 $(".groupinfo").click((e) => { let dom = e.currentTarget; let id = $(dom).attr("data-id"); getgroupstr(id); }); $(".Hotel_hover").click((e) => { let dom = e.currentTarget; let id = $(dom).attr("data-id") ; let datagroup = $(dom).attr("data-group"); let name = $(dom).attr("data-name"); selhotel = id; $(".hiddtext").removeClass("btn-primary"); $(".hiddtext").addClass("btn-success"); $(dom).find(".hiddtext").removeClass("btn-success").addClass("btn-primary"); let oldtext = $('#seltext').text(); $('#seltext').text(datagroup + "-" + name); }); $("#qdbtn").click((e) => { if (selhotel <= 0) { toastr.error('请选择酒店~') return; } MyPost("/api/Sel/", { data: { id: selhotel }, isSwal: true, title: "切换中.." }, (res) => { if (res.IsSuccess) { window.location.href = "/"; } else { toastr.error(res.Result || '切换失败~') } }) }); }) } //如果日志数量元素显示在界面上每隔 5s刷新一次log数量 // 初始化数量 Getudplogcount(); //是否未在刷新 false 时 let udplogcount = false; let udplogtime = setInterval(function () { //不自动刷新数量 只会有一次结果 clearInterval(udplogtime) return; if (!$('#udplogcount').is(":hidden") ) { if (!udplogcount) { udplogcount = true; setTimeout(() => { Getudplogcount(); }, 4500) } } }, 500) // 获取UDPlog 数量 和 rcu数量 function Getudplogcount() { if ($('#udplogcount').length <= 0) { return; } MyPost("/Api/Getudplogcount", { isSwal: false }, (X) => { $('#rcucount').text(X.rcu||0); $('#udplogcount').text(X.udp||0); if (udplogcount) udplogcount = false; }, (err) => { console.log(err); clearInterval(udplogtime) }) } // 5s刷新一次log数量 结束 // rucs 服务状态 // 状态回调 服务器状态监测 let RUCSSTATUS_BACK = []; // 状态值 let RUCSSTATUS_Val = Cookies.get('RUCSSTATUS_Val') || null; RUCSSTATUS_Val = RUCSSTATUS_Val == null ? [] : JSON.parse(RUCSSTATUS_Val); $(function () { let sx_token = false; setInterval(() => { if (sx_token) { return; } sx_token = true; MyPost("/api/Token", { isSwal: false }, (res) => { if (IsUndefined(res) || IsUndefined(res.IsSuccess) || res.IsSuccess != true) { window.href = "~/Api/signout"; return; } RUCSSTATUS_Val = res.Result; Cookies.set('RUCSSTATUS_Val', RUCSSTATUS_Val); RUCSSTATUS_BACK.forEach(x => { x(RUCSSTATUS_Val); }); sx_token = false; }); },1000 * 5 ) });