bug修复
This commit is contained in:
@@ -193,6 +193,15 @@ watch(() => props.hiddenDangerData?.progress, (newVal) => {
|
||||
refreshProcessCharts(newVal)
|
||||
}, { deep: true })
|
||||
|
||||
// 辅助函数:安全地将值转换为数字,处理 NaN 和字符串 "NaN" 的情况
|
||||
const safeNumber = (val: any): number => {
|
||||
if (val === null || val === undefined || val === '' || val === 'NaN') {
|
||||
return 0
|
||||
}
|
||||
const num = Number(val)
|
||||
return isNaN(num) ? 0 : num
|
||||
}
|
||||
|
||||
// 更新图表数据
|
||||
const refreshProcessCharts = (process): void => {
|
||||
if (!props.hiddenDangerData?.progress) {
|
||||
@@ -200,11 +209,12 @@ const refreshProcessCharts = (process): void => {
|
||||
return
|
||||
}
|
||||
const option = { ...progressChartOption.value }
|
||||
// 确保所有 value 都是有效的数字,将字符串 "NaN" 或真正的 NaN 转换为 0
|
||||
option.series[0].data = [
|
||||
{ value: process.overdue || 0, name: '已逾期', itemStyle: { color: '#ef4444' } },
|
||||
{ value: process.processed || 0, name: '已处理', itemStyle: { color: '#10b981' } },
|
||||
// { value: process.pending || 0, name: '待排查', itemStyle: { color: '#eab308' } },
|
||||
{ value: process.processing || 0, name: '处理中', itemStyle: { color: '#3b82f6' } }
|
||||
{ value: safeNumber(process.overdue), name: '已逾期', itemStyle: { color: '#ef4444' } },
|
||||
{ value: safeNumber(process.processed), name: '已处理', itemStyle: { color: '#10b981' } },
|
||||
// { value: safeNumber(process.pending), name: '待排查', itemStyle: { color: '#eab308' } },
|
||||
{ value: safeNumber(process.processing), name: '处理中', itemStyle: { color: '#3b82f6' } }
|
||||
]
|
||||
progressChartOption.value = option
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user