|
@@ -15,7 +15,7 @@
|
|
|
* ⚠️ 键 `bos.audit.export@v1` 尚未绑给运营三角色(2026-11-18 补绑撞平台 grant ceiling)⇒ 未绑期仍回
|
|
* ⚠️ 键 `bos.audit.export@v1` 尚未绑给运营三角色(2026-11-18 补绑撞平台 grant ceiling)⇒ 未绑期仍回
|
|
|
* `11001`(按 `AUDIT_EXPORT_WIRING_NOTE` 提示,⛔ 说成「接口未声明」),KLT-R20903 ⇒ W38,KLT-S405 ⇒ W39。
|
|
* `11001`(按 `AUDIT_EXPORT_WIRING_NOTE` 提示,⛔ 说成「接口未声明」),KLT-R20903 ⇒ W38,KLT-S405 ⇒ W39。
|
|
|
*/
|
|
*/
|
|
|
-import { useState } from "react";
|
|
|
|
|
|
|
+import { useEffect, useState } from "react";
|
|
|
import { PageIntro } from "../components/PageIntro";
|
|
import { PageIntro } from "../components/PageIntro";
|
|
|
import { ChevronDown, Download, Fingerprint, Search, UserRound } from "lucide-react";
|
|
import { ChevronDown, Download, Fingerprint, Search, UserRound } from "lucide-react";
|
|
|
import { Button } from "../components/ui/button";
|
|
import { Button } from "../components/ui/button";
|
|
@@ -254,13 +254,23 @@ export function AuditLogPage({ pageTitle = "审计日志", partyView = false }:
|
|
|
const role = identity?.role;
|
|
const role = identity?.role;
|
|
|
const canExport = role === "admin" || role === "regAdmin"; // U-77:未放开身份不渲染按钮(⛔ 灰按钮)
|
|
const canExport = role === "admin" || role === "regAdmin"; // U-77:未放开身份不渲染按钮(⛔ 灰按钮)
|
|
|
const list = useAuditList();
|
|
const list = useAuditList();
|
|
|
|
|
+ const { applied, apply: applyFilter } = list;
|
|
|
const [draft, setDraft] = useState<AuditFilter>(EMPTY_AUDIT_FILTER);
|
|
const [draft, setDraft] = useState<AuditFilter>(EMPTY_AUDIT_FILTER);
|
|
|
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 hasFilter = Object.values(draft).some(Boolean) || Object.values(applied).some(Boolean);
|
|
|
|
|
+ const needsObjectType = Boolean(draft.objectId && !draft.objectType);
|
|
|
|
|
+ const objectTypeError = "主体定位须先选择对象类型。";
|
|
|
|
|
+ const visibleFilterError = partyView && needsObjectType ? objectTypeError : filterError;
|
|
|
const intro = partyView ? "按时间、操作人或业务对象查找本方的变更记录。" : "需要追查一笔操作时,可按时间、账号或业务对象查找记录。";
|
|
const intro = partyView ? "按时间、操作人或业务对象查找本方的变更记录。" : "需要追查一笔操作时,可按时间、账号或业务对象查找记录。";
|
|
|
|
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ if (!partyView || draft === applied || needsObjectType) return;
|
|
|
|
|
+ const timer = window.setTimeout(() => applyFilter(draft), 300);
|
|
|
|
|
+ return () => window.clearTimeout(timer);
|
|
|
|
|
+ }, [partyView, draft, applied, needsObjectType, applyFilter]);
|
|
|
|
|
+
|
|
|
const change = (key: keyof AuditFilter, value: string) => {
|
|
const change = (key: keyof AuditFilter, value: string) => {
|
|
|
setDraft((current) => ({ ...current, [key]: value }));
|
|
setDraft((current) => ({ ...current, [key]: value }));
|
|
|
setFilterError(null);
|
|
setFilterError(null);
|
|
@@ -268,8 +278,8 @@ export function AuditLogPage({ pageTitle = "审计日志", partyView = false }:
|
|
|
|
|
|
|
|
const apply = () => {
|
|
const apply = () => {
|
|
|
// 主体定位只接受 ID 且须与对象类型成对(作业§5.4);缺类型 ⇒ 拒发并提示,⛔ 静默丢条件
|
|
// 主体定位只接受 ID 且须与对象类型成对(作业§5.4);缺类型 ⇒ 拒发并提示,⛔ 静默丢条件
|
|
|
- if (draft.objectId && !draft.objectType) {
|
|
|
|
|
- setFilterError("主体定位须先选择对象类型。");
|
|
|
|
|
|
|
+ if (needsObjectType) {
|
|
|
|
|
+ setFilterError(objectTypeError);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
setFilterError(null);
|
|
setFilterError(null);
|
|
@@ -282,6 +292,13 @@ export function AuditLogPage({ pageTitle = "审计日志", partyView = false }:
|
|
|
list.apply(EMPTY_AUDIT_FILTER);
|
|
list.apply(EMPTY_AUDIT_FILTER);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ const objectTypeSelect = (
|
|
|
|
|
+ <FilterSelect icon="type" aria-label="对象类型筛选" value={draft.objectType} onChange={(event) => change("objectType", event.target.value)}>
|
|
|
|
|
+ <option value="">全部对象类型</option>
|
|
|
|
|
+ {AUDIT_OBJECT_TYPES.map((type) => <option value={type} key={type}>{AUDIT_OBJECT_TYPE_DISPLAY[type]}</option>)}
|
|
|
|
|
+ </FilterSelect>
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
// 读口未声明(audit_read_ready=false 等价信号)⇒ 整页 W35,⚠️ 不显 W15
|
|
// 读口未声明(audit_read_ready=false 等价信号)⇒ 整页 W35,⚠️ 不显 W15
|
|
|
if (list.phase.kind === "undeclared") {
|
|
if (list.phase.kind === "undeclared") {
|
|
|
return (
|
|
return (
|
|
@@ -319,20 +336,12 @@ export function AuditLogPage({ pageTitle = "审计日志", partyView = false }:
|
|
|
|
|
|
|
|
<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)/时间区间+关键字 */}
|
|
|
- <form className="ops-toolbar flex-wrap" aria-label="筛选操作记录" onSubmit={(event) => { event.preventDefault(); apply(); }}>
|
|
|
|
|
|
|
+ <form className="ops-toolbar flex-wrap" aria-label="筛选操作记录" onSubmit={(event) => { event.preventDefault(); if (!partyView) apply(); }}>
|
|
|
{partyView && <label className="ops-search party-audit-keyword">
|
|
{partyView && <label className="ops-search party-audit-keyword">
|
|
|
<Search size={17} aria-hidden="true" />
|
|
<Search size={17} aria-hidden="true" />
|
|
|
<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>}
|
|
</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)}>
|
|
|
|
|
- <option value="">全部对象类型</option>
|
|
|
|
|
- {AUDIT_OBJECT_TYPES.map((type) => (
|
|
|
|
|
- <option value={type} key={type}>
|
|
|
|
|
- {AUDIT_OBJECT_TYPE_DISPLAY[type]}
|
|
|
|
|
- </option>
|
|
|
|
|
- ))}
|
|
|
|
|
- </FilterSelect>
|
|
|
|
|
|
|
+ {!partyView && objectTypeSelect}
|
|
|
<label className="ops-search">
|
|
<label className="ops-search">
|
|
|
{partyView ? <Fingerprint size={17} aria-hidden="true" /> : <Search size={17} />}
|
|
{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)} />
|
|
<Input aria-label="主体定位(对象 ID)" placeholder={partyView ? "对象 ID" : "主体定位:对象 ID"} value={draft.objectId} onChange={(event) => change("objectId", event.target.value)} />
|
|
@@ -341,21 +350,22 @@ export function AuditLogPage({ pageTitle = "审计日志", partyView = false }:
|
|
|
{partyView ? <UserRound size={17} aria-hidden="true" /> : <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>
|
|
|
- {!partyView && <DateRangeFilter label="时间范围" from={draft.from} to={draft.to} onChange={change} constrainRange />}
|
|
|
|
|
|
|
+ {partyView && objectTypeSelect}
|
|
|
|
|
+ <DateRangeFilter label="时间范围" from={draft.from} to={draft.to} onChange={change} constrainRange />
|
|
|
{!partyView && <label className="ops-search">
|
|
{!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>}
|
|
</label>}
|
|
|
- <Button type="submit" size="sm">
|
|
|
|
|
|
|
+ {!partyView && <Button type="submit" size="sm">
|
|
|
查询
|
|
查询
|
|
|
- </Button>
|
|
|
|
|
|
|
+ </Button>}
|
|
|
{(!partyView || hasFilter) && <Button type="button" size="sm" variant="ghost" onClick={reset}>
|
|
{(!partyView || hasFilter) && <Button type="button" size="sm" variant="ghost" onClick={reset}>
|
|
|
重置筛选
|
|
重置筛选
|
|
|
</Button>}
|
|
</Button>}
|
|
|
</form>
|
|
</form>
|
|
|
- {filterError && (
|
|
|
|
|
|
|
+ {visibleFilterError && (
|
|
|
<p className="ops-form-error" role="alert">
|
|
<p className="ops-form-error" role="alert">
|
|
|
- {filterError}
|
|
|
|
|
|
|
+ {visibleFilterError}
|
|
|
</p>
|
|
</p>
|
|
|
)}
|
|
)}
|
|
|
|
|
|
|
@@ -406,7 +416,7 @@ export function AuditLogPage({ pageTitle = "审计日志", partyView = false }:
|
|
|
</div>
|
|
</div>
|
|
|
{list.nextCursor && (
|
|
{list.nextCursor && (
|
|
|
<footer className="ops-list-footer">
|
|
<footer className="ops-list-footer">
|
|
|
- <Button variant="outline" size="sm" type="button" disabled={list.loadingMore} onClick={list.loadMore}>
|
|
|
|
|
|
|
+ <Button variant="outline" size="sm" type="button" disabled={list.loadingMore || (partyView && (draft !== applied || list.phase.kind === "loading"))} onClick={list.loadMore}>
|
|
|
{list.loadingMore ? "加载中…" : "加载更多"}
|
|
{list.loadingMore ? "加载中…" : "加载更多"}
|
|
|
</Button>
|
|
</Button>
|
|
|
</footer>
|
|
</footer>
|