var onCloseCallFunName=undefined;var VPAGEFIN="circulation";var frequencyRows;var objfocus;var initJson;$(function(){initJson=[{key:"rdrtype",condition:"libcode",value:vLibcode},{code:"page_libcode,libcode,curlibcode",key:"libcode",condition:"code",value:vLibcode},{code:"rdrstatus",key:"rdrstatus"},{code:"page_sysid",key:"sysid"},{code:"finsearchfintype",key:"fintype"},{code:"finsearchrectype",key:"rectype"},{code:"finsearchpayway",key:"payway"}];_myPage.prototype.initData(initJson);$("#cirDataGridList").datagrid({onSelect:onSelectCirDataGridList,onDblClickRow:onDblClickCirDataGridListRow,rowStyler:rowCirOverdueStyler});$("#acqDataGridList").datagrid({onSelect:onSelectAcqDataGridList,onDblClickRow:onDblClickAcqFun});enterEvent("keyword",searchRdrRecord);enterEvent("barcode",serachBibOk);enterEvent("destoryMoney",destoryBook);enterEvent("curlostRate",lostBook);circurlationHandler(vType);initServiceSelect("1");initIndexCommbox();$(".easyui-panel").panel("resize");enterEvent("syear",getFocusToVolnum);enterEvent("svolnum",loanBookOK)});function getFrequencyList(){var a=base_path+"par/common/getInitData.do";var b={fmt:"entity",key:"frequency"};$.post(a,b,function(c){if(c.total>0){console.log(c);frequencyRows=c.rows}},"json")}function getFocusToVolnum(){$("#svolnum").numberbox("textbox").focus()}_myPage.prototype.onLoadSuccess=function(a,b){getPageConfig("page_type",callSetParaResult);_fmtGridDataRows=a};function callSetParaResult(c){if(c.status=="0"){var b=c.rows[0];var a=JSON.parse(b.paramjson);setValue("index",a.rdrSearchWay);setValue("bibindex",a.bookSearchWay);setJsonData("page_",a);setWebSocket(a)}}function initIndexCommbox(){var b={key:"bibindex"};var a=base_path+"par/common/getInitData.do";$.post(a,b,function(c){$("#bibindex").combobox({data:c.rows,valueField:"code",textField:"name",loadFilter:function(d){var e={};e={};e.code="SPM";e.name="商品码";d.splice(0,0,e);e={};e.code="SEPBAR";e.name="虚拟条码";d.splice(0,0,e);return d},onLoadSuccess:function(){$(this).combobox("select","ISBN")}});$("#page_bookSearchWay").combobox({data:c.rows,valueField:"code",textField:"name",onLoadSuccess:function(){$(this).combobox("select","ISBN")}})},"json")}function barReturnApp(){var a=base_path+"cir/speloan/return.do";var b={};b.loankey=getValue("barcode");$.post(a,b,function(c){if(c.status=="0"){var d=c.rows[0];updateDataGirdList(d);if(parseInt(getValue("curloan"))>0){setValue("curloan",parseInt(getValue("curloan"))-1)}}else{openCirMessageDlg(c.message,getFocusHoldins)}},"json")}function serachBibOk(){var e={};if(getValue("barcode").length==0){return openMessageDlg("检索值不能为空")}if(vType=="barreturn"){barReturnApp()}else{$("#tabsGrid").tabs("select",1);var c=0;var d=$("#acqDataGridList").datagrid("getSelected");if(d){c=$("#acqDataGridList").datagrid("getRowIndex",d)}var b=base_path+"lib/biblios/page.do";deleteGridData("acqDataGridList");e.rows=10;e.page=1;e.condition=getValue("bibindex");e.value=getValue("barcode");if(getValue("page_sysid").length>0){e["limit[0].condition"]="sysid";e["limit[0].value"]=getValue("page_sysid")}if(e.condition=="SPM"){if((e.value.length!=13&&e.value.length!=15)||e.value.toString().substr(0,3)!="977"){return openCirMessageDlg("无效的商品码",getFocusHoldins)}e.condition="ISBN"}if(getValue("page_libcode").length>0){e["limit[1].condition"]="libcode";e["limit[1].typeHandler"]="3";e["limit[1].value"]=getSqlConditionLimitIn(getValue("page_libcode"))}if(e.value.indexOf("|")>0){var a=e.value.split("|");if(a&&a.length>0){e.value=a[0]}}if(e.condition=="SEPBAR"){e={};b=base_path+"/cir/speloan/getBookInfoByVBar.do";e.vbarcode=getValue("barcode")}$("#acqDataGridList").datagrid({url:b,queryParams:e,onLoadSuccess:function(f){if(f.total==1){if(getValue("bibindex")=="SEPBAR"){$("#acqDataGridList").datagrid("selectRow",0);d=$("#acqDataGridList").datagrid("getSelected");loanBookOK(e.vbarcode,d)}else{$("#acqDataGridList").datagrid("selectRow",0);d=$("#acqDataGridList").datagrid("getSelected");speLoanOpenDlgFun(d,"svolnum")}}else{if(f.total>0){$("#acqDataGridList").datagrid("selectRow",c)}else{openCirMessageDlg("没有找到合适的数据!",getFocusHoldins)}}},method:"post"})}}function rowCirOverdueStyler(a,b){if(b.returndate0){c=""+c+'('+b.total+")"}$("#tabsGrid").tabs("update",{tab:a,options:{title:c}})}function searchHoldRecord(){var a=base_path+"hld/holding/getHoldingWithBib.do";var b={};if(getValue("barcode").length==0){return openCirMessageDlg("条码号不能为空",getFocusHoldins)}b.barcode=getValue("barcode");$.post(a,b,function(c){if(c.status=="0"){var d=c.rows[0];setJsonData(null,d);cirHandlerApp()}else{openCirMessageDlg(c.message,getFocusHoldins)}},"json")}function cirHandlerApp(){if(vType=="loan"){loanBook()}}function onDblClickAcqFun(a,b){if(getValue("bibindex")!="SEPBAR"){$.messager.confirm("提示消息","您确要借出你当前选中的书目吗?",function(c){if(c){speLoanOpenDlgFun(b,"syear")}})}}function speLoanOpenDlgFun(d,b){objfocus=b;setValue("syear","");setValue("svolnum","");var c={};c.condition=getValue("bibindex");c.value=getValue("barcode");if(c.condition=="SPM"&&(c.value.length==13||c.value.length==15)){if(c.value.length==13){setValue("syear","20"+c.value.substring(10,12))}if(c.value.length==15){setValue("syear","20"+c.value.substring(10,12));setValue("svolnum",c.value.substring(13,15))}}else{if(c.value.indexOf("|")>0){var a=c.value.split("|");if(a&&a.length>1){setValue("syear",a[1])}if(a&&a.length>2){setValue("svolnum",a[2])}}else{setValue("syear",getCurDateYMD().substring(0,4));getBibOrderInfo(d)}}$("#loanBookDlg").dialog("open")}function getBibOrderInfo(c){var b={};b.bibid=c.id;var a=base_path+"per/order/page.do";$.post(a,b,function(e){if(e.status=="0"){var f=e.rows[0];if(f){setValue("syear",f.orderyear);if(f.issuenum){var d=getVolnumByFrequency(f.issuenum);setValue("svolnum",d)}}}else{openMessageDlg(e.message)}},"json")}function getVolnumByFrequency(b){var a=new Date();var c=a.getMonth()+1;if(b=="1"){return b}if(b=="2"){if(c>6){return 1}return 2}if(b=="4"){if(c>9){return 4}if(c>6){return 3}if(c>3){return 2}return 1}if(b=="6"){return Math.floor(c/2)}if(b=="12"){return c+1}if(b=="24"){return c*2}if(b=="36"){return c*3}if(b=="52"){return getWeek()}if(b=="365"||b=="366"){return getDays()}return 1}function getWeek(){var b,a,c=new Date();c.setDate(c.getDate()+4-(c.getDay()||7));b=c.getTime();c.setMonth(0);c.setDate(1);a=Math.floor(Math.round((b-c)/86400000)/7)+1;return a}function getDays(){var a,c,b=new Date();b.setDate(b.getDate()+4-(b.getDay()||7));a=b.getTime();b.setMonth(0);b.setDate(1);c=Math.floor(Math.round((a-b)/86400000))+1;return c}function onOpenLoanBookDlg(){if(objfocus&&objfocus=="svolnum"){$("#svolnum").textbox("textbox").focus()}else{$("#syear").numberbox("textbox").focus()}}function loanBookOK(b,e){var c=base_path+"cir/speloan/loan.do";var d={};if(getValue("rdrno").length==0){return openCirMessageDlg("读者证号不能为空",getFocusReader)}d.rdrno=getValue("rdrno");d.bibid=getValue("id");d.loankey=getValue("barcode");d.location=getValue("service");if(!b){if(d.loankey.indexOf("|")>0){var a=d.loankey.split("|");if(a&&a.length>0){d.loankey=a[0]}}if(getValue("syear").length>0){d.loankey=d.loankey+"|"+getValue("syear")}if(getValue("svolnum").length>0){d.loankey=d.loankey+"|"+getValue("svolnum")}}else{d.bibid=e.bibid}$.post(c,d,function(f){if(f.status=="0"){$("#loanBookDlg").dialog("close");$("#tabsGrid").tabs("select",0);var g=f.rows[0];updateDataGirdList(g);setValue("curloan",parseInt(getValue("curloan"))+1)}else{openCirMessageDlg(f.message,getFocusHoldins)}},"json")}function loanBook(){var a=base_path+"cir/speloan/loan.do";var b={};if(getValue("rdrno").length==0){return openCirMessageDlg("读者证号不能为空",getFocusReader)}b.rdrno=getValue("rdrno");b.bibid=getValue("bibid");b.location=getValue("service");$.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 returnBookRecordResult(b){var a=base_path+"cir/speloan/return.do";var d={};var c=$("#cirDataGridList").datagrid("getSelected");if(c){d.id=c.id;$.post(a,d,function(e){if(e.status=="0"){var f=e.rows[0];updateDataGirdList(f);if(parseInt(getValue("curloan"))>0){setValue("curloan",parseInt(getValue("curloan"))-1)}}else{openCirMessageDlg(e.message,getFocusHoldins)}},"json")}}function barRenewBook(){if(getValue("barcode").length==0){return openCirMessageDlg("条码号不能为空",getFocusHoldins)}renewBookRecordResult()}function renewBookRecordResult(a){var b=base_path+"cir/speloan/renew.do";var d={};var c=$("#cirDataGridList").datagrid("getSelected");if(c){d.id=c.id;$.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/speloan/damage.do";var b={};b.id=c.id;b.money=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","");$("#lostHandlerDlg").window("open")}function onOpenLostDlg(){$("#curlostRate").textbox("textbox").focus()}function lostBook(){if(parseFloat(getValue("service"))>0){var c=$("#cirDataGridList").datagrid("getSelected");var a=base_path+"cir/speloan/lost.do";var b={};b.id=c.id;b.money=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 updateDataGirdList(a){getCirDataGridList(a.rdrid);setValue("index","rdrno");setValue("keyword",a.rdrno);searchRdrRecord(a);insertCirResultDataGridListRow(a)}function getCirDataGridList(b){getComCirDataGridList(b);getSepCirDataGridList(b);var a=base_path+"cir/speloan/pageCurLoan.do";var c={};setValue("curloan","0");clearGridData("cirDataGridList");c.rows=10;c.page=1;c.rdrid=b;c.location=getValue("service");$("#cirDataGridList").datagrid({url:a,queryParams:c,onLoadSuccess:function(e){var d=$("#tabsGrid").tabs("getTab",0);updateTabsTitle(d,"专项外借",e);if(e.total>0){setValue("curloan",e.total)}},method:"post"})}function getSepCirDataGridList(b){createSepGridList();var a=base_path+"cir/speloan/pageCurLoan.do";a=base_path+"cir/speloan/listUnion.do";var c={};clearGridData("sepDataGridList");c.rows=10;c.page=1;c["limit[0].condition"]="rdrid";c["limit[0].typeHandler"]="0";c["limit[0].value"]=b;c["limit[1].condition"]="location";c["limit[1].typeHandler"]="8";c["limit[1].value"]=getValue("service");$("#sepDataGridList").datagrid({url:a,queryParams:c,onLoadSuccess:function(e){var d=$("#tabsGrid").tabs("getTab",3);updateTabsTitle(d,"其他借阅列表",e)},method:"post"})}function createSepGridList(){var b=[{field:"libcode",title:"文献所属馆",formatter:onShowLibName,width:80},{field:"loankey",title:"借阅词条",width:100},{field:"loandate",title:"借出日期",formatter:onShowFmtDate,width:80},{field:"loantime",title:"借出时间",formatter:onShowFmtDate,width:80},{field:"returndate",title:"字段代码",formatter:onShowLibName,width:80},{field:"renewnum",title:"续借次数",width:60},{field:"title",title:"题名",width:200},{field:"isbn",title:"续借次数",width:80},{field:"author",title:"ISBN号",width:100},{field:"price",title:"价格",width:60}];var a=$("#sepDataGridList");if(!a.attr("class")){a.datagrid({iconCls:"e-icon fa fa-table",title:"",fit:true,fitColumns:true,singleSelect:true,border:false,nowrap:false,pagination:true,striped:true,onClickRow:onClickEditorRow,columns:[b]})}}function getFocusByPara(){var b=getValue("page_barcodetordrno");if(b>0){var a=parseInt(b);setTimeout(getFocusBarcodeToRdrno,a)}}function getFocusBarcodeToRdrno(){circurlationHandler("借出")}function focusToTextByType(a){$("#keyword").next().show();$("#index").next().show();$("#barcode").next().hide();$(".loan-barcode-tip").hide();$("#keyword").textbox("textbox").focus().select();$("#bibindex").combobox({disabled:false});if(a=="barreturn"){$("#keyword").next().hide();$("#index").next().hide();$("#barcode").next().show();$(".loan-barcode-tip").show();setValue("bibindex","SEPBAR");$("#barcode").textbox("textbox").focus().select();$("#bibindex").combobox("disable")}}function getFocusBarCode(){if(vType=="loan"){$("#barcode").next().show();$(".loan-barcode-tip").show();$("#barcode").textbox("textbox").focus().select()}}function getFocusHoldins(){$("#barcode").textbox("textbox").focus().select()}function getFocusReader(){$("#keyword").textbox("textbox").focus().select();$("#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 setPara(){onSerachRdrBarcode();$("#pageconfig_setpara_dlg").window("open")}function onSerachRdrBarcode(){clearGridData("rdrBarcodeDataGridList,holdBarcodeDataGridList");var a=base_path+"par/common/getInitData.do?key=barformat&type=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&type=type&value=0";var b={};$("#holdBarcodeDataGridList").datagrid({url:a,queryParams:b,onLoadSuccess:function(c){},method:"post"})};