<!-- 动态数据表格 -->
<table class="tablea" border="1" id="qTable">
<thead id="tableHead">
</thead>
<tbody id="woInfoMaterialPrint">
</tbody>
</table>
/**
* 判断是否处于 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,
issueData: {},
usedData: {},
returnData: {}
};
}
const group = grouped[key];
if (item.binCode) {
const bin = item.binCode.trim();
binSet.add(bin);
group.binData[bin] = parseInt(item.qty || 0);
group.issueData[bin] = parseInt(item.issueQty || 0);
group.usedData[bin] = parseInt(item.usedQty || 0);
group.returnData[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) {
let qty = 0;
if (woNoStatus === 'Completed') {
qty = group.issueData[bin] || 0;
} else {
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.style.width = "45px";
input.oninput = function () {
// 禁止输入以 0 开头的非法数字(例如 01、06)
if (this.value.length > 1 && this.value.startsWith('0')) {
this.value = this.value.replace(/^0+/, '');
}
// 如果为空则设置为空字符串
if (this.value === '') {
this.value = '';
}
};
if (woNoStatus === 'Completed') {
input.value = group.usedData[bin] || 0;
} else if (woNoStatus === 'InUse') {
if (bin === "BINX") {
input.value = group.usedData[bin] || 0; // BINX 保留原始值
} else {
input.value = ''; // 其他 bin 默认为空
}
} else {
input.value = 0;
input.disabled = true;
input.style.backgroundColor = "";
input.style.color = "";
}
if (bin === "BINX") {
input.disabled = true;
input.style.backgroundColor = "";
input.style.color = "";
} else if (woNoStatus !== 'InUse') {
input.disabled = true;
input.style.backgroundColor = "";
input.style.color = "";
}
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.style.width = "45px";
input.oninput = function () {
// 禁止输入以 0 开头的非法数字
if (this.value.length > 1 && this.value.startsWith('0')) {
this.value = this.value.replace(/^0+/, '');
}
if (this.value === '') {
this.value = '';
}
};
if (woNoStatus === 'Completed') {
input.value = group.returnData[bin] || 0;
} else if (woNoStatus === 'InUse') {
if (bin === "BINX") {
input.value = group.returnData[bin] || 0;
} else {
input.value = '';
}
} else {
input.value = 0;
input.disabled = true;
input.style.backgroundColor = "";
input.style.color = "";
}
if (bin === "BINX") {
input.disabled = true;
input.style.backgroundColor = "";
input.style.color = "";
} else if (woNoStatus !== 'InUse') {
input.disabled = true;
input.style.backgroundColor = "";
input.style.color = "";
}
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处理!");
}
});
}
参考我这个实现的动态打印界面,现在我需要改下下面的这个代码:
<%@page import="com.sjsemi.lsmm.domain.WoInfo" %>
<%@ 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.domain.WoInfo" %>
<%@ page import="com.sjsemi.lsmm.vo.WoInfoVo" %>
<!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">
a {
color: #fdfeff;
text-decoration: none;
}
.table1 {
width: 70%;
}
.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;
}
</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 woNo = FormatUtils.parseString(request.getParameter("woNo"));
WoInfoVo woInfoPrint = materialManageService.getWoInfoPrintData(woNo);
%>
<body>
<!--begin-->
<div>
<OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height=0 id="WebBrowser" width=0></OBJECT>
<form id="frmWoInfo" action="tdWoInfoManage.jsp" 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">
<table class="table1">
<thead>
<tr>
<th style="width: 30px;">工单号</th>
<input type="hidden" id="wn" name="wn" value="<%=woInfoPrint.getWoNo() %>">
<input type="hidden" id="pd" name="pd" value="<%=woInfoPrint.getProdId() %>">
<input type="hidden" id="li" name="li" value="<%=woInfoPrint.getMainLotId() %>">
<input type="hidden" id="ctm" name="ctm" value="<%=woInfoPrint.getMainLotCTMLotId() %>">
<input id="woWaferQty" name="woWaferQty" style="display: none"
value="<%=woInfoPrint.getWaferQty() %>"/>
<td style="width: 10%;">
<svg id="barcode1"></svg>
</td>
<th style="width: 180px;">MainLotID</th>
<td style="width: 10%;">
<svg id="barcode3"></svg>
</td>
<th style="width: 180px;">MainlotCTMLotID</th>
<td style="width: 10%;">
<svg id="barcode4"></svg>
</td>
<th style="font-size: 14px; width: 8%;">
<%=woInfoPrint.getIssueTime() %>
<c:set var="status" scope="session" value="<%=woInfoPrint.getStatus() %>"/>
<c:if test="${status eq 'I' || status eq 'R'}">
<th style="width: 5%;"/>
<td id="ContrastId">
<p style="text-align: center;">扫码</p>
<input id="contrast" name="contrast" type="text" style="width: 100px;"
autocomplete="off"/>
</td>
</c:if>
<td style="width: 130px;">
<div style="text-align: center;"></div>
<td style="width: 130px;"></td>
</tr>
<tr>
<th>PartNo</th>
<td>
<svg id="barcode2"></svg>
</td>
<th>WaferQty</th>
<td style="width: 10%;">
<svg id="barcode5"></svg>
</td>
<th style="width: 8%;text-align: center;">MainlotWaferID</th>
<td style="width: 5%;text-align: center;"><%=woInfoPrint.getMainLotWaferId() %>
<th style="width: 5%;"/>
<th>
<div style="text-align: center;">发料者
<input type="text" style="width: 60px;" value="<%=loginUser.getUsername() %>"
readonly/>
</div>
</th>
<th>
<div style="text-align: center;">退料人
<input id="Return" name="Return" type="text" style="width: 60px;"
onBlur="mOut(this)" autocomplete="off"/>
</div>
</th>
<th>
<div style="text-align: center;">收料人
<input type="text" style="width: 60px;" value="<%=loginUser.getUsername() %>"
readonly/>
</div>
</th>
</tr>
</thead>
</table>
<table class="tablea">
<tbody>
<tr>
<th rowspan="2" style="text-align: center; width: 5%;">No</th>
<th rowspan="2" style="text-align: center; width: 6%;">MaterialName</th>
<th rowspan="2" style="text-align: center; width: 6%;">Prod ID</th>
<th rowspan="2" style="text-align: center; width: 6%;">SJ Lot ID</th>
<th rowspan="2" style="text-align: center; width: 6%;">WaferID</th>
<th rowspan="2" style="text-align: center; width: 6%;">Qty</th>
<th rowspan="2" style="text-align: center; width: 6%;">库位</th>
<th rowspan="2" style="text-align: center; width: 6%;">对比</th>
<th rowspan="2" style="text-align: center; width: 6%;">物料状态</th>
<th rowspan="2" style="text-align: center; width: 6%;">BinCode</th>
<th colspan="2" style="text-align: center; width: 6%;">发</th>
<th colspan="1" style="text-align: center; width: 6%;">用</th>
<th colspan="2" style="text-align: center; width: 6%;">剩余</th>
<th colspan="2" style="text-align: center; width: 6%;">备注</th>
</tr>
<tr>
<td style="text-align: center;">Bin1</td>
<td style="text-align: center;">BinX</td>
<td style="text-align: center;">Bin1</td>
<td style="text-align: center;">Bin1</td>
<td style="text-align: center;">BinX</td>
</tr>
<tbody id="q"></tbody>
</tbody>
</table>
<!--end-->
<div id="dy" class="modal-footer" style="display: block;">
<input type="hidden" name="woStatus" value="<%=woInfoPrint.getStatus() %>">
<c:set var="status" scope="session" value="<%=woInfoPrint.getStatus() %>"/>
<c:if test="${status eq 'I'}">
<button type="button" class="btn btn-primary" id="butSend" name="butSend"
onclick="issueMaterial();">发料
</button>
</c:if>
<c:if test="${status eq 'R'}">
<button type="button" class="btn btn-primary" id="butBack" name="butBack"
onclick="returnMaterial();">退料
</button>
</c:if>
<c:if test="${status eq 'I' || status eq 'R'}">
<button type="button" class="btn btn-primary" id="Print">打印</button>
</c:if>
<a class="btn btn-primary"
href="tdWoNoManage.jsp?status=<%=woInfoPrint.getStatus() %>">返回工单查询</a>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
<script src="lib/bootstrap/js/bootstrap.js"></script>
<script type="text/javascript">
//工单状态
var woNoStatus = $("#frmWoInfo input[name='woStatus']").val();
//循环次数
var printQuantity;
//工单打印界面总WaferId数量进行对比
var waferIdCompare;
//是否为新逻辑
var isShare;
$(document).ready(function () {
getWoInfoPrint();
var wn = $("#frmWoInfo input[name='wn']").val();
var pd = $("#frmWoInfo input[name='pd']").val();
var li = $("#frmWoInfo input[name='li']").val();
var ctm = $("#frmWoInfo input[name='ctm']").val();
var woWaferQty = $("#frmWoInfo input[name='woWaferQty']").val();
//设置条形码
JsBarcode("#barcode1", wn, {width: 1, height: 20});
JsBarcode("#barcode2", pd, {width: 1, height: 20});
JsBarcode("#barcode3", li, {width: 1, height: 20});
JsBarcode("#barcode4", ctm, {width: 1, height: 20});
JsBarcode("#barcode5", woWaferQty, {width: 1, height: 20});
/* //实例化二维码并调整二维码大小
var qrcode = new QRCode(document.getElementById("qrcode"), {
width: 80,
height: 80,
correctLevel: QRCode.CorrectLevel.H
});
//生成二维码
function makeCode() {
//qrcode.clear();
qrcode.makeCode(li);
};
//调用生成二维码方法
makeCode(); */
});
//保存字段在打印页面中
function mOut(obj) {
var id = obj.id;
document.getElementById(id).setAttribute('value', obj.value);
}
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 ''
}
//打印功能
$("#Print").click(function () {
ContrastId.style.display = "none";
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();
}
});
//对比功能
$("#frmWoInfo input[name='contrast']").bind('keypress', function (event) {
var waferId = $("#frmWoInfo input[name='contrast']").val();
var count = printQuantity;
var sum = 0;
var waferIdList = waferIdCompare.split(",");
if (event.keyCode == '13') {
if (waferId != "") {
if (woNoStatus == "I" || woNoStatus == "R") {
for (var i = 0; i < count; i++) {
if (waferIdList[i] == waferId) {
sum = 999;
document.getElementById("pass" + (i + 1)).innerHTML = "PASS";
$("#frmWoInfo input[name='contrast']").val("");
$("#frmWoInfo input[name='contrast']").focus();
break;
}
}
}
if (sum != 999) {
$("#frmWoInfo input[name='contrast']").val("");
$("#frmWoInfo input[name='contrast']").focus();
alert(waferId + " Wafer ID未在该工单中找到,请核对!");
}
} else {
alert("请输入Wafer ID");
}
}
});
//显示循环数量
var j = 0;
//获取工单打印界面数据
function getWoInfoPrint() {
var count = 0;
var materialName = "";
var waferId = "";
var lotId = "";
var waferNo = "";
var prodId = "";
var binCode = "";
var qty = "";
var status = "";
var PLocation = "";
var initQty = "";
var initQtyX = "";
var useQty = "";
var remainingQty = "";
var remainingQtyX = "";
var tailpiece = "";
var tips = "";
var isShareWo = "";
var shareColor = "";
var isShareWaferId = "";
var waferIdStr = "";
var woNo = $("#frmWoInfo input[name='wn']").val();
var woProdId = $("#frmWoInfo input[name='pd']").val();
if (woNoStatus != "Y") {
$.ajax({
type: "POST",
url: "DispatchAction?accessMethod=<%=AccessMethod.AJAX %>",
data: {
'actionCode': '<%=ActionCode.SELECT_WO_INFO_PRINT %>',
'woNo': woNo,
'prodId': woProdId
},
dataType: "json",
success: function (data) {
if (data.return_code == "0") {
printQuantity = data.return_value.length;
isShare = data.return_value[printQuantity - 1].isShareWo;
for (var i = 0; i < data.return_value.length; i++) {
count = data.return_value.length;
j++
waferId = data.return_value[i].waferId;
waferIdStr = waferIdStr + "," + waferId;
prodId = data.return_value[i].prodId;
binCode = data.return_value[i].binCode;
qty = data.return_value[i].qty;
lotId = data.return_value[i].lotId;
waferNo = data.return_value[i].waferNo;
materialName = data.return_value[i].materialName;
status = data.return_value[i].status;
PLocation = data.return_value[i].PLocation;
initQty = data.return_value[i].initQty;
initQtyX = data.return_value[i].initQtyX;
remainingQty = data.return_value[i].remainingQty;
remainingQtyX = data.return_value[i].remainingQtyX;
tailpiece = data.return_value[i].tail;
if (materialName.indexOf("Dummy") == -1) {
if (tailpiece == "") {
tips += "," + waferId;
}
}
if (data.return_value[i].isShareWaferId != "") {
isShareWaferId = data.return_value[i].isShareWaferId;
} else {
isShareWaferId = "N";
}
if (materialName == "") {
color = "red";
} else {
color = "green";
}
if (isShareWaferId == "Y") {
shareColor = "red";
} else {
shareColor = "";
}
if (i == printQuantity - 1) {
isShareWo = data.return_value[i].isShareWo;
}
var readonly = "false";
if (woNoStatus != "R") {
readonly = "true";
}
const tbody = document.getElementById('q');
var newTr = document.createElement('tr');
newTr.innerHTML = newTr.innerHTML +
'<td style="text-align: center;">' + j + '</td>' +
'<td style="width: 80px;text-align: center;color: ' + shareColor + ';"" id="MaterialName' + j + '" Name="MaterialName' + j + '" >' + materialName + '</td>' +
'<td style="width: 50px;text-align: center;" id="ProdId' + j + '" Name="ProdId' + j + '" >' + prodId + '</td>' +
'<td style="width: 60px;text-align: center;color: ' + color + ';" id="lotId' + j + '" Name="lotId' + j + '" >' + lotId + '</td>' +
'<td style="width: 30px;text-align: center;color: ' + color + ';" id="waferNo' + j + '" Name="waferNo' + j + '" >' + waferNo + '</td>' +
'<td style="width: 20px;text-align: center;" id="DieQty' + j + '" Name="DieQty' + j + '">' + qty + '</td>' +
'<td style="width: 20px;text-align: center;">' + PLocation + '</td>' +
'<td style="width: 20px;text-align: center;" id="pass' + j + '" Name="pass' + j + '"></td>' +
'<td style="width: 20px;text-align: center;" id="Status' + j + '" Name="Status' + j + '">' + status + '</td>' +
'<td style="width: 50px;text-align: center;">' + binCode + '</td>' +
'<td style="text-align: center;"><input type="text" style="text-align: center;width: 35px;" id="aName' + j + '" name="aName' + j + '" value=' + initQty + ' readonly /></td>' +
'<td style="text-align: center;"><input type="text" style="text-align: center;width: 35px;" id="bName' + j + '" name="bName' + j + '" value=' + initQtyX + ' readonly /></td>';
if (woNoStatus == 'R') {
newTr.innerHTML = newTr.innerHTML + '<td style="text-align: center;"><input id="cName' + j + '" name="cName' + j + '" type="text" style="width: 35px;" onBlur="mOut(this)" autocomplete="off" value=' + qty + ' /></td>';
tbody.appendChild(newTr);
} else {
newTr.innerHTML = newTr.innerHTML + '<td style="text-align: center;"><input id="cName' + j + '" name="cName' + j + '" type="text" style="width: 25px;" onBlur="mOut(this)" autocomplete="off" readonly="' + readonly + '" /></td>';
tbody.appendChild(newTr);
}
newTr.innerHTML = newTr.innerHTML +
'<td style="text-align: center;"><input type="text" style="text-align: center;width: 35px;" id="TBin1' + j + '" name="TBin1' + j + '" type="text" style="width: 35px;" value=' + remainingQty + ' readonly /></td>' +
'<td style="text-align: center;"><input type="text" style="text-align: center;width: 35px;" id="TBinX' + j + '" name="TBinX' + j + '" type="text" style="width: 35px;" value=' + remainingQtyX + ' readonly /></td>' +
'<td class="word-wrap" style="width: 10%;text-align: center;">' + tailpiece + '</td>' +
'<td style="display: none"><input id="isShareWaferId' + j + '" name="isShareWaferId' + j + '" value=' + isShareWaferId + '></td>';
tbody.appendChild(newTr);
}
waferIdCompare = waferIdStr.substring(1);
if (woNoStatus == "I") {
if (tips != "") {
alert("当前 [" + tips.substring(1) + "] 不满足 [发Good Bin-Qty>0]!");
}
}
} else {
alert(data.return_value);
}
},
error: function () {
alert("Ajax HTTP访问失败, 请联系IT处理!");
}
});
} else {
//已发料
if (woNoStatus == "Y") {
$.ajax({
type: "POST",
url: "DispatchAction?accessMethod=<%=AccessMethod.AJAX %>",
data: {
'actionCode': '<%=ActionCode.SELECT_WO_HIST_PRINT %>',
'woNo': woNo,
},
dataType: "json",
success: function (data) {
if (data.return_code == "0") {
printQuantity = data.return_value.length;
for (var i = 0; i < data.return_value.length; i++) {
j++
tailpiece = data.return_value[i].tail;
materialName = data.return_value[i].materialName;
prodId = data.return_value[i].prodId;
waferId = data.return_value[i].waferId;
waferIdStr = waferIdStr + "," + waferId;
binCode = data.return_value[i].binCode;
qty = data.return_value[i].qty;
lotId = data.return_value[i].lotId;
waferNo = data.return_value[i].waferNo;
status = data.return_value[i].status;
PLocation = data.return_value[i].PLocation;
initQty = data.return_value[i].initQty;
initQtyX = data.return_value[i].initQtyX;
useQty = data.return_value[i].useQty;
remainingQty = data.return_value[i].remainingQty;
remainingQtyX = data.return_value[i].remainingQtyX;
q.innerHTML = q.innerHTML +
'<td style="text-align: center;">' + j + '</td>' +
'<td style="width: 80px;text-align: center;color: ' + shareColor + ';"" id="MaterialName' + j + '" Name="MaterialName' + j + '" >' + materialName + '</td>' +
'<td style="width: 50px;text-align: center;" id="prodId' + j + '" name="prodId' + j + '" >' + prodId + '</td>' +
'<td style="width: 60px;text-align: center;color: green;" id="lotId' + j + '" name="lotId' + j + '" >' + lotId + '</td>' +
'<td style="width: 30px;text-align: center;color: green;" id="waferNo' + j + '" name="waferNo' + j + '" >' + waferNo + '</td>' +
'<td style="width: 20px;text-align: center;" id="qty' + j + '" name="qty' + j + '">' + qty + '</td>' +
'<td style="width: 20px;text-align: center;">' + PLocation + '</td>' +
'<td style="width: 20px;text-align: center;" id="pass' + j + '" name="pass' + j + '"></td>' +
'<td style="width: 20px;text-align: center;" id="status' + j + '" name="status' + j + '">' + status + '</td>' +
'<td style="width: 50px;text-align: center;">' + binCode + '</td>' +
'<td style="text-align: center;"><input type="text" style="text-align: center;width: 35px;" id="aName' + j + '" name="aName' + j + '" value=' + initQty + ' readonly /></td>' +
'<td style="text-align: center;"><input type="text" style="text-align: center;width: 35px;" id="bName' + j + '" name="bName' + j + '" value=' + initQtyX + ' readonly /></td>' +
'<td style="text-align: center;"><input type="text" style="text-align: center;width: 35px;" id="cName' + j + '" name="cName' + j + '" value=' + useQty + ' readonly /></td>' +
'<td style="text-align: center;"><input type="text" style="text-align: center;width: 35px;" id="TBin1' + j + '" name="TBin1' + j + '" value=' + remainingQty + ' readonly /></td>' +
'<td style="text-align: center;"><input type="text" style="text-align: center;width: 35px;" id="TBinX' + j + '" name="TBinX' + j + '" value=' + remainingQtyX + ' readonly /></td>' +
'<td style="width: 50px;text-align: center;">' + tailpiece + '</td>';
}
} else {
alert(data.return_value);
}
},
error: function () {
alert("Ajax HTTP访问失败, 请联系IT处理!");
}
});
}
}
}
function issueMaterial() {
//记录状态为PASS数量
var passStr = "";
var isPass = 0;
var woNo = $("#frmWoInfo input[name='wn']").val();
var prodId = $("#frmWoInfo input[name='pd']").val();
for (i = 1; i <= printQuantity; i++) {
var pass = document.getElementById("pass" + i).innerHTML;
passStr = passStr + "," + pass;
var ss = passStr.split(",");
if (ss[i] == "PASS") {
isPass++;
}
}
if (isPass == printQuantity) {
$('#butSend').attr("disabled", "disabled");
$.ajax({
type: "POST",
url: "DispatchAction?accessMethod=<%=AccessMethod.AJAX %>",
data: {
'actionCode': '<%=ActionCode.UPDATE_MATERIALS_INFO_PRINT %>',
'woNo': woNo,
'operateFlag': 'Issue',
'prodId': prodId,
},
dataType: "json",
success: function (data) {
if (data.return_code == "0") {
alert(data.return_value);
location.reload();
} else {
alert(data.return_value);
$('#butSend').attr("disabled", false);
}
},
error: function () {
alert("Ajax HTTP访问失败, 请联系IT处理!");
$('#butSend').attr("disabled", false);
}
});
} else {
alert("当前工单中没有补全PASS!");
}
}
function returnMaterial() {
var listData = [];
//记录状态为PASS数量
var isPass = 0;
var passStr = "";
for (let i = 1; i <= printQuantity; i++) {
var lotId = document.getElementById("lotId" + i).innerHTML;
var waferNo = document.getElementById("waferNo" + i).innerHTML;
var pass = document.getElementById("pass" + i).innerHTML;
var useQty = $("#frmWoInfo input[id='cName" + i + "']").val();
passStr = passStr + "," + pass;
var ss = passStr.split(",");
if (ss[i] == "PASS") {
isPass++;
}
//用
if (useQty == "") {
alert("用 GoodDie异常! (存在空值)");
return;
} else {
if (Number(useQty) < 0) {
alert("用 GoodDie异常! (存在小于0的GoodDie)");
return;
}
}
listData.push({waferId: lotId + "-" + waferNo, useQty: useQty});
}
var woNo = $("#frmWoInfo input[name='wn']").val();
var prodId = $("#frmWoInfo input[name='pd']").val();
var jsonData = JSON.stringify(listData);
if (isPass == printQuantity) {
$('#butBack').attr("disabled", "disabled");
$.ajax({
type: "POST",
url: "DispatchAction?accessMethod=<%=AccessMethod.AJAX %>",
data: {
'actionCode': '<%=ActionCode.UPDATE_MATERIALS_INFO_PRINT %>',
'woNo': woNo,
'operateFlag': 'Return',
'prodId': prodId,
'jsonData': jsonData,
},
dataType: "json",
success: function (data) {
if (data.return_code == "0") {
alert(data.return_value);
location.reload();
} else {
alert(data.return_value);
$('#butBack').attr("disabled", false);
}
},
error: function () {
alert("Ajax HTTP访问失败, 请联系IT处理!");
$('#butBack').attr("disabled", false);
}
});
} else {
alert("当前工单中没有补全PASS!");
}
}
</script>
</body>
</html>