var selectEditBibId=0;var noEditBibGridByCode=false;$(function(){commonSetParaInit(initflag,null,"all",initJson);initGirdColumns();try{initIndexCommbox(vOrgType)}catch(a){initIndexCommbox(null)}try{if(!vOrderUrl){}}catch(a){vOrderUrl=null}initSearchSelectByLibcode();enterEvent("keyword",serachBib);$("#keyword").textbox("textbox").focus();if($("#acqDataGridList").length>0){$("#acqDataGridList").datagrid({rowStyler:rowStylerIsUpdateByLibcode,onSelect:onSelectAcqDataGridList})}if($("#orderDataGridList").length>0){$("#orderDataGridList").datagrid({onDblClickRow:updateOrderBib})}if($("#tabsGrid").length>0){$("#tabsGrid").tabs({onSelect:onSelectTabsGrid})}rateHandler();volumesHandler()});function setBntIsShowByLibcode(a){if(a){noEditBibGridByCode=true;$("#saveBibRecord").linkbutton({disabled:true});$("#deleteBibRecord").linkbutton({disabled:true});$("#acceptBibRecord").linkbutton({disabled:true});$("#appendRecord").linkbutton({disabled:true});$("#insertRow").linkbutton({disabled:true});$("#removeit").linkbutton({disabled:true});$("#z3950DownLoadToCopyEditGrid").linkbutton({disabled:true});$("#editBibGrid").datagrid({title:"不能修改非本馆或者非子馆的数据哦!"})}else{noEditBibGridByCode=false;$("#saveBibRecord").linkbutton({disabled:false});$("#deleteBibRecord").linkbutton({disabled:false});$("#acceptBibRecord").linkbutton({disabled:false});$("#appendRecord").linkbutton({disabled:false});$("#insertRow").linkbutton({disabled:false});$("#removeit").linkbutton({disabled:false});$("#z3950DownLoadToCopyEditGrid").linkbutton({disabled:false});$("#editBibGrid").datagrid({title:"编目数据"})}}function initSearchSelectByLibcode(){var b={key:"libcode"};var a=base_path+"par/common/getInitData.do";$.post(a,b,function(c){$("#libcodeSelect").combobox({data:c.rows,valueField:"code",textField:"name",loadFilter:function(d){var e={};e.code="";e.name="不限分馆";d.splice(0,0,e);return d},onLoadSuccess:function(){$(this).combobox("select",vLibcode)}})},"json");if($("#orderbatchno").length>0){b={type:"0",page:"1",rows:"500"};a=base_path+"par/batchno/page.do";$.post(a,b,function(f){var e=[];for(var d=0;d0){var f=getValue(c+"orderprice");if(f==0){var b=0;var a=base_path+"par/rate/getRate.do";var e={};e.originalncy=getValue(c+"ncy");e.conversionncy=getValue(c+"orderncy");$.post(a,e,function(h){if(h.status=="0"){b=h.rows[0];if(d>0&&b>0){setValue(c+"orderprice",d*b);var g=getValue(c+"volumes");if(g>0){setValue(c+"ordertotalprice",getValue(c+"orderprice")*g)}else{setValue(c+"ordertotalprice",getValue(c+"orderprice"))}}}},"json")}}}function volumesHandlerMain(b){var a=getValue(b+"ordertotalprice");var c=getValue(b+"volumes");if(a>0&&c>0){setValue(b+"orderprice",a/c)}}function setVolumesByBibPage(n,k){try{if(n.price){var g=/(\d{1,3})+(?:\.\d+)?/g;var l=n.price.match(g);var f=/[¥$CNYUSD]/g;var j=n.price.match(f);var b="";if(j){for(var d=0;d-1){m+=parseInt(l[d])}}}}if(m>0){setValue(k+"volumes",m)}else{setValue(k+"volumes",1)}}}catch(h){}rateHandlerMain(k)}function callSetParaResult(c){if(c.status=="0"){var b=c.rows[0];var a=JSON.parse(b.paramjson);if(a.sysid){setJsonData("page_",a);initEidtBiBModel(a.editmodel)}}else{openMessageDlg("请您先点点击设置按钮,设置相关参数!")}}function checkSystemPara(){if(getValue("page_sysid").length==0){return openMessageDlg("请您先点点击设置按钮,设置分系统参数!")}if(getValue("page_ctrlno").length==0){return openMessageDlg("请您先点点击设置按钮,设置控制区号参数!")}}function pageConfigIsNull(){if(getValue("page_ctrlno").length>0&&getValue("page_sysid").length>0){return true}openMessageDlg("请点击页面设置,设置分系统和控制号");return false}function initGirdColumns(){if(vCurPageFlag=="cat"){$("#acqDataGridList").datagrid("hideColumn","orderno");$("#acqDataGridList").datagrid("hideColumn","unifiedno")}else{if(vCurPageFlag=="per"||vCurPageFlag=="percheck"){var a=$("#acqDataGridList").datagrid("getColumnOption","title");a.title="刊名";$("#acqDataGridList").datagrid()}}}function serachBib(b,a){if(isUpdateData){$.messager.confirm("提示消息","您有修改过的数据未保存,您确定要执行当前操作吗?",function(c){if(c){serachBibOk(b,a);isUpdateData=false}})}else{serachBibOk(b,a)}}function serachBibOk(e,b){$("#keyword").textbox("textbox").focus().select();checkSystemPara();var d=0;var g=$("#acqDataGridList").datagrid("getSelected");if(g){d=$("#acqDataGridList").datagrid("getRowIndex",g)}var f={};var c=base_path+"lib/biblios/page.do";if(vOrderUrl){c=base_path+vOrderUrl+"/page.do";f["limit[2].condition"]="catacode";f["limit[2].value"]=getValue("catacode")}else{if(getValue("keyword").length==0&&!b){return openMessageDlg("检索值不能为空")}}clearComBibGridData();f.rows=10;f.page=1;if(vCurPageFlag=="cat"){f["limit[0].condition"]="status";f["limit[0].value"]="0";f.condition=getValue("bibindex")}else{f.condition=getValue("perindex")}f["limit[1].condition"]="sysid";f["limit[1].value"]=getValue("page_sysid");f.value=getValue("keyword");var h=$("#libcodeSelect");if(h.length>0&&getValue("libcodeSelect").length>0){f["limit[3].condition"]="libcode";f["limit[3].value"]=getValue("libcodeSelect")}var a=$("#orderbatchno");if(a.length>0&&getValue("orderbatchno").length>0){f["limit[4].condition"]="ORDBATCHNO";f["limit[4].value"]=getValue("orderbatchno")}if(e){f.condition=e;f.value=b}$("#acqDataGridList").datagrid({url:c,queryParams:f,onLoadSuccess:function(i){if(i.status=="0"){if(i.total>0){if(vOrderUrl){ischeckItem(i)}else{$("#acqDataGridList").datagrid("selectRow",d)}}else{if(vCurPageFlag=="cat"){$("#tabsGrid").tabs("select",1)}}}else{if(i.status=="9006"){openMessageDlg(i.message)}}},method:"post"});if(vCurPageFlag=="cat"){searchCenterDataGridList(e,b)}if(vCurPageFlag=="percheck"){$("#tabsLeftGrid").tabs("select",0)}}function addBibRecord(){if(isUpdateData){$.messager.confirm("提示消息","您有修改过的数据未保存,您确定要执行当前操作吗?",function(a){if(a){addBibRecordOk();isUpdateData=false}})}else{addBibRecordOk()}}function addBibRecordOk(){setBntIsShowByLibcode(false);selectEditBibId=0;if(pageConfigIsNull()){clearComBibGridData();var b=getValue("page_template");if(b){var a=base_path+"par/template/getTemplate.do?pk="+b;var c={};$.post(a,c,function(f){if(f.status=="0"){if(f.total>0){var d=jQuery.parseJSON(f.rows[0].paramjson);var e=d.rows;$("#editBibGrid").datagrid("loadData",e);insertCtrlNo()}}else{openMessageDlg(f.message)}},"json")}}if(vCurPageFlag=="percheck"){$("#tabsLeftGrid").tabs("select",1)}}function saveBibRecord(){if(pageConfigIsNull()){accept();var b=base_path+"lib/biblios/saveMarcRecord.do";if(vOrderUrl){b=base_path+vOrderUrl+"/saveMarcRecord.do"}var e={};var d=$("#editBibGrid").datagrid("getRows");if(d.length>0){for(var c=0;c0){e.id=selectEditBibId;a="update"}e.sysid=getValue("page_sysid");$.post(b,e,function(f){if(f.status=="0"){isUpdateData=false;selectEditBibId=f.rows[0].id;bindAcqDataGridDetailById(selectEditBibId);repeatSerachBib(a,selectEditBibId)}else{openMessageDlg(f.message)}},"json")}}}function deleteBibRecord(){var a=$("#acqDataGridList").datagrid("getSelected");if(!a){return openMessageDlg("请先选择一条书目信息,进行删除")}openConfirmDlg("您确定要删除记录号为["+selectEditBibId+"]的书目数据吗?",null,deleteBibRecordResult,null)}function deleteBibRecordResult(){var a=base_path+"lib/biblios/delete.do";if(vOrderUrl){a=base_path+vOrderUrl+"/delete.do"}var b={};b.id=selectEditBibId;$.post(a,b,function(c){if(c.status=="0"){repeatSerachBib("delete");openMessageDlg(c.message)}else{openMessageDlg(c.message)}},"json")}function repeatSerachBib(b,a){if(b=="delete"){bindAcqDataGridDetailById(0)}else{if(b=="add"&&a>0){serachBib("ID",selectEditBibId)}}}function bindAcqDataGridDetailById(a){if(a==0){selectEditBibId=a;$(".showEditbib-tip").html("");$("#editBibGrid").datagrid("loadData",[])}else{selectEditBibId=a;$(".showEditbib-tip").html("书目记录号【"+selectEditBibId+"】");showDataGridDetailById(selectEditBibId,"editBibGrid")}}function showDataGridDetailById(a,c){var b=base_path+"lib/biblios/getMarcRecordForEdit.do";if(vOrderUrl){b=base_path+vOrderUrl+"/getMarcRecordForEdit.do"}var d={};d.id=a;$.post(b,d,function(f){if(f.status=="0"){var e=f.rows;$("#"+c+"").datagrid("loadData",e)}else{openMessageDlg(f.message)}},"json")}function setParaBatchNo(a){var b="设置图书订购批号";if(a==0){b="设置图书订购批号"}if(a==1){b="设置图书验收批号"}if(a==2){b="设置期刊订购批号"}if(a==3){b="设置期刊验收批号"}if(a==4){b="设置期刊装订批号"}myFrame.window.onLoadGridData(a);$("#bibsetpara_batchno_dlg").dialog("setTitle",b);$("#bibsetpara_batchno_dlg").dialog("open")}function stylerFormatBibStatus(b,c,a){if(b=="0"){return}return"color:green;"}function insertCtrlNo(){var b=getValue("page_editmodel");if(b=="marc"){$(".showEditbib-tip").html("");selectEditBibId=0;var d=getValue("page_ctrlno");if(d){var a=base_path+"par/ctrlno/get.do?pk="+d;var c={};$.post(a,c,function(e){if(e.status=="0"){if(e.total>0){$("#editBibGrid").datagrid("insertRow",{index:0,row:{field:"001",indicator:"",data:e.rows[0].currentctrlno}})}}else{openMessageDlg(e.message)}},"json")}}};