import { computed, defineComponent, onMounted, reactive, ref } from 'vue'; import styles from './index.module.less'; import { NButton, NDataTable, NForm, NFormItem, NImage, NModal, NProgress, NSpace } from 'naive-ui'; import SearchInput from '@/components/searchInput'; import CSelect from '@/components/CSelect'; import Pagination from '@/components/pagination'; import { api_trainingDetail, api_trainingStudentList } from '../api'; import { useRoute } from 'vue-router'; import CBreadcrumb from '/src/components/CBreadcrumb'; import defultHeade from '@/components/layout/images/teacherIcon.png'; import { trainingStatusArray } from '@/utils/searchArray'; import dayjs from 'dayjs'; import TheEmpty from '/src/components/TheEmpty'; import TrainingDetails from '../../classList/modals/TrainingDetails'; import { evaluateDifficult } from '/src/utils/contants'; import { modalClickMask } from '/src/state'; export default defineComponent({ name: 'homewrok-record-detail', setup() { const route = useRoute(); const state = reactive({ searchForm: { keyword: '', vipFlag: null as any, trainingStatus: '' as any, classGroupId: '' as any }, loading: false, pagination: { page: 1, rows: 10, pageTotal: 4 }, studentClassList: [] as any, tableList: [] as any, workInfo: {} as any, detailVisiable: false, activeRow: null as any, index: 0 }); const TrainingDetailsRef = ref(); const routerList = ref([ { name: '作业', path: '/homework-record' }, { name: route.query.name, path: '/homework-record-detail' } ] as any); const search = () => { state.pagination.page = 1; getList(); }; const onReset = () => { state.searchForm = { keyword: '', vipFlag: null, trainingStatus: '' as any, classGroupId: '' as any }; search(); }; const getList = async (type?: string, page?: number) => { state.loading = true; try { const res = await api_trainingStudentList({ trainingId: route.query.id, ...state.searchForm, ...state.pagination, page: page || state.pagination.page }); state.tableList = res.data.rows; state.pagination.pageTotal = res.data.total; state.pagination.page = res.data.current; state.loading = false; if (type === 'next') { state.index = 0; goToNext(); } else if (type === 'prev') { state.index = state.tableList.length + 1; gotoPre(); } } catch (e) { state.loading = false; console.log(e); } }; const getWorkInfo = async () => { try { const res = await api_trainingDetail({ id: route.query.id }); const result = res.data || {}; // state.workInfo let pTitle = ''; let eTitle = ''; if ( result.studentLessonTrainingDetails && result.studentLessonTrainingDetails.length > 0 ) { result.studentLessonTrainingDetails.forEach((child: any) => { // if (child.trainingType === 'PRACTICE' && child.musicName) { // pTitle += pTitle ? '、' + child.musicName : child.musicName; // } // if (child.trainingType === 'EVALUATION' && child.musicName) { // eTitle += eTitle ? '、' + child.musicName : child.musicName; // } const trainingContent = child.trainingContent ? JSON.parse(child.trainingContent) : null; if (child.trainingType === 'PRACTICE' && child.musicName) { pTitle += '《' + child.musicName + '》'; if (trainingContent) { const tempList = [ `${trainingContent.practiceChapterBegin}-${trainingContent.practiceChapterEnd}小节`, `速度${trainingContent.practiceSpeed || 0}`, `${trainingContent.trainingTimes}分钟` ]; pTitle += tempList.join(' | ') + ';'; } } if (child.trainingType === 'EVALUATION' && child.musicName) { eTitle += '《' + child.musicName + '》'; if (trainingContent) { const tempList = [ `${evaluateDifficult[trainingContent.evaluateDifficult]}`, `${trainingContent.practiceChapterBegin || 0}-${trainingContent.practiceChapterEnd || 0}小节`, `速度${trainingContent.evaluateSpeed || 0}`, `${trainingContent.trainingTimes}分达标` ]; eTitle += tempList.join(' | ') + ';'; } } }); } result.pTitle = pTitle; result.eTitle = eTitle; state.workInfo = result; // 班级列表 const classList = result.studentClassGroup || []; classList.forEach((item: any) => { state.studentClassList.push({ label: item.name, value: item.id }); }); } catch (e) { console.log(e); } }; const lookDetail = (row: any, index: number) => { console.log(index, 'index'); state.index = index + 1; state.activeRow = row; state.detailVisiable = true; }; onMounted(() => { getWorkInfo(); getList(); }); const columns = () => { return [ { title: '学生姓名', key: 'studentName' }, { title: '最后提交时间', key: 'submitTime', render(row: any) { return row.submitTime ? dayjs(row.submitTime).format('YYYY-MM-DD') : '--'; } }, { title: '所属班级', key: 'classGroupName' }, { title: '作业状态', key: 'trainingStatus', render(row: any) { return (
{row.trainingStatus == 'UNSUBMITTED' ? (

未提交

) : null} {row.trainingStatus == 'SUBMITTED' ? (

未达标

) : null} {row.trainingStatus == 'TARGET' ? (

达标

) : null}
); } }, { title: '是否会员', key: 'vipFlag', render(row: any) { return row.vipFlag ? '是' : '否'; } }, { title: '操作', key: 'id', render(row: any, index: number) { return ( { lookDetail(row, index); }}> 详情 ); } } ]; }; const goToNext = () => { if (state.index >= state.tableList.length) { getList('next', state.pagination.page + 1); } else { ++state.index; state.activeRow = state.tableList[state.index - 1]; TrainingDetailsRef.value.getTrainingDetail( state.activeRow.studentLessonTrainingId ); } }; const gotoPre = () => { if (state.index === 1 && state.pagination.page !== 1) { getList('prev', state.pagination.page - 1); } else { --state.index; state.activeRow = state.tableList[state.index - 1]; TrainingDetailsRef.value.getTrainingDetail( state.activeRow.studentLessonTrainingId ); } }; const currentStudentIndex = computed(() => { return state.index + (state.pagination.page - 1) * state.pagination.rows; }); return () => (

{state.workInfo.teacherName}

{state.workInfo.createTime && (

布置时间: {state.workInfo.createTime && dayjs(state.workInfo.createTime).format( 'YYYY-MM-DD HH:mm' )}{' '} |{' '} 截止时间: {state.workInfo.expireDate && dayjs(state.workInfo.expireDate).format( 'YYYY-MM-DD HH:mm' )}

)}
{state.workInfo.name}
{state.workInfo.pTitle && (

练习曲目:

{state.workInfo.pTitle}

)} {state.workInfo.eTitle && (

评测曲目:

{state.workInfo.eTitle}

)}
作业完成情况
{state.workInfo.trainingNum || 0} / {state.workInfo.expectNum || 0}
已提交
{state.workInfo.trainingRate || 0}%
提交率
{state.workInfo.standardNum || 0}
达标人数
{state.workInfo.qualifiedRate || 0}%
达标率
(state.searchForm.keyword = val) }> 搜索 重置
}} class={styles.classTable} loading={state.loading} columns={columns()} data={state.tableList}>
goToNext()} onPre={() => gotoPre()} ref={TrainingDetailsRef} onClose={() => (state.detailVisiable = false)} total={state.pagination.pageTotal} current={currentStudentIndex.value} activeRow={state.activeRow}>
); } });