'use client'; import { useState } from 'react'; import { motion } from 'framer-motion'; import { CloseIcon } from './Icons'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@/components/ui/select'; export default function ScanImportConfirmModal({ scannedFunds, selectedScannedCodes, onClose, onToggle, onConfirm, refreshing, groups = [], isOcrScan = false }) { const [selectedGroupId, setSelectedGroupId] = useState('all'); const handleConfirm = () => { onConfirm(selectedGroupId); }; const formatAmount = (val) => { if (!val) return null; const num = parseFloat(String(val).replace(/,/g, '')); if (isNaN(num)) return null; return num; }; return ( e.stopPropagation()} style={{ width: 480, maxWidth: '90vw' }} >
确认导入基金
{isOcrScan && (
拍照识别方案目前还在优化,请确认识别结果是否正确。
)} {scannedFunds.length === 0 ? (
未识别到有效的基金代码,请尝试更清晰的截图或手动搜索。
) : ( <>
{scannedFunds.map((item) => { const isSelected = selectedScannedCodes.has(item.code); const isAlreadyAdded = item.status === 'added'; const isInvalid = item.status === 'invalid'; const isDisabled = isAlreadyAdded || isInvalid; const displayName = item.name || (isInvalid ? '未找到基金' : '未知基金'); const holdAmounts = formatAmount(item.holdAmounts); const holdGains = formatAmount(item.holdGains); const hasHoldingData = holdAmounts !== null && holdGains !== null; return (
e.preventDefault()} onClick={() => { if (isDisabled) return; onToggle(item.code); }} style={{ cursor: isDisabled ? 'not-allowed' : 'pointer', flexDirection: 'column', alignItems: 'stretch' }} >
{displayName} #{item.code}
{isAlreadyAdded ? ( 已添加 ) : isInvalid ? ( 未找到 ) : (
{isSelected &&
}
)}
{hasHoldingData && !isDisabled && (
{holdAmounts !== null && ( 持有金额:¥{holdAmounts.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })} )} {holdGains !== null && ( 持有收益:= 0 ? 'var(--danger)' : 'var(--success)', fontWeight: 500 }}> {holdGains >= 0 ? '+' : '-'}¥{Math.abs(holdGains).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })} )}
)}
); })}
添加到分组:
)}
); }