var fieldComBoxData=[];var jsonGridColumns=[{field:"fld",title:"字段名",width:"10%",editor:"textbox",},{field:"indicator",title:"指示符",width:"10%",editor:"textbox"},{field:"value",title:"字段内容",width:"70%",editor:"textbox"},{field:"addnewfld",title:"是否新增字段",width:"10%",formatter:onShowCheckBoxName,editor:{type:"checkbox",options:{on:"1",off:"0"}}},];var deleteGridColumns=[{field:"fld",title:"字段名",width:"10%",editor:"textbox",},{field:"fldid",title:"字段序号",width:"10%",editor:"textbox"},{field:"subfldid",title:"子字段序号",width:"10%",editor:"textbox"},];var updateGridColumns=[{field:"fld",title:"字段名",width:"10%",editor:"textbox",},{field:"indicator",title:"指示符",width:"10%",editor:"textbox"},{field:"oldvalue",title:"原值",width:"30%",editor:"textbox"},{field:"newvalue",title:"新值",width:"30%",editor:"textbox"},{field:"partialreplace",title:"局部替换",width:"10%",formatter:onShowCheckBoxName,editor:{type:"checkbox",options:{on:"1",off:"0"}}},];var recordDeleteGridColumns=[{field:"fld",title:"字段名",width:"10%",editor:"textbox",},{field:"value",title:"字段内容",width:"80%",editor:"textbox"},];var curPerviewIndex=1;var maxPerviewNum=undefined;var wbTotal=0;var myWebSocket;var myOptype=undefined;var _bacth;var stopBnt='
';$(function(){setCurImportDataGridHeight(350);bibindex();var b=[{code:"libcode",key:"libcode",condition:"code",value:vLibcode},{key:"sysid"}];_myPage.prototype.initData(b);initFormatDesignGrid("fldadd");$("#opertype").combobox({onChange:function(d,c){if(d){initFormatDesignGrid(d)}}});initWebSocket();var a=mystorage.get("lowerlibcode")+",";console.log(a)});function onShowCheckBoxName(b,c,a){if(b=="1"){return"是"}else{return"否"}}function bibindex(){var b={key:"bibindex"};var a=base_path+"par/common/getInitData.do";$.post(a,b,function(c){$("#bacthindex").combobox({data:c.rows,valueField:"code",textField:"name",panelHeight:"200px",loadFilter:function(d){return d},onLoadSuccess:function(){$(this).combobox("select","ID")}});$("#bibindex").combobox({data:c.rows,valueField:"code",textField:"name",panelHeight:"200px",onLoadSuccess:function(){$(this).combobox("select","ISBN")}});$("#bibindex1").combobox({data:c.rows,valueField:"code",textField:"name",panelHeight:"200px",onLoadSuccess:function(){$(this).combobox("select","TITLE")}});$("#bibindex2").combobox({data:c.rows,valueField:"code",textField:"name",panelHeight:"200px",onLoadSuccess:function(){$(this).combobox("select","AUTHOR")}})},"json")}function initFormatDesignGrid(a){eidtorGridObject=$("#setFldHandlerGrid");var b;if(a=="fldadd"){b=jsonGridColumns}else{if(a=="fldmod"){b=updateGridColumns}else{if(a=="flddel"){b=deleteGridColumns}else{if(a=="recdel"){b=recordDeleteGridColumns}}}}eidtorGridObject.datagrid("loadData",[]);$("#setFldHandlerGrid").datagrid({iconCls:"e-icon fa fa-cog",fit:true,title:"设置要处理的字段",fitColumns:true,singleSelect:true,border:false,nowrap:false,striped:true,toolbar:toolbar,onClickRow:onClickEditorRow,columns:[b]});$("#setFldHandlerGrid").datagrid("resize")}function onPerviewData(c){$("#showPerviewOrgMarcData").html("");$("#showPerviewTagMarcData").html("");var b=getCurPageRecord();var a=eidtorGridObject.datagrid("getRows");if(a.length==0&&b.optype!="recdel"){return openMessageDlg("请设置你要进行批处理的条件")}if(b){if(c){curPerviewIndex=c}else{curPerviewIndex=1}b.previewindex=curPerviewIndex;b.express="preview";myWSSend(b)}}function stopAccept(){var a={};a.optype="stop";a.express="stop";myOptype="stop";myWSSend(a);$.messager.progress("close");$.messager.progress({title:"数据批处理",msg:"正在停止批处理,请稍等..."})}function initWebSocket(a){if("WebSocket" in window){myWebSocket=new WebSocket("ws://"+wbServerUrl+"websocket/handleMarc");myWebSocket.onopen=function(){};myWebSocket.onmessage=function(b){myWSOnMessage(b)};myWebSocket.onclose=function(b){openMessageDlg("连接已关闭...");$.messager.progress("close")};myWebSocket.onerror=function(b){openMessageDlg("连接出错...");$.messager.progress("close")}}else{openMessageDlg("您的浏览器不支持 WebSocket!")}}function myWSOnMessage(a){var b=JSON.parse(a.data);if(b.status=="0"){console.log(b);var c=b.rows[0];onHandlerBacthApp(c);if(c&&(c.express=="bacth"||c.express=="stop")){onBacthResult(b)}else{if(c&&c.express=="preview"){setDataToPageShowPerview(b)}else{}}}else{openMessageDlg(b.message)}}function myWSSend(a){myWebSocket.send(JSON.stringify(a))}function getCurPageRecord(){var b={};var c={};c.limit=getSrchlimit();b.srchlimit=c;b.optype=getValue("opertype");acceptEidtorGrid();var a=eidtorGridObject.datagrid("getRows");var d=[];d={};d.optype=getValue("opertype");if(a.length>0){d.list=a}b.param=d;return b}function getSrchlimit(){var b=[];var a=$('[item-type="export_record"]');var c=0;a.each(function(e,g){var f={};var j=g.id;var d=g.attributes["link-combobox"];var i=g.attributes["handler-type"];var h=g.attributes["table-type"];if(i){if(getValue(j).length>0){if(d){f.condition=getValue(d.value)}else{if(h){f.condition=h.value+"."+j.replace("export_beg_","").replace("export_end_","").replace("export_","")}else{f.condition=j.replace("export_beg_","").replace("export_end_","").replace("export_","")}}f.typeHandler=i.value;f.value=getValue(j);b.push(f)}}});return b}function setDataToPageShowPerview(e){var m=e.rows[0];if(m&&m.orgmarc){maxPerviewNum=m.total;$("#showPerviewOrgMarcData").html("");var c=m.orgmarc.split(/[\n\r]/g);var g=""+curPerviewIndex+"
";for(var f=0;f'+c[f].replace(/[$]([A-Za-z0-9])/g,'$$$1')+""}$("#showPerviewOrgMarcData").html(g);if(m.tagmarc){$("#showPerviewTagMarcData").html("");var a=m.tagmarc.split(/[\n\r]/g);g=""+curPerviewIndex+"
";for(var f=0;f3&&k.length>3){if(k.substr(0,3)==h.substr(0,3)){var l=getValue("opertype");if(l=="fldadd"&&h.indexOf(n[d].value)>-1){b="background:red;color:#fff;";break}else{if(l=="flddel"){b="background:red;color:#fff;";break}else{if(l=="fldmod"&&h.indexOf(n[d].newvalue)>-1){b="background:red;color:#fff;";break}}}}}}g+=''+a[f].replace(/[$]([A-Za-z0-9])/g,'$$$1')+"
"}$("#showPerviewTagMarcData").html(g)}}else{if(e.message&&e.status!="0"){openMessageDlg(e.message)}}}function onPerviewNextData(){if(curPerviewIndex>=maxPerviewNum){return openMessageDlg("已经是最后一条记录了")}onPerviewData(curPerviewIndex+1)}function onPerviewPrevData(){if(curPerviewIndex>1){onPerviewData(curPerviewIndex-1)}else{openMessageDlg("已经是第一条了")}}function onHandlerBacth(){onPerviewData(1);_bacth="bacth"}function onHandlerBacthApp(b){if(b){if(_bacth&&!b.complete&&b.total){_bacth=undefined;var a=getCurPageRecord();a.express="bacth";$.messager.confirm("提示消息","共命中["+b.total+"]条记录,您确定要做批处理操作吗?",function(c){if(c){myOptype=undefined;$.messager.progress({title:"数据批处理",msg:"正在处理数据,请稍等..."+stopBnt});myWSSend(a)}})}}}function checkErrorFile(){var c=base_path+"com/webuploader/download.do?filename="+errorfile;var b=window.open(c)}function onBacthResult(b){errorcount=0;handlecount=0;successcount=0;errorfile="";var c=b.rows[0];if(c.handlecount>=0){$.messager.progress("close");errorfile=c.errorfile;errorcount+=c.errorcount;handlecount+=c.handlecount;successcount+=c.successcount;wbTotal=c.total;var a="";if(myOptype){myOptype=undefined;a=""}else{a=stopBnt}$.messager.progress({title:"数据批处理",msg:"已处理["+handlecount+"]条数据,成功["+successcount+"]条,失败["+errorcount+"]条,请等待处理完成 ..."+a});if(c.complete){$.messager.progress("close");$(".handlecount").html("已处理["+handlecount+"]条数据");$(".successcount").html("成功["+successcount+"]条");$(".errorcount").html("失败["+errorcount+"]条");$("#checkerrorfile").show();$("#acceptFileResultDlg").dialog("open")}}}function setCurImportDataGridHeight(b){var a=$(window).height();var c=a-b;$(".import-data-div").css("height",c+"px");$("#perviewlayout").layout("resize");$(".acceptTextTip").hide()};