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 { 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'; 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: '', 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 }); 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[1].id; } // getList(); setCache({ current: state.searchForm, saveKey: route.path }); }; 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; }); 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[1].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 { // } }; 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) => (

{item.teacherName}

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

{item.status === 1 ? '已结束' : '进行中'}
{item.name}
作业对象: {item.homeworkObjName}
作业内容:
{item.pTitle && (

{item.pTitle}

)} {item.eTitle && (

{item.eTitle}

)}
已提交: {item.trainingNum || 0}/{item.trainingNum || 0}人 提交率: {item.trainingRate || 0}% 合格人数: {item.standardNum || 0}人 合格率: {item.qualifiedRate || 0}%
{ state.resetVisiable = true; state.resetItem = item; }}> 撤回
))}
{state.tableList.length <= 0 && ( )}
{state.tableList.length > 0 && ( )}

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

(state.resetVisiable = false)}> 取消 确定
); } });