|
|
@ -60,18 +60,25 @@ export const VideoList: FC<Props> = ({categoryKey, setCategoryKey}) => { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function rateOfLearning(id: number, class_hour: number): JSX.Element { |
|
|
|
function rateOfLearning(id: number, class_hour: number): JSX.Element { |
|
|
|
switch (categoryKey) { |
|
|
|
const find = records.find(d => d?.course_id === id) |
|
|
|
case "is_required": |
|
|
|
if (find) { |
|
|
|
case "is_not_required": |
|
|
|
if (class_hour === find.finished_count) { |
|
|
|
const find = records.find(d => d?.course_id === id) |
|
|
|
return <View>已完成</View> |
|
|
|
if (find) { |
|
|
|
} |
|
|
|
if (class_hour === find.finished_count) { |
|
|
|
return (<View>{`共${class_hour}节/已学${find.finished_count}节`}</View>) |
|
|
|
return <View>已完成</View> |
|
|
|
} |
|
|
|
} |
|
|
|
return (<View>{`共${class_hour}节/已学0节`}</View>) |
|
|
|
return (<View>{`共${class_hour}节/已学${find.finished_count}节`}</View>) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return (<View>{`共${class_hour}节/已学0节`}</View>) |
|
|
|
function rateOfPercent(id: number, class_hour: number): string { |
|
|
|
|
|
|
|
const find = records.find(d => d?.course_id === id) |
|
|
|
|
|
|
|
if (find) { |
|
|
|
|
|
|
|
if (class_hour === find.finished_count) { |
|
|
|
|
|
|
|
return '100%' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return ` ${((find.finished_count / class_hour) * 100).toFixed(0)}%` |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return '0%' |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -117,6 +124,7 @@ export const VideoList: FC<Props> = ({categoryKey, setCategoryKey}) => { |
|
|
|
key={c.id} |
|
|
|
key={c.id} |
|
|
|
time={formatMinute(c.course_duration)} |
|
|
|
time={formatMinute(c.course_duration)} |
|
|
|
content={rateOfLearning(c.id, c.class_hour)} |
|
|
|
content={rateOfLearning(c.id, c.class_hour)} |
|
|
|
|
|
|
|
schedule={`学习进度${rateOfPercent(c.id, c.class_hour)}`} |
|
|
|
/>) |
|
|
|
/>) |
|
|
|
} |
|
|
|
} |
|
|
|
</View> |
|
|
|
</View> |
|
|
|