补充监查访视问题模块内容、翻页功能UI统一

This commit is contained in:
Cheng Zhou
2026-02-28 09:51:13 +08:00
parent db2d38edbc
commit af0c1b4b7d
16 changed files with 2372 additions and 84 deletions
+53 -5
View File
@@ -129,6 +129,23 @@ const splitAuditDetailSegments = (line: string): string[] => {
};
const auditFieldLabelMap: Record<string, string> = {
issue_no: "问题编号",
source: "问题来源",
monitor_type: "监查类型",
monitor_item: "监查项",
category: "问题分类",
recommendation: "建议措施",
subject_name: "受试者",
subject_code: "受试者缩写号",
description: "问题描述",
action_taken: "采取措施",
follow_up_progress: "跟进计划及进展",
found_date: "发现时间",
due_at: "预计解决日期",
actual_resolve_date: "实际解决日期",
closed_at: "关闭日期",
responsible_name: "责任人",
creator_name: "创建者",
status: "状态",
is_active: "启用状态",
role: "角色",
@@ -148,6 +165,35 @@ const auditFieldLabelMap: Record<string, string> = {
plan_end_date: "计划结束日期",
};
const stableSerialize = (value: any): string => {
if (value === null || value === undefined) return "";
if (Array.isArray(value)) return `[${value.map((item) => stableSerialize(item)).join(",")}]`;
if (typeof value === "object") {
const entries = Object.entries(value as Record<string, any>)
.sort(([a], [b]) => a.localeCompare(b))
.map(([k, v]) => `${k}:${stableSerialize(v)}`);
return `{${entries.join(",")}}`;
}
return String(value);
};
const isSameValue = (prev: any, next: any): boolean => stableSerialize(prev) === stableSerialize(next);
const compactObjectValue = (value: Record<string, any>): string => {
const preferredKeys = ["name", "label", "title", "code", "id", "value"];
for (const key of preferredKeys) {
const text = String(value[key] ?? "").trim();
if (text) return text;
}
const entries = Object.entries(value).filter(([, v]) => v !== null && v !== undefined && String(v).trim() !== "");
if (entries.length === 0) return "未填写";
const rendered = entries
.slice(0, 3)
.map(([k, v]) => `${toReadableFieldLabel(k)}=${String(v)}`)
.join("");
return entries.length > 3 ? `${rendered}${entries.length}` : rendered;
};
const toReadableFieldLabel = (key: string): string => {
const normalized = String(key || "").trim();
if (!normalized) return "字段";
@@ -170,11 +216,13 @@ const toReadableValue = (key: string, value: any): string => {
}
return text;
}
if (Array.isArray(value)) return `${value.length}`;
if (Array.isArray(value)) {
if (value.length === 0) return "未填写";
const rendered = value.slice(0, 3).map((item) => toReadableValue(key, item)).join("、");
return value.length > 3 ? `${rendered}${value.length}` : rendered;
}
if (typeof value === "object") {
if (typeof value.name === "string" && value.name.trim()) return value.name.trim();
if (typeof value.label === "string" && value.label.trim()) return value.label.trim();
return "已配置";
return compactObjectValue(value as Record<string, any>);
}
return String(value);
};
@@ -187,7 +235,7 @@ const buildDiffText = (before?: Record<string, any>, after?: Record<string, any>
Object.keys({ ...prevObj, ...nextObj }).forEach((key) => {
const prev = prevObj[key];
const next = nextObj[key];
if (prev === next) return;
if (isSameValue(prev, next)) return;
const label = toReadableFieldLabel(key);
const prevText = toReadableValue(key, prev);
const nextText = toReadableValue(key, next);