刘光辉
3 小时以前 cf11e63b659afcc9792ab3e395f1b45d844431a8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import { defHttp } from '#/api/request';
 
export type AuditEventId = number | string;
export type AuditEventType = 'BIZ_ACTION' | 'DATA_CHANGE' | 'E_SIGNATURE' | 'PRINT';
 
export interface AuditPageQuery {
  actionCode?: string;
  appName?: string;
  bizCode?: string;
  bizModule?: string;
  bizType?: string;
  currentPage: number;
  endTime?: string;
  eventType?: AuditEventType;
  keyword?: string;
  operatorName?: string;
  pageSize: number;
  startTime?: string;
  targetTable?: string;
}
 
export interface DmsFolderAuditPageQuery {
  actionCode?: string;
  currentPage: number;
  endTime?: string;
  folderId?: string;
  keyword?: string;
  operatorName?: string;
  pageSize: number;
  signed?: boolean;
  startTime?: string;
}
 
export interface AuditEventListDTO {
  actionCode?: string;
  actionLabel?: string;
  appName?: string;
  bizCode?: string;
  bizModule?: string;
  parentBizModule?: string;
  bizType?: string;
  browser?: string;
  clientEventId?: string;
  createdAt?: string;
  diffCount?: number;
  entryId?: string;
  entryName?: string;
  entryType?: string;
  eventTime?: string;
  eventType?: AuditEventType | string;
  folderName?: string;
  id: AuditEventId;
  ip?: string;
  ipRegion?: string;
  operationId?: null | string;
  operatorId?: string;
  operatorName?: string;
  operatorOrgId?: string;
  os?: string;
  parentFolderName?: string;
  reason?: string;
  recordTitle?: string;
  requestUri?: string;
  signatureRole?: 'PRIMARY' | 'REVIEW' | string;
  signed?: boolean;
  sourceLayer?: number;
  subEvents?: AuditEventListDTO[];
  subTitleCount?: number;
  subTitles?: string[];
  targetId?: string;
  targetTable?: string;
  tenantId?: string;
}
 
export interface AuditFieldDiffDTO {
  changeType?: string;
  chidData?: Array<Record<string, unknown>>;
  chidField?: Array<Record<string, unknown>>;
  componentType?: string;
  field?: string;
  fieldName?: string;
  jnpfKey?: string;
  masked?: boolean;
  nameModified?: boolean;
  newData?: unknown;
  newDisplay?: unknown;
  oldData?: unknown;
  oldDisplay?: unknown;
  technical?: boolean;
  type?: number | string;
  valueType?: string;
}
 
export interface AuditEventDetailDTO extends Omit<AuditEventListDTO, 'diffCount' | 'subEvents'> {
  dataSnapshot?: string;
  extra?: string;
  fieldDiffList?: AuditFieldDiffDTO[] | null;
  fieldDiffs?: string;
  prevHash?: string;
}
 
export interface AuditPagination {
  currentPage: number;
  pageSize: number;
  total: number;
}
 
export interface AuditEventPageDTO {
  list: AuditEventListDTO[];
  pagination: AuditPagination;
}
 
export interface DmsFolderAuditDetailDTO {
  business: AuditEventDetailDTO;
  signatures: AuditEventDetailDTO[];
}
 
interface AuditApiResult<T> {
  code: number;
  data: T;
  msg?: string;
}
 
export const AUDIT_EVENT_API = {
  detail: '/api/audit/audit/events',
  page: '/api/audit/audit/events/page',
  timeline: '/api/audit/audit/events/timeline',
} as const;
 
export const AUDIT_SIGNATURE_API = {
  detail: '/api/audit/audit/signatures',
  page: '/api/audit/audit/signatures/page',
} as const;
 
export const DMS_FOLDER_AUDIT_API = {
  detail: '/api/audit/audit/dms/folders/events',
  page: '/api/audit/audit/dms/folders/page',
  timeline: '/api/audit/audit/dms/folders',
} as const;
 
const silentErrorOptions = { errorMessageMode: 'none' as const };
 
/** Query operation-deduplicated BUSINESS rows with related signature event summaries. */
export function getAuditEventPage(data: AuditPageQuery) {
  return defHttp.post<AuditApiResult<AuditEventPageDTO>>({ url: AUDIT_EVENT_API.page, data }, silentErrorOptions);
}
 
/** Query a single event detail. Callers must not log or cache this response. */
export function getAuditEventDetail(id: AuditEventId) {
  return defHttp.get<AuditApiResult<AuditEventDetailDTO>>({ url: `${AUDIT_EVENT_API.detail}/${id}` }, silentErrorOptions);
}
 
/** Query the operation-grouped event timeline for an exact target record. */
export function getAuditEventTimeline(targetId: string) {
  return defHttp.get<AuditApiResult<AuditEventListDTO[]>>({ url: AUDIT_EVENT_API.timeline, params: { targetId } }, silentErrorOptions);
}
 
/** Query physical audit_events rows whose target_table is strictly lims_sign. */
export function getAuditSignaturePage(data: AuditPageQuery) {
  return defHttp.post<AuditApiResult<AuditEventPageDTO>>({ url: AUDIT_SIGNATURE_API.page, data }, silentErrorOptions);
}
 
/** Query one lims_sign audit event detail; other target tables are rejected by the backend. */
export function getAuditSignatureDetail(id: AuditEventId) {
  return defHttp.get<AuditApiResult<AuditEventDetailDTO>>({ url: `${AUDIT_SIGNATURE_API.detail}/${id}` }, silentErrorOptions);
}
 
/** Query operation-grouped DMS folder audit rows under the backend's fixed tenant and business scope. */
export function getDmsFolderAuditPage(data: DmsFolderAuditPageQuery) {
  return defHttp.post<AuditApiResult<AuditEventPageDTO>>({ url: DMS_FOLDER_AUDIT_API.page, data }, silentErrorOptions);
}
 
/** Query one DMS folder business event together with its optional primary/review signatures. */
export function getDmsFolderAuditDetail(id: AuditEventId) {
  return defHttp.get<AuditApiResult<DmsFolderAuditDetailDTO>>({ url: `${DMS_FOLDER_AUDIT_API.detail}/${id}` }, silentErrorOptions);
}
 
/** Query the fixed-scope operation timeline for one exact DMS folder. */
export function getDmsFolderAuditTimeline(folderId: string) {
  return defHttp.get<AuditApiResult<AuditEventListDTO[]>>(
    {
      url: `${DMS_FOLDER_AUDIT_API.timeline}/${encodeURIComponent(folderId)}/timeline`,
    },
    silentErrorOptions,
  );
}