常熟吴彦祖 3 weeks ago
parent
commit
6420fd91fe
  1. 50
      src/main/resources/static/js/pdaOther/productionBagReturnStep1.js
  2. 56
      src/main/resources/static/js/pdaOther/productionBagReturnStep2.js
  3. 2
      src/main/resources/templates/pdaOther/productionBagReturnStep1.ftl
  4. 2
      src/main/resources/templates/pdaOther/productionBagReturnStep2.ftl

50
src/main/resources/static/js/pdaOther/productionBagReturnStep1.js

@ -8,21 +8,49 @@ var currentData = null;
const COOKIE_ORDER = "prodBagRetPdaOrder"; const COOKIE_ORDER = "prodBagRetPdaOrder";
const COOKIE_TABLE = "prodBagRetPdaTable"; const COOKIE_TABLE = "prodBagRetPdaTable";
// 兼容清理历史 path Cookie,避免同名 Cookie 导致读取不稳定 - rqrq
function clearOrderCookie () {
$.cookie(COOKIE_ORDER, "", { expires: -1, path: "/" });
$.cookie(COOKIE_ORDER, "", { expires: -1 });
}
// 兼容清理历史 path Cookie,避免同名 Cookie 导致读取不稳定 - rqrq
function clearTableCookie () {
$.cookie(COOKIE_TABLE, "", { expires: -1, path: "/" });
$.cookie(COOKIE_TABLE, "", { expires: -1 });
}
// 退出到菜单时清理步骤缓存,防止下次进入串单 - rqrq
function clearBagReturnCookies () {
clearOrderCookie();
clearTableCookie();
}
// 读取订单缓存并做容错,异常时清理坏数据 - rqrq
function readOrderCookieSafe () {
var saved = $.cookie(COOKIE_ORDER);
if (saved == null || saved === "") {
return null;
}
try {
return JSON.parse(saved);
} catch (e) {
clearOrderCookie();
return null;
}
}
$(function () { $(function () {
if (titleName != null && titleName !== "") { if (titleName != null && titleName !== "") {
$("#titleName").text(titleName); $("#titleName").text(titleName);
} else { } else {
window.location.href = "/login"; window.location.href = "/login";
} }
var saved = $.cookie(COOKIE_ORDER);
if (saved != null && saved !== "") {
try {
currentData = JSON.parse(saved);
currentData = readOrderCookieSafe();
if (currentData != null) {
initVal(); initVal();
} catch (e) {
currentData = null;
}
$.cookie(COOKIE_ORDER, "");
// Step2 回到 Step1 的一次性订单缓存,读取后立即清理 - rqrq
clearOrderCookie();
} }
$("#orderNo_search").focus(); $("#orderNo_search").focus();
}); });
@ -58,7 +86,8 @@ function getOrderNoData () {
return false; return false;
} }
} }
$.cookie(COOKIE_TABLE, "", { expires: -1, path: "/" });
// 重新扫描新订单时清空步骤2缓存(兼容历史 path)- rqrq
clearTableCookie();
initVal(); initVal();
} else { } else {
layer.msg("未解析到生产订单!"); layer.msg("未解析到生产订单!");
@ -95,6 +124,7 @@ function pageJump () {
layer.msg("当前无生产订单信息!"); layer.msg("当前无生产订单信息!");
return false; return false;
} }
// 写入根路径 Cookie,确保 Step2 稳定读取 - rqrq
$.cookie(COOKIE_ORDER, JSON.stringify(currentData), { path: "/" }); $.cookie(COOKIE_ORDER, JSON.stringify(currentData), { path: "/" });
var menuId = $("#menuId").val(); var menuId = $("#menuId").val();
var superiorName = $("#current_titleName").val(); var superiorName = $("#current_titleName").val();
@ -102,5 +132,7 @@ function pageJump () {
} }
function pdaBaseJump () { function pdaBaseJump () {
// 退出菜单时清理全部缓存,避免下一单残留 - rqrq
clearBagReturnCookies();
window.location.href = "/pda/pdaBase"; window.location.href = "/pda/pdaBase";
} }

56
src/main/resources/static/js/pdaOther/productionBagReturnStep2.js

@ -12,6 +12,40 @@ var confirmSubmitting = false;
const COOKIE_ORDER = "prodBagRetPdaOrder"; const COOKIE_ORDER = "prodBagRetPdaOrder";
const COOKIE_TABLE = "prodBagRetPdaTable"; const COOKIE_TABLE = "prodBagRetPdaTable";
// 兼容清理历史 path Cookie,避免同名 Cookie 导致读取不稳定 - rqrq
function clearOrderCookie () {
$.cookie(COOKIE_ORDER, "", { expires: -1, path: "/" });
$.cookie(COOKIE_ORDER, "", { expires: -1 });
}
// 兼容清理历史 path Cookie,避免同名 Cookie 导致读取不稳定 - rqrq
function clearTableCookie () {
$.cookie(COOKIE_TABLE, "", { expires: -1, path: "/" });
$.cookie(COOKIE_TABLE, "", { expires: -1 });
}
// 退出菜单或异常场景统一清理缓存 - rqrq
function clearBagReturnCookies () {
clearOrderCookie();
clearTableCookie();
}
// 读取 JSON Cookie 并容错,坏数据自动清理 - rqrq
function readJsonCookieSafe (cookieName, clearFn) {
var raw = $.cookie(cookieName);
if (raw == null || raw === "") {
return null;
}
try {
return JSON.parse(raw);
} catch (e) {
if (clearFn) {
clearFn();
}
return null;
}
}
/** 与本单已录入行比对:seqNo_itemNo(与二维码第4、5段一致)- rqrq */ /** 与本单已录入行比对:seqNo_itemNo(与二维码第4、5段一致)- rqrq */
function bagLabelDupKey(seqNo, itemNo) { function bagLabelDupKey(seqNo, itemNo) {
return String(seqNo) + "_" + String(itemNo); return String(seqNo) + "_" + String(itemNo);
@ -23,19 +57,21 @@ $(function () {
} else { } else {
window.location.href = "/login"; window.location.href = "/login";
} }
var orderCookie = $.cookie(COOKIE_ORDER);
if (orderCookie != null && orderCookie !== "") {
currentData = JSON.parse(orderCookie);
var orderCookie = readJsonCookieSafe(COOKIE_ORDER, clearOrderCookie);
if (orderCookie != null) {
currentData = orderCookie;
} else { } else {
// 缺少订单上下文时清空残留缓存并返回步骤1 - rqrq
clearBagReturnCookies();
layer.msg("请先扫袋装标签选择订单"); layer.msg("请先扫袋装标签选择订单");
var menuId = $("#menuId").val(); var menuId = $("#menuId").val();
var superiorName = $("#current_titleName").val(); var superiorName = $("#current_titleName").val();
window.location.href = "/pdaOther/productionBagReturnStep1?menuId=" + encodeURIComponent(menuId || "") + "&titleName=" + encodeURIComponent(superiorName || ""); window.location.href = "/pdaOther/productionBagReturnStep1?menuId=" + encodeURIComponent(menuId || "") + "&titleName=" + encodeURIComponent(superiorName || "");
return; return;
} }
var list = $.cookie(COOKIE_TABLE);
if (list != null && list !== "") {
tableList = JSON.parse(list);
var list = readJsonCookieSafe(COOKIE_TABLE, clearTableCookie);
if (Array.isArray(list)) {
tableList = list;
changeTable(); changeTable();
} }
$("#partNo_search").focus(); $("#partNo_search").focus();
@ -211,7 +247,7 @@ function confirmReturn () {
success: function (data) { success: function (data) {
if (data.code === 0) { if (data.code === 0) {
layer.msg(data.msg || "操作成功!"); layer.msg(data.msg || "操作成功!");
$.cookie(COOKIE_TABLE, "", { expires: -1, path: "/" });
clearTableCookie();
tableList = []; tableList = [];
changeTable(); changeTable();
$("#wareHouse").val(""); $("#wareHouse").val("");
@ -244,3 +280,9 @@ function superiorJump () {
var superiorName = $("#current_titleName").val(); var superiorName = $("#current_titleName").val();
window.location.href = "/pdaOther/productionBagReturnStep1?menuId=" + encodeURIComponent(menuId || "") + "&titleName=" + encodeURIComponent(superiorName || ""); window.location.href = "/pdaOther/productionBagReturnStep1?menuId=" + encodeURIComponent(menuId || "") + "&titleName=" + encodeURIComponent(superiorName || "");
} }
function pdaBaseJump () {
// 直接返回菜单时清理步骤缓存,避免下次进入串单 - rqrq
clearBagReturnCookies();
window.location.href = "/pda/pdaBase";
}

2
src/main/resources/templates/pdaOther/productionBagReturnStep1.ftl

@ -58,7 +58,7 @@
<header class="mint-header is-fixed"> <header class="mint-header is-fixed">
<div class="mint-header-button is-left"> <div class="mint-header-button is-left">
<div class="header-title"> <div class="header-title">
<a href="/pda/pdaBase" class="go-back"><i class="mintui mintui-back"></i></a>
<a href="javascript:void(0);" class="go-back" onclick="pdaBaseJump()"><i class="mintui mintui-back"></i></a>
<span id = "titleName"></span> <span id = "titleName"></span>
</div> </div>
</div> </div>

2
src/main/resources/templates/pdaOther/productionBagReturnStep2.ftl

@ -58,7 +58,7 @@
<header class="mint-header is-fixed"> <header class="mint-header is-fixed">
<div class="mint-header-button is-left"> <div class="mint-header-button is-left">
<div class="header-title"> <div class="header-title">
<a href="/pda/pdaBase" class="go-back"><i class="mintui mintui-back"></i></a>
<a href="javascript:void(0);" class="go-back" onclick="pdaBaseJump()"><i class="mintui mintui-back"></i></a>
<span id = "titleName"></span> <span id = "titleName"></span>
</div> </div>
</div> </div>

Loading…
Cancel
Save