agent-backend/contracts/AppDataSource/naiveDAC/naiveDAC.js

56 lines
1.5 KiB
JavaScript
Raw Normal View History

2021-09-26 04:49:24 +00:00
var loadStatus = function(){
executeCurrentContract("isOwner","",onIsOwner);
};
var onIsOwner = function(data){
if (data.result=="true"){
console.log("isOnwer!");
flushApplylist();
flushAcceptlist();
$(".ownerDIV").css("display","block");
}
else {
$("#applyForm").css("display","block");
refreshMyStatus();
}
};
var flushAllList = function(){
flushApplylist();
flushAcceptlist();
}
var flushApplylist = function(){
executeCurrentContract("getApplyList","",onApplyList);
};
var flushAcceptlist = function(){
executeCurrentContract("getAcceptList","",onAcceptList);
};
var onApplyList = function(data){
global.applyList = JSON.parse(data.result);
fillApplyData(global.applyList);
};
var onAcceptList = function(data){
global.acceptList = JSON.parse(data.result);
fillAcceptList(global.acceptList);
};
var apply = function(){
var arg = $("#remarkInput")[0].value;
if (arg!=undefined && arg.length>0)
executeCurrentContract("apply",arg,onApplyResult);
else alert("备注不能为空");
};
var onApplyResult = function(data){
alert("申请结果:"+data.result);
};
var refreshMyStatus = function(){
var pubkey = global.sm2Key.publicKey;
executeCurrentContract("hasPermission","",onHasPermission);
};
var onHasPermission = function(data){
if (data.result=="null" || data.result=="false"){
$("#statusSpan")[0].innerHTML="暂无权限";
}
else {
$("#statusSpan")[0].innerHTML = "有权";
}
};
loadStatus();