var proxypath;
$(function () {
// initSystemName();
// initActionType();
ljzqInit();
var appid = getAppId() != null ? getAppId() : null;
// var proxypath = "http://71.3.251.51:8066";
proxypath = "http://192.168.20.106:8066";
//proxypath = "http://192.168.20.106:8066";
// var ServerPath = "http://71.3.251.51:8067/manage";
// var tokenjson = "E:/terraproxy/terraproxy/application.yml";
// var servletpath = $("#appProp").val() != "" ? $("#appProp").val() :
// tokenjson;
$("#jqGrid").jqGrid({
ajaxGridOptions:{
xhrFields:{
withCredentials:false
}
},
url: proxypath + '/log/queryBlackLists',
// url: proxypath + '/serv/queryServlet',
datatype: "json",
colModel: [
{ label: '服务名称', name: 'serverName', index: 'serverName', width: 50, align: 'center' },
{ label: '访问来源系统', name: 'visitfromsys', index: 'visitfromsys', width: 50, align: 'center' },
{ label: '申请IP', name: 'requestip', index: 'requestip', width: 100, align: 'center' },
{ label: '申请服务Url', name: 'serverurl', index: 'serverurl', width: 80, align: 'center' },
{ label: '申请资源Id', name: 'resourceid', index: 'resourceid', width: 80, align: 'center' },
// { label: '申请服务系统', name: 'fromSys', index: 'TITLE', width: 80,align:'center',formatter:function(value,grid,rows,state) {
// var id = rows.resourceid;
// if (id != null) {
// var html = ""
// +rows.title+"";
// return html;
// } else {
// return "";
// }
// }
// },
{ label: '申请服务系统', name: 'fromSys', index: 'fromSys', width: 80, align: 'center' },
// { label: '生效日期', name: 'date', index: 'DODATE', width: 80,align:'center',formatter:function(value,grid,rows,state){
// var date =rows.dodate;
// var d=date.substring(0,11);
// return date;
// }
// },
{
label: '黑名单状态', name: 'status', index: 'status', align: 'center', width: 50, formatter: function (value, grid, rows, state) {
if (value == "2") {
return "黑名单失效";
}
else if (value == "1") {
return "黑名单生效";
}
else if (value == "3") {
return "白名单生效";
}
else if (value == "4") {
return "白名单失效";
}
}
},
// { label: '操作', name: 'right', index: 'right',align:'center', width: 200}
{
label: '操作', name: 'right', index: 'right', align: 'center', width: 100, formatter: function (value, grid, rows, state) {
var id = rows.id;
var requestip = rows.requestip;
var template = `
`;
return template;
//return '' + ' ' + ''
}
},
],
// postData:{'appid':appid},
viewrecords: true,
height: "auto",
rowNum: 10,
//rowList : [10,30,50],
rownumbers: true,
rownumWidth: 50,
autowidth: true,
pager: "#jqGridPager",
jsonReader: {
root: "data",
// page: "page.currPage",
page: "1",
total: "totalpage",
// total: "total",
// records: "page.totalCount"
records: "total"
},
prmNames: {
page: "page",
rows: "limit",
// order: "order"
},
gridComplete: function () {
//闅愯棌grid搴曢儴婊氬姩鏉�
$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x": "hidden" });
},
onSortCol: function (index, colindex, sortorder) {
jQuery("#jqGrid").jqGrid('setGridParam', {
page: $(".ui-pg-input").val()
});
}
});
$("#jqGrid").jqGrid('setLabel', 'rn', '序号', { 'text-align': 'center' }, '');
});
function del() {
vm.del()
}
//拦截周期修改提交
function submitLJInfo() {
let time = $('#time').val() //拦截周期
let seltime = $('#seltime option:selected').val()// s m h
let count = $('#count').val() //拦截次数
if (time == '' || count == '') {
time = 60
count = 1000
}
$.ajax({
url: restServerBaseURL + '/log/updateBlackRule',
type: 'post',
data: JSON.stringify({
time: time,
seltime: seltime,
count: count
}),
dataType: 'json',
contentType: 'application/json',
success: function (data) {
alert("拦截规则更新成功");
window.location.reload();
}
})
}
//拦截周期初始化显示
function ljzqInit() {
$.ajax({
url: restServerBaseURL + '/log/selectBalckRule',
type: 'GET',
dataType: 'text',
success: function (data) {
data = JSON.parse(data);
$('#time').val(data.data.time) //拦截周期
$("#seltime option[value=" + data.data.seltime + "] ").attr("selected", true)// s m h
$('#count').val(data.data.count) //拦截次数
}
})
}
var restServerBaseURL = "http://192.168.20.106:8066";
var vm = new Vue({
el: '#rapp',
data: {
showList: true,
title: null,
action: {}
},
methods: {
query: function () {
// if (!checkDate()) {
// // $("#End_Date").focus();
// // $("#End_Date").focus();
// return false;
// }
vm.reload();
},
add: function () {
vm.showList = false;
vm.title = "鏂板";
vm.action = {};
},
update: function (requestip) {
// var actionid = getSelectedRow();
// if (actionid == null) {
// return;
// }
// vm.showList = false;
// vm.title = "淇敼";
// vm.getInfo(actionid)
confirm('你确定要加入白名单吗?', function () {
$.ajax({
url: proxypath + '/log/updateWhite',
type: 'post',
data: {
requestip: requestip,
status: 2
},
dataType: 'text',
success: function (data) {
if (JSON.parse(data).code == 0) {
alert("加入白名单成功");
} else {
alert("加入白名单失败");
}
vm.reload();
},
error: function (s1, s2, s3) {
alert("error");
}
});
});
},
saveOrUpdate: function () {
var url = vm.action.actionid == null ? "log/action/save" : "log/action/update";
$.ajax({
type: "POST",
url: restServerBaseURL + url,
contentType: "application/json",
data: JSON.stringify(vm.action),
success: function (r) {
if (r.code === 0) {
alert('鎿嶄綔鎴愬姛', function () {
vm.reload();
});
} else {
alert(r.msg);
}
}
});
},
del: function (id, requestip) {
// var actionids = getSelectedRows();
// if (actionids == null) {
// return;
// }
confirm('你确定要移除黑名单吗?', function () {
$.ajax({
url: terraProxyUrl + '/log/delBlack',
type: 'post',
data: {
id: id,
requestip: requestip,
status: '2'
},
dataType: 'text',
success: function (data) {
if (JSON.parse(data).code == 0) {
alert("移除黑名单成功");
}
vm.reload();
},
error: function (s1, s2, s3) {
alert("error");
}
});
// $.ajax({
// type: "POST",
// url: restServerBaseURL + "/log/delBlack",
// contentType: "application/json",
// data: JSON.stringify(actionids),
// success: function (r) {
// if (r.code == 0) {
// alert('成功', function () {
// vm.reload();
// });
// } else {
// alert(r.msg);
// }
// }
// });
});
},
getInfo: function (actionid) {
$.get(restServerBaseURL + "log/action/info/" + actionid, function (r) {
vm.action = r.action;
});
},
reload: function () {
var ip = $("#requestip").val();
var status = $("#status").val();
vm.showList = true;
var page = $("#jqGrid").jqGrid('getGridParam', 'page');
$("#jqGrid").jqGrid('setGridParam', {
postData: {
'ip': ip,
'status': status
}, page: 1
}).trigger("reloadGrid");
},
refresh: function () {
vm.showList = true;
window.location.reload();
}
}
});
function initSystemName() {
var local = window.location.href;
$.ajax({
type: "GET",
url: restServerBaseURL + "sys/systeminfo/queryListAll",
contentType: "application/json",
success: function (msg) {
var systemList = msg.systemList;
jQuery("#appidName").append("");
var appid = '';
if (getAppId() != null) {
appid = getAppId();
}
jQuery.each(systemList, function (i, item) {
if (appid == item.appid) {
jQuery("#appidName").append("");
}
else {
jQuery("#appidName").append("");
}
});
}
});
}
function findUserByWord() {
var username = $("#UserName").val();
$("#UserName").autocomplete({
source: restServerBaseURL + 'org/user/findUserByWord?keyWord=' + encodeURI(encodeURI(username)), //璇锋眰鐨剈rl
minLength: 1,
});
}
function initActionType() {
var local = window.location.href;
$.ajax({
type: "GET",
url: restServerBaseURL + "log/action/actionType",
contentType: "application/json",
success: function (msg) {
var list = msg.actionTypes;
jQuery("#actionType").append("");
jQuery.each(list, function (i, item) {
jQuery("#actionType").append("");
});
}
});
}
//鎵撳紑璧勬簮鏌ョ湅椤甸潰
function openZY(id) {
$.ajax({
type: "GET",
url: LanCatalogBaseURL + "api/cheackZYIsExist?resourceid=" + id,
contentType: "application/json",
success: function (data) {
if (data) {
window.open(LanCatalogBaseURL + "res/ZiYuan/ZiYuanBaseInfo?resourceid=" + id, "_blank");
} else {
alert("璇ヨ祫婧愬凡鍒犻櫎锛�");
}
}
});
}
function checkDate() {
var beginDate = $("#Begin_Date").val();
var endDate = $("#End_Date").val();
if (beginDate != "" && endDate != "") {
var pubdatestart = new Date(beginDate.replace(/-/g, "/"));
var pubdateend = new Date(endDate.replace(/-/g, "/"));
if (pubdatestart > pubdateend) {
alert("缁撴潫鏃堕棿涓嶈兘灏忎簬寮€濮嬫椂闂达紒", function () {
$("#End_Date").focus();
$("#End_Date").focus();
});
return false;
}
else {
return true;
}
}
else {
return true;
}
}