var commonGridObj_orderlist; var comboVESSEL;//船名 var comboVOYNO;//航次 var comboCUSTOMERNAME;//委托单位 var comboOP;//操作人员 var s0=""; function $(id){ return document.getElementById(id); } function createGrid() { //header var headerArgs_orderlist = new Array("业务状态","费用状态","委托方式","录入人","录入日期", "船名","航次","主提单号","开船日期","发货人","委托单位","集装箱","订舱代理","揽货人","操作","单证","客服","航线","装货港","卸货港","交货地","目的地", "会计期间","分提单号","委托编号","运单号","装运方式","场站","截港日期","预抵日期", "运输条款","品名","货物毛重","货物尺码","件数","包装","箱TEU","船公司","报关行","承运车队", "发票号","业务来源","来源明细","订舱类型","订舱编号","装箱类型","仓库","截单日期","集港日期","其他箱型"); //width var widthArgs_orderlist = new Array("70","70","70","70","120", "150","70","150","120","120","120","120","120","70","70","70","70","120","150","150","150","150","70","150","150","100","100","100","120","120", "100","100","100","100","100","100","100","120","120","120", "100","100","100","100","150","100","120","120","120","60"); //column align var colAlignArgs_orderlist = new Array("center","left","left","left","left", "left","left","left","left","left","left","left","left","left","left","left","left","left","left","left","left","left","left","left","left","left","left","left","left","left", "left","left","left","left","left","left","left","left","left","left", "left","left","left","left","left","left","left","left","left","left"); //column sort var colSortArgs_orderlist = new Array("str","str","str","str","str", "str","str","str","str","str","str","str","str","str","str","str","str","str","str","str","str","str","str","str","str","str","str","str","str","str", "str","str","str","str","str","str","str","str","str","str", "str","str","str","str","str","str","str","str","str","str"); //column type var colTypeArgs_orderlist = new Array("ro","ro","ro","ro","ro", "ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro", "ro","ro","ro","ro","ro","ro","ro","ro","ro","ro", "ro","ro","ro","ro","ro","ro","ro","ro","ro","ro"); // s0=""; var strCNTR = dhtmlxAjax.getSync("../FeeCodes/TopCtnAdapter.aspx?cntr=cntr&val="+newGuid()); var sCNTR = strCNTR.xmlDoc.responseText; var jsonCtnObj = null; if(sCNTR.trim() != ""){ jsonCtnObj = eval('(' + sCNTR + ')'); for(var i=0;i' + "").value; comboOP = dhtmlXComboFromSelect("ddlOP"); comboOP.loadXML("../FeeCodes/OPAdapter.aspx?mask=0&pos=0&rName=isOperator&userID="+strUserID); } function initComboOP2(){//操作人员 comboOP.attachEvent("onChange", function(){ comboOP.setComboText($("hd_comboOP").value); }); comboOP.attachEvent("onBlur", function(){ var s1 = comboOP.getComboText().trim(); var s2 = s1.indexOf("|"); if(s1=="") { $("hd_comboOP").value=""; comboOP.setComboText($("hd_comboOP").value); } else { if(s2>0) { s2=s2+2; } var s3 = s1.substring(s2); if(s2>0) { comboOP.setComboText(s3); $("hd_comboOP").value=s3; } else { comboOP.setComboText($("hd_comboOP").value); } } }); comboOP.setComboText($("hd_comboOP").value); comboOP.attachEvent("onKeyPressed", function(keyCode){ if(keyCode!="8"){ var arrayArg = new Array(); setTimeout(function(){ var filterCount = 0; var is = -1; var ishd = $("hd_comboOP").value.trim(); if("" != comboOP.getComboText().trim()){ while("undefined" != typeof comboOP.getOptionByIndex(filterCount)){ var comboValue = comboOP.getOptionByIndex(filterCount).text.toUpperCase();//.value; var enterValue = comboOP.getComboText().trim().toUpperCase(); $("hd_comboOP").value = comboOP.getComboText().trim().toUpperCase(); if(comboValue.indexOf(enterValue) == 0){ comboOP.selectOption(filterCount,true,true); is=filterCount; break; } ++filterCount; } if(is==-1){ $("hd_comboOP").value = ishd; alert("无此内容,请重新选择!"); } } },10); } }); comboOP.attachEvent("onSelectionChange", function(){ $("hd_comboOP").value = comboOP.getComboText().trim(); }); } function initComboCUSTOMERNAME(){//委托单位 comboCUSTOMERNAME = dhtmlXComboFromSelect("ddlCUSTOMERNAME"); comboCUSTOMERNAME.loadXML("../FeeCodes/WebCrmClientAdapter.aspx?mask=0&pos=0&strIS=ISCONTROLLER"); } function initComboCUSTOMERNAME2(){//委托单位 comboCUSTOMERNAME.attachEvent("onChange", function(){ comboCUSTOMERNAME.setComboText($("hd_comboCUSTOMERNAME").value); }); comboCUSTOMERNAME.attachEvent("onBlur", function(){ var s1 = comboCUSTOMERNAME.getComboText().trim(); var s2 = s1.indexOf("|"); if(s1=="") { $("hd_comboCUSTOMERNAME").value=""; comboCUSTOMERNAME.setComboText($("hd_comboCUSTOMERNAME").value); } else { if(s2>0){ s2=s2+2; } var s3 = s1.substring(s2); if(s2>0){ comboCUSTOMERNAME.setComboText(s3); $("hd_comboCUSTOMERNAME").value=s3; }else{ comboCUSTOMERNAME.setComboText($("hd_comboCUSTOMERNAME").value); } } }); comboCUSTOMERNAME.setComboText($("hd_comboCUSTOMERNAME").value); comboCUSTOMERNAME.attachEvent("onKeyPressed", function(keyCode){ if(keyCode!="8"){ var arrayArg = new Array(); setTimeout(function(){ var filterCount = 0; var is = -1; var ishd = $("hd_comboCUSTOMERNAME").value.trim(); if("" != comboCUSTOMERNAME.getComboText().trim()){ while("undefined" != typeof comboCUSTOMERNAME.getOptionByIndex(filterCount)){ var comboValue = comboCUSTOMERNAME.getOptionByIndex(filterCount).text.toUpperCase();//.value; var enterValue = comboCUSTOMERNAME.getComboText().trim().toUpperCase(); $("hd_comboCUSTOMERNAME").value = comboCUSTOMERNAME.getComboText().trim().toUpperCase(); if(comboValue.indexOf(enterValue) == 0){ comboCUSTOMERNAME.selectOption(filterCount,true,true); is=filterCount; break; } ++filterCount; } if(is==-1){ $("hd_comboCUSTOMERNAME").value = ishd; alert("无此内容,请重新选择!"); } } },10); } }); comboCUSTOMERNAME.attachEvent("onSelectionChange", function(){ $("hd_comboCUSTOMERNAME").value = comboCUSTOMERNAME.getComboText().trim(); }); } function initComboVESSEL(){//船名 comboVESSEL = dhtmlXComboFromSelect("ddlVESSEL"); comboVESSEL.loadXML("../FeeCodes/TCodeVesselAdapter.aspx?mask=0&pos=0"); // comboVOYNO = dhtmlXComboFromSelect("ddlVOYNO"); var strVESSEL=$("hd_comboVESSEL").value; comboVOYNO.loadXML("../FeeCodes/TCodeVoynoAdapter.aspx?mask=0&pos=0&strVESSEL="+strVESSEL); } function initComboVESSEL2(){//船名 comboVESSEL.setComboText($("hd_comboVESSEL").value); comboVESSEL.attachEvent("onKeyPressed", function(keyCode){ if(keyCode!="8"){ var arrayArg = new Array(); setTimeout(function(){ var filterCount = 0; if("" != comboVESSEL.getComboText().trim()){ while("undefined" != typeof comboVESSEL.getOptionByIndex(filterCount)){ var comboValue = comboVESSEL.getOptionByIndex(filterCount).text.toUpperCase();//.value; var enterValue = comboVESSEL.getComboText().toUpperCase(); $("hd_comboVESSEL").value = comboVESSEL.getComboText().toUpperCase(); if(comboValue.indexOf(enterValue) == 0){ comboVESSEL.selectOption(filterCount,true,true); $("hd_comboVESSEL").value = comboVESSEL.getComboText().trim(); break; } ++filterCount; } } },10); } }); comboVESSEL.attachEvent("onBlur", function(){ $("hd_comboVESSEL").value = comboVESSEL.getComboText().trim(); $("hd_comboVOYNO").value=""; initComboVOYNO(); }); comboVESSEL.attachEvent("onChange", function(){ comboVESSEL.setComboText($("hd_comboVESSEL").value); }); comboVESSEL.attachEvent("onSelectionChange", function(){ $("hd_comboVESSEL").value = comboVESSEL.getComboText().trim(); }); } function initComboVOYNO()//航次 { var strVESSEL; try{ strVESSEL=comboVESSEL.getSelectedValue().trim();//$("hd_comboVESSEL").value; }catch(e){ strVESSEL=""; } //var strVESSEL=comboVESSEL.getSelectedValue().trim();//$("hd_comboVESSEL").value; comboVOYNO.loadXML("../FeeCodes/TCodeVoynoAdapter.aspx?mask=0&pos=0&strVESSEL="+strVESSEL); comboVOYNO.setComboText($("hd_comboVOYNO").value); comboVOYNO.attachEvent("onChange", function(){ comboVOYNO.setComboText($("hd_comboVOYNO").value); }); comboVOYNO.attachEvent("onKeyPressed", function(keyCode){ if(keyCode!="8"){ var arrayArg = new Array(); setTimeout(function(){ var filterCount = 0; if("" != comboVOYNO.getComboText().trim()){ while("undefined" != typeof comboVOYNO.getOptionByIndex(filterCount)){ var comboValue = comboVOYNO.getOptionByIndex(filterCount).text.toUpperCase();//.value; var enterValue = comboVOYNO.getComboText().trim().toUpperCase(); $("hd_comboVOYNO").value = comboVOYNO.getComboText().trim().toUpperCase(); if(comboValue.indexOf(enterValue) == 0){ comboVOYNO.selectOption(filterCount,true,true); break; } ++filterCount; } } },10); } }); comboVOYNO.attachEvent("onSelectionChange", function(){ $("hd_comboVOYNO").value = comboVOYNO.getComboText().trim(); }); } function ShowDetailSelect(){ createGrid(); } function GetRange(){ var loader; var dates; var strR=""; var getstrgid = commonGridObj_orderlist.getGridObj(); var strgid = getstrgid.getSelectedRowId(); if ($("hdRangeV").value != $("hdRangeO").value){ if($("hdRangeO").value=="1"){//分公司 loader = dhtmlxAjax.getSync("../FeeCodes/RangeAdapter.aspx?RangeID=1&strGID="+strgid+"&RangeName=modOrderManagement&val="+newGuid());//委托管理列表 dates = loader.xmlDoc.responseText; if(dates==""){ alert("您没有操作此数据的权限!"); return 0; } } if($("hdRangeO").value=="2"){//分公司 loader = dhtmlxAjax.getSync("../FeeCodes/RangeAdapter.aspx?RangeID=2&strGID="+strgid+"&RangeName=modOrderManagement&val="+newGuid());//委托管理列表 dates = loader.xmlDoc.responseText; if(dates==""){ alert("您没有操作此数据的权限!"); return 0; } }else if($("hdRangeO").value="3"){//个人 loader = dhtmlxAjax.getSync("../FeeCodes/RangeAdapter.aspx?RangeID=3&strGID="+strgid+"&RangeName=modOrderManagement&val="+newGuid());//委托管理列表 dates = loader.xmlDoc.responseText; if(dates==""){ alert("您没有操作此数据的权限!"); return 0; } } } } //获取GUID function newGuid() { var guid = ""; for (var i = 1; i <= 32; i++){ var n = Math.floor(Math.random()*16.0).toString(16); guid += n; if((i==8)||(i==12)||(i==16)||(i==20)) guid += "-"; } return guid.toUpperCase(); } function deleteOrder(){ var ii = GetRange(); if(ii==0){ return; } // var orderGridObj = commonGridObj_orderlist.getGridObj(); var selRowID = orderGridObj.getSelectedRowId(); var selGroup = new Array(); if(selRowID.indexOf(",") > 0){ selGroup = selRowID.split(","); }else{ if(selRowID != null){ selGroup.push(selRowID); } } //查看是否有被选中的费用项 if(selGroup.length > 0){ if(selGroup.length > 1){ var delCount = 0; if(window.confirm("您确定删除已选中的委托信息")){ while(delCount < selGroup.length){ var rowIndex = orderGridObj.getRowIndex(selGroup[delCount]); var feeName = orderGridObj.cellByIndex(rowIndex,1).getValue(); var cusName = orderGridObj.cellByIndex(rowIndex,2).getValue(); var urlVal = "SeaeOrderListBSGenlegGridSource.aspx?handle=delete&bsno="+selGroup[delCount]+"&val="+commonGridObj_orderlist.newGuid()+"&tbNO="+escape($("tbNO").value)+"&VESSEL="+escape($("hd_comboVESSEL").value)+"&VOYNO="+escape($("hd_comboVOYNO").value)+"&tbETD="+$("tbETD").value+"&tbETD2="+$("tbETD2").value+"&CUSTOMERNAME="+escape($("hd_comboCUSTOMERNAME").value)+"&ddlOP="+escape($("hd_comboOP").value+"&cntr="+s0); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; if(loadVal > 0 ) { //alert("删除成功"); } else { if(loadVal == -1){ alert("存在关联信息不能删除"); } } delCount++; } createGrid(); } }else{ var delCount = 0; while(delCount < selGroup.length){ var rowIndex = orderGridObj.getRowIndex(selGroup[delCount]); var feeName = orderGridObj.cellByIndex(rowIndex,1).getValue(); var cusName = orderGridObj.cellByIndex(rowIndex,2).getValue(); if(window.confirm("您确定要将所选委托信息删除")){ var urlVal = "SeaeOrderListBSGenlegGridSource.aspx?handle=delete&bsno="+selGroup[delCount]+"&val="+commonGridObj_orderlist.newGuid()+"&tbNO="+escape($("tbNO").value)+"&VESSEL="+escape($("hd_comboVESSEL").value)+"&VOYNO="+escape($("hd_comboVOYNO").value)+"&tbETD="+$("tbETD").value+"&tbETD2="+$("tbETD2").value+"&CUSTOMERNAME="+escape($("hd_comboCUSTOMERNAME").value)+"&ddlOP="+escape($("hd_comboOP").value+"&cntr="+s0); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; if(loadVal > 0 ){ //alert("删除成功"); createGrid(); }else{ if(loadVal == -1){ alert("存在关联信息不能删除"); } } } delCount++; } } }else{ alert("请选择您要删除的委托信息"); } } function refreshOrder(){ createGrid(); } function addOrder(){ var openSet = "height=700, width=1024, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " +(screen.height-750)/2 + ",Left= "+(screen.width-1100)/2 var openType = "_blank"; var openUrl = "../shipping/SeaeOrderListBSGenlegEdit.aspx?handle=add"; window.open (openUrl,openType,openSet); } function addFullOrder(){ var orderGridObj = commonGridObj_orderlist.getGridObj(); var selRowID = orderGridObj.getSelectedRowId(); if(selRowID==null || selRowID==""){ alert("请先选择要操作的数据!"); }else{ var openSet = "height=700, width=1024, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " +(screen.height-750)/2 + ",Left= "+(screen.width-1100)/2 var openType = "_blank"; var openUrl = "../shipping/SeaeOrderListBSGenlegEdit.aspx?handle=addfull&id="+selRowID; window.open (openUrl,openType,openSet); } } //校验时间格式 function validateDateTime(dateTimeObj){ var isValid = false; var parseToObj = new Date(dateTimeObj.replace(/-/g, "/")); if(!isNaN(parseToObj)){ isValid = true; } return isValid; } function DateTimeEqual(beginObj,endObj){ var isEqual = 0; var begin = new Date(beginObj.replace(/-/g, "/")); var end = new Date(endObj.replace(/-/g, "/")); if(Date.parse(begin) - Date.parse(end) > 0){ isEqual = -1;//起始时间大于结束时间 }else if(Date.parse(begin) - Date.parse(end) == 0){ isEqual = -2;//起始时间与结束时间相等 } return isEqual; } //根据条件查询付费申请信息 function search(){ var _begintime = $("tbETD").value.trim(); if(_begintime.trim() != ""){ if(!validateDateTime(_begintime)){ alert("起始时间格式错误"); return; } } var _endtime = $("tbETD2").value.trim(); if(_endtime.trim() != ""){ if(!validateDateTime(_endtime)){ alert("结束时间格式错误"); return; } } var _customer = $("hd_comboCUSTOMERNAME").value.trim(); var _vessel = $("hd_comboVESSEL").value.trim(); var _voyno = $("hd_comboVOYNO").value.trim(); var _op = $("hd_comboOP").value.trim(); var _checkno = $("tbNO").value.trim(); var searchJson = ""; //begin searchJson +="{"; searchJson += "["; //如果查询条件设置了起始时间和结束时间则判断结束时间是否大于起始时间 if(_begintime != "" && _endtime != ""){ if(_begintime.length > 9 && _endtime.length > 9){ var status = DateTimeEqual(_begintime,_endtime); if(status == 0){ searchJson += "\"btime\":\""+_begintime+"\"," searchJson += "\"etime\":\""+_endtime+"\"," }else if(status == -1){ alert("时间设置错误,起始时间不能大于结束时间,请修改!"); return; } // else if(status == -2){ // alert("时间设置错误,起始时间不能等于结束时间,请修改!"); // return; // } } else{ alert("时间格式有问题,长度应大于9个字符,请修改!"); return; } }else{ searchJson += "\"btime\":\""+_begintime+"\"," searchJson += "\"etime\":\""+_endtime+"\"," } searchJson += "\"cus\":\""+_customer+"\","; searchJson += "\"vessel\":\""+_vessel+"\","; searchJson += "\"voyno\":\""+_voyno+"\","; searchJson += "\"op\":\""+_op+"\","; searchJson += "\"no\":\""+_checkno+"\""; searchJson += "]"; searchJson +="}";//alert(searchJson); commonGridObj_orderlist.initGrid(); commonGridObj_orderlist.setRequest("SeaeOrderListBSGenlegGridSource.aspx?handle=list&show_page=15&cur_page=1&search="+escape(searchJson)+"&uid="+commonGridObj_orderlist.newGuid()+"&cntr="+s0); commonGridObj_orderlist.bind(); commonGridObj_orderlist.setSearch(searchJson); commonGridObj_orderlist.initPageByHandle("list"); commonGridObj_orderlist.getGridObj().attachEvent("onRowSelect", function(id,ind){ var openSet = "height=700, width=1024, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " +(screen.height-750)/2 + ",Left= "+(screen.width-1100)/2 var openType = "_blank"; var openUrl = "../shipping/SeaeOrderListBSGenlegEdit.aspx?handle=edit&id="+id; window.open (openUrl,openType,openSet); }); commonGridObj_orderlist.clickEvent = function(){ commonGridObj_orderlist.getGridObj().attachEvent("onRowSelect", function(id,ind){ var openSet = "height=700, width=1024, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " +(screen.height-750)/2 + ",Left= "+(screen.width-1100)/2 var openType = "_blank"; var openUrl = "../shipping/SeaeOrderListBSGenlegEdit.aspx?handle=edit&id="+id; window.open (openUrl,openType,openSet); }); } } String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); }