feat(platform): link quality issues to history evidence

This commit is contained in:
lingniu
2026-07-04 11:43:41 +08:00
parent 27e99f21d8
commit b03f9b1a3a
3 changed files with 104 additions and 2 deletions

View File

@@ -121,6 +121,18 @@ function qualityShareURL() {
return `${window.location.origin}${window.location.pathname}${window.location.hash}`;
}
function issueEvidenceDate(value?: string) {
const match = String(value ?? '').match(/^(\d{4})-(\d{2})-(\d{2})/);
return match ? `${match[1]}-${match[2]}-${match[3]}` : '';
}
function nextDate(value: string) {
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value.trim());
if (!match) return '';
const date = new Date(Date.UTC(Number(match[1]), Number(match[2]) - 1, Number(match[3]) + 1));
return date.toISOString().slice(0, 10);
}
function qualityActionRecommendation(row: QualityIssueRow) {
if (row.issueType === 'NO_SOURCE') {
return {
@@ -251,11 +263,13 @@ async function copyQualityShareURL() {
export function Quality({
onOpenVehicle,
onOpenHistory,
onHealthLoaded,
onFiltersChange,
initialFilters = {}
}: {
onOpenVehicle: (vin: string, protocol?: string) => void;
onOpenHistory?: (filters: Record<string, string>) => void;
onHealthLoaded?: (health: OpsHealth) => void;
onFiltersChange?: (filters: Record<string, string>) => void;
initialFilters?: Record<string, string>;
@@ -338,6 +352,17 @@ export function Quality({
filters.protocol ? `数据来源:${qualityProtocolLabel(filters.protocol)}` : '',
filters.issueType ? `问题类型:${qualityIssueLabel(filters.issueType)}` : ''
].filter(Boolean);
const openIssueHistory = (row: QualityIssueRow) => {
const lookup = qualityIssueVehicleLookup(row);
const dateFrom = issueEvidenceDate(row.lastSeen);
const dateTo = nextDate(dateFrom);
onOpenHistory?.({
keyword: lookup.key,
protocol: row.protocol,
...(dateFrom ? { dateFrom } : {}),
...(dateTo ? { dateTo } : {})
});
};
return (
<div className="vp-page">
@@ -573,13 +598,14 @@ export function Quality({
},
{
title: '操作',
width: 250,
width: 330,
render: (_: unknown, row: QualityIssueRow) => {
const lookup = qualityIssueVehicleLookup(row);
return (
<Space spacing={4}>
<Button size="small" icon={<IconCopy />} onClick={() => copyText(row.phone, '手机号')}></Button>
<Button size="small" icon={<IconCopy />} onClick={() => copyText(row.sourceEndpoint, '来源')}></Button>
<Button size="small" disabled={!lookup.key || !onOpenHistory} onClick={() => openIssueHistory(row)}></Button>
<Button size="small" disabled={!lookup.key} onClick={() => onOpenVehicle(lookup.key, row.protocol)}>
{lookup.label}
</Button>