press-next
Version:
Vue3 组件库,支持 Composition API
37 lines (30 loc) • 782 B
text/typescript
/**
* 赛程列表相关工具函数
*/
export function getListViewScheList(scheList: any[]) {
if (!scheList?.length) {
return [];
}
let result: Array<{
sche?: any;
roundInfo?: any;
}> = [];
// 构造符合组件需求的数据
scheList.forEach((elem) => {
elem?.forEach((item: any) => {
item.battleList.forEach((battle: any) => {
result.push({
sche: battle,
roundInfo: item.roundInfo,
});
});
});
});
result = result
.filter(elem => !!elem);
return result;
}
export const filterScheByRoundName = (list: any[], curRoundFilter?: string) => list?.filter((elem) => {
const { round_name: tag } = elem.roundInfo || {};
return tag === curRoundFilter || curRoundFilter === '全部';
});