var initflag;var initJson;var bindTableMenu;var bindTableTarget;$(function(){initflag="page_,bindper_";initJson=[{key:"sysid",condition:"type",value:"1"},{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}];var c={key:"location",condition:"libcode",value:vLibcode};initPageDataSingleElement("bindper_loccode",c,null);var a=[{id:"bindper_loccode",key:"location",condition:"libcode",value:vLibcode},{id:"checkhold_doctype",key:"doctype",condition:"libcode",value:vLibcode}];initNextSelectCombobox("checkhold_libcode",a);$(".order_batchno").hide();$(".bind_batchno").hide();var b=$("#bindDataGridList");b.datagrid({onDblClickRow:updateBindPerBib,onHeaderContextMenu:function(f,d){f.preventDefault();if(!bindTableMenu){createColumnMenu(b)}bindTableMenu.menu("show",{left:f.pageX,top:f.pageY})}});$(".easyui-panel").panel("resize")});function checkBarcodeRepeat(){var a=getValue("bindper_barcode");if(a>=0){var b=base_path+"hld/holding/getCheckHoldBarcode.do";var c={};c.barcode=a;$.post(b,c,function(d){if(d.status=="0"){if(d.total>0){openMessageDlg("条码号已存在,请重新输入")}}else{openMessageDlg(d.message)}},"json")}}function onCloseMessageFun(){if($(".global-message-body").html()=="条码号已存在,请重新输入"){$("#bindper_barcode").textbox({prompt:"条码号["+getValue("bindper_barcode")+"]已存在,请重新输入"});setValue("bindper_barcode","");$("#bindper_barcode").textbox("textbox").focus();$("#bindper_barcode").textbox("textbox").blur(function(a){checkBarcodeRepeat()})}}function closebindper(){setValue("bindper_barcode","");$("#bindper_dlg").dialog("close")}function clearComBibGridData(){selectEditBibId=0;clearGridData("editBibGrid,acqDataGridList");$("#tabsGrid").tabs("select",0)}function onSelectAcqDataGridList(b,a){bindAcqDataGridDetailById(a.id);getInitGridDataByBibId(a.id)}function getInitGridDataByBibId(a){bindDataGridListByBibId(a,"bind");bindDataGridListByBibId(a,"hold")}function bindDataGridListByBibId(b,d,a){if(b>0){var c=base_path+"per/"+d+"/page.do";if(d=="hold"){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&&d=="bind"){$("#bindDataGridList").datagrid("selectRow",a);$("#bindDataGridList").datagrid("scrollTo",a)}},method:"post"})}else{deleteGridData(""+d+"DataGridList")}}function onSelectTabsGrid(b,a){if(a==1){$("#deleteBindPer").show()}else{$("#deleteBindPer").hide()}}function updateBindPerBib(b,a){bindPerRecord(a)}function bindPerRecord(c){var a="装订验收";$("#bindper_barcode").textbox({prompt:"请输入条码号"});$("#bindper_barcode").textbox("textbox").blur(function(f){checkBarcodeRepeat()});cleanJsonData("bindper_record");if(!c){if(getValue("page_check_batchno").length==0){return openMessageDlg("请点击页面设置,在其他参数页面中设置验收批号")}var d=$("#acqDataGridList").datagrid("getSelected");if(!d){return openMessageDlg("请先选择一条期刊数据,进行订购")}if(!d.classno){return openMessageDlg("你要进行装订验收的书目信息没有分类号,请完善书目信息才能进行装订验收!")}getCallnoToCheckCallno(d);var b=getCurDateYMD();setValue("bindper_id","");setValue("bindper_binddate",b);$(".bindper_tip").html("提示:请您确认当前要订购的期刊记录号【"+d.id+"】");bibDataToDlgData(d,"bindper_",a)}else{$(".bindper_tip").html("");gridDataToDlgData(c,"bindper_",a)}}function setCheckCallNo(){var b={};var a=getValue("bindper_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("bindper_callno",a.classno+"/1")}else{var d=e.rows[0];setValue("bindper_callno",d.classno+"/"+d.titnum)}}else{openMessageDlg(e.message)}},"json")}function gridDataToDlgData(c,a,d){var b=$('[item-type="'+a+'record"]');b.each(function(f,h){var g=h.id.replace(a,"");if(h.id==""+a+"binddate"){if(c[g]){var e=c[g].toString();setValue(h.id,e)}}else{if(c[g]){setValue(h.id,c[g])}}});$("#"+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);if(d.price){setValue(""+b+"price",d.price);setValue(""+b+"totalprice",d.price)}setValue(""+b+"bibid",d.id);a.each(function(f,g){var e=getValue(g.id);if(g.id=="page_check_batchno"){setValue("bindper_batchno",e)}else{var i=""+b+""+g.id.replace("page_","");var h=$("#"+i);if(h){setValue(i,e)}}});$("#"+b+"dlg").dialog("setTitle",c);$("#"+b+"dlg").dialog("open")}function savebindper(){var b=getJsonData("bindper_","record");if(!b){openMessageDlg("记录异常");return}if(!b.barcode){openMessageDlg("条码号不能为空!");return}if(!b.price){openMessageDlg("价格不能为空!");return}if(!b.doctype){openMessageDlg("文献类型不能为空!");return}if(!b.loccode){openMessageDlg("馆藏地点不能为空!");return}var e=$("#bindDataGridList").datagrid("getSelected");var d;if(e){d=$("#bindDataGridList").datagrid("getRowIndex",e)}var a=getValue("bindper_id");var c=base_path+"per/bind/insert.do";if(a>0){c=base_path+"per/bind/update.do"}$.post(c,b,function(f){if(f.status=="0"){bindDataGridListByBibId(f.rows[0].bibid,"bind",d);bindDataGridListByBibId(f.rows[0].bibid,"hold");openMessageDlg(f.message,5000);$("#bindper_dlg").dialog("close");$("#tabsGrid").tabs("select",1)}else{openMessageDlg(f.message)}},"json")}function deleteBindPer(){var a=$("#bindDataGridList").datagrid("getSelected");if(!a){return openMessageDlg("请先选择一条装订验收信息,进行删除")}openConfirmDlg("您确定要删除记录号为["+a.id+"]的装订验收数据吗?",null,deleteBindPerResult,null)}function deleteBindPerResult(){var c=$("#bindDataGridList").datagrid("getSelected");var b={};b.pk=c.id;var a=base_path+"per/bind/delete.do";$.post(a,b,function(d){if(d.status=="0"){openMessageDlg(d.message,5000);bindCheckDetailDataGridList(c.bibid)}else{openMessageDlg(d.message)}},"json")}function onOpenBindPerDlg(){$("#bindper_barcode").textbox("textbox").focus()}function setPerPara(){$("#pageconfig_setpara_dlg").dialog("open")};