fix: 三个必修 bug——Dashboard 颜色判反+legend 错+SideNav zhipianren 用户管理漏显
This commit is contained in:
@@ -20,11 +20,16 @@ import './Dashboard.css'
|
||||
* 判色取该期 air_date 所属年份的 yearly_targets 行(不是当前年)。
|
||||
*/
|
||||
function getShareColor(share, targets, airYear) {
|
||||
const target = targets.find(t => t.year === airYear)
|
||||
// 强制转数值,避免后端返回字符串导致数值比较失败
|
||||
const n = Number(share)
|
||||
const target = targets.find(t => Number(t.year) === Number(airYear))
|
||||
if (!target) return '#999'
|
||||
if (share > target.stretch_target) return '#cf1322' // 红=优秀
|
||||
if (share >= target.base_target) return '#6b8e6b' // 蓝=达标
|
||||
return '#d4a017' // 绿=待提升
|
||||
if (isNaN(n)) return '#999'
|
||||
const stretch = Number(target.stretch_target)
|
||||
const base = Number(target.base_target)
|
||||
if (n > stretch) return '#cf1322' // 红=超过摸高目标(优秀)
|
||||
if (n >= base) return '#6b8e6b' // 蓝=未达摸高目标(达标)
|
||||
return '#d4a017' // 绿=未达基础目标(待提升)
|
||||
}
|
||||
|
||||
function getBarHeight(share) {
|
||||
@@ -181,9 +186,9 @@ function Dashboard() {
|
||||
})}
|
||||
</div>
|
||||
<div className="chart-legend">
|
||||
<span className="legend-item"><span className="dot" style={{ background: '#cf1322' }}></span>红=优秀</span>
|
||||
<span className="legend-item"><span className="dot" style={{ background: '#6b8e6b' }}></span>蓝=达标</span>
|
||||
<span className="legend-item"><span className="dot" style={{ background: '#d4a017' }}></span>绿=待提升</span>
|
||||
<span className="legend-item"><span className="dot" style={{ background: '#d4a017' }}></span>绿=未达基础目标(待提升)</span>
|
||||
<span className="legend-item"><span className="dot" style={{ background: '#6b8e6b' }}></span>蓝=未达摸高目标(达标)</span>
|
||||
<span className="legend-item"><span className="dot" style={{ background: '#cf1322' }}></span>红=超过摸高目标(优秀)</span>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
Reference in New Issue
Block a user