feat: 支持顺运宝批量创建采集任务 (#153)
This commit is contained in:
+16
-8
@@ -40,18 +40,25 @@
|
||||
}
|
||||
|
||||
/* ── 选中数量 ────────────────────────────── */
|
||||
function checkedCount() {
|
||||
return document.querySelectorAll(
|
||||
"tbody input[type=checkbox]:checked:not(:disabled)"
|
||||
function supportsSelectAction(box, action) {
|
||||
if (!action) return true;
|
||||
var actions = (box.getAttribute("data-select-action") || "").split(/\s+/);
|
||||
return actions.indexOf(action) !== -1;
|
||||
}
|
||||
|
||||
function checkedCount(action) {
|
||||
return Array.prototype.filter.call(
|
||||
document.querySelectorAll("tbody input[type=checkbox]:checked:not(:disabled)"),
|
||||
function (box) { return supportsSelectAction(box, action); }
|
||||
).length;
|
||||
}
|
||||
|
||||
/* ── 需要勾选才能点的按钮 ──────────────────
|
||||
标了 data-need-checked 的按钮,没勾选任何行时禁用。 */
|
||||
function syncButtons() {
|
||||
var n = checkedCount();
|
||||
document.querySelectorAll("[data-need-checked]").forEach(function (btn) {
|
||||
btn.disabled = n === 0;
|
||||
var action = btn.getAttribute("data-need-checked") || "";
|
||||
btn.disabled = checkedCount(action) === 0;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -148,8 +155,8 @@
|
||||
if (singleID) {
|
||||
selected[singleID] = true;
|
||||
} else {
|
||||
document.querySelectorAll("tbody input[name=ids]:checked").forEach(function (box) {
|
||||
selected[box.value] = true;
|
||||
document.querySelectorAll("tbody input[name=ids]:checked:not(:disabled)").forEach(function (box) {
|
||||
if (supportsSelectAction(box, "purchase")) selected[box.value] = true;
|
||||
});
|
||||
}
|
||||
var shown = 0;
|
||||
@@ -183,11 +190,12 @@
|
||||
if (!form || !modal) return;
|
||||
var count = modal.querySelector("[data-collect-count]");
|
||||
var submitButton = modal.querySelector("[data-collect-submit]");
|
||||
var action = openButton.getAttribute("data-collect-action") || "";
|
||||
if (!count || !submitButton) return;
|
||||
|
||||
openButton.addEventListener("click", function () {
|
||||
var fixedCount = openButton.getAttribute("data-collect-count-value");
|
||||
count.textContent = fixedCount === null ? checkedCount() : fixedCount;
|
||||
count.textContent = fixedCount === null ? checkedCount(action) : fixedCount;
|
||||
});
|
||||
form.addEventListener("submit", function (event) {
|
||||
if (event.submitter !== submitButton) return;
|
||||
|
||||
Reference in New Issue
Block a user