条码系统,装箱扫描,出货扫描,校验扫描
2021-05-22 为了做华为三码合一,自己开发两码合一,包条码,箱条码
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<title>wms条码系统--装箱扫描</title>
<link rel="stylesheet" type="text/css" href="<%=basePath%>/js/jquery-3.5.1/jquery.datetimepicker.css" >
<script src="<%=basePath%>/js/jquery.js"></script>
<script src="<%=basePath%>/js/jquery-3.5.1/jquery.datetimepicker.full.js"></script>
<style type="text/css">
table
{
border-collapse: collapse;
}
table td, table th
{
border: 1px solid #cad9ea;
color: #666;
height: 30px;
}
table thead th
{
background-color: #CCE8EB;
width: 100px;
}
table tr:nth-child(odd)
{
background: #fff;
}
table tr:nth-child(even)
{
background: #F5FAFA;
}
.divcss5{ display:inline}
</style>
<script>
$(document).ready(function(){
$("#addTable").click(function(){
var i=document.getElementById('table1').rows.length;
var tr="<tr><td></td><td></td><td>内包条码"+i+"</td><td><input type='text' name='code1' onblur='autoBox(this)'></td></tr>";
$("#table1").append(tr);
});
$("#deleteTable").click(function(){
var i=document.getElementById('table1').rows.length;
if(i>2)
{
document.getElementById('table1').deleteRow(i-1);
}
});
})
var data =null;
function addbox()
{
var isgo=false;
var boxbarcode=document.getElementById("boxbarcode").value;
var code1=document.getElementsByName("code1");
for(var i=0;i<code1.length;i++){
var code1str=code1[i].value;
if(code1str.length>0)
{
var strbegin=beforegetStr(boxbarcode,";;")
var boxbegin=beforegetStr(code1str,";;")
var strcode=code1str.substring(0,strbegin);//截取字符串
var boxcode=boxbarcode.substring(0,boxbegin);//截取字符串
if(strcode!=boxcode)
{
alert("内包物料号与箱物料号不一致!");
return false;
}
isgo=true;
}
}
if(boxbarcode.length==0)
{
alert("请输入箱条码!");
return false;
}
alert("装箱成功!");
return isgo;
}
// $.ajax({
// url:'http://localhost:8066/meetRoom/room_findAlljson',
// type: 'get',
// data: null,
// timeout: 5000,
// dataType: "json",
// success: function(data){
// initPage(data);
// }
// });
//function initPage(data)
//{
// alert("装箱完成!");
// window.location.reload();
//}
function autoBox(obj)
{
var boxbarcode=document.getElementById("boxbarcode").value;//箱条码
var code1=document.getElementsByName("code1");//内包条码
if(obj.value.length==0)
{
alert("内条码输入不准确!");
return ;
}
var allint=0;//累加数量
for(var i=0;i<code1.length;i++){
var codestr=code1[i].value;//内包条码
var end=codestr.lastIndexOf(";"); //最后;
if(end!=-1)//存在条码
{
alert("内包"+codestr);
var strint=aftergetStr(codestr,";;").substring(0,aftergetStr(codestr,";;").length-1);//数字
if(boxbarcode.length==0)
{
createboxcode=codestr;//第一次扫描
}else
{
//var boxstrint=boxbarcode.substring(boxend+1,boxbarcode.length)
createboxcode=beforegetStr(codestr,";;");
allint=Number(allint)+Number(strint);
createboxcode=createboxcode+";;"+allint+";";
//非第一次,数量要累加
}
}
obj.readOnly=true
document.getElementById("boxbarcode").value=createboxcode;
}
}
//获取字符串的前面
function beforegetStr(string,str){
var str_before = string.split(str)[0];
return str_before;
}
//获取字符串的后面
function aftergetStr(string,str){
var str_after = string.split(str)[1];
return str_after;
}
</script>
</head>
<body>
<form onsubmit="return addbox();" method="post" action="<%=basePath%>/AutoBoxServlet">
<span><h2>装箱扫描</h2></span>
<a href="<%=basePath%>/wms/wms.jsp">返回首页</a>
<table id="table1">
<tr>
<td>箱条码</td>
<td colspan="3"><input type="text" id="boxbarcode" name="boxbarcode" readonly="true" style="width:100%;height:80px;"></td>
</tr>
<tr>
<td></td><td><input type="button" value="增加" name="addTable" id="addTable"/></td><td>内包条码1</td><td><input type="text" name="code1" onblur="autoBox(this)"></td>
</tr>
<tr>
<td></td><td></td><td>内包条码2</td><td><input type="text" name="code1" onblur="autoBox(this)"></td>
</tr>
<tr>
<td></td><td></td><td>内包条码3</td><td><input type="text" name="code1" onblur="autoBox(this)" ></td>
</tr>
<tr>
<td></td><td></td><td>内包条码4</td><td><input type="text" name="code1" onblur="autoBox(this)"></td>
</tr>
<tr>
<td></td><td></td><td>内包条码5</td><td><input type="text" name="code1" onblur="autoBox(this)"></td>
</tr>
</table>
<input type="submit" value="提交" />
<input type="button" value="删除" name="deleteTable" id="deleteTable"/>
</form>
</body>
</html>