feat(fulfillment): 自动核销任务展示并搜索核销码
This commit is contained in:
@@ -315,6 +315,31 @@ export default function VoucherConsumePolicyPanel() {
|
||||
width: 170,
|
||||
render: (value: string) => value || '-',
|
||||
},
|
||||
{
|
||||
title: '核销码',
|
||||
dataIndex: 'voucher_codes',
|
||||
width: 210,
|
||||
render: (values: string[] | null | undefined) => {
|
||||
const codes = Array.isArray(values)
|
||||
? values.map((value) => String(value || '').trim()).filter(Boolean)
|
||||
: []
|
||||
if (codes.length === 0) {
|
||||
return '-'
|
||||
}
|
||||
return (
|
||||
<Space direction="vertical" size={2}>
|
||||
{codes.slice(0, 3).map((code) => (
|
||||
<Typography.Text key={code} copyable={{ text: code }} ellipsis>
|
||||
{code}
|
||||
</Typography.Text>
|
||||
))}
|
||||
{codes.length > 3 ? (
|
||||
<Typography.Text type="secondary">另有 {codes.length - 3} 个</Typography.Text>
|
||||
) : null}
|
||||
</Space>
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '计划时间',
|
||||
dataIndex: 'due_at',
|
||||
@@ -415,7 +440,7 @@ export default function VoucherConsumePolicyPanel() {
|
||||
<Input.Search
|
||||
allowClear
|
||||
prefix={<SearchOutlined />}
|
||||
placeholder="任务号 / 订单号 / 平台单号"
|
||||
placeholder="任务号 / 订单号 / 平台单号 / 核销码"
|
||||
value={keywordDraft}
|
||||
onChange={(event) => {
|
||||
const value = event.target.value
|
||||
@@ -492,7 +517,7 @@ export default function VoucherConsumePolicyPanel() {
|
||||
setPageSize(nextPageSize)
|
||||
},
|
||||
})}
|
||||
scroll={{ x: 1200 }}
|
||||
scroll={{ x: 1420 }}
|
||||
/>
|
||||
</Space>
|
||||
)
|
||||
|
||||
@@ -209,6 +209,7 @@ export type VoucherConsumeJob = {
|
||||
attempt_count: number
|
||||
max_attempts: number
|
||||
last_error: string
|
||||
voucher_codes: string[]
|
||||
created_at: string
|
||||
updated_at: string
|
||||
finished_at: string | null
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import test from 'node:test'
|
||||
|
||||
test('自动核销最近任务展示并搜索核销码', () => {
|
||||
const page = readFileSync(
|
||||
new URL('../src/pages/admin/panels/VoucherConsumePolicyPanel.tsx', import.meta.url).pathname,
|
||||
'utf8',
|
||||
)
|
||||
const service = readFileSync(
|
||||
new URL('../src/services/admin/fulfillment-channel.ts', import.meta.url).pathname,
|
||||
'utf8',
|
||||
)
|
||||
|
||||
assert.ok(page.includes("title: '核销码'"), '最近核销任务必须展示核销码列')
|
||||
assert.ok(page.includes('copyable={{ text: code }}'), '核销码必须支持一键复制')
|
||||
assert.ok(page.includes('任务号 / 订单号 / 平台单号 / 核销码'), '搜索框必须明确支持核销码')
|
||||
assert.ok(service.includes('voucher_codes: string[]'), '任务接口类型必须包含核销码数组')
|
||||
})
|
||||
@@ -8,7 +8,7 @@ const panel = readFileSync(
|
||||
)
|
||||
|
||||
test('最近核销任务提供关键词、平台、渠道和状态筛选', () => {
|
||||
assert.ok(panel.includes('placeholder="任务号 / 订单号 / 平台单号"'))
|
||||
assert.ok(panel.includes('placeholder="任务号 / 订单号 / 平台单号 / 核销码"'))
|
||||
assert.ok(panel.includes('placeholder="全部平台"'))
|
||||
assert.ok(panel.includes('placeholder="全部渠道"'))
|
||||
assert.ok(panel.includes('placeholder="全部状态"'))
|
||||
|
||||
Reference in New Issue
Block a user