|
@@ -17,7 +17,7 @@
|
|
|
*/
|
|
*/
|
|
|
import { useState } from "react";
|
|
import { useState } from "react";
|
|
|
import { PageIntro } from "../components/PageIntro";
|
|
import { PageIntro } from "../components/PageIntro";
|
|
|
-import { Download, Search } from "lucide-react";
|
|
|
|
|
|
|
+import { ChevronDown, Download, Fingerprint, Search, UserRound } from "lucide-react";
|
|
|
import { Button } from "../components/ui/button";
|
|
import { Button } from "../components/ui/button";
|
|
|
import { Input } from "../components/ui/input";
|
|
import { Input } from "../components/ui/input";
|
|
|
import { FilterSelect } from "../components/ui/filter-select";
|
|
import { FilterSelect } from "../components/ui/filter-select";
|
|
@@ -54,6 +54,7 @@ import {
|
|
|
} from "../lib/copy-jobs";
|
|
} from "../lib/copy-jobs";
|
|
|
import type { AuditItem } from "../lib/api/types";
|
|
import type { AuditItem } from "../lib/api/types";
|
|
|
import "../styles/operations.css";
|
|
import "../styles/operations.css";
|
|
|
|
|
+import "../styles/party-audit.css";
|
|
|
|
|
|
|
|
/** occurred_at → 东八区「日期+时刻」两行(总则§10.2,⚠️ 不显 UTC 串);null ⇒ 「—」(时刻未知,⛔ 猜) */
|
|
/** occurred_at → 东八区「日期+时刻」两行(总则§10.2,⚠️ 不显 UTC 串);null ⇒ 「—」(时刻未知,⛔ 猜) */
|
|
|
function TimeCell({ at }: { at: string | null }) {
|
|
function TimeCell({ at }: { at: string | null }) {
|
|
@@ -64,7 +65,7 @@ function TimeCell({ at }: { at: string | null }) {
|
|
|
const timeText = new Intl.DateTimeFormat("zh-CN", { timeZone: "Asia/Shanghai", hour: "2-digit", minute: "2-digit", second: "2-digit", hour12: false }).format(date);
|
|
const timeText = new Intl.DateTimeFormat("zh-CN", { timeZone: "Asia/Shanghai", hour: "2-digit", minute: "2-digit", second: "2-digit", hour12: false }).format(date);
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
|
- {dateText}
|
|
|
|
|
|
|
+ <span className="audit-time-date">{dateText}</span>
|
|
|
<br />
|
|
<br />
|
|
|
<small>{timeText}</small>
|
|
<small>{timeText}</small>
|
|
|
</>
|
|
</>
|
|
@@ -78,7 +79,7 @@ function ActionCell({ action }: { action: string }) {
|
|
|
if (display) return <>{display}</>;
|
|
if (display) return <>{display}</>;
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
|
- <span className="ops-mono">{action}</span>
|
|
|
|
|
|
|
+ <span className="ops-mono" title={action}>{action}</span>
|
|
|
<br />
|
|
<br />
|
|
|
<small>{AUDIT_ACTION_UNREGISTERED}</small>
|
|
<small>{AUDIT_ACTION_UNREGISTERED}</small>
|
|
|
</>
|
|
</>
|
|
@@ -90,31 +91,60 @@ function ActionCell({ action }: { action: string }) {
|
|
|
* (`detail_json.object`/前后值区的白名单名称键)→ 都取不到才 W32;三种形态都并列「类型 · 主键」小字。
|
|
* (`detail_json.object`/前后值区的白名单名称键)→ 都取不到才 W32;三种形态都并列「类型 · 主键」小字。
|
|
|
* ⛔ 拿当前库里的名字顶替历史行(I38:改名会伪造流水),⛔ 留空。
|
|
* ⛔ 拿当前库里的名字顶替历史行(I38:改名会伪造流水),⛔ 留空。
|
|
|
*/
|
|
*/
|
|
|
-function ObjectCell({ item }: { item: AuditItem }) {
|
|
|
|
|
|
|
+function ObjectCell({ item, compact }: { item: AuditItem; compact: boolean }) {
|
|
|
const typeText = AUDIT_OBJECT_TYPE_DISPLAY[normalizeAuditObjectType(item.object.type)] ?? item.object.type;
|
|
const typeText = AUDIT_OBJECT_TYPE_DISPLAY[normalizeAuditObjectType(item.object.type)] ?? item.object.type;
|
|
|
const snapshot = auditObjectSnapshot(item);
|
|
const snapshot = auditObjectSnapshot(item);
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
|
{snapshot ? (
|
|
{snapshot ? (
|
|
|
- <span title={`对象名取自${snapshot.source}(事件当时的快照,不随后续改名变化)`}>{snapshot.text}</span>
|
|
|
|
|
|
|
+ <span className="audit-object-name" title={`${compact ? `${snapshot.text} · ` : ""}对象名取自${snapshot.source}(事件当时的快照,不随后续改名变化)`}>{snapshot.text}</span>
|
|
|
) : (
|
|
) : (
|
|
|
W32
|
|
W32
|
|
|
)}
|
|
)}
|
|
|
<br />
|
|
<br />
|
|
|
- <small>
|
|
|
|
|
|
|
+ <small title={compact ? `${typeText} · ${item.object.id}` : undefined}>
|
|
|
{typeText} · {item.object.id}
|
|
{typeText} · {item.object.id}
|
|
|
</small>
|
|
</small>
|
|
|
</>
|
|
</>
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function ValueCell({ value }: { value: unknown }) {
|
|
|
|
|
|
|
+function AuditLines({ lines }: { lines: readonly string[] }) {
|
|
|
|
|
+ return lines.map((line, index) => <div key={index}>{line}</div>);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function CompactAuditValue({ value, extra = [] }: {
|
|
|
|
|
+ value: unknown;
|
|
|
|
|
+ extra?: readonly { label: string; lines: readonly string[] }[];
|
|
|
|
|
+}) {
|
|
|
|
|
+ const lines = formatAuditValue(value);
|
|
|
|
|
+ const blank = lines.length === 1 && (lines[0] === "—" || !lines[0]);
|
|
|
|
|
+ const expandable = extra.length > 0 || lines.length > 2 || lines.some((line) => line.length > 64 || line.includes("\n"));
|
|
|
|
|
+
|
|
|
|
|
+ if (!expandable) {
|
|
|
|
|
+ return blank ? <span className="table-placeholder">—</span> : <div className="party-audit-value"><AuditLines lines={lines} /></div>;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
- <>
|
|
|
|
|
- {formatAuditValue(value).map((line, index) => (
|
|
|
|
|
- <div key={index}>{line}</div>
|
|
|
|
|
- ))}
|
|
|
|
|
- </>
|
|
|
|
|
|
|
+ <details className="party-audit-disclosure">
|
|
|
|
|
+ <summary>
|
|
|
|
|
+ <span className="party-audit-preview" title={blank ? undefined : lines[0]}>{blank ? extra[0]?.label : lines[0]}</span>
|
|
|
|
|
+ <span className="party-audit-toggle">
|
|
|
|
|
+ <span className="party-audit-expand">展开</span>
|
|
|
|
|
+ <span className="party-audit-collapse">收起</span>
|
|
|
|
|
+ <ChevronDown size={13} aria-hidden="true" />
|
|
|
|
|
+ </span>
|
|
|
|
|
+ </summary>
|
|
|
|
|
+ <div className="party-audit-value">
|
|
|
|
|
+ {!blank && <AuditLines lines={lines} />}
|
|
|
|
|
+ {extra.map(({ label, lines: groupLines }) => (
|
|
|
|
|
+ <div className="party-audit-value-group" key={label}>
|
|
|
|
|
+ <small>{label}</small>
|
|
|
|
|
+ <AuditLines lines={groupLines} />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ ))}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </details>
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -124,28 +154,31 @@ function ValueCell({ value }: { value: unknown }) {
|
|
|
* 「分账号:」一行⛔ 受前后值区是否为空影响(D-76):订阅类流水前后值都有值,而 D-41 的额度
|
|
* 「分账号:」一行⛔ 受前后值区是否为空影响(D-76):订阅类流水前后值都有值,而 D-41 的额度
|
|
|
* 对齐结果只落在 `detail_json.sub_accounts`,一并短路=审计页读不到补建了哪几个号。
|
|
* 对齐结果只落在 `detail_json.sub_accounts`,一并短路=审计页读不到补建了哪几个号。
|
|
|
*/
|
|
*/
|
|
|
-function AfterCell({ item }: { item: AuditItem }) {
|
|
|
|
|
|
|
+function AfterCell({ item, compact }: { item: AuditItem; compact: boolean }) {
|
|
|
const detail = auditDetailLines(item);
|
|
const detail = auditDetailLines(item);
|
|
|
const seats = auditSeatLines(item);
|
|
const seats = auditSeatLines(item);
|
|
|
|
|
+ if (compact) {
|
|
|
|
|
+ const extra = [
|
|
|
|
|
+ { label: "明细", lines: detail },
|
|
|
|
|
+ { label: "分账号", lines: seats },
|
|
|
|
|
+ ].filter(({ lines }) => lines.length > 0);
|
|
|
|
|
+ return <CompactAuditValue value={item.after} extra={extra} />;
|
|
|
|
|
+ }
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
|
- <ValueCell value={item.after} />
|
|
|
|
|
|
|
+ <AuditLines lines={formatAuditValue(item.after)} />
|
|
|
{detail.length > 0 && (
|
|
{detail.length > 0 && (
|
|
|
<>
|
|
<>
|
|
|
<br />
|
|
<br />
|
|
|
<small>明细:</small>
|
|
<small>明细:</small>
|
|
|
- {detail.map((line, index) => (
|
|
|
|
|
- <div key={`detail-${index}`}>{line}</div>
|
|
|
|
|
- ))}
|
|
|
|
|
|
|
+ <AuditLines lines={detail} />
|
|
|
</>
|
|
</>
|
|
|
)}
|
|
)}
|
|
|
{seats.length > 0 && (
|
|
{seats.length > 0 && (
|
|
|
<>
|
|
<>
|
|
|
<br />
|
|
<br />
|
|
|
<small>分账号:</small>
|
|
<small>分账号:</small>
|
|
|
- {seats.map((line, index) => (
|
|
|
|
|
- <div key={`seat-${index}`}>{line}</div>
|
|
|
|
|
- ))}
|
|
|
|
|
|
|
+ <AuditLines lines={seats} />
|
|
|
</>
|
|
</>
|
|
|
)}
|
|
)}
|
|
|
</>
|
|
</>
|
|
@@ -216,7 +249,7 @@ function ExportDialog({ filter, onCancel, onDone }: { filter: AuditFilter; onCan
|
|
|
* 运营侧标题「审计日志」并可导出;`partnerAcct`/`opAcct`/`teamLead` 由宿主路由传入
|
|
* 运营侧标题「审计日志」并可导出;`partnerAcct`/`opAcct`/`teamLead` 由宿主路由传入
|
|
|
* `pageTitle="本方变更记录"`,横幅与导出按钮都按身份自动收起(四类身份⛔ 渲染导出)。
|
|
* `pageTitle="本方变更记录"`,横幅与导出按钮都按身份自动收起(四类身份⛔ 渲染导出)。
|
|
|
*/
|
|
*/
|
|
|
-export function AuditLogPage({ pageTitle = "审计日志" }: { pageTitle?: string } = {}) {
|
|
|
|
|
|
|
+export function AuditLogPage({ pageTitle = "审计日志", partyView = false }: { pageTitle?: string; partyView?: boolean } = {}) {
|
|
|
const identity = useDemoIdentity();
|
|
const identity = useDemoIdentity();
|
|
|
const role = identity?.role;
|
|
const role = identity?.role;
|
|
|
const canExport = role === "admin" || role === "regAdmin"; // U-77:未放开身份不渲染按钮(⛔ 灰按钮)
|
|
const canExport = role === "admin" || role === "regAdmin"; // U-77:未放开身份不渲染按钮(⛔ 灰按钮)
|
|
@@ -225,6 +258,8 @@ export function AuditLogPage({ pageTitle = "审计日志" }: { pageTitle?: strin
|
|
|
const [filterError, setFilterError] = useState<string | null>(null);
|
|
const [filterError, setFilterError] = useState<string | null>(null);
|
|
|
const [exporting, setExporting] = useState(false);
|
|
const [exporting, setExporting] = useState(false);
|
|
|
const [notice, setNotice] = useState<string | null>(null);
|
|
const [notice, setNotice] = useState<string | null>(null);
|
|
|
|
|
+ const hasFilter = Object.values(draft).some(Boolean) || Object.values(list.applied).some(Boolean);
|
|
|
|
|
+ const intro = partyView ? "按时间、操作人或业务对象查找本方的变更记录。" : "需要追查一笔操作时,可按时间、账号或业务对象查找记录。";
|
|
|
|
|
|
|
|
const change = (key: keyof AuditFilter, value: string) => {
|
|
const change = (key: keyof AuditFilter, value: string) => {
|
|
|
setDraft((current) => ({ ...current, [key]: value }));
|
|
setDraft((current) => ({ ...current, [key]: value }));
|
|
@@ -254,7 +289,7 @@ export function AuditLogPage({ pageTitle = "审计日志" }: { pageTitle?: strin
|
|
|
<header className="ops-heading">
|
|
<header className="ops-heading">
|
|
|
<div>
|
|
<div>
|
|
|
<h1>{pageTitle}</h1>
|
|
<h1>{pageTitle}</h1>
|
|
|
- <PageIntro>需要追查一笔操作时,可按时间、账号或业务对象查找记录。</PageIntro>
|
|
|
|
|
|
|
+ <PageIntro>{intro}</PageIntro>
|
|
|
</div>
|
|
</div>
|
|
|
</header>
|
|
</header>
|
|
|
<div className="ops-empty">
|
|
<div className="ops-empty">
|
|
@@ -266,11 +301,11 @@ export function AuditLogPage({ pageTitle = "审计日志" }: { pageTitle?: strin
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
- <section className="ops-page ops-page--audit page-fill">
|
|
|
|
|
|
|
+ <section className={partyView ? "ops-page ops-page--audit party-audit-page page-fill page-fill-window" : "ops-page ops-page--audit page-fill"}>
|
|
|
<header className="ops-heading">
|
|
<header className="ops-heading">
|
|
|
<div>
|
|
<div>
|
|
|
<h1>{pageTitle}</h1>
|
|
<h1>{pageTitle}</h1>
|
|
|
- <PageIntro>需要追查一笔操作时,可按时间、账号或业务对象查找记录。</PageIntro>
|
|
|
|
|
|
|
+ <PageIntro>{intro}</PageIntro>
|
|
|
</div>
|
|
</div>
|
|
|
{canExport && (
|
|
{canExport && (
|
|
|
<Button variant="outline" type="button" onClick={() => setExporting(true)}>
|
|
<Button variant="outline" type="button" onClick={() => setExporting(true)}>
|
|
@@ -280,11 +315,16 @@ export function AuditLogPage({ pageTitle = "审计日志" }: { pageTitle?: strin
|
|
|
)}
|
|
)}
|
|
|
</header>
|
|
</header>
|
|
|
|
|
|
|
|
- <ScopeBanners role={role} />
|
|
|
|
|
|
|
+ {partyView ? <aside className="party-audit-scope" aria-label="记录可见范围"><ScopeBanners role={role} /></aside> : <ScopeBanners role={role} />}
|
|
|
|
|
|
|
|
<section className="ops-list-shell list-shell-fill" aria-label="操作记录">
|
|
<section className="ops-list-shell list-shell-fill" aria-label="操作记录">
|
|
|
{/* 检索区四件(契约 14.4.1):对象类型/主体定位(只接受 ID)/操作人(ID)/时间区间+关键字 */}
|
|
{/* 检索区四件(契约 14.4.1):对象类型/主体定位(只接受 ID)/操作人(ID)/时间区间+关键字 */}
|
|
|
- <div className="ops-toolbar flex-wrap">
|
|
|
|
|
|
|
+ <form className="ops-toolbar flex-wrap" aria-label="筛选操作记录" onSubmit={(event) => { event.preventDefault(); apply(); }}>
|
|
|
|
|
+ {partyView && <label className="ops-search party-audit-keyword">
|
|
|
|
|
+ <Search size={17} aria-hidden="true" />
|
|
|
|
|
+ <Input aria-label="关键字" placeholder="搜索变更记录" value={draft.keyword} onChange={(event) => change("keyword", event.target.value)} />
|
|
|
|
|
+ </label>}
|
|
|
|
|
+ {partyView && <DateRangeFilter label="时间范围" from={draft.from} to={draft.to} onChange={change} constrainRange />}
|
|
|
<FilterSelect icon="type" aria-label="对象类型筛选" value={draft.objectType} onChange={(event) => change("objectType", event.target.value)}>
|
|
<FilterSelect icon="type" aria-label="对象类型筛选" value={draft.objectType} onChange={(event) => change("objectType", event.target.value)}>
|
|
|
<option value="">全部对象类型</option>
|
|
<option value="">全部对象类型</option>
|
|
|
{AUDIT_OBJECT_TYPES.map((type) => (
|
|
{AUDIT_OBJECT_TYPES.map((type) => (
|
|
@@ -294,25 +334,25 @@ export function AuditLogPage({ pageTitle = "审计日志" }: { pageTitle?: strin
|
|
|
))}
|
|
))}
|
|
|
</FilterSelect>
|
|
</FilterSelect>
|
|
|
<label className="ops-search">
|
|
<label className="ops-search">
|
|
|
- <Search size={17} />
|
|
|
|
|
- <Input aria-label="主体定位(对象 ID)" placeholder="主体定位:对象 ID" value={draft.objectId} onChange={(event) => change("objectId", event.target.value)} />
|
|
|
|
|
|
|
+ {partyView ? <Fingerprint size={17} aria-hidden="true" /> : <Search size={17} />}
|
|
|
|
|
+ <Input aria-label="主体定位(对象 ID)" placeholder={partyView ? "对象 ID" : "主体定位:对象 ID"} value={draft.objectId} onChange={(event) => change("objectId", event.target.value)} />
|
|
|
</label>
|
|
</label>
|
|
|
<label className="ops-search">
|
|
<label className="ops-search">
|
|
|
- <Search size={17} />
|
|
|
|
|
|
|
+ {partyView ? <UserRound size={17} aria-hidden="true" /> : <Search size={17} />}
|
|
|
<Input aria-label="操作人(账号 ID)" placeholder="操作人:账号 ID" value={draft.actorId} onChange={(event) => change("actorId", event.target.value)} />
|
|
<Input aria-label="操作人(账号 ID)" placeholder="操作人:账号 ID" value={draft.actorId} onChange={(event) => change("actorId", event.target.value)} />
|
|
|
</label>
|
|
</label>
|
|
|
- <DateRangeFilter label="时间范围" from={draft.from} to={draft.to} onChange={change} constrainRange />
|
|
|
|
|
- <label className="ops-search">
|
|
|
|
|
|
|
+ {!partyView && <DateRangeFilter label="时间范围" from={draft.from} to={draft.to} onChange={change} constrainRange />}
|
|
|
|
|
+ {!partyView && <label className="ops-search">
|
|
|
<Search size={17} />
|
|
<Search size={17} />
|
|
|
<Input aria-label="关键字" placeholder="关键字" value={draft.keyword} onChange={(event) => change("keyword", event.target.value)} />
|
|
<Input aria-label="关键字" placeholder="关键字" value={draft.keyword} onChange={(event) => change("keyword", event.target.value)} />
|
|
|
- </label>
|
|
|
|
|
- <Button type="button" size="sm" onClick={apply}>
|
|
|
|
|
|
|
+ </label>}
|
|
|
|
|
+ <Button type="submit" size="sm">
|
|
|
查询
|
|
查询
|
|
|
</Button>
|
|
</Button>
|
|
|
- <Button type="button" size="sm" variant="ghost" onClick={reset}>
|
|
|
|
|
|
|
+ {(!partyView || hasFilter) && <Button type="button" size="sm" variant="ghost" onClick={reset}>
|
|
|
重置筛选
|
|
重置筛选
|
|
|
- </Button>
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ </Button>}
|
|
|
|
|
+ </form>
|
|
|
{filterError && (
|
|
{filterError && (
|
|
|
<p className="ops-form-error" role="alert">
|
|
<p className="ops-form-error" role="alert">
|
|
|
{filterError}
|
|
{filterError}
|
|
@@ -329,12 +369,12 @@ export function AuditLogPage({ pageTitle = "审计日志" }: { pageTitle?: strin
|
|
|
)}
|
|
)}
|
|
|
|
|
|
|
|
<div className="measured-table-scroll ops-table-wrap" role="region" aria-label={`${pageTitle},可横向滚动查看字段`} tabIndex={0}>
|
|
<div className="measured-table-scroll ops-table-wrap" role="region" aria-label={`${pageTitle},可横向滚动查看字段`} tabIndex={0}>
|
|
|
- <table className="ops-table">
|
|
|
|
|
- <OpsTableColumns widths={[11, 11, 13, 18, 22, 25]} />
|
|
|
|
|
|
|
+ <table className={partyView ? "ops-table party-audit-table" : "ops-table"} aria-busy={partyView ? list.phase.kind === "loading" || list.loadingMore : undefined}>
|
|
|
|
|
+ <OpsTableColumns widths={partyView ? [11, 13, 14, 18, 22, 22] : [11, 11, 13, 18, 22, 25]} />
|
|
|
<thead>
|
|
<thead>
|
|
|
<tr>
|
|
<tr>
|
|
|
{W31_COLUMNS.map((column) => (
|
|
{W31_COLUMNS.map((column) => (
|
|
|
- <th key={column}>{column}</th>
|
|
|
|
|
|
|
+ <th key={column} scope="col">{column}</th>
|
|
|
))}
|
|
))}
|
|
|
</tr>
|
|
</tr>
|
|
|
</thead>
|
|
</thead>
|
|
@@ -344,18 +384,18 @@ export function AuditLogPage({ pageTitle = "审计日志" }: { pageTitle?: strin
|
|
|
<td>
|
|
<td>
|
|
|
<TimeCell at={item.occurred_at} />
|
|
<TimeCell at={item.occurred_at} />
|
|
|
</td>
|
|
</td>
|
|
|
- <td>{item.actor.username ?? item.actor.user_id ?? <span className="table-placeholder">—</span>}</td>
|
|
|
|
|
|
|
+ <td title={partyView ? item.actor.username ?? item.actor.user_id ?? undefined : undefined}>{item.actor.username ?? item.actor.user_id ?? <span className="table-placeholder">—</span>}</td>
|
|
|
<td>
|
|
<td>
|
|
|
<ActionCell action={item.action} />
|
|
<ActionCell action={item.action} />
|
|
|
</td>
|
|
</td>
|
|
|
<td>
|
|
<td>
|
|
|
- <ObjectCell item={item} />
|
|
|
|
|
|
|
+ <ObjectCell item={item} compact={partyView} />
|
|
|
</td>
|
|
</td>
|
|
|
<td>
|
|
<td>
|
|
|
- <ValueCell value={item.before} />
|
|
|
|
|
|
|
+ {partyView ? <CompactAuditValue value={item.before} /> : <AuditLines lines={formatAuditValue(item.before)} />}
|
|
|
</td>
|
|
</td>
|
|
|
<td>
|
|
<td>
|
|
|
- <AfterCell item={item} />
|
|
|
|
|
|
|
+ <AfterCell item={item} compact={partyView} />
|
|
|
</td>
|
|
</td>
|
|
|
</tr>
|
|
</tr>
|
|
|
))}
|
|
))}
|