update pay function
This commit is contained in:
@@ -167,55 +167,76 @@ const ConceptTimelineModal = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 转换时间轴数据为日历事件格式
|
// 转换时间轴数据为日历事件格式(一天拆分为多个独立事件)
|
||||||
const calendarEvents = useMemo(() => {
|
const calendarEvents = useMemo(() => {
|
||||||
return timelineData.map(item => {
|
const events = [];
|
||||||
|
|
||||||
|
timelineData.forEach(item => {
|
||||||
const priceInfo = getPriceInfo(item.price);
|
const priceInfo = getPriceInfo(item.price);
|
||||||
const hasEvents = item.events && item.events.length > 0;
|
|
||||||
const newsCount = (item.events || []).filter(e => e.type === 'news').length;
|
const newsCount = (item.events || []).filter(e => e.type === 'news').length;
|
||||||
const reportCount = (item.events || []).filter(e => e.type === 'report').length;
|
const reportCount = (item.events || []).filter(e => e.type === 'report').length;
|
||||||
|
|
||||||
// 根据涨跌幅和事件确定颜色
|
|
||||||
let backgroundColor = '#e2e8f0'; // 默认灰色(无数据)
|
|
||||||
if (hasEvents) {
|
|
||||||
backgroundColor = '#9F7AEA'; // 紫色(有事件)
|
|
||||||
} else if (item.price) {
|
|
||||||
if (priceInfo.color === 'red') {
|
|
||||||
backgroundColor = '#FC8181'; // 红色(上涨)
|
|
||||||
} else if (priceInfo.color === 'green') {
|
|
||||||
backgroundColor = '#68D391'; // 绿色(下跌)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 构建显示标题:同时显示事件和涨跌幅
|
|
||||||
const hasPriceData = item.price && item.price.avg_change_pct !== null;
|
const hasPriceData = item.price && item.price.avg_change_pct !== null;
|
||||||
let title = '';
|
|
||||||
|
|
||||||
if (hasEvents && hasPriceData) {
|
// 如果有新闻,添加新闻事件
|
||||||
// 同时有事件和价格数据
|
if (newsCount > 0) {
|
||||||
title = `📰${newsCount} 📊${reportCount} ${priceInfo.text}`;
|
events.push({
|
||||||
} else if (hasEvents) {
|
id: `${item.date}-news`,
|
||||||
// 只有事件
|
title: `📰 ${newsCount} 条新闻`,
|
||||||
title = `📰${newsCount} 📊${reportCount}`;
|
date: item.date,
|
||||||
} else if (hasPriceData) {
|
start: item.date,
|
||||||
// 只有价格数据
|
backgroundColor: '#9F7AEA',
|
||||||
title = priceInfo.text;
|
borderColor: '#9F7AEA',
|
||||||
|
extendedProps: {
|
||||||
|
eventType: 'news',
|
||||||
|
count: newsCount,
|
||||||
|
originalData: item,
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
// 如果有研报,添加研报事件
|
||||||
id: item.date,
|
if (reportCount > 0) {
|
||||||
title,
|
events.push({
|
||||||
date: item.date,
|
id: `${item.date}-report`,
|
||||||
backgroundColor,
|
title: `📊 ${reportCount} 篇研报`,
|
||||||
borderColor: backgroundColor,
|
date: item.date,
|
||||||
extendedProps: {
|
start: item.date,
|
||||||
...item,
|
backgroundColor: '#805AD5',
|
||||||
newsCount,
|
borderColor: '#805AD5',
|
||||||
reportCount,
|
extendedProps: {
|
||||||
priceInfo,
|
eventType: 'report',
|
||||||
|
count: reportCount,
|
||||||
|
originalData: item,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果有价格数据,添加价格事件
|
||||||
|
if (hasPriceData) {
|
||||||
|
let bgColor = '#e2e8f0';
|
||||||
|
if (priceInfo.color === 'red') {
|
||||||
|
bgColor = '#FC8181'; // 红色(上涨)
|
||||||
|
} else if (priceInfo.color === 'green') {
|
||||||
|
bgColor = '#68D391'; // 绿色(下跌)
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
events.push({
|
||||||
|
id: `${item.date}-price`,
|
||||||
|
title: priceInfo.text,
|
||||||
|
date: item.date,
|
||||||
|
start: item.date,
|
||||||
|
backgroundColor: bgColor,
|
||||||
|
borderColor: bgColor,
|
||||||
|
extendedProps: {
|
||||||
|
eventType: 'price',
|
||||||
|
priceInfo,
|
||||||
|
originalData: item,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return events;
|
||||||
}, [timelineData]);
|
}, [timelineData]);
|
||||||
|
|
||||||
// 处理日期点击
|
// 处理日期点击
|
||||||
@@ -235,11 +256,11 @@ const ConceptTimelineModal = ({
|
|||||||
|
|
||||||
// 处理事件点击
|
// 处理事件点击
|
||||||
const handleEventClick = (info) => {
|
const handleEventClick = (info) => {
|
||||||
const clickedDate = info.event.id;
|
// 从事件的 extendedProps 中获取原始数据
|
||||||
const dateData = timelineData.find(item => item.date === clickedDate);
|
const dateData = info.event.extendedProps?.originalData;
|
||||||
|
|
||||||
if (dateData) {
|
if (dateData) {
|
||||||
setSelectedDate(clickedDate);
|
setSelectedDate(dateData.date);
|
||||||
setSelectedDateData(dateData);
|
setSelectedDateData(dateData);
|
||||||
onDateDetailOpen();
|
onDateDetailOpen();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user