feat(platform): add realtime customer question flow

This commit is contained in:
lingniu
2026-07-05 16:05:12 +08:00
parent 0f6b47e97e
commit 06bfe79851
3 changed files with 155 additions and 1 deletions

View File

@@ -1287,6 +1287,49 @@ export function Realtime({
onClick: exportRealtime
}
];
const realtimeCustomerQuestions = [
{
question: '这辆车现在在哪里?',
answer: selectedMapRow ? selectedMapRow.plate || selectedMapRow.vin : `${locatedCount.toLocaleString()} 辆有定位`,
evidence: selectedMapRow && isValidCoordinate(selectedMapRow) ? `${selectedMapRow.longitude}, ${selectedMapRow.latitude}` : `定位有效率 ${formatPercent(locatedRate)}`,
action: '地图定位',
color: locatedCount > 0 ? 'blue' as const : 'orange' as const,
disabled: false,
onClick: () => {
if (selectedMapRow) {
selectRealtimeRow(selectedMapRow);
}
window.location.hash = buildAppHash({ page: 'map', protocol: filters.protocol, filters });
}
},
{
question: '这辆车还在线吗?',
answer: selectedMapRow ? selectedMapRow.online ? '在线' : '离线' : `${onlineCount.toLocaleString()} 辆在线`,
evidence: selectedMapRow ? dataFreshness(selectedMapRow).detail : `在线率 ${formatPercent(onlineRate)}`,
action: '只看在线',
color: selectedMapRow ? selectedMapRow.online ? 'green' as const : 'orange' as const : onlineCount > 0 ? 'green' as const : 'orange' as const,
disabled: false,
onClick: () => applyFilters({ ...filters, online: 'online' })
},
{
question: '为什么状态异常?',
answer: selectedMapRow ? realtimeIssueLabels(selectedMapRow)[0] : `${Math.max(degradedCount, sourceIssueRows.length).toLocaleString()} 辆关注`,
evidence: selectedMapRow ? vehicleServiceStatus(selectedMapRow).label : `${degradedCount.toLocaleString()} 降级 / ${staleCount.toLocaleString()} 超时`,
action: '异常清单',
color: degradedCount > 0 || staleCount > 0 || sourceIssueRows.length > 0 ? 'orange' as const : 'green' as const,
disabled: false,
onClick: () => copyRealtimeIssueChecklist()
},
{
question: '当前状态能交接吗?',
answer: realtimeImpactLevel,
evidence: `当前页 ${rows.length.toLocaleString()} / 总计 ${pagination.total.toLocaleString()}`,
action: '复制交接包',
color: realtimeImpactColor,
disabled: false,
onClick: () => copyRealtimeDutyHandoff()
}
];
const timeWindowMonitorBlock = (
<Card bordered className="vp-time-window-monitor">
<div className="vp-time-window-summary">
@@ -1740,6 +1783,36 @@ export function Realtime({
<Button size="small" theme="light" onClick={copyRealtimeSummary}></Button>
</Space>
</div>
<div className="vp-realtime-question-board">
<div className="vp-realtime-question-summary">
<Space wrap>
<Tag color="blue"></Tag>
<Tag color={realtimeImpactColor}>{realtimeImpactLevel}</Tag>
<Tag color={selectedMapRow ? 'green' : 'grey'}>{selectedMapRow ? '已选车辆' : '未选车辆'}</Tag>
</Space>
<Typography.Title heading={5} style={{ margin: 0 }}></Typography.Title>
<Typography.Text type="secondary">
线
</Typography.Text>
</div>
<div className="vp-realtime-question-grid">
{realtimeCustomerQuestions.map((item) => (
<button
key={item.question}
type="button"
className="vp-realtime-question-item"
disabled={item.disabled}
onClick={item.onClick}
aria-label={`实时客户常问 ${item.question} ${item.action}`}
>
<Tag color={item.color}>{item.question}</Tag>
<strong>{item.answer}</strong>
<span>{item.evidence}</span>
<em>{item.action}</em>
</button>
))}
</div>
</div>
<div className="vp-realtime-next-actions">
{realtimeNextActions.map((item) => (
<button

View File

@@ -1530,6 +1530,79 @@ body {
align-content: start;
}
.vp-realtime-question-board {
display: grid;
grid-template-columns: minmax(260px, 0.62fr) minmax(0, 1.38fr);
gap: 14px;
padding: 16px;
border-bottom: 1px solid var(--vp-border);
background: #ffffff;
}
.vp-realtime-question-summary {
padding: 14px;
border: 1px solid rgba(22, 100, 255, 0.18);
border-radius: var(--vp-radius);
background: #f7faff;
display: grid;
gap: 10px;
align-content: start;
}
.vp-realtime-question-grid {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 12px;
}
.vp-realtime-question-item {
min-height: 142px;
padding: 12px;
border: 1px solid var(--vp-border);
border-radius: var(--vp-radius);
background: #fbfcff;
color: inherit;
text-align: left;
cursor: pointer;
font: inherit;
display: grid;
gap: 8px;
align-content: start;
}
.vp-realtime-question-item:hover,
.vp-realtime-question-item:focus-visible {
border-color: rgba(22, 100, 255, 0.42);
background: #f5f9ff;
outline: none;
}
.vp-realtime-question-item:disabled {
cursor: not-allowed;
opacity: 0.58;
}
.vp-realtime-question-item strong {
color: var(--vp-text);
font-size: 17px;
line-height: 23px;
font-weight: 700;
word-break: break-word;
}
.vp-realtime-question-item span {
color: var(--vp-text-muted);
font-size: 12px;
line-height: 18px;
}
.vp-realtime-question-item em {
color: var(--vp-primary);
font-size: 12px;
font-style: normal;
font-weight: 700;
}
.vp-realtime-next-actions {
padding: 16px;
border-bottom: 1px solid var(--vp-border);
@@ -6645,6 +6718,8 @@ button.vp-realtime-command-item:focus-visible {
.vp-time-delivery-strip,
.vp-time-delivery-grid,
.vp-realtime-customer-board .semi-card-body,
.vp-realtime-question-board,
.vp-realtime-question-grid,
.vp-realtime-next-actions,
.vp-realtime-customer-steps,
.vp-time-window-monitor .semi-card-body,

View File

@@ -9193,6 +9193,12 @@ test('frames realtime page as one vehicle service with source evidence', async (
expect(screen.getAllByText('高德地图待配置').length).toBeGreaterThan(0);
expect(screen.getByText('客户实时监控')).toBeInTheDocument();
expect(screen.getByText('从实时列表直接完成车辆监控闭环')).toBeInTheDocument();
expect(screen.getByText('实时客户常问')).toBeInTheDocument();
expect(screen.getByText('把实时数据翻译成客户能直接理解的车辆状态')).toBeInTheDocument();
expect(screen.getByRole('button', { name: '实时客户常问 这辆车现在在哪里? 地图定位' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '实时客户常问 这辆车还在线吗? 只看在线' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '实时客户常问 为什么状态异常? 异常清单' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '实时客户常问 当前状态能交接吗? 复制交接包' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '实时运营建议 先处理异常车辆 关注异常' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '实时运营建议 复盘选中车辆 轨迹回放' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: '实时运营建议 导出当前实时清单 导出 CSV' })).toBeInTheDocument();
@@ -9210,7 +9216,7 @@ test('frames realtime page as one vehicle service with source evidence', async (
expect(screen.getAllByText('2/2 通道在线').length).toBeGreaterThan(0);
expect(screen.getByText('实时运营影响')).toBeInTheDocument();
expect(screen.getByRole('button', { name: /复制影响报告/ })).toBeInTheDocument();
expect(screen.getByText('需要处置')).toBeInTheDocument();
expect(screen.getAllByText('需要处置').length).toBeGreaterThan(0);
expect(screen.getByText('车辆范围')).toBeInTheDocument();
expect(screen.getByText('在线影响')).toBeInTheDocument();
expect(screen.getByText('定位影响')).toBeInTheDocument();