feat: 优化批量匹配和分页默认值 (#244)

This commit is contained in:
chengma
2026-08-15 15:56:16 +08:00
parent f315b02d3d
commit ad5bd834d3
17 changed files with 340 additions and 82 deletions
+16 -4
View File
@@ -639,7 +639,20 @@ input.wide { width: 100%; }
white-space: nowrap;
color: #57606a;
}
.inner-code-notice { flex: 0 0 auto; margin: -4px 0 10px; }
.inner-code-toast {
position: fixed;
right: 16px;
bottom: 56px;
z-index: 9;
max-width: min(520px, calc(100vw - 32px));
margin: 0;
padding: 10px 14px;
border: 1px solid #9ec5a8;
border-radius: 4px;
color: #155724;
background: #f0fff4;
box-shadow: 0 4px 16px rgba(0, 0, 0, .16);
}
.inner-code-table-wrap { flex: 1 1 auto; min-height: 180px; overflow: auto; scrollbar-gutter: stable; }
.inner-code-table { min-width: 1500px; }
.inner-code-table th { position: sticky; top: 0; z-index: 1; }
@@ -688,13 +701,12 @@ select {
gap: 4px;
font-size: 13px;
}
.page-size-form select,
.page-size-form button {
.page-size-form select {
min-height: 28px;
font-size: 13px;
}
.page-size-form select { padding: 3px 6px; }
.page-size-form button { padding: 3px 8px; }
.page-size-loading { font-size: 12px; color: #57606a; }
.pagination a,
.pagination span.disabled {
padding: 4px 10px;
+31 -8
View File
@@ -93,22 +93,18 @@
}
/* ── 每页条数立即生效 ─────────────────────────
普通 GET 表单仍是无 JavaScript 时的完整回退;脚本只做渐进增强,让采购员
选择 20/50/100 后不用再点一次“应用”。select 不能禁用,否则浏览器提交时
会丢掉 page_size。 */
采购员选择 20/50/100 后直接提交 GET 表单。select 不能禁用,否则浏览器
提交时会丢掉 page_size。 */
function setupPageSizeForms() {
document.querySelectorAll("[data-page-size-form]").forEach(function (form) {
var select = form.querySelector("[data-page-size-select]");
var submit = form.querySelector("[data-page-size-submit]");
var loading = form.querySelector("[data-page-size-loading]");
if (!select) return;
function beginSubmit() {
if (form.getAttribute("aria-busy") === "true") return false;
form.setAttribute("aria-busy", "true");
if (submit) {
submit.disabled = true;
submit.textContent = "加载中…";
}
if (loading) loading.hidden = false;
return true;
}
@@ -126,6 +122,32 @@
});
}
/* 操作结果通过 POST/Redirect/GET 返回。成功提示固定定位并自动消失,错误交给
通用弹窗;两者都不占表格高度。页面读到结果后清掉临时查询参数,避免 F5
重复弹出同一条反馈。 */
function setupTransientFeedback() {
var feedbacks = document.querySelectorAll("[data-transient-feedback]");
if (!feedbacks.length) return;
var paramsToRemove = {};
feedbacks.forEach(function (feedback) {
(feedback.getAttribute("data-transient-query") || "").split(/\s+/).forEach(function (name) {
if (name) paramsToRemove[name] = true;
});
if (feedback.hasAttribute("data-auto-dismiss-toast")) {
window.setTimeout(function () {
feedback.hidden = true;
feedback.remove();
}, 4000);
}
});
var current = new URL(window.location.href);
Object.keys(paramsToRemove).forEach(function (name) { current.searchParams.delete(name); });
var cleanURL = current.pathname + (current.search ? current.search : "") + current.hash;
window.history.replaceState(window.history.state, "", cleanURL);
}
/* ── 全选 / 反选 ──────────────────────────────
表头的勾选框控制本表格所有行的勾选框。 */
function setupCheckAll(root) {
@@ -888,6 +910,7 @@
document.addEventListener("DOMContentLoaded", function () {
setupModuleNavigationState();
setupPageSizeForms();
setupTransientFeedback();
document.querySelectorAll("table").forEach(setupCheckAll);
setupConfirmDelete();
setupConfirmSubmit();