var onCloseCallFunName=undefined;var VPAGEFIN="circulation";var initJson;var cirContorller=function(){};$(function(){cirContorller.prototype.init();cirContorller.prototype.bind()});cirContorller.prototype.bind=function(){enterEvent("keyword",searchRdrRecord);enterEvent("barcode",searchHoldRecord);circurlationHandler(vType);autoSearchInfo()};cirContorller.prototype.init=function(){cirContorller.prototype.initConfig();cirContorller.prototype.initView()};cirContorller.prototype.initConfig=function(){initJson=[{key:"rdrtype"},{code:"libcode,biblibcode,curlibcode,formatdesign_libcode",key:"libcode"},{code:"rdrstatus",key:"rdrstatus"},{code:"finsearchfintype",key:"fintype"},{code:"finsearchrectype",key:"rectype"},{code:"finsearchpayway",key:"payway"},{code:"formatdesign_operid",key:"operid"}];_myPage.prototype.getLoadData(initJson)};_myPage.prototype.getLoadSuccess=function(a,b){_fmtGridDataRows=a;getPageConfig("page_type",callSetParaResult,"cirLoanRetu")};cirContorller.prototype.initView=function(){var a=$(window).height();var c=$(".loan-table-input").width();var d=a-40;$(".cir-circulation").css("height",d+"px");var b=$("#cirlayout").layout("panel","south");b.panel("resize",{height:(d-240)+"px"});$(".easyui-layout").layout("resize");$(".easyui-panel").panel("resize")};cirContorller.prototype.config=function(){var a="../circulation/com/cir_pageconfig.jsp";var b=$("#pageconfig_setpara_dlg").dialog({href:a,onLoad:function(){cirConfig.prototype.init()}}).dialog("open")};function noCardCheck(){$("#noCardDlg").dialog("open");toNoCardRdrno();enterEvent("noCardRdrno",toNoCardPwd);enterEvent("noCardPwd",checkNoCardRdr);setValue("noCardRdrno","");setValue("noCardPwd","")}function toNoCardRdrno(){$("#noCardRdrno").textbox("textbox").focus().select()}function toNoCardPwd(){$("#noCardPwd").textbox("textbox").focus().select()}function checkNoCardRdr(){var a=base_path+"cir/reader/noCardCir.do";var b={};b.rdrno=getValue("noCardRdrno");b.password=getValue("noCardPwd");if(!b.rdrno){return openCirMessageDlg("读者证号不能为空",toNoCardRdrno)}if(!b.password){return openCirMessageDlg("读者密码不能为空",toNoCardPwd)}$.post(a,b,function(c){if(c.status=="0"){$("#noCardDlg").dialog("close");setValue("keyword",c.rows[0].rdrno);searchRdrRecord(null,"rdrno")}else{openCirMessageDlg(c.message,toNoCardRdrno)}},"json")}function cirRdrList(){$("#cirRdrListDlg").dialog("open");var a=mystorage.get("cir_log_rdrlist");var c="
暂无操作记录
";if(a){c="";for(var b=a.length;b>0;b--){c+=""+a[b-1].time+",读者姓名:"+a[b-1].name+",读者证号"+a[b-1].rdrno+"
"}}$(".cirRdrListBox").html(c)}function cirRdrListOnClick(a){$("#cirRdrListDlg").dialog("close");setValue("keyword",a);searchRdrRecord(null,"rdrno")}function addCirRrdList(e){var f=e.rows[0];if(!f){return}var b=mystorage.get("cir_log_rdrlist");var a;if(!b){b=[];a={rdrno:f.rdrno,name:f.name,time:showCurTime()}}else{var d=false;for(var c=0;c0){$("#fin_debt_dlg").window("open");searchDepositGridList(f,"debt")}searchRdrRecordResult(e)}else{if(e.total>0){searchRdrRecordResult(e)}openCirMessageDlg(e.message,getFocusReader)}}addCirRrdList(e)},"json")}function searchRdrRecordResult(a){var b=a.rows[0];setJsonData(null,b);setValue("rdrstatus",b.status);setValue("rdrid",b.id);getCirDataGridList(b.id)}function searchHoldRecord(){var a=base_path+"hld/holding/getHoldingWithBib.do";var b={};if(getValue("barcode").length==0){return circurlationHandler("loan")}b.barcode=getValue("barcode");$.post(a,b,function(c){if(c.status=="0"){var d=c.rows[0];d.libcode=getValue("libcode");setJsonData(null,d);cirHandlerApp()}else{openCirMessageDlg(c.message,getFocusHoldins)}},"json")}function cirHandlerApp(){if(vType=="loan"){loanBook()}else{if(vType=="return"){returnBook()}else{if(vType=="barrenew"){barRenewBook()}else{if(vType=="close"){var a=getValue("return_date");if(a.length==0){return openMessageDlg("请设置闭馆还书日期!")}returnBook(a)}}}}}function loanBook(){var a=base_path+"cir/circulation/loan.do";var b={};if(getValue("rdrno").length==0){return openCirMessageDlg("读者证号不能为空",getFocusReader)}b.rdrno=getValue("rdrno");b.barcode=getValue("barcode");$.post(a,b,function(c){if(c.status=="0"){var d=c.rows[0];updateDataGirdList(d);setValue("curloan",parseInt(getValue("curloan"))+1)}else{openCirMessageDlg(c.message,getFocusHoldins)}},"json")}function returnBook(b){var a=base_path+"cir/circulation/return.do";var c={};if(getValue("barcode").length==0){return openCirMessageDlg("条码号不能为空",getFocusHoldins)}if(b){c.return_date=b}c.barcode=getValue("barcode");$.post(a,c,function(d){if(d.status=="0"){var e=d.rows[0];updateDataGirdList(e);if(parseInt(getValue("curloan"))>0){setValue("curloan",parseInt(getValue("curloan"))-1)}if(e.status=="3"){openCirMessageDlg(d.message+",该书已经被预约,请下架放到预约处!")}}else{openCirMessageDlg(d.message,getFocusHoldins)}},"json")}function barRenewBook(){if(getValue("barcode").length==0){return openCirMessageDlg("条码号不能为空",getFocusHoldins)}renewBookRecordResult(getValue("barcode"))}function renewBookRecordResult(a){var b=base_path+"cir/circulation/renew.do";var d={};if(a){d.barcode=a}else{var c=$("#cirDataGridList").datagrid("getSelected");d.barcode=c.barcode}$.post(b,d,function(e){if(e.status=="0"){var f=e.rows[0];updateDataGirdList(f)}else{openCirMessageDlg(e.message,getFocusHoldins)}},"json")}function destoryBookRecordResult(){var a=$("#cirDataGridList").datagrid("getSelected");setValue("bibPrice",a.price);setValue("destoryMoney","");$("#destoryHandlerDlg").window("open")}function onOpenDestoryDlg(){$("#destoryMoney").textbox("textbox").focus()}function destoryBook(){if(getValue("destoryMoney")>0){var c=$("#cirDataGridList").datagrid("getSelected");var a=base_path+"cir/circulation/damage.do";var b={};b.barcode=c.barcode;b.damageMoney=getValue("destoryMoney");$.post(a,b,function(d){if(d.status=="0"){$("#destoryHandlerDlg").window("close");var e=d.rows[0];updateDataGirdList(e)}else{openCirMessageDlg(d.message,getFocusHoldins)}},"json")}else{openMessageDlg("要设置的污损罚款必须大于0")}}function lostBookRecordResult(){var a=$("#cirDataGridList").datagrid("getSelected");setValue("lostBibPrice",a.price);setValue("curlostRate","");getLostFinRate();$("#lostHandlerDlg").window("open")}function getLostFinRate(){var c=$("#cirDataGridList").datagrid("getSelected");var a=base_path+"cir/circulation/getLoanRule.do";var b={};b.doctype=c.doctype;b.curlocation=c.curlocation;b.rdrtype=getValue("rdrtype");$.post(a,b,function(e){if(e.status=="0"){var f=e.rows[0];var d=JSON.parse(f.paramjson);setValue("lostMinRate",d.zui_xiao_fa_bei);setValue("lostMaxRate",d.zui_da_fa_bei)}else{openCirMessageDlg(e.message,getFocusHoldins)}},"json")}function onOpenLostDlg(){$("#curlostRate").textbox("textbox").focus()}function lostBook(){if(parseFloat(getValue("curlostRate")).toFixed(2)>=getValue("lostMinRate")&&parseFloat(getValue("curlostRate")).toFixed(2)<=getValue("lostMaxRate")){var c=$("#cirDataGridList").datagrid("getSelected");var a=base_path+"cir/circulation/lost.do";var b={};b.barcode=c.barcode;b.rate=getValue("curlostRate");$.post(a,b,function(d){if(d.status=="0"){$("#lostHandlerDlg").window("close");var e=d.rows[0];updateDataGirdList(e)}else{openCirMessageDlg(d.message,getFocusHoldins)}},"json")}else{openMessageDlg("要设置的罚款倍率必须大于等于最小罚款倍率并且小于等于最大罚款倍率")}}function insertCirResultDataGridListRow(d){var a="";if(d.debt_1>0){a+="有图书过期["+d.overdays+"]天,共产生罚款["+d.debt_1+"]元。"}if(d.stopdate&&d.stopdate>0){a+="有图书过期["+d.overdays+"]天,停借到["+d.stopdate+"]。"}if(d.debt_2>0){a+="污损处理,共产生罚款["+d.debt_2+"]元。"}if(d.debt_3>0){a+="丢失处理,共产生罚款["+d.debt_3+"]元。"}if(d.debt_1>0||d.debt_2>0||d.debt_3>0){d.id=d.rdrid;if(vType!="return"||(vType=="return"&&(cirConfigParamjson&&cirConfigParamjson.handlerfin&&cirConfigParamjson.handlerfin==0))){$("#fin_debt_dlg").window("open");searchDepositGridList(d,"debt")}}var b="";if(d.opertype=="借出"){b="color: #ee7621;"}else{if(d.opertype=="还回"){b="color: #00CD66;"}else{b="color: #ff66d5;"}}if($("#jifenchuli").length>0){if(d.bonus){a+="获得"+d.bonus+"分。"}if(d.over_bonus){a+="超期处罚"+d.over_bonus+"分。"}if(d.bonus_message){a+=d.bonus_message}}var c="["+d.opertype+"]—{"+d.returndate+"(还)}"+a+"—{"+d.rdrno+":"+d.name+"}—{"+d.barcode+":"+d.callno+"—"+d.title+":"+d.author+"}";d.note=''+c+"
";$("#cirResultDataGridList").datagrid("insertRow",{index:0,row:d})}function updateDataGirdList(a){getCirDataGridList(a.rdrid);setValue("index","rdrno");setValue("keyword",a.rdrno);searchRdrRecord(a);insertCirResultDataGridListRow(a)}function getCirDataGridList(b){getSepCirDataGridList(b);var a=base_path+"hld/holding/listHoldingWithBib.do";var c={};clearGridData("cirDataGridList");c.rows=10;c.page=1;c.rdrid=b;$("#cirDataGridList").datagrid({url:a,queryParams:c,onLoadSuccess:function(e){var d=$("#cir_tabsGrid").tabs("getTab",0);updateTabsTitle(d,"现借列表",e)},method:"post"})}function getSepCirDataGridList(b){createSepGridList();var a=base_path+"cir/speloan/pageCurLoan.do";var c={};clearGridData("sepDataGridList");c.rows=10;c.page=1;c.rdrid=b;$("#sepDataGridList").datagrid({url:a,queryParams:c,onLoadSuccess:function(e){var d=$("#cir_tabsGrid").tabs("getTab",1);updateTabsTitle(d,"其他借阅列表",e)},method:"post"})}function updateTabsTitle(a,c,b){if(b.total>0){c=""+c+'('+b.total+")"}$("#cir_tabsGrid").tabs("update",{tab:a,options:{title:c}})}function getFocusByPara(){if(cirConfigParamjson&&cirConfigParamjson.barcodetordrno){var b=cirConfigParamjson.barcodetordrno;if(b>0){var a=parseInt(b);setTimeout(getFocusBarcodeToRdrno,a)}}}function getFocusBarcodeToRdrno(){circurlationHandler("借出")}function focusToTextByType(a){if(a=="return"||a=="barrenew"||a=="close"){$("#index").next().hide();$("#keyword").next().hide();getFocusBarCode()}else{$("#keyword").next().show();$("#index").next().show();$("#barcode").next().hide();$(".loan-barcode-tip").hide();$("#keyword").textbox("textbox").focus().select()}}function getFocusBarCode(){if(vType=="return"||vType=="barrenew"||vType=="loan"||vType=="close"){$("#barcode").next().show();$(".loan-barcode-tip").show();getFocusHoldins();if(vType=="close"){$(".returndate-div").show()}}}function getFocusHoldins(){setValue("barcode","");$("#barcode").textbox("textbox").focus().select()}function getFocusReader(){$("#keyword").textbox("textbox").focus().select();setValue("barcode","");$("#barcode").next().hide();$(".loan-barcode-tip").hide()}function openCirMessageDlg(b,a){$("#circulationTipDlg").dialog("open");$(".circulation-message-body").html(b);$(".iKnow-close").focus();onCloseCallFunName=a}function onCloseCirTipDlg(){if(onCloseCallFunName){onCloseCallFunName()}}function iKnow(){$("#circulationTipDlg").dialog("close")}function onSerachRdrBarcode(){clearGridData("rdrBarcodeDataGridList,holdBarcodeDataGridList");var a=base_path+"par/common/getInitData.do?key=barformat&condition=type&value=1";var b={};$("#rdrBarcodeDataGridList").datagrid({url:a,queryParams:b,onLoadSuccess:function(c){},method:"post"});a=base_path+"par/common/getInitData.do?key=barformat&condition=type&value=0";var b={};$("#holdBarcodeDataGridList").datagrid({url:a,queryParams:b,onLoadSuccess:function(c){},method:"post"})}function callSetParaResult(c){if(c.status=="0"){var b=c.rows[0];var a=JSON.parse(b.paramjson);setValue("index",a.initindex);setJsonData("page_",a);setWebSocket(a)}}function onJumpRdrPage(){if(getValue("keyword").length>0){mystorage.set("rdr_index",getValue("index"));mystorage.set("rdr_keyword",getValue("keyword"))}parent.addTab("读者数据管理","circulation/new_reader.jsp","vcard","4201","no")}function autoSearchInfo(){var b=mystorage.get("cir_keyword");var a=mystorage.get("cir_index");if(b){mystorage.set("cir_index",null);mystorage.set("cir_keyword",null);setValue("keyword",b);searchRdrRecord(null,a)}};