//两端去空格函数 String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ""); } function $(id) { return document.getElementById(id); } function nTabs(thisObj, Num) { if (thisObj.className == "active") return; var tabObj = thisObj.parentNode.id; var tabList = document.getElementById(tabObj).getElementsByTagName("li"); for (i = 0; i < tabList.length; i++) { if (i == Num) { thisObj.className = "active"; document.getElementById(tabObj + "_Content" + i).style.display = "block"; } else { tabList[i].className = "normal"; document.getElementById(tabObj + "_Content" + i).style.display = "none"; } } } //document.oncontextmenu=new Function("event.returnValue=false;"); //禁止右键功能,单击右键将无任何反应 //document.onselectstart=new Function("event.returnValue=false;"); //禁止先择,也就是无法复制 function $(id) { return document.getElementById(id); } var comboCUSTOMERNAME; //委托单位 var comboSALE; //揽货人 function initComboCUSTOMERNAME()//委托单位 { comboCUSTOMERNAME = dhtmlXComboFromSelect("ddlCUSTOMERNAME"); comboCUSTOMERNAME.loadXML("../FeeCodes/WebCrmClientAdapter.aspx?mask=0&pos=0");//&strIS=ISCONTROLLER } function initComboCUSTOMERNAME3()//委托单位 { comboCUSTOMERNAME.loadXML("../FeeCodes/WebCrmClientAdapter.aspx?mask=0&pos=0");//&strIS=ISCONTROLLER } function initComboCUSTOMERNAME2()//委托单位 { if ($("hdEnabled").value == "false") { comboCUSTOMERNAME.disable(true); } // comboCUSTOMERNAME.setOptionWidth(200); 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); } } // var amtdr = $("tbAMTDR").value.trim() == "" ? 0 : $("tbAMTDR").value.trim(); var fcydr = $("tbFCYDR").value.trim() == "" ? 0 : $("tbFCYDR").value.trim(); var amtcr = $("tbAMTCR").value.trim() == "" ? 0 : $("tbAMTCR").value.trim(); var fcycr = $("tbFCYCR").value.trim() == "" ? 0 : $("tbFCYCR").value.trim(); var dAmtdr = parseFloat(amtdr); var dFcydr = parseFloat(fcydr); var dAmtcr = parseFloat(amtcr); var dFcycr = parseFloat(fcycr); var faraptype = "FARCODE"; if (dAmtcr != 0 || dFcycr != 0) { var faraptype = "FAPCODE"; } var urlVal = "CwVouchersListGridSource_2.aspx?read=getfarapcode&customername=" + escape($("hd_comboCUSTOMERNAME").value) + "&faraptype=" + faraptype + "&val=" + newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; $("tbCORPID").value = loadVal.trim(); }); 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 initComboSALE()//揽货人 { //生成 var strUserID = $("hdUserID").value; comboSALE = dhtmlXComboFromSelect("ddlSALE"); comboSALE.loadXML("../FeeCodes/OPAdapter.aspx?mask=0&pos=0&rName=isSaleMan&userID=" + strUserID); } function initComboSALE3()//揽货人 { //生成 comboSALE.loadXML("../FeeCodes/OPAdapter.aspx?mask=0&pos=0&rName=isSaleMan&userID=" + strUserID); } function initComboSALE2()//揽货人 { if ($("hdEnabled").value == "false") { comboSALE.disable(true); } // comboSALE.attachEvent("onChange", function() { comboSALE.setComboText($("hd_comboSALE").value); }); comboSALE.attachEvent("onBlur", function() { var s1 = comboSALE.getComboText().trim(); var s2 = s1.indexOf("|"); if (s1 == "") { $("hd_comboSALE").value = ""; comboSALE.setComboText($("hd_comboSALE").value); } else { if (s2 > 0) { s2 = s2 + 2; } var s3 = s1.substring(s2); if (s2 > 0) { comboSALE.setComboText(s3); $("hd_comboSALE").value = s3; } else { comboSALE.setComboText($("hd_comboSALE").value); } } }); comboSALE.setComboText($("hd_comboSALE").value); comboSALE.attachEvent("onKeyPressed", function(keyCode) { if (keyCode != "8") { var arrayArg = new Array(); setTimeout(function() { var filterCount = 0; var is = -1; var ishd = $("hd_comboSALE").value.trim(); if ("" != comboSALE.getComboText().trim()) { while ("undefined" != typeof comboSALE.getOptionByIndex(filterCount)) { var comboValue = comboSALE.getOptionByIndex(filterCount).text.toUpperCase(); //.value; var enterValue = comboSALE.getComboText().trim().toUpperCase(); $("hd_comboSALE").value = comboSALE.getComboText().trim().toUpperCase(); if (comboValue.indexOf(enterValue) == 0) { comboSALE.selectOption(filterCount, true, true); is = filterCount; break; } ++filterCount; } if (is == -1) { $("hd_comboSALE").value = ishd; alert("无此内容,请重新选择!"); } } }, 10); } }); comboSALE.attachEvent("onSelectionChange", function() { $("hd_comboSALE").value = comboSALE.getComboText().trim(); }); } function initComboACCID()//科目代码 { //生成 comboACCID = dhtmlXComboFromSelect("ddlACCID"); comboACCID.loadXML("../FeeCodes/ACCIDAdapter.aspx?mask=0&pos=0"); } function initComboACCID3()//科目代码 { //生成 comboACCID.loadXML("../FeeCodes/ACCIDAdapter.aspx?mask=0&pos=0"); } function initComboACCID2()//科目代码 { if ($("hdEnabled").value == "false") { comboACCID.disable(true); } // comboACCID.attachEvent("onChange", function() { comboACCID.setComboText($("hd_comboACCID").value); }); comboACCID.attachEvent("onBlur", function() { var s1 = comboACCID.getComboText().trim(); var s2 = s1.indexOf("|"); if (s1 == "") { $("hd_comboACCID").value = ""; comboACCID.setComboText($("hd_comboACCID").value); } else { if (s2 > 0) { s2 = s2 - 1; } if (s2 > 0) { var s3 = s1.substring(0, s2); comboACCID.setComboText(s3); $("hd_comboACCID").value = s3; } else { comboACCID.setComboText($("hd_comboACCID").value); } } // var urlVal5 = "../FeeCodes/ACCIDAdapter.aspx?handle=accid&accid=" + $("hd_comboACCID").value + "&val=" + newGuid(); var loader5 = dhtmlxAjax.getSync(urlVal5); var sLabel = loader5.xmlDoc.responseText; $("tbACCNAME").value = sLabel; }); comboACCID.setComboText($("hd_comboACCID").value); comboACCID.attachEvent("onKeyPressed", function(keyCode) { if (keyCode != "8") { var arrayArg = new Array(); setTimeout(function() { var filterCount = 0; var is = -1; var ishd = $("hd_comboACCID").value.trim(); if ("" != comboACCID.getComboText().trim()) { while ("undefined" != typeof comboACCID.getOptionByIndex(filterCount)) { var comboValue = comboACCID.getOptionByIndex(filterCount).text.toUpperCase(); //.value; var enterValue = comboACCID.getComboText().trim().toUpperCase(); $("hd_comboACCID").value = comboACCID.getComboText().trim().toUpperCase(); if (comboValue.indexOf(enterValue) == 0) { comboACCID.selectOption(filterCount, true, true); is = filterCount; break; } ++filterCount; } } }, 10); } }); comboACCID.attachEvent("onSelectionChange", function() { $("hd_comboACCID").value = comboACCID.getComboText().trim(); }); } function getonload() { initComboSALE2(); initComboCUSTOMERNAME2(); initComboACCID2(); } //是否为数字,且数值格式是否正确 function IsNumFormat(val) { var re = /^[-\+]?\d+(\.\d+)?$/; if (!re.test(val)) { return false; } else { if (val.toString().indexOf(".") > 0) { val.toString().replace("-", ""); val.toString().replace("+", ""); if (val.toString().substr(0, 1) == "0" && val.toString().substr(0, 2) != "0.") { return false; } } else { var re1 = /^[-\+]+[1-9]+[0-9]*]*$/; if (!re1.test(val)) { re1 = /^[1-9]+[0-9]*]*$/; if (!re1.test(val)) { return false; } } } return true; } } // function getIsNum(x) { var str = x.value.trim(); if (str == "0") { return; } else if (str == "") { str = 0; x.value = 0; } else { var bl = IsNumFormat(str); if (!bl) { alert("数值格式错误!"); x.focus(); x.select(); } } } function printAction() { var strBSNO = ""; strBSNO = $("hdGid").value; var printUrl = ""; var companyID = ""; var typeName = "SEAOP"; var dbSourceID = ""; var userID = ""; var url = "../Reports/ReportService.aspx?handle=printCwVouchers&bsno=" + strBSNO + "&val=" + newGuid(); var loader = dhtmlxAjax.getSync(url); var reportVal = loader.xmlDoc.responseText; var reportObj = null; if (reportVal != "") { reportObj = eval('(' + reportVal + ')'); if (reportObj.reports.length > 0) { if (reportObj.reports[0].compid != "") { companyID = reportObj.reports[0].compid; } if (reportObj.reports[0].sourceid != "") { dbSourceID = reportObj.reports[0].sourceid; } if (reportObj.reports[0].compid != "") { userID = reportObj.reports[0].userid; } printUrl = "print://?comp=" + companyID + "&type=" + typeName + "&dbid=" + dbSourceID + "&uid=" + userID; //alert(printUrl); window.location.href = window.location.href; location.href = printUrl; } } else { alert("没有要打印的报表"); return; } } 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 fun() { //"8"退格,"13"回车,"45"负号,“46”英文的点,“xxx<48 and xxx>57”指数值键 if ((event.keyCode < 48 || event.keyCode > 57) && (event.keyCode != 8) && event.keyCode != 13 && event.keyCode != 45 && event.keyCode != 46) { alert("错误,只能填写整数!"); return false; } } //--件数、重量、平方等计数--> function IsNumeric(s) { var inum = s.replace(/[^\d]/g, ''); var bReturn = true; if (inum == "" || inum == null || inum == NaN) { bReturn = false; } return bReturn; } function setEnter() { var ls = ""; if ($("hd_comboACCID").value.trim() == "") { alert("财务科目代码不允许为空!"); return; } // // if ($("tbCORPID").value.trim() == "") { // alert("客户财务代码、财务科目代码不允许为空!"); // return; // } // if (($("tbAMTDR").value.trim() == "" || $("tbAMTDR").value.trim() == "0" || $("tbAMTDR").value.trim() == "0.00") && ($("tbAMTCR").value.trim() == "" || $("tbAMTCR").value.trim() == "0" || $("tbAMTCR").value.trim() == "0.00") && ($("tbFCYDR").value.trim() == "" || $("tbFCYDR").value.trim() == "0" || $("tbFCYDR").value.trim() == "0.00") && ($("tbFCYCR").value.trim() == "" || $("tbFCYCR").value.trim() == "0" || $("tbFCYCR").value.trim() == "0.00")) { alert("借贷双方不允许同时为0或空!"); return; } // if ((($("tbFCYDR").value.trim() != "" && $("tbFCYDR").value.trim() != "0" && $("tbFCYDR").value.trim() != "0.00") || ($("tbFCYCR").value.trim() != "" && $("tbFCYCR").value.trim() != "0" && $("tbFCYCR").value.trim() != "0.00")) && ($("tbFCYEXRATE").value.trim() == "" || $("tbFCYEXRATE").value.trim() == "0" || $("tbFCYEXRATE").value.trim() == "0.00" || $("tbFCYEXRATE").value.trim() == "1" || $("tbFCYEXRATE").value.trim() == "1.00")) { alert("有外币科目,则汇率不允许为0、1或空!"); return; } // $("hdEnter").value = "0"; msgBox(); setTimeout(postEnterTopCtn, 200); } //post数据 function postEnterTopCtn() { var myForm = document.getElementById("form1"); myForm.submit(); } //回车键控制 document.onkeypress = function() { if (event.keyCode == 13) { if (event.srcElement.tagName == 'TEXTAREA') { return true; } //window.event.keyCode=9; return false; } } function imgFreshChangePic() { var pic1 = document.getElementById("imgFresh"); var start = pic1.src.lastIndexOf("/"); var str = pic1.src.substring(start + 1); if (str == "btnFresh.gif") { pic1.src = "../images/icons/progress.gif"; //pic1.alt="我是B图片"; } else if (str == "progress.gif") { pic1.src = "../images/icons/btnFresh.gif"; //pic1.alt="我是A图片"; } } function ShowDetailFresh() { var strUserID = $("hdUserID").value; comboCUSTOMERNAME.loadXML("../FeeCodes/WebCrmClientAdapter.aspx?mask=0&pos=0&strIS=ISCONTROLLER"); comboSALE.loadXML("../FeeCodes/OPAdapter.aspx?mask=0&pos=0&rName=isSaleMan&userID=" + strUserID); comboACCID.loadXML("../FeeCodes/ACCIDAdapter.aspx?mask=0&pos=0"); } function isAMTDR() { var ls = $("tbAMTDR").value.trim(); if (ls == "" || ls == "0" || ls == "0.00") { return; } else { $("tbAMTCR").value=0; } } function isAMTCR() { var ls = $("tbAMTCR").value.trim(); if (ls == "" || ls == "0" || ls == "0.00") { return; } else { $("tbAMTDR").value = 0; } } function isFCYDR() { var ls = $("tbFCYDR").value.trim(); if (ls == "" || ls == "0" || ls == "0.00") { return; } else { $("tbFCYCR").value = 0; } } function isFCYCR() { var ls = $("tbFCYCR").value.trim(); if (ls == "" || ls == "0" || ls == "0.00") { return; } else { $("tbFCYDR").value = 0; } }