var jsonFormatDesign={code:"I_HLDIMPORTDATA"};var holdId=0;var holdrow=undefined;var datafilename;var bibid=0;var _curBarcode;var _configid=0;var _configparamjson;$(function(){$(".show-result-msg").hide();setHandlerField();setInitPageElementData();getPageConfig("page_type",callSetParaResult);$("#barcode").textbox("textbox").focus();$(".easyui-panel-resize").panel("resize");enterEvent("barcode",onHandlerConfirm);enterEvent("newbarcode",onHandlerRecord);$("#holdDataGridList").datagrid({rowStyler:rowHldStyler});getEnumByHldStatus()});function getEnumByHldStatus(){var b="";var a=base_path+"par/common/getInitData.do";var c={};c.key="hldstatus";$.post(a,c,function(g){var f=g.rows;var d=[];for(var e in f){if("0,1,3,4,5,6,7,8,a,z".indexOf(f[e].code)>-1){d.push(f[e])}}$("#status").combobox({data:d,valueField:"code",textField:"name"});$("#batch_status").combobox({data:d,valueField:"code",textField:"name"});setValue("status","5");$("#batch_status").combobox({data:d,valueField:"code",textField:"name"});setValue("batch_status","5")},"json");return b}function rowHldStyler(a,b){if(vType!="2"){if(b.barcode==_curBarcode){return"color:red;"}}else{if(b.barcode==_curBarcode){return"color:red;"}}}function setInitPageElementData(){setValue("checkdate",getCurDateYMD());var a=[{key:"libcode",condition:"code",value:vLibcode},{key:"hldstatus"},{code:"docsources",key:"docsources"},{code:"curlocation,location",key:"location",condition:"libcode",value:vLibcode},{key:"doctype",condition:"libcode",value:vLibcode}];_myPage.prototype.initData(a);$("#curlocation").combobox({onChange:function(c,b){if(c){setDefaultDoctype(c)}}})}_myPage.prototype.onLoadSuccess=function(a,b){_fmtGridDataRows=a;_myPage.prototype.getOperatorParam()};_myPage.prototype.initComboxByOperatorParm=function(c){var f=_fmtGridDataRows.rows[0].libcode;var a=getValue("page_nextlocation");var g=_fmtGridDataRows.rows[0].location;if(a&&a!="1"){var h;for(var d=0;d-1){e.push(g[d])}}g=e}var b={};b.code="";b.name="保持原值不变";g.splice(0,0,b);$("#location").combobox("loadData",g);$("#curlocation").combobox("loadData",g)};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"});onResetAcceptFormatDesignPage();$("#hldBatchDlg").window("open")}function setDefaultDoctype(c){var a=base_path+"par/location/get.do";var b={};b.pk=c;$.post(a,b,function(d){if(d.total>0){var e=d.rows[0];if(e.defdoctype){setValue("doctype",e.defdoctype)}else{setValue("doctype","")}}},"json")}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{saveHldConfig(successcount);$(".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(a){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.status=a.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"){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];bibid=e.rows[0].bibid;_curBarcode=e.rows[0].barcode;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)]+"]状态,不能进行当前操作")}if(vType=="3"){if(holdrow.status!="0"&&holdrow.status!="1"){return openMessageDlg("条码不是在编或者在馆状态,不能进行当前操作")}}var d=getValue("page_confirm");if(d=="1"){$.messager.confirm("提示消息","您确定要进行此操作吗?",function(g){if(g){onHandlerMian()}})}else{if(vType!="2"){onHandlerMian()}}if(vType=="2"){$("#newbarcode").textbox("setValue","");$("#newbarcode").textbox("enable");$("#barcode").textbox("disable");$("#newbarcode").textbox().next("span").find("input").focus().keydown(function(g){if(g.keyCode==13){onHandlerRecord()}})}}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:"题    名",color:"red"},{code:"author",name:"作    者"},{code:"isbn",name:" ISBN ",color:"red"},{code:"price",name:"价    格"},{code:"classno",name:"分类号"},{code:"publish",name:"出版社"},{code:"publishdate",name:"出版年"}];for(var a=0;a【"+b[a].name+"】   ";if(b[a].color){c+=""}c+=(e[b[a].code]==null?"":e[b[a].code]);if(b[a].color){c+=""}c+=""}$(".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){if(e.total>0){$("#"+c+"DataGridList").datagrid("getPanel").panel("setTitle","馆藏数据列表("+e.total+")")}},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(getValue("shelfno").length>0){a.shelfno=getValue("shelfno")}if(!a.curlocation&&!a.doctype&&!a.location){return openMessageDlg("馆藏地点和文献类型至少有一项不能保持不变")}}else{if(vType=="2"){a.barcode=getValue("newbarcode")}else{if(vType=="3"){a=getLocalAndDocType(a);a.status=getValue("status");a.hldnote=getValue("hldnote")}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);saveHldConfig(1)}else{openMessageDlg(c.message)}},"json")}else{openMessageDlg("未找到馆藏记录号")}}function showHoldHandlerResult(f,b){var e="";var d="";var g=f.rows[0];var a="  ";var c="条码号 【"+_curBarcode+"】";if(vType=="0"){e="入藏确认";d=c+a+e+"成功,馆藏状态已改为【在馆】状态"+getHoldOtherInfo(g,b)}else{if(vType=="1"){e="入藏变更";d=c+a+e+"成功"+getHoldOtherInfo(g,b)}else{if(vType=="2"){setValue("barcode","");$("#newbarcode").textbox("disable");$("#barcode").textbox("enable");e="条码置换";d=e+"成功,旧条码【"+holdrow.barcode+"】已替换为新条码【"+g.barcode+"】"}else{if(vType=="3"){e="馆藏状态变更";d=c+a+e+"成功,馆藏状态已改为【"+getStautsNameByCode(b.status)+"】"+getHoldOtherInfo(g,b)}else{if(vType=="4"){e="馆藏清点";d=c+a+e+"成功,清点日期"+fmtStringToDate(b.checkdate)+getHoldOtherInfo(g,b)}}}}}if(vType!="2"){$("#barcode").textbox("textbox").focus().select()}else{$("#barcode").textbox().next("span").find("input").focus().keydown(function(h){if(h.keyCode==13){onHandlerConfirm()}})}$(".hold-result-data").prepend("
"+d+"
");bindDataGridListByBibId(bibid,"hold")}function clearHldData(){if(_configid>0){saveHldConfig(0,"clear")}}function saveHldConfig(d,f){var b={};b.type="set_hldconfgi_data";var c=base_path+"lib/config/insert.do";if(_configid>0){c=base_path+"lib/config/update.do";b.id=_configid}var a=_configparamjson;var e={};e.data=0;e.date=getCurDateYMD();if(a[vType]){e=a[vType]}if(!e.date){e.date=getCurDateYMD()}e.data+=d;if(f){e.data=0;e.date=""}a[vType]=e;b.paramjson=JSON.stringify(a);$.post(c,b,function(g){if(g.status=="0"){getShowResultData()}},"json")}function getShowResultData(){var b="";if(vType=="0"){b="入藏确认"}else{if(vType=="1"){b="入藏变更"}else{if(vType=="2"){b="条码置换"}else{if(vType=="3"){b="馆藏状态更改"}else{if(vType=="4"){b="馆藏清点"}}}}}var c={};c.type="set_hldconfgi_data";var a=base_path+"lib/config/page.do";$.post(a,c,function(e){_configparamjson={};if(e.status=="0"&&e.rows[0]){_configparamjson=JSON.parse(e.rows[0].paramjson);_configid=e.rows[0].id;var d=_configparamjson[vType];if(d){$(".show-result-msg").show();$(".show-result").html("已"+b+"【"+d.data+"】本,起始日期【"+d.date+"】")}}},"json")}function getStautsNameByCode(a){return onGridShowNameBycode("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)+"】"}if(a.shelfno){b+=",架位号由【"+holdrow.shelfno+"】改为【"+c.shelfno+"】"}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();$("#newbarcode").textbox("disable")}else{if(vType=="3"){showLocDoc(false);$(".status").show();$(".location").show()}else{if(vType=="4"){showLocDoc(true);$(".checkdate").show()}}}}}var a=$(window).height();var b=a-160;$(".datagrid-div").css("height",b+"px");$("#hldProLayOut").layout("resize");getLayWHByResize("hldProLayOut");getShowResultData()}function ikownDlg(){$("#global-message-dlg").dialog("close");$("#barcode").textbox("textbox").focus().select()}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)}}function onResizeByNorth(b,a){if(a!=66){setLayWHByResize("hldProLayOut","north",b,a)}};