这个不行,先解决另一个问题,为什么我的数据找不到,现在不是红色了?
代码如下:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ page import="java.util.*" %>
<%@ page import="com.sjsemi.lsmm.service.*" %>
<%@ page import="com.sjsemi.prms.constants.*" %>
<%@ page import="com.sjsemi.profile.domain.*" %>
<%@ page import="com.sjsemi.common.*" %>
<%@ page import="com.sjsemi.common.constants.*" %>
<%@ page import="com.sjsemi.common.utils.*" %>
<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils" %>
<%@ page import="org.springframework.context.ApplicationContext" %>
<%@ page import="com.sjsemi.lsmm.vo.AB2WoInfoPrintVo" %>
<%@ page import="com.sjsemi.lsmm.vo.AB2WoInfoVo" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><%=Global.WEB_TITLE %>
</title>
<%
request.setCharacterEncoding("UTF-8");
%>
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<link rel="stylesheet" type="text/css" href="lib/bootstrap/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="custom/global.css">
<link rel="stylesheet" type="text/css" href="stylesheets/theme.css">
<link rel="stylesheet" href="lib/font-awesome/css/font-awesome.css">
<link rel="stylesheet" type="text/css" href="stylesheets/jquery-ui.css">
<script src="lib/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="lib/jquery-ui-1.10.4.js" type="text/javascript"></script>
<script src="lib/JsBarcode.all.min.js" type="text/javascript"></script>
<!-- <script src="lib/qrcode.js" type="text/javascript"></script> -->
<!-- Demo page code -->
<style type="text/css">
/* 基本信息表格样式 */
.table1 {
width: 100%;
border-collapse: collapse;
font-family: Arial, sans-serif;
font-size: 12px;
margin-bottom: 20px;
}
.table1 th, .table1 td {
border: 1px solid #000;
text-align: center;
vertical-align: middle;
padding: 6px;
}
/* 表格基础样式 */
#qTable {
width: 100%;
border-collapse: collapse;
font-family: Arial, sans-serif;
font-size: 12px;
}
#qTable th, #qTable td {
border: 1px solid #000;
text-align: center;
vertical-align: middle;
padding: 4px;
}
/* 表头样式 */
#qTable thead th {
background-color: #f2f2f2;
font-weight: bold;
}
/* 输入框样式(保持居中) */
#qTable input[type="number"] {
width: 60px;
text-align: center;
border: none;
background-color: transparent;
outline: none;
}
.table1, .tablea {
width: 100%;
border-collapse: collapse;
}
.table1 th, .table1 td, .tablea th, .tablea td {
border: 1px solid #ccc;
padding: 8px;
}
a {
color: #fdfeff;
text-decoration: none;
}
.tablea th, .tablea td {
padding: 4px;
line-height: 20px;
border-top: 1px solid #dddddd;
}
.brand .first {
color: #FF5C0D;
font-style: italic;
}
input[type="text"] {
margin-bottom: 1px;
}
input[readonly] {
cursor: not-allowed;
background-color: #ffffff;
}
.brand .second {
color: #fff;
font-weight: bold;
}
.Print {
cursor: pointer;
}
</style>
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="lib/html5.js"></script>
<![endif]-->
<!-- Le fav and touch icons -->
<link rel="shortcut icon" href="../assets/ico/favicon.ico">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="../assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="../assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="../assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="../assets/ico/apple-touch-icon-57-precomposed.png">
</head>
<%
UserProfile loginUser = (UserProfile) session.getAttribute("loginUser");
ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
MaterialManageService materialManageService = (MaterialManageService) appContext.getBean("materialManageService");
String lotId = FormatUtils.parseString(request.getParameter("lotId"));
AB2WoInfoVo ab2WoInfoVo = materialManageService.getAB2WoInfoPrintData(lotId.trim());
%>
<body>
<!--begin-->
<div>
<OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height=0 id="WebBrowser" width=0></OBJECT>
<form id="frmWoInfo" action="tdAB2WoInfoPrint.jsp?lotId="
method="post">
<input type="hidden" name="actionCode" value="<%=ActionCode.UPDATE_WO_INFO %>"/>
<div class="container-fluid">
<div>
<div class="block span6" style="width: 99%;">
<div id="tablewidget1" class="block-body collapse in">
<input type="hidden" name="li" value="<%=ab2WoInfoVo.getLotId() %>">
<!-- 基本信息表格 -->
<table class="table1">
<thead>
<tr>
<th style="width: 5%;">AB2 Lot</th>
<td style="width: 10%;" colspan="7">
<svg id="barcode1" style="width: 200px; height: 50px;"></svg>
</td>
</tr>
<tr>
<th style="width: 30px;">工单号</th>
<td><%=ab2WoInfoVo.getWoNo() %>
</td>
<th style="width: 30px;">工单数量</th>
<td><%=ab2WoInfoVo.getOrderQty() %>
</td>
<th style="width: 30px;">Product</th>
<td><%=ab2WoInfoVo.getProductId() %>
</td>
<th style="width: 30px;">CustomerId</th>
<td><%=ab2WoInfoVo.getCustomerId() %>
</td>
</tr>
</thead>
</table>
<!-- 动态数据表格 -->
<table class="tablea" border="1" id="qTable">
<thead id="tableHead">
</thead>
<tbody id="woInfoMaterialPrint">
</tbody>
</table>
<table class="table1">
<thead>
<tr>
<th style="width: 40px;">填写人员</th>
<td style="width: 80px;"></td>
<th style="width: 40px;">Double Check</th>
<td style="width: 80px;"></td>
</tr>
<tr>
<th style="width: 40px;">收料人</th>
<td style="width: 80px;"></td>
<th style="width: 40px;">退料人</th>
<td style="width: 80px;"></td>
</tr>
</thead>
</table>
<!--end-->
<!-- 按钮区域 -->
<div id="dy" class="modal-footer" style="display: block;">
<c:set var="status" scope="session" value="<%=ab2WoInfoVo.getStatus() %>"/>
<c:if test="${status eq 'Ready'}">
<button type="button" class="btn btn-primary" id="butIssueMaterial"
onclick="issueMaterial();">发料
</button>
</c:if>
<c:if test="${status eq 'InUse'}">
<button type="button" class="btn btn-primary" id="butReturnMaterial"
onclick="returnMaterial();">退料
</button>
</c:if>
<c:if test="${status eq 'Ready' || status eq 'InUse'}">
<button type="button" class="btn btn-primary" id="woNoPrint">打印</button>
</c:if>
<a class="btn btn-primary"
href="tdAB2WoInfo.jsp">返回工单查询</a>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
<script src="lib/bootstrap/js/bootstrap.js"></script>
<script type="text/javascript">
//工单状态
var woNoStatus = '<%=ab2WoInfoVo.getStatus()%>';
$(document).ready(function () {
var li = $("#frmWoInfo input[name='li']").val();
//设置条形码
JsBarcode("#barcode1", li, {
width: 2, // 调整宽度系数
height: 30, // 调整高度
fontSize: 14 // 如果需要调整文字字体大小
});
getWoInfoMaterialPrint();
});
var larg, altez;
if (document.layers) {
larg = screen.availWidth - 10;
altez = screen.availHeight - 20;
} else {
larg = screen.availWidth + 8;
altez = screen.availHeight + 7;
}
self.resizeTo(larg, altez);
self.moveTo(-4, -4);
var hkey_root, hkey_path, hkey_key
hkey_root = "HKEY_CURRENT_USER"
hkey_path = "\\Software\\Microsoft\\Internet Explorer\\PageSetup\\"
//设置网页打印的页眉页脚为空
function pagesetup_default() {
try {
var RegWsh = new ActiveXObject("WScript.Shell");
//设置页眉为空
hkey_key = "header";
RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "");
//设置页脚默认
hkey_key = "footer";
RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "&bAttachment No.: TD-GENL-GN-3009-014;Rev.:2;secuity.:2;&b");
//RegWsh.sendKeys('%fu');
} catch (e) {
}
}
function setLandscape() {
try {
var RegWsh = new ActiveXObject("WScript.Shell");
RegWsh.sendKeys('%fu');
RegWsh.sendKeys('%a');
RegWsh.sendKeys('{ENTER}');
} catch (e) {
}
}
function wp() {
var bdhtml = window.document.body.innerHTML;//获取当前页的html代码
var sprnstr = "<!--begin-->";//设置打印开始区域
var eprnstr = "<!--end-->";//设置打印结束区域
var prnhtml = bdhtml.substring(bdhtml.indexOf(sprnstr)); //从开始代码向后取html
var prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));//从结束代码向前取html
window.document.body.innerHTML = prnhtml;
window.print();
location.reload();
}
function doPrint() {
setLandscape();
WebBrowser.execwb(8, 1);//弹出横向打印设置
setTimeout("pagesetup_default()", 1000);
setTimeout("wp()", 1500);
return false;
}
var type = getBrowserType();
console.log("当前浏览器:" + type)
function getBrowserType() {
// 获取浏览器 userAgent
var ua = navigator.userAgent
// 是否为 IE
var isIE11 = (ua.indexOf('Trident') > -1) && (ua.indexOf("rv:11.0") > -1)
// 返回结果
if (isIE11) {
return 'IE11'
}
// 是否为 Chrome
var isChrome = (ua.indexOf("Chrome") > -1) && (ua.indexOf("Safari") > -1) && (ua.indexOf("Edge") == -1)
// 返回结果
if (isChrome) {
return 'Chrome'
}
// 都不是
return ''
}
//打印功能
$("#woNoPrint").click(function () {
// 同步 input
document.querySelectorAll("input").forEach(function (el) {
el.setAttribute("value", el.value);
});
var bdhtml = window.document.body.innerHTML;//获取当前页的html代码
var sprnstr = "<!--begin-->";//设置打印开始区域
var eprnstr = "<!--end-->";//设置打印结束区域
var prnhtml = bdhtml.substring(bdhtml.indexOf(sprnstr)); //从开始代码向后取html
var prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));//从结束代码向前取html
if (type == "Chrome") {
window.document.body.innerHTML = prnhtml;
window.print();
location.reload();
} else if (type == "IE11") {
doPrint();
}
});
/**
* 判断是否处于 pending 状态
*/
function isPending() {
return woNoStatus === "pending";
}
/**
* 如果处于 pending 状态且条件成立,则标红
* @param {HTMLElement} cell - 要标红的单元格
* @param {boolean} condition - 是否满足标红条件
*/
function conditionalHighlight(cell, condition) {
if (isPending() && condition) {
cell.style.backgroundColor = "red";
cell.style.color = "white";
}
}
/**
* 动态生成表头
*/
function generateDynamicTableHeader(binSet) {
const thead = $("#qTable thead");
thead.empty();
const firstRow = document.createElement("tr");
const secondRow = document.createElement("tr");
const fixedColumns = [
"Wafer Type", "Product ID", "WaferLot", "WaferID",
"WaferDieQty", "Bin"
];
const binList = Array.from(binSet);
const totalBins = binList.length;
fixedColumns.forEach(function (col) {
var th = document.createElement("th");
th.setAttribute("rowspan", "2");
th.style.textAlign = "center";
th.innerHTML = col;
firstRow.appendChild(th);
});
const createHeader = (title, span) => {
const th = document.createElement("th");
th.setAttribute("colspan", span);
th.style.textAlign = "center";
th.innerHTML = title;
return th;
};
firstRow.appendChild(createHeader("发料数量", totalBins));
firstRow.appendChild(createHeader("已用数量", totalBins));
firstRow.appendChild(createHeader("退料数量", totalBins));
const thRemark = document.createElement("th");
thRemark.setAttribute("rowspan", "2");
thRemark.style.textAlign = "center";
thRemark.style.width = "100px";
thRemark.innerHTML = "备注";
firstRow.appendChild(thRemark);
[...binList, ...binList, ...binList].forEach((bin, index) => {
const th = document.createElement("th");
th.style.textAlign = "center";
const total = totalBins;
if (index < total) {
th.innerHTML = bin;
} else if (index < total * 2) {
th.innerHTML = binList[index - total];
} else {
th.innerHTML = binList[index - total * 2];
}
secondRow.appendChild(th);
});
thead[0].appendChild(firstRow);
thead[0].appendChild(secondRow);
}
/**
* 填充表格数据
*/
function populateDynamicTable(dataArray) {
const tbody = document.getElementById("woInfoMaterialPrint");
tbody.innerHTML = "";
const binSet = new Set();
const grouped = {};
dataArray.forEach(function (item) {
const key = item.waferLot + "-" + item.waferNo;
const binCodeList = item.binCodeList
.replace(/;/g, "")
.split("|")
.map(b => b.trim())
.filter(b => b);
if (!grouped[key]) {
grouped[key] = {
waferType: item.waferType,
productId: item.productId,
waferLot: item.waferLot,
waferNo: item.waferNo,
waferDieQty: item.waferDieQty,
binData: {},
binCodeList: binCodeList,
status: item.status,
waferId: item.waferId,
};
}
const group = grouped[key];
if (item.binCode) {
const bin = item.binCode.trim();
binSet.add(bin);
group.binData[bin] = parseInt(item.qty || 0);
}
});
const binList = Array.from(binSet);
generateDynamicTableHeader(binSet);
Object.values(grouped).forEach(function (group) {
const row = document.createElement("tr");
// 固定列
row.insertCell().innerHTML = group.waferType;
row.insertCell().innerHTML = group.productId;
row.insertCell().innerHTML = group.waferLot;
row.insertCell().innerHTML = group.waferNo;
row.insertCell().innerHTML = group.waferDieQty;
row.insertCell().innerHTML = group.binCodeList.join("|");
row.setAttribute("data-wafer-id", group.waferId);
// 行背景色
conditionalHighlight(row, group.status === null || group.status === undefined ||
group.status === "" || group.status === "InUse");
// 发料数量列
binList.forEach(function (bin) {
const qty = group.binData[bin] || 0;
const cell = row.insertCell();
cell.innerHTML = qty;
conditionalHighlight(cell, qty === 0 && group.binCodeList.includes(bin));
conditionalHighlight(cell, group.status === "InUse");
});
// 已用数量列(输入框)
binList.forEach(function (bin) {
const cell = row.insertCell();
const input = document.createElement("input");
input.type = "number";
input.name = "usedQty";
input.value = 0;
input.style.width = "45px";
input.oninput = function () {
this.value = this.value.replace(/[^0-9]/g, '');
};
if (bin === "BINX") {
input.disabled = true;
input.style.backgroundColor = "#eee";
input.style.color = "#666";
} else if (woNoStatus !== 'InUse') {
input.disabled = true;
input.style.backgroundColor = "#eee";
input.style.color = "#666";
}
cell.appendChild(input);
conditionalHighlight(cell, group.status === "InUse");
});
// 退料数量列(输入框)
binList.forEach(function (bin) {
const cell = row.insertCell();
const input = document.createElement("input");
input.type = "number";
input.name = "returnQty";
input.value = 0;
input.style.width = "45px";
input.oninput = function () {
this.value = this.value.replace(/[^0-9]/g, '');
};
if (bin === "BINX") {
input.disabled = true;
input.style.backgroundColor = "#eee";
input.style.color = "#666";
} else if (woNoStatus !== 'InUse') {
input.disabled = true;
input.style.backgroundColor = "#eee";
input.style.color = "#666";
}
cell.appendChild(input);
conditionalHighlight(cell, group.status === "InUse");
});
// 备注列
row.insertCell().innerHTML = "";
tbody.appendChild(row);
});
}
/**
* 获取工单打印数据
*/
function getWoInfoMaterialPrint() {
var lotId = $("#frmWoInfo input[name='li']").val();
$.ajax({
type: "POST",
url: "DispatchAction?accessMethod=<%=AccessMethod.AJAX %>",
data: {
'actionCode': '<%=ActionCode.GET_AB2_WO_INFO_MATERIAL_PRINT %>',
'lotId': lotId,
'woNoStatus': woNoStatus
},
dataType: "json",
success: function (data) {
if (data.return_code == "0") {
populateDynamicTable(data.return_value);
} else {
alert(data.return_value);
}
},
error: function () {
alert("Ajax HTTP访问失败, 请联系IT处理!");
}
});
}
function issueMaterial() {
var lotId = $("#frmWoInfo input[name='li']").val();
var operation = 'Issuance'
$('#butIssueMaterial').attr("disabled", "disabled");
$.ajax({
type: "POST",
url: "DispatchAction?accessMethod=<%=AccessMethod.AJAX %>",
data: {
actionCode: '<%=ActionCode.UPDATE_AB2_WO_INFO_MATERIAL_PRINT %>',
lotId: lotId,
operation: operation
},
dataType: "json",
success: function (data) {
if (data.return_code == "0") {
alert(data.return_value);
location.reload();
} else {
alert(data.return_value);
$('#butIssueMaterial').attr("disabled", false);
}
},
error: function () {
alert("Ajax HTTP访问失败, 请联系IT处理!");
$('#butIssueMaterial').attr("disabled", false);
}
});
}
function returnMaterial() {
var listData = [];
var rows = document.querySelectorAll("#woInfoMaterialPrint tr");
var lotId = $("#frmWoInfo input[name='li']").val();
rows.forEach(function (row) {
var waferId = row.getAttribute("data-wafer-id"); // 获取 waferId
var binStr = row.querySelector("td:nth-child(6)")?.innerText.trim();
var binList = binStr ? binStr.split("|").map(b => b.trim()) : [];
// 找到当前行的所有“已用数量”和“退料数量”输入框
var usedQtyInputs = row.querySelectorAll("input[name='usedQty']");
var returnQtyInputs = row.querySelectorAll("input[name='returnQty']");
binList.forEach(function (bin, index) {
if (bin === "BINX") {
return; // 跳出当前循环
}
var usedQty = parseInt(usedQtyInputs[index]?.value || 0);
var returnQty = parseInt(returnQtyInputs[index]?.value || 0);
listData.push({
waferId: waferId,
bin: bin,
usedQty: usedQty,
returnQty: returnQty
});
});
});
var operation = 'Return'
var jsonData = JSON.stringify(listData);
$('#butReturnMaterial').attr("disabled", "disabled");
$.ajax({
type: "POST",
url: "DispatchAction?accessMethod=<%=AccessMethod.AJAX %>",
data: {
actionCode: '<%=ActionCode.UPDATE_AB2_WO_INFO_MATERIAL_PRINT %>',
jsonData: jsonData,
lotId: lotId,
operation: operation
},
dataType: "json",
success: function (data) {
if (data.return_code == "0") {
alert(data.return_value);
location.reload();
} else {
alert(data.return_value);
$('#butReturnMaterial').attr("disabled", false);
}
},
error: function () {
alert("Ajax HTTP访问失败, 请联系IT处理!");
$('#butReturnMaterial').attr("disabled", false);
}
});
}
</script>
</body>
</html>
当前工单状态为:Pending