修复useState位置

This commit is contained in:
甲辰生产 2026-04-11 20:35:44 +08:00
parent 0093367452
commit 615be9805b
1 changed files with 11 additions and 12 deletions

View File

@ -32,6 +32,8 @@ export default function News() {
const [comments, setComments] = useState({}) // const [comments, setComments] = useState({}) //
const [matchedStatus, setMatchedStatus] = useState({}) // const [matchedStatus, setMatchedStatus] = useState({}) //
const [showMatchList, setShowMatchList] = useState(false) const [showMatchList, setShowMatchList] = useState(false)
const [dealVersion, setDealVersion] = useState('龙钞')
const [dealDate, setDealDate] = useState('')
const [matchCollections, setMatchCollections] = useState([]) const [matchCollections, setMatchCollections] = useState([])
const [networkMatchCollections, setNetworkMatchCollections] = useState([]) const [networkMatchCollections, setNetworkMatchCollections] = useState([])
const [showNetworkMatchList, setShowNetworkMatchList] = useState(false) const [showNetworkMatchList, setShowNetworkMatchList] = useState(false)
@ -483,9 +485,6 @@ export default function News() {
<div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}> <div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
{/* 成交行情 - 价格统计表格 */} {/* 成交行情 - 价格统计表格 */}
{activeTab === 'deal' && (() => { {activeTab === 'deal' && (() => {
const [selectedVersion, setSelectedVersion] = useState('龙钞')
const [selectedDate, setSelectedDate] = useState('')
const versions = ['龙钞', '马钞', '蛇钞', '其他'] const versions = ['龙钞', '马钞', '蛇钞', '其他']
const packagings = ['标百', '标十', '单张'] const packagings = ['标百', '标十', '单张']
const categories = ['带4号', '带7号', '永恒号', '钻石号', '如意号', '朦胧号', '天马号', '金山号', '金马号'] const categories = ['带4号', '带7号', '永恒号', '钻石号', '如意号', '朦胧号', '天马号', '金山号', '金马号']
@ -496,10 +495,10 @@ export default function News() {
if (serial.startsWith('J0')) version = '龙钞' if (serial.startsWith('J0')) version = '龙钞'
else if (serial.startsWith('J1')) version = '马钞' else if (serial.startsWith('J1')) version = '马钞'
else if (serial.startsWith('J3')) version = '蛇钞' else if (serial.startsWith('J3')) version = '蛇钞'
if (version !== selectedVersion) return false if (version !== dealVersion) return false
if (selectedDate) { if (dealDate) {
const dealDate = item.deal_date || '' const itemDate = item.deal_date || ''
if (!dealDate.startsWith(selectedDate)) return false if (!itemDate.startsWith(dealDate)) return false
} }
return true return true
}) })
@ -521,15 +520,15 @@ export default function News() {
<div style={{ marginBottom: '16px' }}> <div style={{ marginBottom: '16px' }}>
<div style={{ display: 'flex', gap: '12px', flexWrap: 'wrap', marginBottom: '12px' }}> <div style={{ display: 'flex', gap: '12px', flexWrap: 'wrap', marginBottom: '12px' }}>
{versions.map(v => ( {versions.map(v => (
<button key={v} onClick={() => setSelectedVersion(v)} <button key={v} onClick={() => setDealVersion(v)}
style={{ padding: '6px 16px', borderRadius: '8px', border: 'none', cursor: 'pointer', style={{ padding: '6px 16px', borderRadius: '8px', border: 'none', cursor: 'pointer',
background: selectedVersion === v ? '#3b82f6' : 'rgba(255,255,255,0.1)', background: dealVersion === v ? '#3b82f6' : 'rgba(255,255,255,0.1)',
color: '#fff', fontSize: '13px', fontWeight: selectedVersion === v ? '600' : '400' }}> color: '#fff', fontSize: '13px', fontWeight: dealVersion === v ? '600' : '400' }}>
{v} {v}
</button> </button>
))} ))}
</div> </div>
<select value={selectedDate} onChange={e => setSelectedDate(e.target.value)} <select value={dealDate} onChange={e => setDealDate(e.target.value)}
style={{ padding: '8px 12px', borderRadius: '8px', border: '1px solid rgba(255,255,255,0.2)', style={{ padding: '8px 12px', borderRadius: '8px', border: '1px solid rgba(255,255,255,0.2)',
background: 'rgba(255,255,255,0.05)', color: '#fff', fontSize: '14px' }}> background: 'rgba(255,255,255,0.05)', color: '#fff', fontSize: '14px' }}>
<option value="">全部日期</option> <option value="">全部日期</option>
@ -564,7 +563,7 @@ export default function News() {
<td key={i} style={{ padding: '8px', textAlign: 'center', borderBottom: '1px solid rgba(255,255,255,0.05)' }}> <td key={i} style={{ padding: '8px', textAlign: 'center', borderBottom: '1px solid rgba(255,255,255,0.05)' }}>
{d ? ( {d ? (
<div style={{ color: '#22c55e', fontWeight: '600', cursor: 'pointer' }} <div style={{ color: '#22c55e', fontWeight: '600', cursor: 'pointer' }}
onClick={() => alert(`${selectedVersion} ${cat} ${packagings[i]} 平均价¥${d.avg.toLocaleString()}, 共${d.count}`)}> onClick={() => alert(`${dealVersion} ${cat} ${packagings[i]} 平均价¥${d.avg.toLocaleString()}, 共${d.count}`)}>
¥{d.avg.toLocaleString()} ¥{d.avg.toLocaleString()}
<span style={{ color: '#64748b', fontSize: '11px', marginLeft: '4px' }}>({d.count})</span> <span style={{ color: '#64748b', fontSize: '11px', marginLeft: '4px' }}>({d.count})</span>
</div> </div>