var initflag;var initJson;var checkdetailId;var checkdetailIdx;var checkdetailData;var eidtorAutoBindGridObject=undefined;var eidtorAutoBindGridIndex=undefined;$(function(){initflag="page_,checkper_,checkdetail_,binddlg_";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 b={key:"perordertype"};initPageDataSingleElement("orderbib_ordertype",b,null);var a={key:"percheckstatus"};initPageDataSingleElement("checkdetail_status",a,null);initPageElementLayout();initComboBoxSelectEvent();initAutoBindGrid();$("#checkDataGridList").datagrid({onDblClickRow:updateCheckPer,onSelect:onSelectCheckDataGridList});initRerFrequencyNum()});function initCheckDetailType(){var a=$("#checkper_type").combobox("getData");$("#checkdetail_type").combobox({data:a,valueField:"code",textField:"name",onLoadSuccess:function(){var b=$(this).combobox("getData");if(b.length>0){$(this).combobox("select",b[0].code)}}})}function initRerFrequencyNum(){var a=base_path+"par/common/getInitData.do";var b={};b.key="frequency";b.fmt="entity";$.post(a,b,function(c){$("#rerFrequencyNum").combobox({data:c.rows,valueField:"code",textField:"frequency",onLoadSuccess:function(){}})},"json")}function initComboBoxSelectEvent(){$("#checkper_frequency").combobox({onSelect:function(a){if(a!=null){setValue("rerFrequencyNum",a.code);setValue("checkper_issuenum",$("#rerFrequencyNum").combobox("getText"))}}})}function initPageElementLayout(){$("#acqDataGridList").datagrid({border:false});$("#editBibGrid").datagrid({border:false,title:""});$("#holdDataGridList").datagrid({border:false});$("#checkDataGridList").datagrid({border:false});$("#orderDataGridList").datagrid({border:false});$(".order_batchno").hide();$(".check_batchno").hide();if(vFlag==0){$(".bind_batchno").hide()}$(".easyui-panel").panel("resize")}function onSelectAcqDataGridList(b,a){bindAcqDataGridDetailById(a.id);getInitGridDataByBibId(a.id)}function onSelectCheckDataGridList(b,a){bindCheckDetailDataGridList(a.id)}function getInitGridDataByBibId(a){bindDataGridListByBibId(a,"order");bindDataGridListByBibId(a,"check");bindDataGridListByBibId(a,"hold")}function bindDataGridListByBibId(a,c){if(a>0){var b=base_path+"per/"+c+"/page.do";if(c=="hold"){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(c=="check"){if(e.total>0){$("#checkDataGridList").datagrid("selectRow",0)}}},method:"post"})}else{deleteGridData(""+c+"DataGridList")}}function updateOrderBib(b,a){}function onSelectTabsGrid(b,a){}function clearComBibGridData(){selectEditBibId=0;clearGridData("editBibGrid,acqDataGridList")}function updateCheckPer(b,a){showCheckPerDlgHandler(a)}function addCheckPerRecord(a){setValue("checkper_id","");showCheckPerDlgHandler(a)}function showCheckPerDlgHandler(b){cleanJsonData("checkper_record");var a="总记到";if(!b){if(getValue("page_orderyear").length==0){return openMessageDlg("请点击页面设置,在其他参数页面中设置订购年")}var c=$("#acqDataGridList").datagrid("getSelected");if(!c){return openMessageDlg("请先选择一条期刊数据,进行订购")}$(".checkper_tip").html("提示:请您确认当前要记到的期刊记录号【"+c.id+"】");bibDataToDlgData(c,"checkper_",a)}else{$(".checkper_tip").html("");gridDataToDlgData(b,"checkper_",a)}}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);if(d.price){setValue(""+b+"price",d.price)}if(b=="checkdetail_"){setValue(""+b+"bibid",d.bibid);setValue(""+b+"checkid",d.id)}else{setValue(""+b+"bibid",d.id)}a.each(function(f,g){var e=getValue(g.id);if(g.id=="page_orderyear"){setValue("checkper_year",e);setValue("checkdetail_year",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 updateCheckPerRecord(){var a=$("#checkDataGridList").datagrid("getSelected");if(!a){return openMessageDlg("请先选择一条总记到信息,进行修改")}showCheckPerDlgHandler(a)}function savecheckper(){var b=getJsonData("checkper_","record");if(!b){openMessageDlg("记录异常");return}if(!b.copies){openMessageDlg("副本数必须大于0!");return}if(!b.price){openMessageDlg("册价不能为空!");return}var a=getValue("checkper_id");var c=base_path+"per/check/insert.do";if(a>0){c=base_path+"per/check/update.do"}$.post(c,b,function(d){if(d.status=="0"){bindDataGridListByBibId(d.rows[0].bibid,"check");openMessageDlg(d.message,5000);$("#checkper_dlg").dialog("close")}else{openMessageDlg(d.message)}},"json")}function deleteCheckPerRecord(){var a=$("#checkDataGridList").datagrid("getSelected");if(!a){return openMessageDlg("请先选择一条记到信息,进行删除")}openConfirmDlg("您确定要删除记录号为["+a.id+"]的总记到数据吗?",null,deleteCheckPerRecordResult,null)}function deleteCheckPerRecordResult(){var c=$("#checkDataGridList").datagrid("getSelected");var b={};b.pk=c.id;var a=base_path+"per/check/delete.do";$.post(a,b,function(d){if(d.status=="0"){openMessageDlg(d.message,5000);bindDataGridListByBibId(c.bibid,"check")}else{openMessageDlg(d.message)}},"json")}function onOpenCheckDlg(){$("#checkper_copies").numberbox().next("span").find("input").focus()}function onOpenCheckDetailDlg(){$("#checkdetail_copies").numberbox().next("span").find("input").focus()}function bindCheckDetailDataGridList(b,a){onHnadlerSvaeBntScreen(null,true);var c=base_path+"per/detailcheck/page.do";var d={};d.checkid=b;d.rows=1000;d.page=1;$.post(c,d,function(e){onHnadlerSvaeBntScreen(null,false);if(e.status=="0"){checkdetailBoxs(e)}else{openMessageDlg(e.message)}},"json")}function checkdetailBoxs(e){var l=[{code:"issue",name:"记到期"},{code:"volume",name:"记到卷"},{code:"copies",name:"记到册数"},{code:"totalissue",name:"总期数"},{code:"expectdate",name:"预计日期",title:"true"},{code:"actualdate",name:"实际日期",title:"true"},{code:"price",name:"价格",title:"true"},{code:"note",name:"备注",title:"true"}];var g="";var m=e.rows;checkdetailData=m;for(var f=0;f'+l[d].name+":"+c+"";k+=l[d].name+":"+c+"\n"}else{if(l[d].code=="expectdate"||l[d].code=="actualdate"){c=fmtStringToDate(c)}k+=l[d].name+":"+c+"\n"}}var b=getColorBysStatus(m[f].status);var a=m[f].id;g+='
';g+="
"+h+"
";g+="
"}$(".checkdetail-boxs").html(g);bindEventFun()}function getColorBysStatus(a){var c="";var d=[{code:"0",color:"cell-weidao"},{code:"1",color:"cell-zhengchang"},{code:"2",color:"cell-weidaoqi"},{code:"3",color:"cell-cuique"},{code:"4",color:"cell-zhuangding"},{code:"5",color:"cell-tingding"},{code:"6",color:"cell-yanqi"},{code:"9",color:"cell-qita"},];for(var b=0;b0){var d=i[g-1];a=parseInt((parseInt(e)+parseInt(d.sortfld))/2)}}}else{if(f=="1"){if(g==(i.length-1)){a=parseInt((parseInt(e)*3)/2)}else{if(g<(i.length-1)){var d=i[g+1];a=parseInt((parseInt(e)+parseInt(d.sortfld))/2)}}}}setValue("checkdetail_sortfld",a)}}function savecheckdetail(){var a=getJsonData("checkdetail_","record");if(!a){openMessageDlg("记录异常");return}if(!a.copies){openMessageDlg("副本数必须大于0!");return}if(!a.price){openMessageDlg("册价不能为空!");return}if(!a.year){openMessageDlg("记到年不能为空!");return}if(!a.issuenum){openMessageDlg("记到期数不能为空!");return}if(!a.issue){openMessageDlg("记到期不能为空!");return}if(!a.expectdate){openMessageDlg("预计日期不能为空!");return}var b=checkdetailData[checkdetailIdx];if((a.volume&&b.volume!=a.volume)||(a.issue&&b.issue!=a.issue)||(a.totalissue&&b.totalissue!=a.totalissue)||(a.expectdate&&b.expectdate!=a.expectdate)){openConfirmDlg("您确定要更新该期后的所有的记到记录?",null,savecheckdetailok,savecheckdetailcancle)}else{a.updateFlag=0;savecheckdetailfun(a)}}function savecheckdetailok(b,a){var a=getJsonData("checkdetail_","record");a.updateFlag=1;savecheckdetailfun(a)}function savecheckdetailcancle(b,a){var a=getJsonData("checkdetail_","record");a.updateFlag=0;savecheckdetailfun(a)}function savecheckdetailfun(b){onHnadlerSvaeBntScreen(null,true);var a=getValue("checkdetail_id");var c=base_path+"per/detailcheck/insert.do";if(a>0){c=base_path+"per/detailcheck/check.do"}$.post(c,b,function(d){onHnadlerSvaeBntScreen(null,false);if(d.status=="0"){$("#checkdetail_dlg").dialog("close");bindCheckDetailDataGridList(d.rows[0].checkid)}else{openMessageDlg(d.message)}},"json")}function checkDetailRecord(){var b=checkdetailData[checkdetailIdx];cleanJsonData("checkdetail_record");var a="详细记到";$(".checkdetail_tip").html("");gridDataToDlgData(b,"checkdetail_",a)}function updateCheckDetail(c,b){cleanJsonData("checkdetail_record");var a="详细记到";$(".checkdetail_tip").html("");gridDataToDlgData(b,"checkdetail_",a)}function checkToMarkRecord(){var c=$("#checkDataGridList").datagrid("getSelected");var a=checkdetailData[checkdetailIdx];if(!a){return openMessageDlg("请先选择一条详细记到信息,进行详细记到操作!")}cleanJsonData("checkdetail_record");a.copies=parseInt(a.copies)+1;if(a.copies>=c.copies){a.status="1"}getCurRowIndex=checkdetailIdx;var b=base_path+"per/detailcheck/update.do";$.post(b,a,function(d){if(d.status=="0"){bindCheckDetailDataGridList(d.rows[0].checkid,getCurRowIndex);$("#checkdetail_dlg").dialog("close")}else{openMessageDlg(d.message)}},"json")}function checkToComBineRecord(){var d="";var c=$(".cell-box-selected");c.each(function(e,f){d+=f.id+","});d=d.substr(0,d.length-1);var a={};a.ids=d;var b=base_path+"per/detailcheck/combine.do";$.post(b,a,function(e){if(e.status=="0"){bindCheckDetailDataGridList(e.rows[0].checkid);openMessageDlg(e.message,5000)}else{openMessageDlg(e.message)}},"json")}function deleteCheckDetailRecord(){var a=checkdetailData[checkdetailIdx];if(!a){return openMessageDlg("请先选择一条详细记到信息,进行删除")}openConfirmDlg("您确定要删除记录号为["+a.id+"]的总记到数据吗?",null,deleteCheckDetailRecordResult,null)}function deleteCheckDetailRecordResult(){var c=checkdetailData[checkdetailIdx];var b={};b.pk=c.id;var a=base_path+"per/detailcheck/delete.do";$.post(a,b,function(d){if(d.status=="0"){openMessageDlg(d.message,5000);bindCheckDetailDataGridList(c.checkid)}else{openMessageDlg(d.message)}},"json")}function setPerPara(){$("#pageconfig_setpara_dlg").dialog("open")}function onOpenAutoBindDlg(){}function addAutoBindPerRecord(e){if(getValue("page_bind_batchno").length==0){return openMessageDlg("请在设置-其他参数中设置装订批号")}var b=base_path+"per/bind/bindManual.do";var g={};if(getValue("bindcopies")>0){g.copies=getValue("bindcopies")}if(getValue("bindfee")>0){g.bindfee=getValue("bindfee")}if(getValue("bindcount")>0){g.bindcount=getValue("bindcount")}var f=$("#checkDataGridList").datagrid("getSelected");if(e=="1"){b=base_path+"per/bind/bindAuto.do";if(!f){return openMessageDlg("请先选择一条总记到信息,进行自动装订")}g.checkid=f.id}else{var d="";var c=$(".cell-box-selected");c.each(function(h,i){d+=i.id+","});d=d.substr(0,d.length-1);var a={};g.ids=d;if(d.toString().length==0){return openMessageDlg("请先选择至少一条详细记到信息,进行新增装订")}}setAutoBindText(f);$("#binddlg_eidtorgrid").datagrid({url:b,queryParams:g,onLoadSuccess:function(h){},method:"post"});$("#binddlg_dlg").dialog("open")}function setAutoBindText(a){setValue("binddlg_libcode",a.libcode);setValue("binddlg_binding",getValue("page_binding"));setValue("binddlg_doctype",getValue("page_doctype"));setValue("binddlg_location",getValue("page_location"));setValue("binddlg_finsources",getValue("page_finsources"));setValue("binddlg_batchno",getValue("page_bind_batchno"))}function saveAutoBind(){var d=$("#acqDataGridList").datagrid("getSelected");var f=checkdetailData[checkdetailIdx];var e=getJsonData("binddlg_","record");e.bibid=d.id;var c=$("#binddlg_eidtorgrid").datagrid("getRows");if(c.length>0){for(var b=0;b