feat: 支持勾选部分档口入库码匹配 (#235)

This commit is contained in:
chengma
2026-08-15 09:41:45 +08:00
parent 05b59974e8
commit 63f8407780
10 changed files with 342 additions and 55 deletions
+30 -8
View File
@@ -129,11 +129,15 @@
return actions.indexOf(action) !== -1;
}
function checkedCount(action) {
function checkedBoxes(action) {
return Array.prototype.filter.call(
document.querySelectorAll("tbody input[type=checkbox]:checked:not(:disabled)"),
function (box) { return supportsSelectAction(box, action); }
).length;
);
}
function checkedCount(action) {
return checkedBoxes(action).length;
}
/* ── 需要勾选才能点的按钮 ──────────────────
@@ -350,7 +354,8 @@
}
/* 档口入库码页只有轻量表单联动:一个可见业务日期同步给三个普通表单,
并在确认弹窗里显示当前选中数量。匹配和回写规则仍全部在服务端。 */
并按“匹配/回写”动作分别提交当前页符合条件的选中 ID。
匹配和回写规则仍全部在服务端。 */
function setupInnerCodePage() {
var root = document.querySelector("[data-inner-code-page]");
if (!root) return;
@@ -367,18 +372,33 @@
}
function updateSelectionSummary() {
var selected = Array.prototype.slice.call(document.querySelectorAll(
'input[name="ids"][form="inner-code-apply-form"]:checked:not(:disabled)'
));
var replacements = selected.filter(function (box) {
var matchSelected = checkedBoxes("inner-code-match");
var applySelected = checkedBoxes("inner-code-apply");
var replacements = applySelected.filter(function (box) {
return box.getAttribute("data-inner-code-old-value") === "1";
}).length;
document.querySelectorAll("[data-inner-code-match-count]")
.forEach(function (node) { node.textContent = matchSelected.length; });
document.querySelectorAll("[data-inner-code-selected-count], [data-inner-code-confirm-count]")
.forEach(function (node) { node.textContent = selected.length; });
.forEach(function (node) { node.textContent = applySelected.length; });
document.querySelectorAll("[data-inner-code-replace-count]")
.forEach(function (node) { node.textContent = replacements; });
}
function appendSelectedIDs(form, action) {
form.querySelectorAll("[data-inner-code-generated-id]").forEach(function (field) {
field.remove();
});
checkedBoxes(action).forEach(function (box) {
var field = document.createElement("input");
field.type = "hidden";
field.name = "ids";
field.value = box.getAttribute("data-inner-code-id") || box.value;
field.setAttribute("data-inner-code-generated-id", "");
form.appendChild(field);
});
}
if (dateInput) dateInput.addEventListener("change", syncDate);
if (fileOpen && fileInput) fileOpen.addEventListener("click", function () { fileInput.click(); });
if (fileInput && fileName) {
@@ -393,6 +413,7 @@
if (applyButton) applyButton.addEventListener("click", updateSelectionSummary);
var matchForm = document.getElementById("inner-code-match-form");
if (matchForm) matchForm.addEventListener("submit", function () {
appendSelectedIDs(matchForm, "inner-code-match");
var button = document.querySelector('[form="inner-code-match-form"]');
if (button) {
button.disabled = true;
@@ -402,6 +423,7 @@
});
var applyForm = document.getElementById("inner-code-apply-form");
if (applyForm) applyForm.addEventListener("submit", function () {
appendSelectedIDs(applyForm, "inner-code-apply");
var button = document.querySelector('#inner-code-apply-modal button[type="submit"]');
if (button) {
button.disabled = true;