HEL-351: 修复夜间下拉/日期弹层、一次性初始密码领取与缩放滚动条
夜间控件改走现有 token 与 color-scheme,日期弹层锚定触发器并可翻转; 创建公司账号改为一次性可复制口令窗口,列表与后续接口不再回明文。 Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
co-authored by
Cursor
multica-agent
parent
9d06445d81
commit
acc3c29c49
+81
-10
@@ -129,6 +129,50 @@ function showToast(title, detail = "", kind = "info") {
|
||||
});
|
||||
}
|
||||
|
||||
function copyText(value, button) {
|
||||
const text = String(value || "");
|
||||
const done = () => {
|
||||
if (!button) return;
|
||||
const previous = button.textContent;
|
||||
button.textContent = "已复制";
|
||||
window.setTimeout(() => { button.textContent = previous; }, 1400);
|
||||
};
|
||||
const fallback = () => {
|
||||
const area = document.createElement("textarea");
|
||||
area.value = text;
|
||||
area.setAttribute("readonly", "");
|
||||
area.style.position = "fixed";
|
||||
area.style.left = "-9999px";
|
||||
document.body.append(area);
|
||||
area.select();
|
||||
try { document.execCommand("copy"); } catch (err) { /* ignore */ }
|
||||
area.remove();
|
||||
done();
|
||||
};
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText(text).then(done).catch(fallback);
|
||||
} else {
|
||||
fallback();
|
||||
}
|
||||
}
|
||||
|
||||
function wipeCredentials() {
|
||||
const user = $("#cred-user");
|
||||
const pass = $("#cred-pass");
|
||||
if (user) user.textContent = "";
|
||||
if (pass) pass.textContent = "";
|
||||
}
|
||||
|
||||
function showOnceCredentials({ title, subtitle, username, password }) {
|
||||
const titleEl = $("#cred-title");
|
||||
const subEl = $("#cred-sub");
|
||||
if (titleEl && title) titleEl.textContent = title;
|
||||
if (subEl && subtitle) subEl.textContent = subtitle;
|
||||
if ($("#cred-user")) $("#cred-user").textContent = username || "";
|
||||
if ($("#cred-pass")) $("#cred-pass").textContent = password || "";
|
||||
openModal("credentialDialog");
|
||||
}
|
||||
|
||||
function toastIfLocked(result) {
|
||||
const msg = String(result?.message || "");
|
||||
if (!(result?.year_month || /已结账锁定/.test(msg))) return false;
|
||||
@@ -2675,9 +2719,24 @@ function initAdmin() {
|
||||
}));
|
||||
$("#auditCompany")?.addEventListener("change", filterAuditRows);
|
||||
|
||||
document.querySelectorAll("[data-close]").forEach((el) => el.addEventListener("click", () => closeModal(el.dataset.close)));
|
||||
document.querySelectorAll(".modal-backdrop").forEach((bd) => bd.addEventListener("click", (e) => { if (e.target === bd) bd.classList.remove("open"); }));
|
||||
document.addEventListener("keydown", (e) => { if (e.key === "Escape") document.querySelectorAll(".modal-backdrop.open").forEach((m) => m.classList.remove("open")); });
|
||||
document.querySelectorAll("[data-close]").forEach((el) => el.addEventListener("click", () => {
|
||||
closeModal(el.dataset.close);
|
||||
if (el.dataset.close === "credentialDialog") wipeCredentials();
|
||||
}));
|
||||
$("#cred-copy-user")?.addEventListener("click", () => copyText($("#cred-user")?.textContent, $("#cred-copy-user")));
|
||||
$("#cred-copy-pass")?.addEventListener("click", () => copyText($("#cred-pass")?.textContent, $("#cred-copy-pass")));
|
||||
document.querySelectorAll(".modal-backdrop").forEach((bd) => bd.addEventListener("click", (e) => {
|
||||
if (e.target !== bd) return;
|
||||
bd.classList.remove("open");
|
||||
if (bd.id === "credentialDialog") wipeCredentials();
|
||||
}));
|
||||
document.addEventListener("keydown", (e) => {
|
||||
if (e.key !== "Escape") return;
|
||||
document.querySelectorAll(".modal-backdrop.open").forEach((m) => {
|
||||
m.classList.remove("open");
|
||||
if (m.id === "credentialDialog") wipeCredentials();
|
||||
});
|
||||
});
|
||||
|
||||
async function submitAuditResult(row) {
|
||||
const decision = state.auditDecision;
|
||||
@@ -2889,11 +2948,17 @@ function initAdmin() {
|
||||
closeModal("companyDialog");
|
||||
form.reset();
|
||||
await loadAdminCompanies();
|
||||
showToast(
|
||||
accountCreated ? "公司与账号已创建" : "公司已创建",
|
||||
accountCreated ? `账号 ${result.username} 的初始密码已生成(仅此一次显示):${result.initial_password},首次登录必须修改` : "可稍后在账号管理中创建公司账号",
|
||||
"success",
|
||||
);
|
||||
if (accountCreated) {
|
||||
showOnceCredentials({
|
||||
title: "一次性初始密码",
|
||||
subtitle: "请立即复制并交给出纳。关闭后无法再次查看明文。",
|
||||
username: result.username,
|
||||
password: result.initial_password,
|
||||
});
|
||||
showToast("公司与账号已创建", "请在一次性口令窗口复制初始密码,关闭后无法再看", "success");
|
||||
} else {
|
||||
showToast("公司已创建", "可稍后在账号管理中创建公司账号", "success");
|
||||
}
|
||||
});
|
||||
|
||||
function openCompanyDetail(companyId) {
|
||||
@@ -2933,8 +2998,14 @@ function initAdmin() {
|
||||
if (!response || !response.ok) { showToast("重置失败", result?.message || "请稍后重试", "danger"); return; }
|
||||
$("#btn-reset-pwd").disabled = true;
|
||||
$("#btn-reset-pwd").textContent = "已重置";
|
||||
$("#d-login-meta").textContent = `临时密码已生成(仅此一次):${result.initial_password},首次登录必须修改`;
|
||||
showToast("密码已重置", "临时密码仅本次显示,首次登录必须修改", "success");
|
||||
$("#d-login-meta").textContent = "临时密码已在一次性窗口展示,关闭后无法再查看。";
|
||||
showOnceCredentials({
|
||||
title: "临时密码已生成",
|
||||
subtitle: "仅此一次显示。旧会话已失效,首次登录必须修改。",
|
||||
username: user.username,
|
||||
password: result.initial_password,
|
||||
});
|
||||
showToast("密码已重置", "请在一次性口令窗口复制后交给出纳", "success");
|
||||
});
|
||||
|
||||
const remind = $("#cs-remind");
|
||||
|
||||
Reference in New Issue
Block a user