diff --git a/web/src/pages/mockExamination/chapterList.tsx b/web/src/pages/mockExamination/chapterList.tsx index 175122b..05c1743 100644 --- a/web/src/pages/mockExamination/chapterList.tsx +++ b/web/src/pages/mockExamination/chapterList.tsx @@ -3,222 +3,200 @@ import { useEffect, useState } from 'react'; import { Button, Card, Col, Layout, List, Menu, Progress, Row, Typography } from 'antd'; import { PageContainer } from '@ant-design/pro-layout'; import { useParams, useRequest } from 'umi'; -import { viewMyLearningSubject, listMyLearningChapterCourse } from './service'; +import { viewMyLearningSubject, getCourseExaminationProgressList } from './service'; import type { CardListItemDataType } from './data.d'; import styles from './style.less'; import SubMenu from 'antd/lib/menu/SubMenu'; -console.log('course/list') const { Paragraph } = Typography; import cookie from 'react-cookies'; -// const getList = async (subject_id,chapter_id ) => { -// // const hide = message.loading('正在配置'); -// try { -// const a=await listMyLearningChapterCourse({ -// identity_id:cookie.load('identity_id'), -// person_id:cookie.load('person_id'), -// subject_id:subject_id, -// chapter_id:chapter_id, -// }); -// // message.success('配置成功'); -// return a; -// } catch (error) { -// // message.error('配置失败请重试!'); -// return false; -// } -// }; +import { history } from "@@/core/history"; +let chapterCourse=[]; +let total_process=0; const CardList = () => { - const params = useParams(); - console.log('params', params); - // const ids = params.msg.split(','); + const params = useParams(); - const [currentCourse, SetCurrentCourse] = useState() + const [currentCourse, SetCurrentCourse] = useState() - /** 获取主题下课程 */ - const { data } = useRequest(() => { - return viewMyLearningSubject({ - identity_id: cookie.load('identity_id'), - person_id: cookie.load('person_id'), - data_id: params.data_id, - data_type: params.data_type, - subject_id: params.subject_id + /** 获取主题下课程 */ + const { data } = useRequest(() => { + return viewMyLearningSubject({ + identity_id: cookie.load('identity_id'), + person_id: cookie.load('person_id'), + data_id: params?.data_id, + data_type: params?.data_type, + subject_id: params?.subject_id - }); }); + }); - const list = data?.list || []; - const subject_data = data ? data.subject : []; - const last_data = data ? data.last_learning_course : []; - const chapter_list = data ? data.chapter_list : []; + // const list = data?.list||[]; + const subject_data = data ? data.subject : []; + const last_data = data ? data.last_learning_course : []; + const chapter_list = data ? data.chapter_list : []; - //console.log('currentCourse', currentCourse) - /** 获取课程详情 */ - const { data: chapterCourse, run, loading } = useRequest((params: { subject_id: number, chapter_id: number }) => { - return listMyLearningChapterCourse({ - identity_id: cookie.load('identity_id'), - person_id: cookie.load('person_id'), - subject_id: params?.subject_id,//chapter_list[0].subject_id - chapter_id: params?.chapter_id,//chapter_list[0].chapter_id - }); - }); - - /** 首次页面 当data 变化 执行run, chapterCourse 变化 进行currentCourse赋值 */ - useEffect(() => { - console.log('chapterCourse...', chapterCourse) - if (data !== undefined && data !== null) { - run({ subject_id: data?.chapter_list[0]?.subject_id, chapter_id: data?.chapter_list[0]?.chapter_id }) - SetCurrentCourse(chapterCourse) - } + /** 获取课程详情 */ + const { chapterCourseData, run, loading } = useRequest((params: { subject_id: number, chapter_id: number }) => { + return getCourseExaminationProgressList({ + identity_id: cookie.load('identity_id'), + person_id: cookie.load('person_id'), + subject_id: params?.subject_id, + chapter_id: params?.chapter_id, - }, [data]); + // r_list[0].chapter_id + }); + },{ + formatResult: (result) => { + if(result.list.length!==0){ + let total_finish_count=0; + let total_question_count=0; + result.list.forEach((item)=>{ + total_finish_count+=item.finish_count; + total_question_count+=item.question_count; + if(item.finish_count!==0){ + let num=0; + num=result.finish_count/result.question_count; + item.process=num.toFixed(4) + }else { + item.process=0; + } + }); + if(total_finish_count!==0){ + let total_num=total_finish_count/total_question_count; + total_process=total_num.toFixed(4) - /** run后 chapterCourse 变化 进行currentCourse赋值 */ - useEffect(() => { - console.log('chapterCourse...', chapterCourse) - if (data !== undefined) { - console.log('data', data) - SetCurrentCourse(chapterCourse) + }else { + total_process=0; } - - }, [chapterCourse]); - - - const content = ( -
- {subject_data ? subject_data.subject_name : '--'}} - hoverable={false} - className={styles.card} - actions={[]} - extra={<>开始学习时间: {subject_data ? subject_data.learning_start_time : '--'}距离结束时间:{subject_data ? subject_data.distance_end_time : '--'}考核学时:{subject_data ? subject_data.total_course_hours : '--'}小时} - > - } - title={false} - description={ - <> - - - {subject_data ? subject_data.subject_describe : '--'} - - - 学习进度: - - - 上次学习:{last_data ? last_data.course_name : '--'} 主讲人:{last_data ? last_data.lecture_teacher : '--'} - - - - } - /> - -
- ); - - - console.log('iddddddd', chapter_list.length !== 0 ? chapter_list[0].chapter_id.toString() : '') - const nullData: Partial = {}; - return ( - - - - - } title="章节目录"> - { - chapter_list.length !== 0 ? - chapter_list.map((item) => { - return ( - { - run({ subject_id: item.subject_id, chapter_id: item.chapter_id }) - }} - >{item.chapter_name} - ) - - }) : '' - } - - - - - - {console.log('chapterCourse', chapterCourse)} - { - chapterCourse !== undefined ? - <> - <>{chapterCourse[0]?.course_name} - <>{chapterCourse[0]?.lecture_teacher} - - : <>暂无 - } - - - > - rowKey="id" - // loading={loading} - grid={{ - gutter: 1, - xs: 1, - sm: 2, - md: 1, - lg: 1, - xl: 1, - xxl: 1, + } + chapterCourse=result.list; + + } + }); + + /** 首次页面 当data 变化 执行run, chapterCourse 变化 进行currentCourse赋值 */ + useEffect(() => { + // console.log('chapterCourse首次页面...', chapterCourse) + if (data !== undefined && data !== null && chapter_list.length !== 0) { + run({ subject_id: data?.chapter_list[0]?.subject_id, chapter_id: data?.chapter_list[0]?.chapter_id }) + SetCurrentCourse(chapterCourse) + } + //setSelectedCourse({}) + }, [data]); + + /** run后 chapterCourse 变化 进行currentCourse赋值 */ + useEffect(() => { + // console.log('chapterCourse变化...', chapterCourse) + if (data !== undefined) { + SetCurrentCourse(chapterCourse) + } + //setSelectedCourse({}) + }, [chapterCourse]); + + + const content = ( +
+ {subject_data ? subject_data.subject_name : '--'}} + hoverable={false} + className={styles.card} + actions={[]} + > + } + title={false} + description={ + <> + + + {subject_data ? subject_data.subject_describe : '--'} + + + 章节模拟考试进度: + + + + + + + + + } + /> + +
+ ); + + const nullData: Partial = {}; + return ( + + + + + } title="章节目录"> + { + chapter_list.length !== 0 ? + chapter_list.map((item) => { + return ( + { + run({ subject_id: item.subject_id, chapter_id: item.chapter_id }) }} - dataSource={[nullData, ...chapterCourse]} - renderItem={(item) => { - if (item && item.id) { - return ( - - - {item.title}} - description={ - - - 第1讲 - - - - {item.description} - - - - 23分钟 - - - - - - - - - } - /> - - - ); - } - }} - /> - - - - - ); + >{item.chapter_name} + ) + + }) : '' + } + + + + + + { + chapterCourse !== undefined && chapterCourse !== '' ? + chapterCourse.map((item, index) => { + return ( +
+
+
第{index+1}讲
+
{item?.course_name}
+
{item?.finish_count}题/{item?.question_count}题
+
+ +
+
+ +
+
+ + +
+ ) + }) + + : <>暂无 + } + +
+ +
+ ); }; export default CardList; diff --git a/web/src/pages/mockExamination/service.ts b/web/src/pages/mockExamination/service.ts index 4a1f157..5f3b5ad 100644 --- a/web/src/pages/mockExamination/service.ts +++ b/web/src/pages/mockExamination/service.ts @@ -4,8 +4,8 @@ import type { CardListItemDataType } from './data.d'; /** * 【6.5】(教师首页)当前学习主题课程信息 * /dsideal_yy/ypt/careerTraining/learning/listMyLearningSubject - * @param params - * @returns + * @param params + * @returns */ export async function listMyLearningSubject(params: { page_size: number; @@ -18,8 +18,8 @@ export async function listMyLearningSubject(params: { /** * 【6.5】(教师首页)当前学习主题课程信息 * /dsideal_yy/ypt/careerTraining/learning/listMyLearningSubject - * @param params - * @returns + * @param params + * @returns */ export async function getRulesList(params: { page_size: number; @@ -32,8 +32,8 @@ export async function getRulesList(params: { /** * 05 组卷详情查询 * /dsideal_yy/zygh/training/rules/getRulesPaper - * @param params - * @returns + * @param params + * @returns */ export async function getRulesPaper(params: { page_size: number; @@ -46,8 +46,8 @@ export async function getRulesPaper(params: { /** * 06 获取试卷内容 * /dsideal_yy/zygh/training/rules/getPaperQuestionList - * @param params - * @returns + * @param params + * @returns */ export async function getPaperQuestionList(params: { page_size: number; @@ -79,4 +79,15 @@ export async function listMyLearningChapterCourse(params: { return request(' /dsideal_yy/ypt/careerTraining/learning/listMyLearningChapterCourse', { params, }); -} \ No newline at end of file +} + +export async function getCourseExaminationProgressList(params: { + chapter_id: number; + identity_id: number; + person_id: number; + subject_id: number +}){ + return request('/dsideal_yy/zygh/training/mock/getCourseExaminationProgressList', { + params, + }); +}