var initflag;var initJson;var auto_callno;$(function(){initflag="page_,hold_";initJson=[{key:"sysid",condition:"type",value:vType},{key:"ctrlno",condition:"libcode",value:vLibcode},{key:"z3950",condition:"libcode",value:vLibcode},{key:"bookseller",condition:"libcode",value:vLibcode},{key:"location",condition:"libcode",value:vLibcode},{key:"doctype",condition:"libcode",value:vLibcode},{key:"libcode",condition:"code",value:vLibcode}];$("#holdDataGridList").datagrid({onDblClickRow:updateHoldings});$(".order_batchno").hide();$(".check_batchno").hide();$(".bind_batchno").hide();$("#acqDataGridList").datagrid("showColumn","status")});function checkBarcodeRepeat(){var a=getValue("hold_barcode");var c=getValue("hold_id");if(c.length==0||c=="0"){if(a>=0){var b=base_path+"hld/holding/getCheckHoldBarcode.do";var d={};d.barcode=a;$.post(b,d,function(e){if(e.status=="0"){if(e.total>0){openMessageDlg("条码号已存在,请重新输入")}}else{openMessageDlg(e.message)}},"json")}}}function onCloseMessageFun(){if($(".global-message-body").html()=="条码号已存在,请重新输入"){$("#hold_barcode").textbox({prompt:"条码号["+getValue("hold_barcode")+"]已存在,请重新输入"});setValue("hold_barcode","");$("#hold_barcode").textbox("textbox").focus();$("#hold_barcode").textbox("textbox").blur(function(a){checkBarcodeRepeat()})}}function closeHoldDlg(){setValue("hold_barcode","");$("#hold_dlg").dialog("close")}function onSelectTabsGrid(b,a){if(a==1){$("#deleteHoldRecord").show()}else{$("#deleteHoldRecord").hide()}}function updateHoldings(b,a){onHandlerHoldingsRecord(a)}function onHandlerHoldingsRecord(c){var a="馆藏处理";$("#hold_barcode").textbox({prompt:"请输入条码号"});$("#hold_barcode").textbox("textbox").blur(function(f){checkBarcodeRepeat()});cleanJsonData("hold_record");if(!c){var d=$("#acqDataGridList").datagrid("getSelected");if(!d){return openMessageDlg("请先选择一条书目数据,进行新增馆藏")}if(!d.classno){return openMessageDlg("你要进行馆藏处理的书目信息没有分类号,请完善书目信息才能进行馆藏处理!")}getCallnoToCheckCallno(d);var b=getCurDateYMD();setValue("hold_id","");setValue("hold_senddate",b);setHoldTextByBibData(d,"hold_");$(".hold_tip").html("提示:请您确认当前要处理的书目数据记录号【"+d.id+"】");bibDataToDlgData(d,"hold_",a)}else{$(".hold_tip").html("");gridDataToDlgData(c,"hold_",a)}}function setHoldTextByBibData(k,g){try{if(k.price){var c=/(\d{1,3})+(?:\.\d+)?/g;var h=k.price.match(c);setValue(""+g+"price",h[0]);setValue(""+g+"totalprice",h[0])}if(!k.page){setValue(g+"volumenum",1)}else{var c=/(\d{1,3})+(?:\.\d+)?/g;var h=k.page.match(c);var b=/[\u4e00-\u9fa5]/g;var f=k.page.match(b);var j=0;for(var a=0;a-1){j+=parseInt(h[a])}}}}if(j>0){setValue(g+"volumenum",j)}else{setValue(g+"volumenum",1)}}}catch(d){}}function saveHoldingsRecord(){var a=getJsonData("hold_","record");if(!getValue("page_sysid")){openMessageDlg("请在设置中选择分系统");return}if(!a){openMessageDlg("记录异常");return}if(!a.barcode){openMessageDlg("条码号不能为空!");return}if(!a.price){openMessageDlg("价格不能为空!");return}if(!a.doctype){openMessageDlg("文献类型不能为空!");return}if(!a.location){openMessageDlg("馆藏地点不能为空!");return}var e=$("#holdDataGridList").datagrid("getSelected");var d;if(e){d=$("#holdDataGridList").datagrid("getRowIndex",e)}a.sysid=getValue("page_sysid");if(auto_callno){a.auto_callno=auto_callno}var c=getValue("hold_id");var b=base_path+"hld/holding/saveHolding.do";$.post(b,a,function(f){if(f.status=="0"){holdDataGridListByBibId(f.rows[0].bibid,"hold",d);openMessageDlg(f.message,5000);$("#hold_dlg").dialog("close");$("#tabsGrid").tabs("select",1)}else{openMessageDlg(f.message)}},"json")}function onOpenholdDlg(){$("#hold_barcode").textbox("textbox").focus()}function setCheckCallNo(){var b={};var a=getValue("hold_callno");if(a.length>0&&a.substr(a.length-1,1)=="/"){b=$("#acqDataGridList").datagrid("getSelected");a=a.substr(0,a.length-1);b.classno=a;getCallnoToCheckCallno(b)}else{openMessageDlg("格式为[分类号/]的才能分配索书号,例:A1/")}}function getCallnoToCheckCallno(a){var b=base_path+"cat/titlenum/getCurCallno.do";var c={};c.classno=a.classno;c.bibid=!a.bibid?a.id:a.bibid;$.post(b,c,function(e){if(e.status=="0"){if(e.total==0){setValue("hold_callno",a.classno+"/1")}else{var d=e.rows[0];auto_callno=d.auto_callno;if(d.classno){setValue("hold_callno",d.classno+"/"+d.titnum)}}}else{openMessageDlg(e.message)}},"json")}function gridDataToDlgData(c,a,d){var b=$('[item-type="'+a+'record"]');b.each(function(e,g){var f=g.id.replace(a,"");if(c[f]){setValue(g.id,c[f])}});$("#"+a+"dlg").dialog("setTitle",d);$("#"+a+"dlg").dialog("open")}function bibDataToDlgData(d,b,c){setValue(""+b+"id","0");if(!d){return openMessageDlg("请先选择一条数据,进行馆藏处理")}var a=$('[item-type="page_paramjson"]');setValue(""+b+"libcode",vLibcode);setValue(""+b+"bibid",d.id);a.each(function(f,g){var e=getValue(g.id);var i=""+b+""+g.id.replace("page_","");var h=$("#"+i);if(h){if(g.id=="page_binding"){setValue("hold_bindtype",e)}else{setValue(i,e)}}});$("#"+b+"dlg").dialog("setTitle",c);$("#"+b+"dlg").dialog("open")}function onSelectAcqDataGridList(b,a){if(!isUpdateByLibcode(a.libcode)){setBntIsShowByLibcode(true)}else{setBntIsShowByLibcode(false);if(a.status=="1"){$("#saveBibRecord").linkbutton({disabled:true});$("#deleteBibRecord").linkbutton({disabled:true});$("#appendRecord").linkbutton({disabled:true});$("#insertRow").linkbutton({disabled:true});$("#removeit").linkbutton({disabled:true});$("#editBibGrid").datagrid({title:"已审校的书目数据不可编辑"})}else{$("#saveBibRecord").linkbutton({disabled:false});$("#deleteBibRecord").linkbutton({disabled:false});$("#appendRecord").linkbutton({disabled:false});$("#insertRow").linkbutton({disabled:false});$("#removeit").linkbutton({disabled:false});$("#editBibGrid").datagrid({title:"未审校的书目数据"})}}setValue("bibStatus",a.status);bindAcqDataGridDetailById(a.id);getInitGridDataByBibId(a.id)}function getInitGridDataByBibId(a){holdDataGridListByBibId(a,"hold")}function holdDataGridListByBibId(b,d,a){if(b>0){var c=base_path+"hld/holding/page.do";var e={};e.bibid=b;e.rows=10;e.page=1;$("#"+d+"DataGridList").datagrid({url:c,queryParams:e,onLoadSuccess:function(f){if(a>-1){$("#holdDataGridList").datagrid("selectRow",a);$("#holdDataGridList").datagrid("scrollTo",a)}},method:"post"})}else{deleteGridData(""+d+"DataGridList")}}function deleteHoldRecord(){var a=$("#holdDataGridList").datagrid("getSelected");if(!a){return openMessageDlg("请先选择一条馆藏信息,进行删除")}openConfirmDlg("您确定要删除记录号为["+a.id+"]的馆藏数据吗?",null,deleteHoldRecordResult,null)}function deleteHoldRecordResult(){var c=$("#holdDataGridList").datagrid("getSelected");var b={};b.pk=c.id;var a=base_path+"hld/holding/delete.do";$.post(a,b,function(d){if(d.status=="0"){openMessageDlg(d.message,5000);holdDataGridListByBibId(c.bibid,"hold")}else{openMessageDlg(d.message)}},"json")}function searchCenterDataGridList(){}function clearComBibGridData(){selectEditBibId=0;setValue("bibStatus","0");$("#saveBibRecord").linkbutton({disabled:false});$("#deleteBibRecord").linkbutton({disabled:false});$("#appendRecord").linkbutton({disabled:false});$("#insertRow").linkbutton({disabled:false});$("#removeit").linkbutton({disabled:false});clearGridData("editBibGrid,acqDataGridList,holdDataGridList");$("#tabsGrid").tabs("select",0)}function setPerPara(){$("#pageconfig_setpara_dlg").dialog("open")};