feat: 确认导入基金弹框新增添加后展开详情开关
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/components/ui/select';
|
||||
import { Switch } from '@/components/ui/switch';
|
||||
|
||||
export default function ScanImportConfirmModal({
|
||||
scannedFunds,
|
||||
@@ -22,9 +23,10 @@ export default function ScanImportConfirmModal({
|
||||
isOcrScan = false
|
||||
}) {
|
||||
const [selectedGroupId, setSelectedGroupId] = useState('all');
|
||||
const [expandAfterAdd, setExpandAfterAdd] = useState(true);
|
||||
|
||||
const handleConfirm = () => {
|
||||
onConfirm(selectedGroupId);
|
||||
onConfirm(selectedGroupId, expandAfterAdd);
|
||||
};
|
||||
|
||||
const formatAmount = (val) => {
|
||||
@@ -126,6 +128,13 @@ export default function ScanImportConfirmModal({
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<div style={{ marginTop: 12, display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 8 }}>
|
||||
<span className="muted" style={{ fontSize: 13 }}>添加后展开详情</span>
|
||||
<Switch
|
||||
checked={expandAfterAdd}
|
||||
onCheckedChange={(checked) => setExpandAfterAdd(!!checked)}
|
||||
/>
|
||||
</div>
|
||||
<div style={{ marginTop: 12, display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<span className="muted" style={{ fontSize: 13, whiteSpace: 'nowrap' }}>添加到分组:</span>
|
||||
<Select value={selectedGroupId} onValueChange={(value) => setSelectedGroupId(value)}>
|
||||
|
||||
20
app/page.jsx
20
app/page.jsx
@@ -1283,7 +1283,7 @@ export default function HomePage() {
|
||||
});
|
||||
};
|
||||
|
||||
const confirmScanImport = async (targetGroupId = 'all') => {
|
||||
const confirmScanImport = async (targetGroupId = 'all', expandAfterAdd = true) => {
|
||||
const codes = Array.from(selectedScannedCodes);
|
||||
if (codes.length === 0) {
|
||||
showToast('请至少选择一个基金代码', 'error');
|
||||
@@ -1339,6 +1339,8 @@ export default function HomePage() {
|
||||
}
|
||||
|
||||
if (newFunds.length > 0) {
|
||||
const newCodesSet = new Set(newFunds.map((f) => f.code));
|
||||
|
||||
setFunds(prev => {
|
||||
const updated = dedupeByCode([...newFunds, ...prev]);
|
||||
storageHelper.setItem('funds', JSON.stringify(updated));
|
||||
@@ -1361,6 +1363,22 @@ export default function HomePage() {
|
||||
});
|
||||
if (Object.keys(nextSeries).length > 0) setValuationSeries(prev => ({ ...prev, ...nextSeries }));
|
||||
|
||||
if (!expandAfterAdd) {
|
||||
// 用户关闭“添加后展开详情”:将新添加基金的卡片和业绩走势都标记为收起
|
||||
setCollapsedCodes(prev => {
|
||||
const next = new Set(prev);
|
||||
newCodesSet.forEach((code) => next.add(code));
|
||||
storageHelper.setItem('collapsedCodes', JSON.stringify(Array.from(next)));
|
||||
return next;
|
||||
});
|
||||
setCollapsedTrends(prev => {
|
||||
const next = new Set(prev);
|
||||
newCodesSet.forEach((code) => next.add(code));
|
||||
storageHelper.setItem('collapsedTrends', JSON.stringify(Array.from(next)));
|
||||
return next;
|
||||
});
|
||||
}
|
||||
|
||||
if (targetGroupId === 'fav') {
|
||||
setFavorites(prev => {
|
||||
const next = new Set(prev);
|
||||
|
||||
Reference in New Issue
Block a user