import { defineComponent, reactive, onMounted, ref } from 'vue'; import styles from './index.module.less'; import { NAvatar, NButton, NDivider, NForm, NFormItem, NImage, NModal, NSpace, NSpin, useMessage } from 'naive-ui'; import SearchInput from '@/components/searchInput'; import CDatePicker from '/src/components/CDatePicker'; import CSelect from '@/components/CSelect'; import add from '@/views/studentList/images/add.png'; import { useRoute, useRouter } from 'vue-router'; import { getGradeLevelList, getGradeYearList } from '../home/api'; import { initCache, setCache } from '/src/hooks/use-async'; import { classArray, getgradeNumList } from '../classList/contants'; import teacherIcon from '@components/layout/images/teacherIcon.png'; import Pagination from '/src/components/pagination'; import { api_trainingList, api_withdrawTraining } from './api'; import TheEmpty from '/src/components/TheEmpty'; import { fscreen, getTimes } from '/src/utils'; import dayjs from 'dayjs'; import Train from '../prepare-lessons/components/lesson-main/train'; import ResourceMain from '../prepare-lessons/components/resource-main'; import { useResizeObserver } from '@vueuse/core'; import { nextTick } from 'process'; import PreviewWindow from '../preview-window'; import { state as baseState } from '@/state'; export const getCurrentMonth = () => { return [dayjs().startOf('month').valueOf(), dayjs().endOf('month').valueOf()]; }; export default defineComponent({ name: 'homework-record', setup() { const state = reactive({ workVisiable: false, resetVisiable: false, resetItem: {} as any, searchForm: { keyword: null as any, currentClass: '', homeworkType: '', currentGradeNum: '', subjectId: '', gradeYear: '', gradeLevel: '', homeworkObj: '', status: '', timer: getCurrentMonth() as any, selfFlag: true }, loading: false, pagination: { page: 1, rows: 10, pageTotal: 6 }, gradeNumList: [] as any, tableList: [] as any, studentVisible: false, activeRow: null as any, showaddClass: false, popSelectYearList: [] as any, popSelectLevelList: [] as any, previewModal: false, previewParams: { type: '', courseId: '', subjectId: '', detailId: '' } as any }); const formRef = ref(); const message = useMessage(); const router = useRouter(); const route = useRoute(); const search = () => { state.pagination.page = 1; getList(); setCache({ current: state.searchForm, saveKey: route.path }); }; state.gradeNumList = getgradeNumList(); const onReset = () => { state.searchForm = { keyword: null as any, currentClass: '' as any, currentGradeNum: '' as any, subjectId: '' as any, gradeYear: '' as any, gradeLevel: '', homeworkObj: '', status: '', timer: getCurrentMonth() as any, selfFlag: true }; if (state.popSelectYearList.length > 0) { state.searchForm.gradeYear = state.popSelectYearList[2].id; } // setCache({ current: state.searchForm, saveKey: route.path }); getList(); }; const getModalHeight = () => { useResizeObserver( document.querySelector('#model-homework-height') as HTMLElement, (entries: any) => { const entry = entries[0]; const { height } = entry.contentRect; document.documentElement.style.setProperty( '--window-page-lesson-height', height + 'px' ); } ); }; const getList = async () => { // // classGroupList state.loading = true; try { const res = await api_trainingList({ ...state.searchForm, ...state.pagination, ...getTimes( state.searchForm.timer, ['startTime', 'endTime'], 'YYYY-MM-DD' ) }); const result = res.data.rows || []; result.forEach((item: any) => { let pTitle = ''; let eTitle = ''; if ( item.studentLessonTrainingDetails && item.studentLessonTrainingDetails.length > 0 ) { item.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 + '》'; } }); } item.pTitle = pTitle; item.eTitle = eTitle; let studentName = item.homeworkObjName; if (item.homeworkObjName) { const tempObjName = item.homeworkObjName.split(','); if (tempObjName.length > 5) { studentName = tempObjName.slice(0, 5).join('、') + `...等${tempObjName.length}${ item.homeworkObj === 'CLASS' ? '个班级' : '人' }`; } else { studentName = tempObjName.join('、'); } } item.studentName = studentName; }); state.tableList = res.data.rows; state.pagination.pageTotal = res.data.total; state.loading = false; } catch (e) { state.loading = false; console.log(e); } }; // 获取学年 const getYearList = async () => { try { const { data } = await getGradeYearList(); const temp = data || []; temp.forEach((i: any) => { i.name = i.name + '学年'; }); temp.unshift({ id: '', name: '全部学年' }); state.popSelectYearList = temp || []; if (temp.length > 0 && !state.searchForm.gradeYear) { state.searchForm.gradeYear = temp[2].id; } } catch { // } }; // 获取学级 const getLevelList = async () => { try { const { data } = await getGradeLevelList(); const temp = data || []; temp.forEach((i: any) => { i.name = i.name + '级'; }); temp.unshift({ id: '', name: '全部学级' }); state.popSelectLevelList = temp || []; if (temp.length > 0 && !state.searchForm.gradeLevel) { state.searchForm.gradeLevel = temp[0].id; } } catch { // } }; initCache({ current: state.searchForm, callBack: (active: any) => { state.searchForm = active; } }); const onResetRecord = async () => { try { await api_withdrawTraining({ lessonTrainingId: state.resetItem.id }); message.success('撤回成功'); state.resetVisiable = false; search(); } catch { // } }; // 预览上课 // courseId: '' as any, // 课件编号 // subjectId: '' as any, // 声部编号 // lessonCourseId: '' as any, // 教材编号 // lessonCoursewareDetailId: '' as any, // 章节 // detailId: '' as any, // 编号 - 课程编号 // classGroupId: '' as any, // 上课时需要 班级编号 const onPreviewAttend = (item: any) => { // 判断是否在应用里面 if (window.matchMedia('(display-mode: standalone)').matches) { baseState.application = window.matchMedia( '(display-mode: standalone)' ).matches; state.previewModal = true; fscreen(); state.previewParams = { type: 'preview', courseId: item.chapterLessonCoursewareId, subjectId: null, detailId: item.lessonCoursewareKnowledgeDetailId, lessonCourseId: item.lessonCoursewareId }; } else { const { href } = router.resolve({ path: '/attend-class', query: { type: 'preview', courseId: item.chapterLessonCoursewareId, instrumentId: null, detailId: item.lessonCoursewareKnowledgeDetailId, lessonCourseId: item.lessonCoursewareId } }); window.open(href, +new Date() + ''); } }; onMounted(async () => { state.loading = true; await getYearList(); await getLevelList(); await getList(); state.loading = false; }); return () => (
(state.searchForm.keyword = val) }> 搜索 重置
{ state.workVisiable = true; nextTick(() => { getModalHeight(); }); }} v-slots={{ icon: () => ( <> ) }}> 布置作业
{state.tableList.map((item: any) => (
{ router.push({ path: '/homework-record-detail', query: { id: item.id, name: item.name } }); }}>

{item.teacherName}

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

{/* {item.status ? '已结束' : '进行中'} */}
{/*
*/}

{item.homeworkType === 'CLASSWORK' ? '课外' : '课后'} {item.name}

{item.chapterLessonCoursewareId && ( { e.stopPropagation(); // state.resetVisiable = true; // state.resetItem = item; onPreviewAttend(item); }}> 查看课件 )} {!item.status && ( { e.stopPropagation(); state.resetVisiable = true; state.resetItem = item; }}> 撤回 )}
作业对象: {item.studentName}
作业内容:
{item.pTitle && (

{item.pTitle}

)} {item.eTitle && (

{item.eTitle}

)}
已提交: {item.trainingNum || 0}/{item.expectNum || 0}人 提交率: {item.trainingRate || 0}% 合格人数: {item.standardNum || 0}人 合格率: {item.qualifiedRate || 0}%
{/*
*/}
))}
{state.tableList.length <= 0 && !state.loading && ( )}
{state.tableList.length > 0 && ( )}

撤回作业后,此条作业将被删除,是否确认撤回【{state.resetItem.name} 】?

(state.resetVisiable = false)}> 取消 确定
{ state.workVisiable = val.status; getList(); }} />
{/* 应用内预览或上课 */}
); } });