function HIBC_CheckCode(code) { var nonCheckCode = code.substr(0, code.length - 1); var arr = nonCheckCode.split(""); var sum = 0; var arrayDic = new Array(); arrayDic["0"] = "0"; arrayDic["1"] = "1"; arrayDic["2"] = "2"; arrayDic["3"] = "3"; arrayDic["4"] = "4"; arrayDic["5"] = "5"; arrayDic["6"] = "6"; arrayDic["7"] = "7"; arrayDic["8"] = "8"; arrayDic["9"] = "9"; arrayDic["A"] = "10"; arrayDic["B"] = "11"; arrayDic["C"] = "12"; arrayDic["D"] = "13"; arrayDic["E"] = "14"; arrayDic["F"] = "15"; arrayDic["G"] = "16"; arrayDic["H"] = "17"; arrayDic["I"] = "18"; arrayDic["J"] = "19"; arrayDic["K"] = "20"; arrayDic["L"] = "21"; arrayDic["M"] = "22"; arrayDic["N"] = "23"; arrayDic["O"] = "24"; arrayDic["P"] = "25"; arrayDic["Q"] = "26"; arrayDic["R"] = "27"; arrayDic["S"] = "28"; arrayDic["T"] = "29"; arrayDic["U"] = "30"; arrayDic["V"] = "31"; arrayDic["W"] = "32"; arrayDic["X"] = "33"; arrayDic["Y"] = "34"; arrayDic["Z"] = "35"; arrayDic["-"] = "36"; arrayDic["."] = "37"; arrayDic[" "] = "38"; arrayDic["$"] = "39"; arrayDic["/"] = "40"; arrayDic["+"] = "41"; arrayDic["%"] = "42"; arr.map(function (item, i) { sum += Number(arrayDic[item]); }) var ys = sum % 43; if (Number(ys) == Number(arrayDic[code.substr(code.length - 1, 1)])) return true; else return false;
}
function OtherCode_CheckCode(code) { var arr = code.split(""); var odd = 0, even = 0, num; arr.map(function (item, i) { if (i & 1) {
even += Number(item); } else {
odd += Number(item); } }) var codeLen = code.length; if (codeLen % 2 == 0) { num = String(10 - Number(String(odd * 3 + even).slice(-1)[0])).slice(-1)[0]; } else { num = String(10 - Number(String(odd + even * 3).slice(-1)[0])).slice(-1)[0]; } return num; }
//从批次码中挑选信息 function GetInfoFromRange(Code, Range) {
if (Range != "") { var Ranges = Range.split(","); return Code.substring(parseInt(Ranges[0]) - 1, parseInt(Ranges[1]) + parseInt(Ranges[0]) - 1); } }
//时间类型字段-截取 function GetDateInfoFromRange(Code, Range) {
if (Range != "") { var Ranges = Range.split(','); var dateType = Range.split('|')[1]; return GetDateInformation(Code.substring(parseInt(Ranges[0]) - 1, parseInt(Ranges[1].split('|')[0]) + parseInt(Ranges[0]) - 1), dateType); } else { return ""; } } //时间类型字段-截取 function GetDateInfoFromRange(Code, Range) {
if (Range != ""&&Code!="") { var Ranges = Range.split(','); var dateType = Range.split('|')[1]; return GetDateInformation(Code.substring(parseInt(Ranges[0]) - 1, parseInt(Ranges[1].split('|')[0]) + parseInt(Ranges[0])), dateType); } else { return ""; } }
//根据日期格式格式化日期为要显示日期 //dateString--要格式的日期字条串 如:YYMMDD=>>150928 YYJJJ=>>15182 MMYY==> >1115 //dateType"--格式:如YYMMDD function GetDateInformation(dateString, dateType) { var myDate = new Date(); var ye = myDate.getFullYear().toString().substring(0, 2); var result = 0;
switch (dateType) { case "YYMMDD": result = ye + dateString.substring(0, 2) + "-" + dateString.substring(2, 4) + "-" + dateString.substring(4, 6); break; case "YYJJJ": var flag = 0; var year = parseInt(ye + dateString.substring(0, 2)); var Month = 0; var Days = 0; var monthIndex = 0; var day = parseInt(dateString.substring(2, 5)); if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 100)) flag = 1; else flag = 0; var days = [0, 31, 59 + flag, 90 + flag, 120 + flag, 151 + flag, 181 + flag, 212 + flag, 243 + flag, 273 + flag, 304 + flag, 334 + flag, 365 + flag]; for (var i = 0; i < days.length; i++) { if (day <= days[i]) { Month = i < 10 ? ("0" + i) : i; monthIndex = i - 1; break; } } Days = (day - days[monthIndex] < 10) ? "0" + (day - days[monthIndex]) : (day - days[monthIndex]); result = year + "-" + Month + "-" + Days; break; case "MMYY": year = parseInt(ye + dateString.substring(2, 4)); result = ye + dateString.substring(2, 4) + "-" + dateString.substring(0, 2) + "-01"; break; case "YYMM": result = ye + dateString.substring(0, 2) + "-" + dateString.substring(2, 4) + "-01"; break; default: break; } var nullResult = ""; var matchResult = result.match(/((^((1[8-9]d{2})|([2-9]d{3}))(-)(10|12|0?[13578])(-)(3[01]|[12][0-9]|0?[1-9])$)|(^((1[8-9]d{2})|([2-9]d{3}))(-)(11|0?[469])(-)(30|[12][0-9]|0?[1-9])$)|(^((1[8-9]d{2})|([2-9]d{3}))(-)(0?2)(-)(2[0-8]|1[0-9]|0?[1-9])$)|(^([2468][048]00)(-)(0?2)(-)(29)$)|(^([3579][26]00)(-)(0?2)(-)(29)$)|(^([1][89][0][48])(-)(0?2)(-)(29)$)|(^([2-9][0-9][0][48])(-)(0?2)(-)(29)$)|(^([1][89][2468][048])(-)(0?2)(-)(29)$)|(^([2-9][0-9][2468][048])(-)(0?2)(-)(29)$)|(^([1][89][13579][26])(-)(0?2)(-)(29)$)|(^([2-9][0-9][13579][26])(-)(0?2)(-)(29)$))/); if (matchResult==null) return nullResult; else return result;
}