重命名前端目录

This commit is contained in:
yml2213
2026-07-07 19:55:18 +08:00
parent 8268a3b906
commit dbcb5a4979
182 changed files with 7019 additions and 7017 deletions
@@ -0,0 +1,940 @@
import {
ArrowLeftOutlined,
CheckCircleOutlined,
CloseCircleOutlined,
CopyOutlined,
ReloadOutlined,
RollbackOutlined,
SendOutlined,
SwapOutlined,
ToolOutlined,
UserSwitchOutlined,
} from '@ant-design/icons'
import {
Alert,
App,
Button,
Card,
Descriptions,
Empty,
Image,
Input,
Skeleton,
Space,
Table,
Tabs,
Tag,
Typography,
} from 'antd'
import type { TableColumnsType } from 'antd'
import { useQuery } from '@tanstack/react-query'
import { useEffect, useMemo, useState } from 'react'
import { useNavigate, useParams } from 'react-router'
import JsonPreview from '@/components/admin/JsonPreview'
import PageHeader from '@/components/admin/PageHeader'
import StatusTag from '@/components/admin/StatusTag'
import {
closeAdminTask,
completeAdminTaskManualDispatch,
dispatchAdminTaskKuaishouCloudFulfillment,
fetchAdminTaskDetail,
fetchAdminTaskScreenshot,
markAdminTaskManualReview,
prepareAdminTaskKuaishouCloudFulfillment,
rebindAdminTaskKuaishouCloudRole,
refreshAdminTaskKuaishouCloudRoleInfo,
retryAdminTask,
returnNumberAdminTaskKuaishouCloudFulfillment,
} from '@/services/admin'
import type { AdminTaskActionResponse, AdminTaskDetail } from '@/types/admin'
import { hasAdminRole } from '@/utils/admin-auth'
import {
formatKuaishouRoleInfoLabel,
formatRedeemOutcomeLabel,
formatRedeemResolutionStatus,
formatTaskEventPayload,
formatTaskEventType,
} from '@/utils/admin-display'
import { formatAdminDateTime } from '@/utils/admin-time'
type TaskEvent = AdminTaskDetail['events'][number]
type ManualDispatchForm = {
deliveryReference: string
deliveredCredential: string
resultMessage: string
}
export default function AdminTaskDetailPage() {
const navigate = useNavigate()
const { taskId = '' } = useParams()
const { message, modal } = App.useApp()
const [actionLoadingKey, setActionLoadingKey] = useState('')
const [lastClaimUrl, setLastClaimUrl] = useState('')
const [screenshotPreviewUrl, setScreenshotPreviewUrl] = useState('')
const [manualDispatchForm, setManualDispatchForm] = useState<ManualDispatchForm>({
deliveryReference: '',
deliveredCredential: '',
resultMessage: '',
})
const query = useQuery({
queryKey: ['admin-task-detail', taskId],
queryFn: () => fetchAdminTaskDetail(taskId),
enabled: Boolean(taskId),
})
const detail = query.data?.data
const canManageTaskLifecycle = hasAdminRole('operator')
const canCloseTasks = hasAdminRole('support')
const claimUrl = useMemo(() => {
const tokenStatus = String(detail?.claimToken?.status || '').trim()
const taskStatus = String(detail?.task.status || '').trim()
if (tokenStatus !== 'active' || ['closed', 'expired'].includes(taskStatus)) {
return ''
}
return lastClaimUrl || detail?.claimToken?.claimUrl || ''
}, [detail?.claimToken?.claimUrl, detail?.claimToken?.status, detail?.task.status, lastClaimUrl])
const claimLinkInvalid = Boolean(
detail?.claimToken?.claimUrl &&
String(detail.claimToken.status || '').trim() &&
String(detail.claimToken.status || '').trim() !== 'active',
)
useEffect(() => {
if (!detail) return
setManualDispatchForm({
deliveryReference: detail.manualDispatch?.deliveryReference || '',
deliveredCredential: detail.manualDispatch?.deliveredCredential || '',
resultMessage: detail.manualDispatch?.resultMessage || detail.task.resultMessage || '',
})
}, [detail])
useEffect(() => {
let objectUrl = ''
setScreenshotPreviewUrl('')
if (!detail?.screenshotUrl) {
return undefined
}
fetchAdminTaskScreenshot(detail.task.taskId)
.then((blob) => {
objectUrl = URL.createObjectURL(blob)
setScreenshotPreviewUrl(objectUrl)
})
.catch(() => {
setScreenshotPreviewUrl('')
})
return () => {
if (objectUrl) {
URL.revokeObjectURL(objectUrl)
}
}
}, [detail?.screenshotUrl, detail?.task.taskId])
if (query.isLoading) {
return (
<section className="page-stack">
<PageHeader title="任务详情" extra={<BackButton />} />
<Card>
<Skeleton active paragraph={{ rows: 10 }} />
</Card>
</section>
)
}
if (query.error || !detail) {
return (
<section className="page-stack">
<PageHeader title="任务详情" extra={<BackButton />} />
<Alert
type="error"
showIcon
message={query.error instanceof Error ? query.error.message : '任务不存在或读取失败'}
/>
</section>
)
}
const resolvedDetail = detail
const flow = resolvedDetail.kuaishouCloudFulfillment
const eventColumns: TableColumnsType<TaskEvent> = [
{
title: '时间',
dataIndex: 'createdAt',
width: 180,
render: (value) => formatAdminDateTime(value),
},
{
title: '事件',
dataIndex: 'eventType',
width: 180,
render: (value) => formatTaskEventType(value),
},
{
title: '摘要',
render: (_, row) => formatTaskEventPayload(row.payload),
},
]
async function copyClaimUrl() {
if (!claimUrl) return
await navigator.clipboard.writeText(claimUrl)
message.success('领取链接已复制')
}
function runTaskAction(
actionKey: string,
action: () => Promise<{ data: AdminTaskActionResponse }>,
successMessage: string,
confirmText: string,
) {
modal.confirm({
title: '确认操作',
content: confirmText,
okText: '继续执行',
cancelText: '取消',
centered: true,
onOk: async () => {
setActionLoadingKey(actionKey)
try {
const response = await action()
if (response.data.claimUrl) {
setLastClaimUrl(response.data.claimUrl)
}
message.success(successMessage)
await query.refetch()
} catch (error) {
message.error(error instanceof Error ? error.message : '操作失败')
} finally {
setActionLoadingKey('')
}
},
})
}
function submitManualDispatch(outcome: 'delivered' | 'failed') {
const actionLabel = outcome === 'failed' ? '标记履约失败' : '标记已完成履约'
const confirmText =
outcome === 'failed'
? `确认把任务 ${resolvedDetail.task.taskNo} 回写为人工履约失败吗?这会把任务直接收口并保留失败原因。`
: `确认把任务 ${resolvedDetail.task.taskNo} 回写为人工履约完成吗?这会把任务直接标记为已发放。`
runTaskAction(
`manual-${outcome}`,
() =>
completeAdminTaskManualDispatch(resolvedDetail.task.taskId, {
outcome,
resultMessage: manualDispatchForm.resultMessage,
deliveryReference: manualDispatchForm.deliveryReference,
deliveredCredential: manualDispatchForm.deliveredCredential,
}),
actionLabel,
confirmText,
)
}
return (
<section className="page-stack">
<PageHeader
title="任务详情"
description={resolvedDetail.task.taskNo}
extra={
<Space wrap>
<Button icon={<ReloadOutlined />} onClick={() => query.refetch()}>
</Button>
<BackButton />
</Space>
}
/>
<TaskActionPanel
detail={resolvedDetail}
canManageTaskLifecycle={canManageTaskLifecycle}
canCloseTasks={canCloseTasks}
actionLoadingKey={actionLoadingKey}
onRetry={() =>
runTaskAction(
'retry',
() => retryAdminTask(resolvedDetail.task.taskId),
'任务已重试',
`确认重试任务 ${resolvedDetail.task.taskNo} 吗?`,
)
}
onRebindRole={() =>
runTaskAction(
'rebind-role',
() => rebindAdminTaskKuaishouCloudRole(resolvedDetail.task.taskId),
'角色换绑资源已准备完成',
`确认为任务 ${resolvedDetail.task.taskNo} 换绑角色吗?当前虚拟号会退还,并生成新的绑定二维码。`,
)
}
onPrepareKuaishouCloud={() =>
runTaskAction(
'prepare-kuaishou-cloud',
() => prepareAdminTaskKuaishouCloudFulfillment(resolvedDetail.task.taskId),
'绑定资源已准备完成',
`确认开始为任务 ${resolvedDetail.task.taskNo} 准备绑定资源吗?系统会自动检查背包、余额并申请虚拟号。`,
)
}
onDispatchKuaishouCloud={() =>
runTaskAction(
'dispatch-kuaishou-cloud',
() => dispatchAdminTaskKuaishouCloudFulfillment(resolvedDetail.task.taskId),
'已完成绑定确认并发货',
`确认客户已经完成绑定,并立即为任务 ${resolvedDetail.task.taskNo} 执行发货吗?这个动作会把"确认绑定完成"和"发货"合并为一步。`,
)
}
onReturnKuaishouCloud={() =>
runTaskAction(
'return-kuaishou-cloud',
() => returnNumberAdminTaskKuaishouCloudFulfillment(resolvedDetail.task.taskId),
'号码已退还',
`确认退还任务 ${resolvedDetail.task.taskNo} 当前使用的虚拟号吗?退号后该流程会正式收口。`,
)
}
onMarkManualReview={() =>
runTaskAction(
'manual-review',
() => markAdminTaskManualReview(resolvedDetail.task.taskId),
'任务已转人工处理',
`确认将任务 ${resolvedDetail.task.taskNo} 转为人工处理吗?`,
)
}
onCloseTask={() =>
runTaskAction(
'close',
() => closeAdminTask(resolvedDetail.task.taskId),
'任务已关闭',
`确认关闭任务 ${resolvedDetail.task.taskNo} 吗?关闭后不会自动继续推进。`,
)
}
/>
<Card title="基础信息">
<Descriptions column={{ xs: 1, md: 2, xl: 3 }} bordered size="small">
<Descriptions.Item label="任务 ID">{resolvedDetail.task.taskId}</Descriptions.Item>
<Descriptions.Item label="任务号">{resolvedDetail.task.taskNo}</Descriptions.Item>
<Descriptions.Item label="平台订单号">
{resolvedDetail.task.platformOrderId || resolvedDetail.order?.platformOrderId || '-'}
</Descriptions.Item>
<Descriptions.Item label="任务状态">
<StatusTag value={resolvedDetail.task.status} kind="task" />
</Descriptions.Item>
<Descriptions.Item label="资源状态">
<StatusTag value={resolvedDetail.task.resourceStatus} kind="resource" />
</Descriptions.Item>
<Descriptions.Item label="客户步骤">
<StatusTag value={resolvedDetail.task.customerStatus} kind="customer" />
</Descriptions.Item>
<Descriptions.Item label="商品">
{resolvedDetail.orderItem?.skuName || resolvedDetail.task.skuName || '-'}
</Descriptions.Item>
<Descriptions.Item label="角色">
{resolvedDetail.task.roleName || '-'} {resolvedDetail.task.roleId ? `(${resolvedDetail.task.roleId})` : ''}
</Descriptions.Item>
<Descriptions.Item label="更新时间">
{formatAdminDateTime(resolvedDetail.task.updatedAt)}
</Descriptions.Item>
<Descriptions.Item label="最近错误" span={3}>
{resolvedDetail.task.lastError || '-'}
</Descriptions.Item>
</Descriptions>
</Card>
{resolvedDetail.claimToken ? (
<Card title="领取链接">
<Space direction="vertical" size={8} className="full-width">
{claimUrl ? (
<Typography.Text copyable={{ text: claimUrl }}>{claimUrl}</Typography.Text>
) : claimLinkInvalid ? (
<Typography.Text type="secondary"></Typography.Text>
) : (
<Typography.Text type="secondary"></Typography.Text>
)}
<Space wrap>
<StatusTag value={resolvedDetail.claimToken.status} />
<Typography.Text type="secondary">
{formatAdminDateTime(resolvedDetail.claimToken.expiredAt)}
</Typography.Text>
<Button icon={<CopyOutlined />} disabled={!claimUrl} onClick={copyClaimUrl}>
</Button>
</Space>
</Space>
</Card>
) : null}
{resolvedDetail.task.executorKey === 'manual_dispatch' ||
resolvedDetail.operations.canCompleteManualDispatch ||
resolvedDetail.manualDispatch ? (
<ManualDispatchPanel
detail={resolvedDetail}
form={manualDispatchForm}
canSubmit={canManageTaskLifecycle && resolvedDetail.operations.canCompleteManualDispatch}
actionLoadingKey={actionLoadingKey}
onChange={setManualDispatchForm}
onSubmit={submitManualDispatch}
/>
) : null}
<Tabs
items={[
{
key: 'cloud',
label: '快手 Cloud',
children: flow ? (
<KuaishouCloudPanel
flow={flow}
canRefresh={resolvedDetail.operations.canRefreshKuaishouCloudRoleInfo}
actionLoadingKey={actionLoadingKey}
onRefreshRole={() =>
runTaskAction(
'refresh-role',
() => refreshAdminTaskKuaishouCloudRoleInfo(resolvedDetail.task.taskId),
'角色信息已刷新',
`确认刷新任务 ${resolvedDetail.task.taskNo} 当前云绑定角色信息吗?系统会重新查询 cloudtentacles 的绑定结果。`,
)
}
/>
) : (
<Empty description="无快手 Cloud 履约上下文" />
),
},
{
key: 'resolution',
label: '兑换重试',
children: resolvedDetail.redeemResolution ? (
<RedeemResolutionPanel resolution={resolvedDetail.redeemResolution} />
) : (
<Empty description="无兑换重试记录" />
),
},
{
key: 'screenshot',
label: '截图',
children: resolvedDetail.screenshotUrl ? (
<ScreenshotPanel screenshotPreviewUrl={screenshotPreviewUrl} />
) : (
<Empty description="当前任务没有截图" />
),
},
{
key: 'events',
label: '事件流水',
children: (
<Table<TaskEvent>
rowKey="eventId"
pagination={false}
columns={eventColumns}
dataSource={resolvedDetail.events}
scroll={{ x: 760 }}
/>
),
},
{
key: 'raw',
label: '原始数据',
children: <JsonPreview value={resolvedDetail} />,
},
]}
/>
</section>
)
}
function TaskActionPanel({
detail,
canManageTaskLifecycle,
canCloseTasks,
actionLoadingKey,
onRetry,
onRebindRole,
onPrepareKuaishouCloud,
onDispatchKuaishouCloud,
onReturnKuaishouCloud,
onMarkManualReview,
onCloseTask,
}: {
detail: AdminTaskDetail
canManageTaskLifecycle: boolean
canCloseTasks: boolean
actionLoadingKey: string
onRetry: () => void
onRebindRole: () => void
onPrepareKuaishouCloud: () => void
onDispatchKuaishouCloud: () => void
onReturnKuaishouCloud: () => void
onMarkManualReview: () => void
onCloseTask: () => void
}) {
const operations = detail.operations
const loading = Boolean(actionLoadingKey)
return (
<Card title="任务操作">
<Space wrap>
{canManageTaskLifecycle ? (
<Button
type="primary"
icon={<ReloadOutlined />}
disabled={loading || !operations.canRetry}
loading={actionLoadingKey === 'retry'}
onClick={onRetry}
>
</Button>
) : null}
{operations.canRebindKuaishouCloudRole ? (
<Button
icon={<SwapOutlined />}
disabled={loading}
loading={actionLoadingKey === 'rebind-role'}
onClick={onRebindRole}
>
</Button>
) : null}
{canManageTaskLifecycle && operations.canPrepareKuaishouCloudFulfillment ? (
<Button
type="primary"
ghost
icon={<ToolOutlined />}
disabled={loading}
loading={actionLoadingKey === 'prepare-kuaishou-cloud'}
onClick={onPrepareKuaishouCloud}
>
</Button>
) : null}
{canManageTaskLifecycle && operations.canDispatchKuaishouCloudFulfillment ? (
<Button
type="primary"
icon={<SendOutlined />}
disabled={loading}
loading={actionLoadingKey === 'dispatch-kuaishou-cloud'}
onClick={onDispatchKuaishouCloud}
>
</Button>
) : null}
{canManageTaskLifecycle && operations.canReturnKuaishouCloudFulfillment ? (
<Button
icon={<RollbackOutlined />}
disabled={loading}
loading={actionLoadingKey === 'return-kuaishou-cloud'}
onClick={onReturnKuaishouCloud}
>
退
</Button>
) : null}
{canManageTaskLifecycle ? (
<Button
icon={<UserSwitchOutlined />}
disabled={loading || !operations.canMarkManualReview}
loading={actionLoadingKey === 'manual-review'}
onClick={onMarkManualReview}
>
</Button>
) : null}
{canCloseTasks ? (
<Button
danger
icon={<CloseCircleOutlined />}
disabled={loading || !operations.canClose}
loading={actionLoadingKey === 'close'}
onClick={onCloseTask}
>
</Button>
) : null}
{!canManageTaskLifecycle && !canCloseTasks && !operations.canRebindKuaishouCloudRole ? (
<Typography.Text type="secondary"></Typography.Text>
) : null}
</Space>
{loading ? (
<Typography.Text className="task-action-hint" type="secondary">
</Typography.Text>
) : null}
</Card>
)
}
function ManualDispatchPanel({
detail,
form,
canSubmit,
actionLoadingKey,
onChange,
onSubmit,
}: {
detail: AdminTaskDetail
form: ManualDispatchForm
canSubmit: boolean
actionLoadingKey: string
onChange: (form: ManualDispatchForm) => void
onSubmit: (outcome: 'delivered' | 'failed') => void
}) {
return (
<Card
title="人工履约"
extra={
canSubmit ? (
<Space>
<Button
type="primary"
icon={<CheckCircleOutlined />}
disabled={Boolean(actionLoadingKey)}
loading={actionLoadingKey === 'manual-delivered'}
onClick={() => onSubmit('delivered')}
>
</Button>
<Button
danger
icon={<CloseCircleOutlined />}
disabled={Boolean(actionLoadingKey)}
loading={actionLoadingKey === 'manual-failed'}
onClick={() => onSubmit('failed')}
>
</Button>
</Space>
) : null
}
>
<div className="manual-dispatch-grid">
<div>
<Typography.Text type="secondary"> / </Typography.Text>
<Input
value={form.deliveryReference}
disabled={!canSubmit || Boolean(actionLoadingKey)}
placeholder="例如快递单号、平台消息回执号"
onChange={(event) => onChange({ ...form, deliveryReference: event.target.value })}
/>
</div>
<div>
<Typography.Text type="secondary"></Typography.Text>
<Input.TextArea
value={form.deliveredCredential}
disabled={!canSubmit || Boolean(actionLoadingKey)}
placeholder="可填写人工发送的卡密、链接或关键信息"
rows={3}
onChange={(event) => onChange({ ...form, deliveredCredential: event.target.value })}
/>
</div>
<div>
<Typography.Text type="secondary"></Typography.Text>
<Input.TextArea
value={form.resultMessage}
disabled={!canSubmit || Boolean(actionLoadingKey)}
placeholder="说明实际履约结果,失败时建议写清原因"
rows={3}
onChange={(event) => onChange({ ...form, resultMessage: event.target.value })}
/>
</div>
</div>
<Alert
className="platform-section-gap"
type="info"
showIcon
message="回写后会直接更新任务终态,不再走旧式领取链接流程。"
/>
{detail.manualDispatch ? (
<Descriptions
className="platform-section-gap"
column={{ xs: 1, md: 2, xl: 3 }}
bordered
size="small"
>
<Descriptions.Item label="处理结果">
<StatusTag value={detail.manualDispatch.outcome || detail.task.deliveryStatus} />
</Descriptions.Item>
<Descriptions.Item label="处理时间">
{formatAdminDateTime(detail.manualDispatch.completedAt)}
</Descriptions.Item>
<Descriptions.Item label="处理人">
{detail.manualDispatch.completedBy?.username || '-'} /{' '}
{detail.manualDispatch.completedBy?.role || '-'}
</Descriptions.Item>
<Descriptions.Item label="履约单号">
{detail.manualDispatch.deliveryReference || '-'}
</Descriptions.Item>
<Descriptions.Item label="发放凭据">
{detail.manualDispatch.deliveredCredential || '-'}
</Descriptions.Item>
<Descriptions.Item label="备注">
{detail.manualDispatch.resultMessage || '-'}
</Descriptions.Item>
</Descriptions>
) : null}
</Card>
)
}
function KuaishouCloudPanel({
flow,
canRefresh,
actionLoadingKey,
onRefreshRole,
}: {
flow: NonNullable<AdminTaskDetail['kuaishouCloudFulfillment']>
canRefresh: boolean
actionLoadingKey: string
onRefreshRole: () => void
}) {
const roleInfoEntries = flow.role.rawInfo
? Object.entries(flow.role.rawInfo).filter(
([, value]) => value !== null && value !== undefined && String(value).trim() !== '',
)
: []
const checklist = [
{
key: 'ticket',
label: '核销码校验',
status: flow.ticket.status || 'pending',
detail: flow.ticket.verifiedAt
? `已于 ${formatAdminDateTime(flow.ticket.verifiedAt)} 校验`
: '等待客户提交并校验核销码',
},
{
key: 'bind',
label: '绑定资源',
status: flow.binding.prepareStatus || 'pending',
detail: flow.binding.bindPreparedAt
? `绑定资源已准备,VN ${flow.binding.vnId || '-'}`
: '等待准备 Cloud 绑定资源',
},
{
key: 'role',
label: '角色识别',
status: flow.role.status || 'pending',
detail:
flow.role.name || flow.role.rid
? `${flow.role.name || '-'} / ${flow.role.rid || '-'}`
: '客户绑定后刷新角色信息',
},
{
key: 'dispatch',
label: '发货执行',
status: flow.dispatch.status || 'pending',
detail: flow.dispatch.dispatchAt
? `已于 ${formatAdminDateTime(flow.dispatch.dispatchAt)} 发货`
: '等待客服确认绑定并发货',
},
{
key: 'return',
label: '退还号码',
status: flow.returnNumber.status || 'pending',
detail: flow.returnNumber.returnedAt
? `已于 ${formatAdminDateTime(flow.returnNumber.returnedAt)} 退号`
: '发货后执行退还号码',
},
{
key: 'consume',
label: '快手核销',
status: flow.consume.status || 'pending',
detail: flow.consume.consumedAt
? `已于 ${formatAdminDateTime(flow.consume.consumedAt)} 完成核销`
: flow.consume.errorMessage || '等待退号后核销收口',
},
]
return (
<section className="kuaishou-cloud-stack">
<Card
title="快手 Cloud 履约"
extra={
<Button
icon={<ReloadOutlined />}
disabled={Boolean(actionLoadingKey) || !canRefresh}
loading={actionLoadingKey === 'refresh-role'}
onClick={onRefreshRole}
>
</Button>
}
>
<Descriptions column={{ xs: 1, md: 2, xl: 3 }} bordered size="small">
<Descriptions.Item label="来源账号">
{flow.binding.resolvedSourceLabel || flow.binding.resolvedSourceKey || '-'}
</Descriptions.Item>
<Descriptions.Item label="虚拟号">
{flow.binding.vnPhone || flow.binding.vnId || '-'}
</Descriptions.Item>
<Descriptions.Item label="绑定状态">
<StatusTag value={flow.binding.prepareStatus} />
</Descriptions.Item>
<Descriptions.Item label="角色">
{flow.role.name || '-'} {flow.role.rid ? `(${flow.role.rid})` : ''}
</Descriptions.Item>
<Descriptions.Item label="卡券">
<StatusTag value={flow.ticket.status} />
</Descriptions.Item>
<Descriptions.Item label="发货">
<StatusTag value={flow.dispatch.status} kind="delivery" />
</Descriptions.Item>
<Descriptions.Item label="核销">
<StatusTag value={flow.consume.status} />
</Descriptions.Item>
<Descriptions.Item label="退号">
<StatusTag value={flow.returnNumber.status} />
</Descriptions.Item>
<Descriptions.Item label="绑定链接" span={3}>
{flow.binding.bindUrl ? (
<Typography.Text copyable={{ text: flow.binding.bindUrl }}>
{flow.binding.bindUrl}
</Typography.Text>
) : (
'-'
)}
</Descriptions.Item>
</Descriptions>
</Card>
<Card title="流程检查">
<div className="task-flow-grid">
{checklist.map((item) => (
<div key={item.key} className="task-flow-item">
<Space>
<StatusTag value={item.status} />
<Typography.Text strong>{item.label}</Typography.Text>
</Space>
<Typography.Text type="secondary">{item.detail}</Typography.Text>
</div>
))}
</div>
</Card>
{roleInfoEntries.length > 0 ? (
<Card title="角色原始字段">
<Descriptions column={{ xs: 1, md: 2 }} bordered size="small">
{roleInfoEntries.map(([key, value]) => (
<Descriptions.Item key={key} label={formatKuaishouRoleInfoLabel(key)}>
{typeof value === 'object' ? JSON.stringify(value) : String(value)}
</Descriptions.Item>
))}
</Descriptions>
</Card>
) : null}
{flow.rebind.history.length > 0 ? (
<Card title="换绑记录">
<Table
rowKey={(row) => `${row.attempt}-${row.requestedAt || ''}`}
pagination={false}
dataSource={flow.rebind.history}
scroll={{ x: 860 }}
columns={[
{ title: '次数', dataIndex: 'attempt', width: 80 },
{
title: '时间',
dataIndex: 'requestedAt',
width: 180,
render: (value) => formatAdminDateTime(value),
},
{
title: '状态',
dataIndex: 'status',
width: 120,
render: (value) => (
<Tag color={value === 'success' ? 'green' : value === 'failed' ? 'red' : 'blue'}>
{String(value || '-')}
</Tag>
),
},
{
title: '旧角色',
render: (_, row) =>
`${row.oldBinding.roleName || '-'} / ${row.oldBinding.roleId || '-'}`,
},
{
title: '旧虚拟号',
render: (_, row) =>
row.oldBinding.vnPhone || row.oldBinding.vnId || row.oldBinding.vnKey || '-',
},
{
title: '异常',
dataIndex: 'errorMessage',
render: (value) => value || '-',
},
]}
/>
</Card>
) : null}
</section>
)
}
function RedeemResolutionPanel({
resolution,
}: {
resolution: NonNullable<AdminTaskDetail['redeemResolution']>
}) {
return (
<Card title="兑换重试链路">
<Descriptions column={{ xs: 1, md: 2, xl: 4 }} bordered size="small">
<Descriptions.Item label="处理结果">
{formatRedeemResolutionStatus(resolution.status)}
</Descriptions.Item>
<Descriptions.Item label="任务状态">{resolution.taskStatus || '-'}</Descriptions.Item>
<Descriptions.Item label="替换次数">{resolution.replacementCount}</Descriptions.Item>
<Descriptions.Item label="完成时间">
{formatAdminDateTime(resolution.finishedAt)}
</Descriptions.Item>
</Descriptions>
<Table
className="platform-section-gap"
rowKey={(row) => `${row.attempt}-${row.codeMasked}`}
pagination={false}
dataSource={resolution.attempts}
scroll={{ x: 760 }}
columns={[
{ title: '次数', dataIndex: 'attempt', width: 80 },
{ title: '凭据', dataIndex: 'codeMasked', minWidth: 160 },
{ title: '类型', dataIndex: 'credentialType', minWidth: 120 },
{
title: '结果',
dataIndex: 'outcome',
minWidth: 160,
render: (value) => formatRedeemOutcomeLabel(value),
},
{ title: '代码', dataIndex: 'resultCode', minWidth: 120 },
{ title: '说明', dataIndex: 'resultMessage', minWidth: 220 },
]}
/>
</Card>
)
}
function ScreenshotPanel({ screenshotPreviewUrl }: { screenshotPreviewUrl: string }) {
return (
<Card title="任务截图">
{screenshotPreviewUrl ? (
<div className="task-screenshot-preview">
<Image src={screenshotPreviewUrl} alt="任务截图" />
</div>
) : (
<Empty description="截图加载中或当前不可读取" />
)}
</Card>
)
}
function BackButton() {
const navigate = useNavigate()
return (
<Button icon={<ArrowLeftOutlined />} onClick={() => navigate('/admin/tasks')}>
</Button>
)
}