优化订单履约后台界面

This commit is contained in:
yml2213
2026-07-09 09:51:54 +08:00
parent 9a24268b5a
commit 71602683d2
5 changed files with 702 additions and 75 deletions
@@ -5,7 +5,7 @@ import {
SwapOutlined,
UserSwitchOutlined,
} from '@ant-design/icons'
import { Alert, App, Button, Card, DatePicker, Form, Input, Select, Space, Table, Typography } from 'antd'
import { Alert, App, Button, Card, DatePicker, Form, Input, Select, Space, Table, Tag, Typography } from 'antd'
import type { TableColumnsType } from 'antd'
import { useQuery } from '@tanstack/react-query'
import dayjs from 'dayjs'
@@ -36,6 +36,12 @@ type TaskFilterForm = {
}
type TaskListAction = 'retry' | 'rebind_role' | 'manual_review' | 'close'
type TaskListBlocker = {
label: string
color: string
level: 'normal' | 'error'
detail: string
}
export default function AdminTasksPage() {
const navigate = useNavigate()
@@ -100,12 +106,38 @@ export default function AdminTasksPage() {
</div>
),
},
{
title: '履约 / 卡点',
minWidth: 260,
render: (_, row) => {
const executor = resolveTaskExecutorDisplay(row.executorKey)
const blocker = resolveTaskListBlocker(row)
return (
<div className="cell-stack">
<Space size={[4, 4]} wrap>
<Tag color={executor.color}>{executor.label}</Tag>
<Tag color={blocker.color}>{blocker.label}</Tag>
</Space>
<Typography.Text
className="task-list-blocker-detail"
type={blocker.level === 'error' ? 'danger' : 'secondary'}
title={blocker.detail}
ellipsis
>
{blocker.detail}
</Typography.Text>
</div>
)
},
},
{
title: '状态',
minWidth: 250,
minWidth: 280,
render: (_, row) => (
<Space size={[0, 6]} wrap>
<StatusTag value={row.status} kind="task" />
<StatusTag value={row.deliveryStatus} kind="delivery" />
<StatusTag value={row.resourceStatus} kind="resource" />
<StatusTag value={row.customerStatus} kind="customer" />
</Space>
@@ -364,7 +396,7 @@ export default function AdminTasksPage() {
loading={query.isLoading || query.isFetching}
columns={columns}
dataSource={data?.items || []}
scroll={{ x: 1240 }}
scroll={{ x: 1500 }}
pagination={{
current: data?.pagination.page || page,
pageSize: data?.pagination.pageSize || pageSize,
@@ -389,6 +421,133 @@ function canRebindListTask(item: AdminTaskListItem, canManageTaskLifecycle: bool
)
}
function resolveTaskExecutorDisplay(value: unknown) {
const executorKey = String(value || '').trim()
if (executorKey === 'kuaishou_ct_assisted') {
return { label: '快手 Cloud', color: 'blue' }
}
if (executorKey === 'kuaishou-industry') {
return { label: '行业电子凭证', color: 'cyan' }
}
if (executorKey === 'kuaishou_feifei') {
return { label: 'kuaishou-feifei', color: 'purple' }
}
if (executorKey === 'manual_dispatch') {
return { label: '人工履约', color: 'orange' }
}
return { label: executorKey || '未分配执行器', color: 'default' }
}
function resolveTaskListBlocker(item: AdminTaskListItem): TaskListBlocker {
const taskStatus = normalizeTaskListStatus(item.status)
const deliveryStatus = normalizeTaskListStatus(item.deliveryStatus)
const resourceStatus = normalizeTaskListStatus(item.resourceStatus)
const customerStatus = normalizeTaskListStatus(item.customerStatus)
const errorText = item.lastError || item.resultMessage
if (
['completed', 'redeemed'].includes(taskStatus) ||
['delivered', 'completed', 'success', 'consumed'].includes(deliveryStatus)
) {
return {
label: '已收口',
color: 'green',
level: 'normal',
detail: item.resultMessage || '履约链路已完成。',
}
}
if (taskStatus === 'closed') {
return {
label: '已关闭',
color: 'default',
level: 'normal',
detail: item.resultMessage || item.lastError || '任务已关闭,不会继续自动推进。',
}
}
if (
item.lastError ||
['manual_review', 'retry_pending', 'failed'].includes(taskStatus) ||
['resource_exception', 'binding_exception', 'failed'].includes(resourceStatus) ||
['customer_exception', 'failed'].includes(customerStatus) ||
['failed'].includes(deliveryStatus)
) {
return {
label: '异常处理',
color: 'red',
level: 'error',
detail: errorText || '需要进入详情页按履约层级检查并重试。',
}
}
if (item.executorKey === 'manual_dispatch') {
return {
label: '人工履约',
color: 'orange',
level: 'normal',
detail: item.resultMessage || '等待人工回写履约结果。',
}
}
if (['pending_config'].includes(resourceStatus) || !item.executorKey) {
return {
label: '待配置',
color: 'gold',
level: 'normal',
detail: item.resultMessage || '商品还没有命中明确的履约配置。',
}
}
if (
['not_started', 'pending', 'pending_prepare', 'pending_binding', 'pending_binding_prepare'].includes(
resourceStatus,
)
) {
return {
label: '资源层',
color: 'gold',
level: 'normal',
detail: item.resultMessage || '等待准备履约资源,可在详情页触发对应执行器动作。',
}
}
if (
['waiting_customer', 'waiting_binding', 'waiting_user_claim', 'user_binding'].includes(
customerStatus,
)
) {
return {
label: '客户层',
color: 'blue',
level: 'normal',
detail: item.roleConfirmedAt
? '客户已提交角色信息,等待平台履约收口。'
: '等待客户打开链接、绑定或提交信息。',
}
}
if (deliveryStatus && !['pending', 'not_started'].includes(deliveryStatus)) {
return {
label: '平台层',
color: 'cyan',
level: 'normal',
detail: item.resultMessage || '平台履约执行中,后续可在详情页按层查看。',
}
}
return {
label: '推进中',
color: 'blue',
level: 'normal',
detail: item.resultMessage || '当前没有明确异常,等待任务自动推进。',
}
}
function normalizeTaskListStatus(value: unknown) {
return String(value || '').trim().toLowerCase()
}
function cleanParams(params: Record<string, unknown>) {
const next = new URLSearchParams()
Object.entries(params).forEach(([key, value]) => {