var jsonFormatDesign={code:"I_HLDIMPORTDATA"};var holdId=0;var holdrow=undefined;var datafilename;$(function(){setHandlerField();setInitPageElementData();getPageConfig("page_type",callSetParaResult);$("#barcode").textbox("textbox").focus();$(".easyui-panel-resize").panel("resize");enterEvent("barcode",onHandlerConfirm);enterEvent("newbarcode",onHandlerRecord)});function setInitPageElementData(){setValue("checkdate",getCurDateYMD());var a=[{key:"libcode",condition:"code",value:vLibcode},{key:"hldstatus"},{key:"curlocation",condition:"libcode",value:vLibcode},{key:"doctype",condition:"libcode",value:vLibcode}];commonSetParaInit(null,"record",null,a)}function onHldBacthHandler(){var b=$("#curlocation").combobox("getData");$("#batch_curlocation").combobox({data:b,valueField:"code",textField:"name",groupField:"group",});$("#batch_location").combobox({data:b,valueField:"code",textField:"name",groupField:"group"});var a=$("#doctype").combobox("getData");$("#batch_doctype").combobox({data:a,valueField:"code",textField:"name",groupField:"group"});$("#hldBatchDlg").window("open")}function onStartHldBatch(a){$(".error-msg-result").html("");if(datafilename){if(!a){$.messager.progress({title:"数据批处理",msg:"正在处理数据,请稍等..."})}var c=getJsonData("batch_","record");c=getParamByType(c);if(a){c=a}else{errorcount=0;handlecount=0;successcount=0;c.opertype=vType;c.filename=datafilename.filelist[0];c.page=1;c.rows=500}var b=base_path+"hld/holding/handleHoldingByFile.do";$.post(b,c,function(d){$.messager.progress("close");if(d.status=="0"){var e=d.rows[0];if(e){errorfile=e.errorfile;errorcount+=e.errorcount;successcount+=e.successcount;handlecount+=parseInt(e.handlecount);if(e.nextfile){$.messager.progress({title:"数据批处理",msg:"已处理["+handlecount+"]条数据,请等待处理完成 ..."});c.errorfile=e.errorfile;c.filename=e.nextfile;onStartHldBatch(c)}else{$(".handlecount").html("已处理["+handlecount+"]条数据");$(".successcount").html("成功["+successcount+"]条");$(".errorcount").html("失败["+errorcount+"]条");$("#checkerrorfile").show();$("#acceptFileResultDlg").dialog("open")}}}else{openMessageDlg(d.message)}},"json").error(function(){$(".error-msg-result").html("处理数据中途错误,请查看错误文件!");$(".handlecount").html("已处理["+handlecount+"]条数据");$(".successcount").html("成功["+successcount+"]条");$(".errorcount").html("失败["+errorcount+"]条");$("#checkerrorfile").show();$("#acceptFileResultDlg").dialog("open");$.messager.progress("close")})}else{openMessageDlg("请检查您是否已上传文件")}}function getParamByType(b){var a=b;if(vType=="0"){a.status="1";a.checkdate=""}else{if(vType=="1"){a.status="";a.checkdate=""}else{if(vType=="2"){a={}}else{if(vType=="3"){a={};a.status=b.status}else{if(vType=="4"){a.status=""}}}}}return a}function onPerviewData(c){$("#showPerviewOrgMarcData").html("");if(datafilename){var a=getJsonData("batch_","record");a.filename=datafilename.filelist[0];var b=base_path+"com/webuploader/perviewTextData.do";$.post(b,a,function(d){if(d.status=="0"){setDataToPageShowPerview(d)}else{if(d.status=="9003"){openMessageDlg(d.message)}else{openMessageDlg(d.message)}}},"json")}else{openMessageDlg("请检查您是否已上传文件")}}function setDataToPageShowPerview(d){var c=d.rows;if(c.length>0){var b="";for(var a=0;a"+(a+1)+","+c[a]+""}$("#showPerviewOrgMarcData").html(b)}}function onHandlerConfirm(){holdId=0;if(vType=="2"){$("#newbarcode").textbox("textbox").focus();getHoldByBarcode()}else{onHandlerRecord()}}function onHandlerRecord(){if(getValue("barcode").length==0){return openMessageDlg("条码号不能为空")}if(vType=="2"){if(getValue("newbarcode").length==0){return openMessageDlg("新条码不能为空")}onHandlerMian()}else{getHoldByBarcode()}}function getHoldByBarcode(){if(getValue("barcode").length==0){return openMessageDlg("条码号不能为空")}var a=getValue("barcode");if(a.length>=0){var b=base_path+"hld/holding/getCheckHoldBarcode.do";var c={};c.barcode=a;$.post(b,c,function(e){if(e.status=="0"){if(e.total>0){holdId=e.rows[0].id;holdrow=e.rows[0];bindDataGridListByBibId(e.rows[0].bibid,"hold");bindDataToBiBByBibId(e.rows[0].bibid);var f=["","","借出","预约/预借"];if(holdrow.status=="2"||holdrow.status=="3"){return openMessageDlg("条码处于["+f[parseInt(holdrow.status)]+"]状态,不能进行当前操作")}var d=getValue("page_confirm");if(d=="1"){openConfirmDlg("您确定要进行此操作吗?",null,onHandlerMian,null)}else{if(vType!="2"){onHandlerMian()}}}else{return openMessageDlg("未找到合适的条码号")}}else{openMessageDlg(e.message)}},"json")}}function bindDataToBiBByBibId(c){var a=base_path+"lib/biblios/get.do";var b={};b.id=c;$.post(a,b,function(d){if(d.status=="0"){setBibHtmlShow(d)}else{$(".bib-html-data").html(d.message)}},"json")}function setBibHtmlShow(d){var e=d.rows[0];var c="";var b=[{code:"title",name:"题名"},{code:"author",name:"作者"},{code:"isbn",name:"ISBN"},{code:"price",name:"价格"},{code:"classno",name:"分类号"},{code:"subject",name:"主题词"},{code:"publish",name:"出版社"},{code:"publishaddress",name:"出版地"},{code:"publishdate",name:"出版年"},{code:"callno",name:"索书号"},{code:"content",name:"内容简介"}];for(var a=0;a"+b[a].name+":"+(e[b[a].code]==null?"":e[b[a].code])+""}$(".bib-html-data").html(c)}function bindDataGridListByBibId(a,c){if(a>0){var b=base_path+"hld/holding/page.do";var d={};d.bibid=a;d.rows=10;d.page=1;$("#"+c+"DataGridList").datagrid({url:b,queryParams:d,onLoadSuccess:function(e){},method:"post"})}else{deleteGridData(""+c+"DataGridList")}}function onHandlerMian(){if(holdId>0){var a={};if(vType=="0"){a.status="1";a=getLocalAndDocType(a)}else{if(vType=="1"){a=getLocalAndDocType(a);if(!a.curlocation&&!a.doctype){return openMessageDlg("馆藏地点和文献类型至少有一项不能保持不变")}}else{if(vType=="2"){a.barcode=getValue("newbarcode")}else{if(vType=="3"){a=getLocalAndDocType(a);a.status=getValue("status")}else{if(vType=="4"){a=getLocalAndDocType(a);a.checkdate=getValue("checkdate")}}}}}a.id=holdId;a.handletype=vType;var b=base_path+"hld/holding/handleHolding.do";$.post(b,a,function(c){if(c.status=="0"){showHoldHandlerResult(c,a)}else{openMessageDlg(c.message)}},"json")}else{openMessageDlg("未找到馆藏记录号")}}function showHoldHandlerResult(d,a){var c="";var b="";var e=d.rows[0];if(vType=="0"){c="入藏确认";b=c+"成功,馆藏已改为[在馆]状态"+getHoldOtherInfo(e,a)}else{if(vType=="1"){c="入藏变更";b=c+"成功"+getHoldOtherInfo(e,a)}else{if(vType=="2"){c="条码置换";b=c+"成功,旧条码["+holdrow.barcode+"]已替换为新条码["+e.barcode+"]"}else{if(vType=="3"){c="馆藏剔除";b=c+"成功,馆藏已改为["+getStautsNameByCode(a.status)+"]"+getHoldOtherInfo(e,a)}else{if(vType=="4"){c="馆藏清点";b=c+"成功,清点日期"+fmtStringToDate(a.checkdate)+getHoldOtherInfo(e,a)}}}}}$(".hold-result-data").append("
"+b+"
")}function getStautsNameByCode(a){return onGridShowTextBycode("batch_status",a)}function getHoldOtherInfo(c,a){var b="";if(a.location){b+=",所属馆藏地点由["+getCurLocationNameByCode(holdrow.location)+"]改为["+getCurLocationNameByCode(c.location)+"]"}if(a.curlocation){b+=",当前馆藏地点由["+getCurLocationNameByCode(holdrow.curlocation)+"]改为["+getCurLocationNameByCode(c.curlocation)+"]"}if(a.doctype){b+=",文献类型由["+getDocTypeNameByCode(holdrow.doctype)+"]改为["+getDocTypeNameByCode(c.doctype)+"]"}return b}function getCurLocationNameByCode(a){return onGridShowNameBycode("curlocation",a)}function getDocTypeNameByCode(a){return onGridShowNameBycode("doctype",a)}function getLocalAndDocType(a){if(getValue("curlocation").length>0){a.curlocation=getValue("curlocation")}if(getValue("location").length>0){a.location=getValue("location")}if(getValue("doctype").length>0){a.doctype=getValue("doctype")}return a}function setHandlerField(){if(vType=="0"){showLocDoc(true)}else{if(vType=="1"){showLocDoc(true)}else{if(vType=="2"){showLocDoc(false);$(".newbarcode").show()}else{if(vType=="3"){showLocDoc(false);$(".status").show()}else{if(vType=="4"){showLocDoc(true);$(".checkdate").show()}}}}}var a=$(window).height();var b=a-(126+340);$(".datagrid-div").css("height",b+"px");$("#holdDataGridList").datagrid("resize")}function showLocDoc(a){if(a){$(".location").show();$(".doctype").show()}else{$(".location").hide();$(".doctype").hide()}$(".status").hide();$(".checkdate").hide();$(".newbarcode").hide()}function callSetParaResult(c){if(c.status=="0"){var b=c.rows[0];var a=JSON.parse(b.paramjson);setJsonData("page_",a)}}function setPara(){$("#pageconfig_setpara_dlg").window("open")}function onShowHoldStatusName(a,b){return onGridShowNameBycode("hldstatus",a)}function onResetAcceptFormatDesignPage(){$(".acceptTextTip").show();if(vType=="2"){$(".acceptTextTip").html("请选择要进行批处理的txt文件,一行一个旧条码和新条码,新旧条码用空格分割,如:0001 0002")}else{$(".acceptTextTip").html("请选择要进行批处理的txt文件,一行一个条码")}$("#showPerviewOrgMarcData").html("")}function uploadSuccessHandler(a,b){if(b.status==0){datafilename=b.rows[0]}else{openMessageDlg(b.message)}};