var initflag;var initJson;var linkid;var checkedItems=[];var orderType=0;var successcount=0;$(function(){initflag="page_,orderbib_";initJson=[{key:"sysid",condition:"type",value:vType},{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},{key:"acqstatus"}];$("#acqDataGridList").datagrid({idField:"id",onCheck:function(b,a){addcheckItem()},onUncheck:function(b,a){removeSingleItem(b,a)},onCheckAll:function(a){addcheckItem()},onUncheckAll:function(a){removeAllItem(a)}});$(".acceptTextTip").hide();setTimeout(initDefaultSelect,100)});function initDefaultSelect(){var a=$("#page_sysid").combobox("getData");if(a.length>0){$("#page_sysid").combobox("select",a[0].code);initOrderMenu(getValue("page_sysid"));return}else{setTimeout(initDefaultSelect,100)}}function initOrderMenu(c){var a=base_path+"acq/collectcata/page.do";var b={};b.status="1";b.sysid=c;$.post(a,b,function(d){$("#catacode").combobox({data:d.rows,valueField:"code",textField:"name",onLoadSuccess:function(){var e=$(this).combobox("getData");if(e.length>0){$(this).combobox("select",e[0].code)}}})},"json")}function orderBibRecord(c){orderType=0;var a="征订订购";$(".order-type-div").hide();setTextShowStatus(false);if(!c){cleanJsonData("orderbib_record");if(getValue("page_order_batchno").length==0){return openMessageDlg("请点击页面设置,在采访参数页面中设置订购批号")}var d=$("#acqDataGridList").datagrid("getSelected");if(!d){return openMessageDlg("请先选择一条征订书目,进行订购")}if(!d.classno){return openMessageDlg("你要进行订购的书目信息没有分类号,请完善书目信息才能进行图书订购!")}var b=getCurDateYMD();setValue("orderbib_paydate",b);setValue("orderbib_orderdate",b);setValue("orderbib_catacode",getValue("catacode"));setValue("orderbib_order_ids",d.id);setValue("orderbib_order_type",0);$(".orderbib_tip").html("提示:请您确认当前要订购的书目记录号【"+d.id+"】");bibDataToDlgData(d,"orderbib_",a)}else{$(".orderbib_tip").html("");gridDataToDlgData(c,"orderbib_",a)}}function bacthOrderBibRecord(){orderType=1;$(".order-type-div").show();var d=checkedItems.join(",");var b="批订购";setTextShowStatus(true);cleanJsonData("orderbib_record");var c=getCurDateYMD();setValue("orderbib_paydate",c);setValue("orderbib_orderdate",c);setValue("orderbib_catacode",getValue("catacode"));setValue("orderbib_libcode",vLibcode);setValue("orderbib_order_type",0);$(".orderbib_tip").html("提示:请您确认当前要订购的数量,共选中【"+checkedItems.length+"】条记录");var a=$('[item-type="page_paramjson"]');a.each(function(f,g){var e=getValue(g.id);if(g.id=="page_order_batchno"){setValue("orderbib_batchno",e)}else{if(g.id=="page_ncy"){setValue("orderbib_orderncy",e)}else{var i="orderbib_"+g.id.replace("page_","");var h=$("#"+i);if(h){setValue(i,e)}}}});$("#orderbib_dlg").dialog("setTitle",b);$("#orderbib_dlg").dialog("open")}function setTextShowStatus(a){if(a){$("#orderbib_price").numberbox("disable");$("#orderbib_orderprice").numberbox("disable");$("#orderbib_ordertotalprice").numberbox("disable");$("#orderbib_totalprice").numberbox("disable");$("#orderbib_volumes").textbox("disable");$("#orderbib_volumes").textbox("disable")}else{$("#orderbib_price").numberbox("enable");$("#orderbib_orderprice").numberbox("enable");$("#orderbib_ordertotalprice").numberbox("enable");$("#orderbib_totalprice").numberbox("enable");$("#orderbib_volumes").textbox("enable");$("#orderbib_volumes").textbox("enable")}}function ischeckItem(){for(var a=0;a0){d=base_path+"acq/order/update.do"}c.page=1;c.rows=1;$.post(d,c,function(e){if(e.status=="0"){openMessageDlg(e.message,5000);bindDataGridListByBibId(linkid,"order");$("#orderbib_dlg").dialog("close");$("#tabsGrid").tabs("select",1)}else{openMessageDlg(e.message)}},"json")}else{if(b){onBacthMianFun(b,c)}else{$.messager.confirm("提示消息","您确定要做批订购处理操作吗?",function(e){if(e){c.order_ids=checkedItems.join(",");onBacthMianFun(b,c)}})}}}function checkErrorFile(){var c=base_path+"com/webuploader/download.do?filename="+errorfile;var b=window.open(c)}function onBacthMianFun(a,c){if(!a){$.messager.progress({title:"批订购处理",msg:"正在处理数据,请稍等..."})}if(a){c=a}else{c.rows=200;c.page=1;successcount=0}var b=base_path+"acq/collect/orderCollectbibs.do";$.post(b,c,function(d){$.messager.progress("close");if(d.status=="0"){var e=d.rows[0];if(e){errorfile=e.errorfile;successcount+=parseInt(e.successcount);if(e.nextpage&&e.nextpage>0){$.messager.progress({title:"批订购处理",msg:"请等待处理完成 ..."});c.page=e.nextpage;saveOrderBib(c)}else{$(".handlecount").html("已处理["+successcount+"]条数据");$(".successcount").html("成功["+successcount+"]条");$(".errorcount").html("失败[0]条");$("#checkerrorfile").show();$("#acceptFileResultDlg").dialog("open")}}else{openMessageDlg(d.message)}}else{openMessageDlg(d.message)}},"json")}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+"acq/order/delete.do";$.post(a,b,function(d){if(d.status=="0"){openMessageDlg(d.message,5000);bindDataGridListByBibId(linkid,"order")}else{openMessageDlg(d.message)}},"json")}function cancelOrderBibRecord(){var a=$("#orderDataGridList").datagrid("getSelected");if(!a){return openMessageDlg("请先选择一条订购信息,进行退订处理")}if(a.ordstatus=="1"){return openMessageDlg("已经处于退订状态,无需重复退订!")}openConfirmDlg("您确定要对记录号为["+a.id+"]的数据进行退订处理吗?",null,cancelOrderBibRecordResult,null)}function cancelOrderBibRecordResult(){var c=$("#orderDataGridList").datagrid("getSelected");var b={};b.id=c.id;var a=base_path+"acq/order/cancelOrder.do";$.post(a,b,function(d){if(d.status=="0"){openMessageDlg(d.message,5000);bindDataGridListByBibId(c.bibid,"order")}else{openMessageDlg(d.message)}},"json")}function bindDataGridListByBibId(a,c){if(a>0){var b=base_path+"acq/"+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){},method:"post"})}else{deleteGridData(""+c+"DataGridList")}}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+"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(d,b,c){setValue(""+b+"id","0");if(!d){return openMessageDlg("请先选择一条征订书目,进行订购")}var a=$('[item-type="page_paramjson"]');setValue(""+b+"libcode",vLibcode);setVolumesByBibPage(d,b);setValue(""+b+"bibid",d.id);a.each(function(f,g){var e=getValue(g.id);if(g.id=="page_order_batchno"){setValue("orderbib_batchno",e)}else{if(g.id=="page_check_batchno"){setValue("checkbib_batchno",e)}else{if(g.id=="page_ncy"){setValue(""+b+"orderncy",e)}else{var i=""+b+""+g.id.replace("page_","");var h=$("#"+i);if(h){setValue(i,e)}}}}});setValue("checkbib_hold","");$("#"+b+"dlg").dialog("setTitle",c);$("#"+b+"dlg").dialog("open")}function onSelectAcqDataGridList(b,a){linkid=a.linkid;bindAcqDataGridDetailById(a.id);bindDataGridListByBibId(linkid,"order");bindDataGridListByBibId(linkid,"hold");bindRecommendDataGridListByBibId(a.id)}function bindRecommendDataGridListByBibId(a){if(a>0){var b=base_path+"acq/recommend/pageUnion.do";var c={};c.colid=a;c.rows=10;c.page=1;$("#recommendDataGridList").datagrid({url:b,queryParams:c,onLoadSuccess:function(d){},method:"post"})}else{deleteGridData("recommendDataGridList")}}function onSelectTabsGrid(b,a){if(a==1){$("#deleteOrderBib").show();$("#cancelOrderBibRecord").show()}else{$("#deleteOrderBib").hide();$("#cancelOrderBibRecord").hide()}}function clearComBibGridData(){selectEditBibId=0;clearGridData("editBibGrid,acqDataGridList,orderDataGridList,holdDataGridList");$("#tabsGrid").tabs("select",0)}function onOpenOrderDlg(){$("#orderbib_copies").numberbox().next("span").find("input").focus()}function setPerPara(){$("#pageconfig_setpara_dlg").dialog("open")};