130 lines
5.1 KiB
HTML
130 lines
5.1 KiB
HTML
<!DOCTYPE>
|
|
<html>
|
|
<head>
|
|
<title>BookSystem 图书详情页</title>
|
|
{{Header}}
|
|
{{navcss}}
|
|
</head>
|
|
|
|
<body>
|
|
{{nav}}
|
|
|
|
<div>
|
|
<div>
|
|
<p>图书名称: <b id="book_name"></b> </p>
|
|
<p>ISBN号: <b id="book_isbn"></b> </p>
|
|
<p>类别: <b id="book_type"></b> </p>
|
|
<p>作者: <b id="book_author"></b> </p>
|
|
<p>出版社: <b id="book_publisher"></b> </p>
|
|
<p>出版日期: <b id="book_pubdate"></b> </p>
|
|
</div>
|
|
|
|
<div id="admin_op_panel" class='admin_op' hidden>
|
|
<table border="1">
|
|
<tr>
|
|
<th>管理员操作列表</th>
|
|
</tr>
|
|
<tr><td><p><a id="admin_op_panel_edit">修改图书信息</a></p></td></tr>
|
|
<tr><td><p><a id="admin_op_panel_remove">删除图书信息</a></p></td></tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div>
|
|
<table border="1" id="result_table">
|
|
<tr>
|
|
<th>图书实体号</th>
|
|
<th>存放位置</th>
|
|
<th>状态</th>
|
|
<th>操作</th>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="js_event_box"></div>
|
|
|
|
<script>
|
|
var id=window.location.href.split("=")[1];
|
|
|
|
console.log("ID is ",id);
|
|
if(isNaN(parseInt(id))){
|
|
console.log("Cannot Parse.");
|
|
history.go(-1);
|
|
location.reload();
|
|
}
|
|
|
|
/// Fix Link
|
|
$("#admin_op_panel_edit").attr("href","editbook.html?id="+id);
|
|
$("#admin_op_panel_remove").attr("href","removebook.html?id="+id);
|
|
|
|
mustLogin();
|
|
|
|
/// Check Permission (ViewControl)
|
|
$.post("/cgi-bin/booksys/doCheckPermission",{required:2},function(data){
|
|
console.log("Check Permission Ajax Success");
|
|
if(data.success==1) {
|
|
console.log("ViewControl: Permission Fit");
|
|
$(".admin_op").removeAttr("hidden");
|
|
}
|
|
},"json").fail(function(err){
|
|
console.log("Failed to fetch permission. Ajax Failed.");
|
|
});
|
|
|
|
/// Fetch Book Data
|
|
$.post("/cgi-bin/booksys/doViewBook",{id:id},function(data){
|
|
console.log("Fetch Done.");
|
|
if(data.success==1) {
|
|
console.log("Success!");
|
|
$("#book_name").text(data.book_name);
|
|
$("#book_isbn").text(data.book_isbn);
|
|
$("#book_type").text(data.book_type);
|
|
$("#book_author").text(data.book_author);
|
|
$("#book_publisher").text(data.book_publisher);
|
|
$("#book_pubdate").text(data.book_pubdate);
|
|
} else {
|
|
console.log("Failed");
|
|
}
|
|
|
|
},"json").fail(function(err){
|
|
console.log("Fetch Error: ",err);
|
|
});
|
|
|
|
/// Fetch Book Obj Data
|
|
$.post("/cgi-bin/booksys/doGetBookStatus",{id:id},function(data){
|
|
console.log("Fetch Status Done.");
|
|
if(data.success==1) {
|
|
console.log("Fetch Status Success");
|
|
var cnt_val=0;
|
|
$.each(data.result,function(n,val) {
|
|
cnt_val++;
|
|
$("#result_table").append(
|
|
"<tr><td>"+
|
|
val.obj_id+
|
|
"</td><td>"+
|
|
val.book_pos+
|
|
"</td><td>"+
|
|
(val.book_status==0?"已借出":val.book_status==1?"丢失":val.book_status==2?"在馆":"未知")+
|
|
"</td><td>"+
|
|
(val.book_status==2?"<p><a href='borrowbook.html?bid="+val.obj_id+"'>借阅</a></p>":" ")+
|
|
"<p><a href='editbookobj.html?bid="+val.obj_id+"' class='admin_op' hidden>修改图书实体信息</a></p> "+
|
|
"<p><a href='removebookobj.html?bid="+val.obj_id+"' class='admin_op' hidden>删除图书实体</a></p> "+
|
|
"</td></tr>"
|
|
);
|
|
});
|
|
if(cnt_val==0) {
|
|
$("#result_table").append("<tr><td colspan='4'>无图书实体信息</tr>");
|
|
}
|
|
|
|
$("#result_table").append("<tr><td colspan='4'><a href='addbookobj.html?id="+id+"'>添加图书实体</a></tr>");
|
|
} else {
|
|
console.log("Fetch Status Failed");
|
|
$("#result_table").append("<tr><td colspan='4'>查找图书失败(标准错误)</tr>");
|
|
}
|
|
},"json").fail(function(err){
|
|
console.log("Fetch Status Failed, error:",err);
|
|
$("#result_table").append("<tr><td colspan='4'>查找图书失败(服务器错误)</tr>");
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |