feat(rock): 发货记录表格新增时间与备注列并支持上报失效联动
- 做了什么: 1. 数据库新增 013_rock_tokens_remark.sql 迁移,rock_tokens 表补充 remark 字段并在 ListTokens 中支持备注模糊检索; 2. 后端扩展 UpdateTokenRemark、MarkTokenAbnormal 接口,同时优化 ResetMismatchToken 支持 mismatch 与 abnormal 状态的解冻重置; 3. 前端 RockTokenTable 新增「流转时间」列(入库/绑错/发货/绑定/提货)与「备注」列(TokenRemarkCell 浮窗快捷预设选择与自定义输入); 4. 快捷选择「已上报」或点击「上报失效」自动将链接标记为 abnormal 作废,从可用库存池中剔除,防止被新订单领走; 5. 优化操作列与顶部筛选栏:mismatch 增加「上报失效」与警示重置;abnormal 状态明确显示已失效并提供强制恢复;筛选栏新增「已上报失效」Tab。 - 为什么: 解决绑定错误上报 0868 上游后无法记录备注、且原「解冻重置」容易误将已作废卡密放回可用库存池导致后续订单报错的问题。 - 验证方式: 1. 后端单元测试 TestRockService_TokenRemarkAndAbnormal 与 TestRock 测试集通过; 2. make fmt、go vet 通过; 3. 前端 oxlint 检查通过 (0 errors, 0 warnings),npm run build 生产构建通过。
This commit is contained in:
@@ -0,0 +1,241 @@
|
||||
import { useState } from 'react'
|
||||
import { Button, Divider, Input, Popover, Space, Tag, Typography } from 'antd'
|
||||
import {
|
||||
CheckOutlined,
|
||||
CloseCircleOutlined,
|
||||
DeleteOutlined,
|
||||
EditOutlined,
|
||||
ExclamationCircleOutlined,
|
||||
StopOutlined,
|
||||
} from '@ant-design/icons'
|
||||
import type { RockTokenItem } from '../../api'
|
||||
|
||||
const { Text } = Typography
|
||||
|
||||
export interface TokenRemarkCellProps {
|
||||
record: RockTokenItem
|
||||
onUpdateRemark: (id: number, remark: string, status?: string) => void
|
||||
onMarkAbnormal: (id: number, remark?: string) => void
|
||||
}
|
||||
|
||||
export function TokenRemarkCell({ record, onUpdateRemark, onMarkAbnormal }: TokenRemarkCellProps) {
|
||||
const [open, setOpen] = useState(false)
|
||||
const [inputValue, setInputValue] = useState(record.remark || '')
|
||||
|
||||
const handleQuickMarkAbnormal = (reason: string) => {
|
||||
onMarkAbnormal(record.id, reason)
|
||||
setOpen(false)
|
||||
}
|
||||
|
||||
const handleQuickUpdate = (remarkText: string) => {
|
||||
onUpdateRemark(record.id, remarkText)
|
||||
setOpen(false)
|
||||
}
|
||||
|
||||
const handleSaveCustom = () => {
|
||||
onUpdateRemark(record.id, inputValue.trim())
|
||||
setOpen(false)
|
||||
}
|
||||
|
||||
const handleClear = () => {
|
||||
onUpdateRemark(record.id, '')
|
||||
setInputValue('')
|
||||
setOpen(false)
|
||||
}
|
||||
|
||||
const content = (
|
||||
<div style={{ width: 280 }}>
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
marginBottom: 8,
|
||||
borderBottom: '1px solid #f1f5f9',
|
||||
paddingBottom: 6,
|
||||
}}
|
||||
>
|
||||
<span style={{ fontWeight: 600, fontSize: 13, color: '#0f172a' }}>快速设置备注</span>
|
||||
<Text type="secondary" style={{ fontSize: 11 }}>
|
||||
#{record.upstream_token_id || record.id}
|
||||
</Text>
|
||||
</div>
|
||||
|
||||
<div style={{ marginBottom: 6 }}>
|
||||
<Text type="secondary" style={{ fontSize: 11 }}>
|
||||
快捷选择(点击直接生效):
|
||||
</Text>
|
||||
</div>
|
||||
|
||||
<Space direction="vertical" style={{ width: '100%' }} size={5}>
|
||||
<Button
|
||||
size="small"
|
||||
danger
|
||||
block
|
||||
style={{
|
||||
textAlign: 'left',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
background: '#fef2f2',
|
||||
borderColor: '#fca5a5',
|
||||
}}
|
||||
icon={<StopOutlined />}
|
||||
onClick={() => handleQuickMarkAbnormal('已上报错误 (卡密失效)')}
|
||||
>
|
||||
<span style={{ fontWeight: 600 }}>已上报错误 (标记失效)</span>
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
size="small"
|
||||
block
|
||||
style={{
|
||||
textAlign: 'left',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
borderColor: '#fdba74',
|
||||
color: '#c2410c',
|
||||
background: '#fff7ed',
|
||||
}}
|
||||
icon={<ExclamationCircleOutlined />}
|
||||
onClick={() => handleQuickMarkAbnormal('绑定错误-已上报上游')}
|
||||
>
|
||||
<span>绑定错误 (已上报上游)</span>
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
size="small"
|
||||
block
|
||||
style={{ textAlign: 'left', display: 'flex', alignItems: 'center' }}
|
||||
icon={<EditOutlined />}
|
||||
onClick={() => handleQuickUpdate('买家UID填错 (待核对)')}
|
||||
>
|
||||
<span>买家UID填错 (待核对)</span>
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
size="small"
|
||||
block
|
||||
style={{ textAlign: 'left', display: 'flex', alignItems: 'center' }}
|
||||
icon={<EditOutlined />}
|
||||
onClick={() => handleQuickUpdate('上报处理中 (等待答复)')}
|
||||
>
|
||||
<span>上报处理中 (等待答复)</span>
|
||||
</Button>
|
||||
</Space>
|
||||
|
||||
<Divider style={{ margin: '10px 0 8px 0' }} />
|
||||
|
||||
<div>
|
||||
<div style={{ marginBottom: 4 }}>
|
||||
<Text type="secondary" style={{ fontSize: 11 }}>
|
||||
自定义备注内容:
|
||||
</Text>
|
||||
</div>
|
||||
<Space.Compact style={{ width: '100%' }}>
|
||||
<Input
|
||||
size="small"
|
||||
placeholder="输入自定义备注..."
|
||||
value={inputValue}
|
||||
onChange={(e) => setInputValue(e.target.value)}
|
||||
onPressEnter={handleSaveCustom}
|
||||
/>
|
||||
<Button size="small" type="primary" icon={<CheckOutlined />} onClick={handleSaveCustom}>
|
||||
保存
|
||||
</Button>
|
||||
</Space.Compact>
|
||||
</div>
|
||||
|
||||
{record.remark ? (
|
||||
<div style={{ marginTop: 8, textAlign: 'right' }}>
|
||||
<Button
|
||||
size="small"
|
||||
type="link"
|
||||
danger
|
||||
icon={<DeleteOutlined />}
|
||||
onClick={handleClear}
|
||||
style={{ padding: 0, fontSize: 11 }}
|
||||
>
|
||||
清空当前备注
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
|
||||
const isAbnormalOrReported =
|
||||
record.status === 'abnormal' || (record.remark && record.remark.includes('上报'))
|
||||
|
||||
if (!record.remark) {
|
||||
return (
|
||||
<Popover
|
||||
content={content}
|
||||
trigger="click"
|
||||
open={open}
|
||||
onOpenChange={(v) => {
|
||||
setOpen(v)
|
||||
if (v) setInputValue('')
|
||||
}}
|
||||
placement="bottomLeft"
|
||||
>
|
||||
<span
|
||||
style={{
|
||||
cursor: 'pointer',
|
||||
fontSize: 12,
|
||||
color: '#64748b',
|
||||
padding: '2px 6px',
|
||||
borderRadius: 4,
|
||||
border: '1px dashed #cbd5e1',
|
||||
display: 'inline-flex',
|
||||
alignItems: 'center',
|
||||
gap: 4,
|
||||
transition: 'all 0.2s',
|
||||
}}
|
||||
title="点击快速设置备注"
|
||||
>
|
||||
<EditOutlined style={{ fontSize: 11 }} />
|
||||
添加备注
|
||||
</span>
|
||||
</Popover>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<Popover
|
||||
content={content}
|
||||
trigger="click"
|
||||
open={open}
|
||||
onOpenChange={(v) => {
|
||||
setOpen(v)
|
||||
if (v) setInputValue(record.remark || '')
|
||||
}}
|
||||
placement="bottomLeft"
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
cursor: 'pointer',
|
||||
display: 'inline-flex',
|
||||
alignItems: 'center',
|
||||
maxWidth: 220,
|
||||
}}
|
||||
title="点击修改或快速设置备注"
|
||||
>
|
||||
<Tag
|
||||
color={isAbnormalOrReported ? 'error' : 'blue'}
|
||||
style={{
|
||||
maxWidth: '100%',
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
whiteSpace: 'nowrap',
|
||||
margin: 0,
|
||||
fontSize: 12,
|
||||
padding: '2px 6px',
|
||||
border: isAbnormalOrReported ? '1px solid #fca5a5' : undefined,
|
||||
}}
|
||||
icon={isAbnormalOrReported ? <CloseCircleOutlined /> : <EditOutlined />}
|
||||
>
|
||||
{record.remark}
|
||||
</Tag>
|
||||
</div>
|
||||
</Popover>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user