Commit a5fb3b41 authored by 天马流星拳's avatar 天马流星拳

fix(myQradesPage): 修改查找receiveStatus元素的索引逻辑

将查找第一个包含receiveStatus属性的元素改为查找最后一个,以解决默认选中项不正确的问题
parent b893f5cd
......@@ -76,10 +76,10 @@ class Myqradespage extends React.Component {
return existing ? { ...month, ...existing } : month;
});
// 找到一个包含receiveStatus属性的元素索引
const firstReceiveStatusIndex = mergedMonthInfo.findIndex(item => item.hasOwnProperty('receiveStatus'));
// 找到最后一个包含receiveStatus属性的元素索引
const reversedIndex = mergedMonthInfo.slice().reverse().findIndex(item => item.hasOwnProperty('receiveStatus'));
// 如果找到符合条件的元素,则使用其索引,否则使用默认索引0
const targetIndex = firstReceiveStatusIndex !== -1 ? firstReceiveStatusIndex : 0;
const targetIndex = reversedIndex !== -1 ? (mergedMonthInfo.length - 1 - reversedIndex) : 0;
// 更新状态并在回调中执行后续操作
this.setState({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment