Quellcode durchsuchen

fix(web): 修复成员弹窗裁切并重排主账号转交布局

sy vor 1 Tag
Ursprung
Commit
b9e2e2de83

+ 52 - 30
web-scaffold/src/components/OrganizationTeamAccounts.tsx

@@ -1,5 +1,5 @@
 import { useState, type FormEvent, type ReactNode } from "react";
-import { ArrowRightLeft, PencilLine, Plus, Search, Trash2, X } from "lucide-react";
+import { ArrowRight, ArrowRightLeft, CheckCircle2, PencilLine, Plus, Search, Trash2, X } from "lucide-react";
 import { useSession } from "../auth/session";
 import { notifySessionNotice } from "../lib/session-notice";
 import { OrganizationAccountStatus } from "./OrganizationAccountStatus";
@@ -64,7 +64,7 @@ function MemberFormDialog({ title, onClose, busy, centered = true, children }: {
 }) {
   const close = () => { if (!busy) onClose(); };
   return <div className={centered ? "org-dialog-backdrop org-centered-backdrop" : "org-dialog-backdrop"} onMouseDown={close} role="presentation">
-    <section aria-label={title} aria-modal="true" className={centered ? "org-dialog org-editor-modal" : "org-dialog"} onMouseDown={(event) => event.stopPropagation()} role="dialog">
+    <section aria-label={title} aria-modal="true" className={centered ? "org-dialog org-editor-modal org-member-dialog" : "org-dialog org-member-dialog"} onMouseDown={(event) => event.stopPropagation()} role="dialog">
       <header>
         <h2>{title}</h2>
         <button aria-label="关闭" className="org-icon-button" disabled={busy} onClick={close} type="button"><X size={18} /></button>
@@ -305,6 +305,54 @@ function OperationsMemberEditDialog({ team, member, onClose }: { team: Operation
   </MemberFormDialog>;
 }
 
+function PrimaryTransferConfirmation({ team, from, to, effect, selfAffected, busy, error, done, onClose, onConfirm }: {
+  team: string;
+  from: { name: string; login?: string };
+  to: { name: string; login?: string };
+  effect: string;
+  selfAffected: boolean;
+  busy: boolean;
+  error: string;
+  done: string;
+  onClose: () => void;
+  onConfirm: () => Promise<void>;
+}) {
+  return <MemberFormDialog title={`设为主账号 · ${team}`} onClose={onClose} busy={busy}>
+    <div className="org-dialog-content">
+      {done ? <div className="org-primary-transfer-result" role="status">
+        <CheckCircle2 size={20} aria-hidden="true" />
+        <div><strong>主账号已转交</strong><p>{done}</p></div>
+      </div> : <>
+        <div className="org-primary-transfer-accounts">
+          <div className="org-primary-transfer-person">
+            <span className="org-primary-transfer-label">当前主账号</span>
+            <strong>{from.name}</strong>
+            {from.login && from.login !== from.name && <small>{from.login}</small>}
+            <span className="org-primary-transfer-role">转交后为子账号</span>
+          </div>
+          <ArrowRight className="org-primary-transfer-arrow" size={18} aria-hidden="true" />
+          <div className="org-primary-transfer-person is-recipient">
+            <span className="org-primary-transfer-label">接任成员</span>
+            <strong>{to.name}</strong>
+            {to.login && to.login !== to.name && <small>{to.login}</small>}
+            <span className="org-primary-transfer-role">转交后为主账号</span>
+          </div>
+        </div>
+        <p className="org-primary-transfer-effect">{effect}</p>
+        {selfAffected && <p className="org-primary-transfer-session" role="note">此次转交涉及当前登录账号,确认后会自动刷新你的权限。</p>}
+        {error && <p className="org-form-error" role="alert">{error}</p>}
+      </>}
+    </div>
+    <footer>{done
+      ? <button className="org-button" onClick={onClose} type="button">完成</button>
+      : <>
+        <Action onClick={onClose} disabled={busy}>取消</Action>
+        <button className="org-button" disabled={busy} onClick={() => void onConfirm()} type="button">{busy ? "正在转交…" : "确认转交"}</button>
+      </>}
+    </footer>
+  </MemberFormDialog>;
+}
+
 /**
  * 运营团队主账号转交(OR-11):二次确认 → `ent_team/transfer_primary@v1`。
  *
@@ -342,20 +390,7 @@ function TransferPrimaryDialog({ team, from, to, onClose }: { team: OperationsTe
       setBusy(false);
     }
   }
-  const heading = `设为主账号 · ${team.name}`;
-  return <div className="org-dialog-backdrop" onMouseDown={onClose} role="presentation"><section aria-label={heading} aria-modal="true" className="org-confirm" onMouseDown={(event) => event.stopPropagation()} role="dialog"><h2>{heading}</h2>
-    {done ? <><p className="org-account-notice" role="status">{done}</p><p>新主账号的菜单与可操作项在其下一次刷新页面或重新登录后按 `opsMain` 生效;本页成员标记已回读更新。</p><div className="org-confirm-actions"><button className="org-button" onClick={onClose} type="button">完成</button></div></> : <>
-      <p>每团队有且仅有一个主账号。确认后立即生效:</p>
-      <ul>
-        <li>「{to.name}」(登录名 {to.login || FIELD_UNAVAILABLE})升为主账号,角色码 opsSub → opsMain;</li>
-        <li>「{from.name}」(登录名 {from.login || FIELD_UNAVAILABLE})降为子账号,角色码 opsMain → opsSub;</li>
-        <li>两人的团队归属、登录名与负责范围不变;权限按角色判,随本次转交互换。</li>
-      </ul>
-      {selfAffected && <p className="org-account-notice" role="note">你转交/接收的是当前登录账号本人:确认后会自动重取会话上下文并按新角色跳转,无需重新登录。</p>}
-      {error && <p className="org-form-error" role="alert">{error}</p>}
-      <div className="org-confirm-actions"><Action onClick={onClose} disabled={busy}>取消</Action><button className="org-button" disabled={busy} onClick={() => void submit()} type="button">确认设为主账号</button></div>
-    </>}
-  </section></div>;
+  return <PrimaryTransferConfirmation team={team.name} from={from} to={to} effect="确认后,双方的账号权限随角色调整,负责范围保持原样。" selfAffected={selfAffected} busy={busy} error={error} done={done} onClose={onClose} onConfirm={submit} />;
 }
 
 /** 删除成员:运营走 `ent_team/member_remove`(回 blockers 原文),运维走 `ops_team/member_remove`。 */
@@ -456,20 +491,7 @@ function MaintenanceTransferPrimaryDialog({ team, from, to, onClose }: { team: M
       setBusy(false);
     }
   }
-  const heading = `设为主账号 · ${team.name}`;
-  return <div className="org-dialog-backdrop" onMouseDown={onClose} role="presentation"><section aria-label={heading} aria-modal="true" className="org-confirm" onMouseDown={(event) => event.stopPropagation()} role="dialog"><h2>{heading}</h2>
-    {done ? <><p className="org-account-notice" role="status">{done}</p><div className="org-confirm-actions"><button className="org-button" onClick={onClose} type="button">完成</button></div></> : <>
-      <p>每团队有且仅有一个主账号。确认后立即生效:</p>
-      <ul>
-        <li>「{to.name}」(登录名 {to.login || FIELD_UNAVAILABLE})升为主账号,角色码 ops → teamLead;</li>
-        <li>「{from.name}」(登录名 {from.login || FIELD_UNAVAILABLE})降为子账号,角色码 teamLead → ops;</li>
-        <li>两人的团队归属、登录名与负责范围不变;新主账号可处理类型强制随团队。</li>
-      </ul>
-      {selfAffected && <p className="org-account-notice" role="note">你转交/接收的是当前登录账号本人:确认后会自动重取会话上下文并按新角色跳转,无需重新登录。</p>}
-      {error && <p className="org-form-error" role="alert">{error}</p>}
-      <div className="org-confirm-actions"><Action onClick={onClose} disabled={busy}>取消</Action><button className="org-button" disabled={busy} onClick={() => void submit()} type="button">确认设为主账号</button></div>
-    </>}
-  </section></div>;
+  return <PrimaryTransferConfirmation team={team.name} from={from} to={to} effect="确认后,新主账号可处理的工单类型将跟随团队。" selfAffected={selfAffected} busy={busy} error={error} done={done} onClose={onClose} onConfirm={submit} />;
 }
 
 export function MaintenanceAccounts({ team }: { team: MaintenanceTeam }) {

+ 60 - 0
web-scaffold/src/styles/organization.css

@@ -708,6 +708,66 @@ a.org-overview-card{text-decoration:none;color:inherit}
 .org-editor-modal .org-form-error{margin:0}
 @media(max-width:600px){.org-editor-modal .org-dialog-content{gap:13px;padding:18px 20px 20px}.org-editor-modal header,.org-editor-modal footer{padding:18px 20px}}
 
+.org-member-dialog > :is(header, footer),
+.org-member-dialog form > footer { flex-shrink: 0; }
+.org-member-dialog .org-dialog-content { min-height: 0; overscroll-behavior: contain; }
+.org-member-dialog .org-dialog-content > * { flex-shrink: 0; }
+.org-member-dialog > header h2 { overflow-wrap: anywhere; }
+.org-member-dialog > header .org-icon-button { flex-shrink: 0; }
+
+.org-primary-transfer-accounts {
+  display: grid;
+  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
+  align-items: stretch;
+  gap: 12px;
+}
+.org-primary-transfer-person {
+  display: grid;
+  grid-template-rows: auto auto 1fr auto;
+  align-items: start;
+  gap: 4px;
+  min-width: 0;
+  padding: 14px;
+  border: 1px solid var(--border);
+  border-radius: 9px;
+  background: var(--surface-subtle);
+  overflow-wrap: anywhere;
+}
+.org-primary-transfer-person.is-recipient { border-color: var(--primary-border); background: var(--primary-soft); }
+.org-primary-transfer-person strong { color: var(--foreground); font-size: var(--type-section); font-weight: 650; }
+.org-primary-transfer-label, .org-primary-transfer-person small { color: var(--text-secondary); font-size: var(--type-support); }
+.org-primary-transfer-role {
+  grid-row: 4;
+  justify-self: start;
+  margin-top: 6px;
+  padding: 3px 8px;
+  border-radius: 5px;
+  background: var(--card);
+  color: var(--text-secondary);
+  font-size: var(--type-support);
+  font-weight: 600;
+}
+.org-primary-transfer-person.is-recipient .org-primary-transfer-role { color: var(--primary-soft-foreground); }
+.org-primary-transfer-arrow { align-self: center; color: var(--primary); }
+.org-primary-transfer-effect, .org-primary-transfer-session { margin: 0; color: var(--text-secondary); font-size: var(--type-support); }
+.org-primary-transfer-session { padding: 9px 12px; border-radius: 6px; background: var(--surface-subtle); }
+.org-primary-transfer-result {
+  display: flex;
+  align-items: flex-start;
+  gap: 10px;
+  padding: 14px;
+  border: 1px solid var(--primary-border);
+  border-radius: 9px;
+  background: var(--primary-soft);
+  color: var(--primary-soft-foreground);
+}
+.org-primary-transfer-result svg { flex: none; }
+.org-primary-transfer-result p { margin: 3px 0 0; overflow-wrap: anywhere; }
+@media (max-width: 480px) {
+  .org-primary-transfer-accounts { grid-template-columns: minmax(0, 1fr); gap: 8px; }
+  .org-primary-transfer-arrow { justify-self: center; transform: rotate(90deg); }
+}
+
 /* 运维团队新建/编辑:录入项一行两个;「负责范围」整段跨两列,窄屏回落一列。
    行距按内容收(`align-content:start` + 10px 行距):抽屉高度富余时 ⛔ 把隐式行拉伸成大片留白。 */
 .org-editor-modal .org-dialog-content.org-editor-form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));align-content:start;align-items:start;gap:10px 16px}