var initflag;var initJson;$(function(){initflag="page_,orderbib_";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 a={key:"perordertype"};initPageDataSingleElement("orderbib_ordertype",a,null);$(".check_batchno").hide();$(".bind_batchno").hide();initComboBoxSelectEvent();$(".easyui-panel").panel("resize");initRerFrequencyNum()});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(){$("#orderbib_frequency").combobox({onSelect:function(a){if(a!=null){setValue("rerFrequencyNum",a.code);setValue("orderbib_issuenum",$("#rerFrequencyNum").combobox("getText"));ratePerHandlerMain("orderbib_",$("#rerFrequencyNum").combobox("getText"))}}})}function onSelectTabsGrid(b,a){if(a==1){$("#deleteOrderBib").show()}else{$("#deleteOrderBib").hide()}}function clearComBibGridData(){selectEditBibId=0;clearGridData("editBibGrid,acqDataGridList");$("#tabsGrid").tabs("select",0)}function onSelectAcqDataGridList(b,a){bindAcqDataGridDetailById(a.id);getInitGridDataByBibId(a.id)}function updateOrderBib(b,a){orderBibRecord(a,a.ordertype)}function orderBibRecord(e,d){cleanJsonData("orderbib_record");var c=$("#orderDataGridList").datagrid("getRows");var a="期刊";if(d==0){a+="新订"}if(d==1){a+="续订";if(c.length==0){return openMessageDlg("请先进行新订,才能进行续订操作")}e=$("#orderDataGridList").datagrid("getSelected");e.id=null}if(d==2){a+="停订";if(c.length==0){return openMessageDlg("请先进行新订,才能进行停订操作")}e=$("#orderDataGridList").datagrid("getSelected");e.id=null}setValue("orderbib_ordertype",d);if(!e){if(getValue("page_order_batchno").length==0){return openMessageDlg("请点击页面设置,在其他参数页面中设置订购批号")}if(getValue("page_orderyear").length==0){return openMessageDlg("请点击页面设置,在其他参数页面中设置订购年")}var f=$("#acqDataGridList").datagrid("getSelected");if(!f){return openMessageDlg("请先选择一条期刊数据,进行订购")}var b=getCurDateYMD();setValue("orderbib_id","");setValue("orderbib_paydate",b);setValue("orderbib_orderdate",b);$(".orderbib_tip").html("提示:请您确认当前要订购的期刊记录号【"+f.id+"】");bibDataToDlgData(f,"orderbib_",a)}else{$(".orderbib_tip").html("");gridDataToDlgData(e,"orderbib_",a)}}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+"ordertype"){}else{if(h.id==""+a+"orderdate"||h.id==""+a+"paydate"||h.id==""+a+"checkdate"){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(o,k,n){try{setValue(""+k+"id","0");if(!o){return openMessageDlg("请先选择一条期刊数据,进行订购")}var c=$('[item-type="page_paramjson"]');setValue(""+k+"libcode",vLibcode);if(o.orderno){setValue(""+k+"orderno",o.orderno)}if(o.price){var h=/(\d{1,3})+(?:\.\d+)?/g;var m=o.price.match(h);var g=/[¥$CNYUSD]/g;var l=o.price.match(g);var b="";if(l){for(var f=0;f0){var g=getValue(d+"orderprice");if(g==0||b){var c=0;var a=base_path+"par/rate/getRate.do";var f={};f.originalncy=getValue(d+"ncy");f.conversionncy=getValue(d+"orderncy");$.post(a,f,function(i){if(i.status=="0"){c=i.rows[0];if(e>0&&c>0){setValue(d+"orderprice",e*c);var h=getValue(d+"issuenum");if(b){h=parseInt(b)}if(h>0){setValue(d+"ordertotalprice",getValue(d+"orderprice")*h);setValue(""+d+"totalprice",getValue(d+"orderprice")*h)}else{setValue(d+"ordertotalprice",getValue(d+"orderprice"))}}}},"json")}}}function onOpenOrderDlg(){$("#orderbib_copies").numberbox().next("span").find("input").focus()}function saveOrderBib(){onHnadlerSvaeBntScreen("saveOrderBibBnt",true);var b=getJsonData("orderbib_","record");if(!b){openMessageDlg("记录异常");return}if(!b.copies){openMessageDlg("副本数必须大于0!");return}if(!b.orderprice){openMessageDlg("订购价格不能为空!");return}var e=$("#orderDataGridList").datagrid("getSelected");var d;if(e){d=$("#orderDataGridList").datagrid("getRowIndex",e)}var a=getValue("orderbib_id");var c=base_path+"per/order/insert.do";if(a>0){c=base_path+"per/order/update.do"}$.post(c,b,function(f){onHnadlerSvaeBntScreen("saveOrderBibBnt",false);if(f.status=="0"){bindDataGridListByBibId(f.rows[0].bibid,"order",d);openMessageDlg(f.message,5000);$("#orderbib_dlg").dialog("close");$("#tabsGrid").tabs("select",1)}else{openMessageDlg(f.message)}},"json")}function getInitGridDataByBibId(a){bindDataGridListByBibId(a,"order");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=="order"){$("#orderDataGridList").datagrid("selectRow",a);$("#orderDataGridList").datagrid("scrollTo",a)}else{if(d=="order"){$("#orderDataGridList").datagrid("selectRow",0)}}},method:"post"})}else{deleteGridData(""+d+"DataGridList")}}function deleteOrderBib(){var a=$("#orderDataGridList").datagrid("getSelected");if(!a){return openMessageDlg("请先选择一条订购信息,进行删除")}openConfirmDlg("您确定要删除记录号为["+a.id+"]的订购数据吗?",null,deleteOrderBibResult,null)}function deleteOrderBibResult(){var c=$("#orderDataGridList").datagrid("getSelected");var b={};b.pk=c.id;var a=base_path+"per/order/delete.do";$.post(a,b,function(d){if(d.status=="0"){openMessageDlg(d.message,5000);bindDataGridListByBibId(c.bibid,"order")}else{openMessageDlg(d.message)}},"json")}function setPerPara(){$("#pageconfig_setpara_dlg").dialog("open")};