From 261dbbacdb1a1e23dd4a03106ee64974b448afc5 Mon Sep 17 00:00:00 2001 From: lingniu Date: Sun, 5 Jul 2026 18:04:10 +0800 Subject: [PATCH] feat(platform): add customer export center --- .../apps/web/src/pages/History.tsx | 69 ++++++++++++++ .../apps/web/src/styles/global.css | 93 +++++++++++++++++++ .../apps/web/src/test/App.test.tsx | 6 ++ 3 files changed, 168 insertions(+) diff --git a/vehicle-data-platform/apps/web/src/pages/History.tsx b/vehicle-data-platform/apps/web/src/pages/History.tsx index 531811d3..597f32a7 100644 --- a/vehicle-data-platform/apps/web/src/pages/History.tsx +++ b/vehicle-data-platform/apps/web/src/pages/History.tsx @@ -1092,6 +1092,45 @@ export function History({ onClick: () => copyScheduledHistoryReportPlan() } ]; + const fieldEvidenceCount = rawFieldRows.length > 0 ? rawFieldRows.length : selectedFieldCount; + const customerExportCenterItems = [ + { + title: '行程历史', + value: validLocations.length > 0 ? `${validLocations.length.toLocaleString()} 点` : '0 点', + detail: '交付轨迹路线、位置点、速度、里程断点和时间范围。', + action: '导出轨迹', + color: validLocations.length > 0 ? 'green' as const : 'orange' as const, + disabled: locations.items.length === 0, + onClick: () => exportLocations() + }, + { + title: '里程对账', + value: formatNumber(mileageDelta, ' km'), + detail: '跳到同一车辆和时间窗的里程统计,核对区间差值和日报闭合。', + action: '统计查询', + color: isFiniteNumber(mileageDelta) ? 'green' as const : 'grey' as const, + disabled: !onOpenMileage, + onClick: () => onOpenMileage?.({ keyword: currentVehicleKeyword, protocol: currentProtocol, ...(filters.dateFrom ? { dateFrom: filters.dateFrom } : {}), ...(filters.dateTo ? { dateTo: filters.dateTo } : {}) }) + }, + { + title: '字段证据', + value: `${fieldEvidenceCount.toLocaleString()} 字段`, + detail: '按客户指定字段裁剪导出,避免把完整原始 JSON 暴露给客户。', + action: '导出字段', + color: fieldEvidenceCount > 0 ? 'green' as const : 'orange' as const, + disabled: rawFieldRows.length === 0, + onClick: () => exportRawFields() + }, + { + title: '告警说明', + value: anomalyTotal > 0 ? `${anomalyTotal.toLocaleString()} 项异常` : '无明显异常', + detail: '复制交付说明,附带断点、里程回退、超速和证据链接。', + action: '复制说明', + color: anomalyTotal > 0 ? 'orange' as const : 'green' as const, + disabled: false, + onClick: () => copyDeliveryPackage() + } + ]; const customerReportCadenceItems = [ { title: '每日运营复盘', @@ -1490,6 +1529,36 @@ export function History({ 数据通道:{currentProtocol || '全部数据通道'} {scopeDescription} + {mode === 'query' ? ( +
+
+ + 客户导出中心 + {deliveryState} + {currentVehicleKeyword || '全部车辆'} + + 按客户用途选择报表:行程历史、里程对账、字段证据和告警说明。 + 客户要的是可交付报表和复盘说明;原始记录、字段裁剪和协议来源只作为证据层。 +
+
+ {customerExportCenterItems.map((item) => ( + + ))} +
+
+ ) : null} {mode === 'query' ? (
diff --git a/vehicle-data-platform/apps/web/src/styles/global.css b/vehicle-data-platform/apps/web/src/styles/global.css index 1563a75c..2c5b342c 100644 --- a/vehicle-data-platform/apps/web/src/styles/global.css +++ b/vehicle-data-platform/apps/web/src/styles/global.css @@ -6204,6 +6204,92 @@ button.vp-realtime-command-item:focus-visible { line-height: 18px; } +.vp-history-export-center { + margin-top: 16px; + border: 1px solid rgba(22, 100, 255, 0.16); + border-radius: var(--vp-radius); + background: #fff; + display: grid; + grid-template-columns: minmax(300px, 0.64fr) minmax(0, 1.36fr); + overflow: hidden; + box-shadow: var(--vp-shadow-sm); +} + +.vp-history-export-center-summary { + padding: 18px; + border-right: 1px solid var(--vp-border); + background: #f8fbff; + display: grid; + gap: 10px; + align-content: start; +} + +.vp-history-export-center-summary strong { + color: var(--vp-text); + font-size: 18px; + line-height: 26px; + font-weight: 700; +} + +.vp-history-export-center-summary span { + color: var(--vp-text-muted); + font-size: 13px; + line-height: 20px; +} + +.vp-history-export-center-grid { + padding: 16px; + display: grid; + grid-template-columns: repeat(4, minmax(0, 1fr)); + gap: 10px; +} + +.vp-history-export-center-item { + min-height: 136px; + padding: 12px; + border: 1px solid var(--vp-border); + border-radius: 8px; + background: #fbfcff; + text-align: left; + cursor: pointer; + font: inherit; + display: grid; + gap: 8px; + align-content: start; +} + +.vp-history-export-center-item:hover, +.vp-history-export-center-item:focus-visible { + border-color: rgba(22, 100, 255, 0.45); + box-shadow: var(--vp-shadow-sm); + outline: none; +} + +.vp-history-export-center-item:disabled { + cursor: not-allowed; + opacity: 0.62; +} + +.vp-history-export-center-item strong { + color: var(--vp-text); + font-size: 20px; + line-height: 26px; +} + +.vp-history-export-center-item span { + color: var(--vp-text-muted); + font-size: 12px; + line-height: 18px; +} + +.vp-history-export-center-item em { + color: #1664ff; + font-style: normal; + font-size: 12px; + font-weight: 700; + line-height: 18px; +} + .vp-history-customer-export-board { margin-top: 16px; overflow: hidden; @@ -8280,6 +8366,8 @@ button.vp-realtime-command-item:focus-visible { .vp-trajectory-impact-grid, .vp-history-time-window-board, .vp-history-time-window-grid, + .vp-history-export-center, + .vp-history-export-center-grid, .vp-history-customer-export-board .semi-card-body, .vp-history-customer-export-steps, .vp-history-report-templates, @@ -8317,6 +8405,11 @@ button.vp-realtime-command-item:focus-visible { border-bottom: 1px solid var(--vp-border); } + .vp-history-export-center-summary { + border-right: 0; + border-bottom: 1px solid var(--vp-border); + } + .vp-customer-vehicle-monitor-copy { border-right: 0; border-bottom: 1px solid var(--vp-border); diff --git a/vehicle-data-platform/apps/web/src/test/App.test.tsx b/vehicle-data-platform/apps/web/src/test/App.test.tsx index 9cffc627..dec9052f 100644 --- a/vehicle-data-platform/apps/web/src/test/App.test.tsx +++ b/vehicle-data-platform/apps/web/src/test/App.test.tsx @@ -6615,6 +6615,12 @@ test('shows parsed field history as a flattened evidence table', async () => { render(); expect(await screen.findByRole('heading', { name: '历史查询导出' })).toBeInTheDocument(); + expect(screen.getByText('客户导出中心')).toBeInTheDocument(); + expect(screen.getByText('按客户用途选择报表:行程历史、里程对账、字段证据和告警说明。')).toBeInTheDocument(); + expect(screen.getByRole('button', { name: '客户导出中心 行程历史 0 点 导出轨迹' })).toBeInTheDocument(); + expect(screen.getByRole('button', { name: '客户导出中心 里程对账 - 统计查询' })).toBeInTheDocument(); + expect(screen.getByRole('button', { name: '客户导出中心 字段证据 2 字段 导出字段' })).toBeInTheDocument(); + expect(screen.getByRole('button', { name: '客户导出中心 告警说明 无明显异常 复制说明' })).toBeInTheDocument(); expect(screen.getByText('自定义时间窗监控台')).toBeInTheDocument(); expect(screen.getByText('客户选定车辆和时间范围后,直接判断这个窗口能否用于轨迹复盘、统计核对、历史证据导出和告警说明。')).toBeInTheDocument(); expect(screen.getByRole('button', { name: '自定义时间窗监控 轨迹复盘 位置历史' })).toBeInTheDocument();