119 lines
4.5 KiB
HTML
119 lines
4.5 KiB
HTML
<!DOCTYPE>
|
|
<html>
|
|
<head>
|
|
<title>BookSystem 添加图书</title>
|
|
{{Header}}
|
|
{{navcss}}
|
|
</head>
|
|
|
|
<body>
|
|
{{nav}}
|
|
<div>
|
|
<div id="error_panel" hidden></div>
|
|
<p>添加图书</p>
|
|
<p>ISBN: <input type="text" id="book_isbn" /></p>
|
|
<p>图书种类: <select id="book_type_select"></select> <a href="changebooktype.html">添加或删除图书种类</a></p>
|
|
<p>图书名称: <input type="text" id="book_name" /></p>
|
|
<p>作者: <input type="text" id="book_author" /></p>
|
|
<p>出版商: <input type="text" id="book_publish" /></p>
|
|
<p>出版日期: <input type="date" id="book_pubdate" /></p>
|
|
<p>状态:
|
|
<select id="book_status_select">
|
|
<option value=2>正常</option>
|
|
<option value=0>隐藏</option>
|
|
<option value=1>禁用</option>
|
|
</select>
|
|
</p>
|
|
<button id="b_confirm">添加图书</button>
|
|
<button id="b_cancel">取消</button>
|
|
</div>
|
|
|
|
<script>
|
|
$("button").button();
|
|
|
|
$("#error_panel").click(function(){
|
|
$("#error_panel").hide("");
|
|
});
|
|
|
|
mustLogin();
|
|
checkPermission(2,function() { GoBack(); } );
|
|
|
|
/// Fetch BookTypes
|
|
$.post("/cgi-bin/booksys/doGetBookTypes",function(data){
|
|
console.log("BookType Fetch Success");
|
|
if(data.success!=1) {
|
|
console.log("BookType Fetch not success.");
|
|
$("#book_type_select").append("<option>获取图书种类失败(服务错误)</option>");
|
|
} else {
|
|
$.each(data.result,function(n,val){
|
|
$("#book_type_select").append(
|
|
"<option>"+val+"</option>"
|
|
);
|
|
});
|
|
}
|
|
},"json").fail(function(err){
|
|
console.log("BookType Fetch Failed");
|
|
$("#book_type_select").append("<option>获取图书种类失败(一般错误)</option>");
|
|
});
|
|
|
|
/// Submit Data
|
|
$("#b_confirm").click(function(){
|
|
var error_panel=$("#error_panel");
|
|
|
|
error_panel.hide("",function(){
|
|
error_panel.text("正在提交...").removeClass();
|
|
createHighlight(error_panel);
|
|
error_panel.show("");
|
|
});
|
|
|
|
$.post("/cgi-bin/booksys/doAddBook",
|
|
{
|
|
book_isbn:$("#book_isbn").val(),
|
|
book_type:$("#book_type_select").find("option:selected").text(),
|
|
book_name:$("#book_name").val(),
|
|
book_author:$("#book_author").val(),
|
|
book_publish:$("#book_publish").val(),
|
|
book_pubdate:$("#book_pubdate").val(),
|
|
book_status:$("#book_status_select").val()
|
|
},
|
|
function(data) {
|
|
console.log("Confirm Ajax Success");
|
|
if(data.success==1) {
|
|
console.log("AddBook Success");
|
|
|
|
error_panel.hide("",function(){
|
|
error_panel.text("操作成功").removeClass();
|
|
createHighlight(error_panel);
|
|
error_panel.show("");
|
|
});
|
|
|
|
/// Reload Page
|
|
location.reload();
|
|
} else {
|
|
console.log("Failed to addbook.");
|
|
|
|
error_panel.hide("",function(){
|
|
error_panel.text("添加图书失败(服务错误)").removeClass();
|
|
createError(error_panel);
|
|
error_panel.show("");
|
|
});
|
|
}
|
|
},
|
|
"json").fail(function(err){
|
|
console.log("Confirm Ajax Failed");
|
|
|
|
error_panel.hide("",function(){
|
|
error_panel.text("添加图书失败(一般错误)").removeClass();
|
|
createError(error_panel);
|
|
error_panel.show("");
|
|
});
|
|
});
|
|
});
|
|
|
|
/// Cancel
|
|
$("#b_cancel").click(function(){
|
|
location.href="listbook.html";
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |