$(function () {
initSystemName();
initActionType();
var appid = getAppId() != null ? getAppId() : null;
var proxypath = "http://192.168.20.106:8066";
debugger
$("#jqGrid").jqGrid({
ajaxGridOptions: {
xhrFields: {
withCredentials: false
}
},
url: proxypath + '/token/selectTokenRecord',
datatype: "json",
colModel: [
{ label: '服务名称', name: 'SERVERNAME', index: 'SERVERNAME', width: 50, align: 'center' },
{ label: '申请使用系统', name: 'IDENTYINFO', index: 'IDENTYINFO', width: 50, align: 'center' },
{ label: '申请者ip', name: 'TOKENAPPLYER', index: 'TOKENAPPLYER', width: 50, align: 'center' },
{ label: '申请时间', name: 'APPLYTIME', index: 'APPLYTIME', width: 80, align: 'center' },
{ label: '申请使用时间(s)', name: 'EXPIRATION', index: 'EXPIRATION', width: 80, align: 'center' },
{
label: 'token串', name: 'TOKEN', index: 'TOKEN', width: 80, align: 'center'
},
{
label: 'token所属资源id', name: 'RESOURCEID', index: 'RESOURCEID', width: 80, align: 'center'
},
{ label: 'token信息', name: 'TOKENINFO', index: 'TOKENINFO', align: 'center', width: 50 },
{ label: 'token状态', name: 'TOKENSTATUS', index: 'TOKENSTATUS', align: 'center', width: 50 },
{ label: '自动续约', name: 'AUTOTOKEN', index: 'AUTOTOKEN', align: 'center', width: 50 },
{
label: '操作', name: 'right', index: 'right', align: 'center', width: 100, formatter: function (value, grid, rows, state) {
var id = rows.ID;
var obj = JSON.stringify(rows).replace(/\"/g, "'");
var template = `
`;
return template;
}
},
],
postData: { 'appid': appid },
viewrecords: true,
height: "auto",
rowNum: 10,
rownumbers: true,
rownumWidth: 50,
autowidth: true,
pager: "#jqGridPager",
jsonReader: {
root: "data",
page: "1",
total: "totalpage",
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 () {
vm.reload();
},
add: function () {
vm.showList = false;
vm.title = "鏂板";
vm.action = {};
},
update: function (resourceid, token) {
try {
$("body").remove($("#tokenPanel"));
}
catch (ex) { }
var template = `
`;
var content = `
`;
template = template.replace('customHtml', content)
$("body").append(template)
var modal = $("#tokenPanel")
modal.modal();
},
setToken() {
debugger
var Extendedtokens, Extendedtokenstime, times;
Extendedtokens = $("#tokenbh").val();
Extendedtokenstime = parseFloat($("#expiration").val());
times = parseFloat($("#times").val());
Extendedtokenstime = times * Extendedtokenstime;
$.ajax({
url: terraProxyUrl + '/token/tokenTimeExtend?tokenlist=' +
Extendedtokens + '&expireSeconds=' +
Extendedtokenstime,
type: 'post',
dataType: 'text',
success: function (data) {
if (data == "ok") {
alert("续期成功");
}
var modal = $("#tokenPanel")
modal.modal("hide");
try {
$("body").remove($("#tokenPanel"));
}
catch (ex) { }
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 (obj) {
// var actionids = { ID: id };
confirm('是否确认删除!', function () {
$.ajax({
type: "POST",
url: terraProxyUrl + '/token/delTokenRecord',
dataType: "text",
data: {
token: obj.TOKEN
},
success: function (r) {
if (r == "success") {
alert('删除成功', function () {
vm.reload();
});
} else {
alert(r.msg);
}
},
error: function (res, s, x) {
}
});
});
},
getInfo: function (actionid) {
$.get(restServerBaseURL + "log/action/info/" + actionid, function (r) {
vm.action = r.action;
});
},
reload: function () {
var resourceId = $("#RESOURCEID").val();
var token = $("#TOKEN").val();
var tokenstatus = $("#TOKENSTATUS").val();
var identyinfo = '';
var page = $("#jqGrid").jqGrid('getGridParam', 'page');
$("#jqGrid").jqGrid('setGridParam', {
postData: {
'resourceId': resourceId,
'token': token,
'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;
}
}