var proxypath;
$(function () {
// initSystemName();
// initActionType();
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/selectWhiteList',
// url: proxypath + '/serv/queryServlet',
datatype: "json",
colModel: [
{ label: '白名单IP', name: 'requestip', index: 'requestip', width: 50, align: 'center' },
{ label: '生效日期', name: 'date', index: 'date', width: 50, align: 'center' },
{ label: '申请人', name: 'IDENTYINFO', index: 'IDENTYINFO', width: 100, align: 'center' },
{ label: 'token信息', name: 'TOKENINFO', index: 'TOKENINFO', width: 80, align: 'center' },
{ label: '白名单状态', name: 'status', index: 'status', width: 80, align: 'center',formatter: function (value, grid, rows, state) {
if (value == "3") {
return "白名单生效";
}
else if (value == "4") {
return "白名单失效";
}
} },
// { 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: 'right', index: 'right', width: 80,align:'center'},
{
label: '操作', name: 'right', index: 'right', align: 'center', width: 100, formatter: function (value, grid, rows, state) {
var id = rows.id;
var ip = rows.requestip
var status = rows.status
var template = ` `;
return template;
//return '' + ' ' + ''
}
},
// { 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},
// { label: '操作', name: 'right', index: 'right',align:'center', width: 200}
],
// 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' }, '');
});
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 () {
var actionid = getSelectedRow();
if (actionid == null) {
return;
}
vm.showList = false;
vm.title = "淇敼";
vm.getInfo(actionid)
},
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, ip,sta) {
// var actionids = getSelectedRows();
// if (actionids == null) {
// return;
// }
confirm("是否确认移除白名单", function () {
$.ajax({
url: proxypath + '/log/updateWhite',
type: 'post',
data: {
id: id,
requestip: ip,
status:sta
},
dataType: 'text',
success: function (data) {
if (JSON.parse(data).msg === "操作成功") {
alert('操作成功', function () {
vm.reload();
});
} else {
alert(JSON.parse(data).msg);
}
// if (data == "success") {
// alert("从redis中删除成功");
// }
// vm.reload();
},
error: function (s1, s2, s3) {
alert("error");
}
});
})
// confirm('纭畾瑕佸垹闄ら€変腑鐨勮褰曪紵', function(){
// $.ajax({
// type: "POST",
// url: restServerBaseURL + "log/action/delete",
// 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 () {
debugger
// var beginDate = $("#Begin_Date").val();
// var endDate = $("#End_Date").val();
// var UserName = $("#UserName").val();
// var appid = $("#appidName").val();
// var actiontype = $("#actionType").val();
// var requestip = $("#requestip").val();
var tokenbinder = $("#tokenbinder").val();
var tokenstatus = $("#tokenstatus").val();
vm.showList = true;
var page = $("#jqGrid").jqGrid('getGridParam', 'page');
$("#jqGrid").jqGrid('setGridParam', {
postData: {
'tokenbinder': tokenbinder,
'tokenstatus': tokenstatus,
'identyinfo': ''
}, 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;
}
}