feat:自动补货/手动采购逻辑修改:批量获取-》打包-》获取Token列表

This commit is contained in:
2026-10-29 16:05:39 +08:00
parent 8198bd6feb
commit 8494fabc82
23 changed files with 3679 additions and 85 deletions
@@ -11,6 +11,8 @@ export interface PurchaseTokenModalProps {
upstreamPoints: number
estimatedCost: number
isPointsInsufficient: boolean
tokenCost: number
upstreamStock: number | null
onPurchaseCountChange: (value: number) => void
onCancel: () => void
onConfirm: (count: number) => void
@@ -25,10 +27,13 @@ export function PurchaseTokenModal({
upstreamPoints,
estimatedCost,
isPointsInsufficient,
tokenCost,
upstreamStock,
onPurchaseCountChange,
onCancel,
onConfirm,
}: PurchaseTokenModalProps) {
const isStockInsufficient = upstreamStock !== null && purchaseCount > upstreamStock
return (
<Modal
title={
@@ -48,15 +53,16 @@ export function PurchaseTokenModal({
type="primary"
icon={<ShoppingCartOutlined />}
loading={purchasing}
disabled={isPointsInsufficient || purchaseCount <= 0}
disabled={isPointsInsufficient || isStockInsufficient || purchaseCount <= 0}
onClick={() => onConfirm(purchaseCount)}
style={{
background: isPointsInsufficient
? undefined
: 'linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%)',
background:
isPointsInsufficient || isStockInsufficient
? undefined
: 'linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%)',
}}
>
确认采购 {purchaseCount} 个 ({estimatedCost} 点)
确认采购 {purchaseCount} 个 ({estimatedCost.toFixed(2)} 点)
</Button>,
]}
destroyOnClose
@@ -88,12 +94,48 @@ export function PurchaseTokenModal({
</Col>
</Row>
<Divider style={{ margin: '10px 0' }} />
<div style={{ display: 'flex', justifyContent: 'space-between', fontSize: 12, color: '#64748b' }}>
<span>采购单价:<strong style={{ color: '#0f172a' }}>21 点 / 个</strong></span>
<span>最大可采购:<strong style={{ color: '#2563eb' }}>{maxPurchasable} 个</strong></span>
<div
style={{
display: 'flex',
justifyContent: 'space-between',
flexWrap: 'wrap',
gap: 8,
fontSize: 12,
color: '#64748b',
}}
>
<span>
采购单价:<strong style={{ color: '#0f172a' }}>{tokenCost.toFixed(2)} 点 / 个</strong>
</span>
<span>
上游可用库存:
<strong style={{ color: isStockInsufficient ? '#dc2626' : '#0f172a' }}>
{upstreamStock === null ? '未获取' : `${upstreamStock} 个`}
</strong>
</span>
<span>
最大可采购:<strong style={{ color: '#2563eb' }}>{maxPurchasable} 个</strong>
</span>
</div>
</div>
{/* 上游库存不足提示 */}
{isStockInsufficient && (
<div
style={{
background: '#fef2f2',
border: '1px solid #fecaca',
borderRadius: 8,
padding: '10px 16px',
marginBottom: 14,
fontSize: 13,
color: '#b91c1c',
}}
>
⚠️ 上游可用库存不足:当前 {upstreamStock} 个,本次需要 {purchaseCount} 个,请减少采购数量。
</div>
)}
{/* 采购数量输入 */}
<div style={{ marginBottom: 14 }}>
<div style={{ fontWeight: 600, marginBottom: 8, color: '#0f172a' }}>
@@ -153,7 +195,7 @@ export function PurchaseTokenModal({
本次采购消耗积分:
</span>
<strong style={{ color: isPointsInsufficient ? '#dc2626' : '#16a34a', fontSize: 16 }}>
{estimatedCost} 点
{estimatedCost.toFixed(2)} 点
</strong>
</div>
<div