import { defineComponent, onMounted, reactive, ref } from 'vue'; import styles from '../index.module.less'; import { NButton, NDataTable, NForm, NFormItem, NImage, NModal, NSelect, NSpace } from 'naive-ui'; import SearchInput from '@/components/searchInput'; import CSelect from '@/components/CSelect'; import Pagination from '@/components/pagination'; import { getWorkDetail, getTrainingStudentList } from '../api'; import add from './images/add.png'; import { useRoute } from 'vue-router'; import CBreadcrumb from '/src/components/CBreadcrumb'; import CDatePicker from '/src/components/CDatePicker'; import defultHeade from '@/components/layout/images/teacherIcon.png'; import { getNowDateAndMonday, getNowDateAndSunday, getTimes } from '/src/utils/dateFormat'; import { trainingStatusArray } from '@/utils/searchArray'; import TrainingDetails from '../modals/TrainingDetails'; import dayjs from 'dayjs'; import { lookup } from 'dns'; export default defineComponent({ name: 'student-studentList', setup(props, { emit }) { const state = reactive({ searchForm: { keyword: '', trainingStatus: null as any }, loading: false, pagination: { page: 1, rows: 10, pageTotal: 4 }, tableList: [] as any, workInfo: { createTime: '', expireDate: '', teacherAvatar: '', teacherName: '' }, detailVisiable: false, activeRow: null as any, index: 0 }); const timer = ref<[number, number]>([ getNowDateAndMonday(new Date().getTime()), getNowDateAndSunday(new Date().getTime()) ]); const TrainingDetailsRef = ref(); const route = useRoute(); const routerList = ref([ { name: '班级管理', path: '/classList' }, { name: route.query.name, path: '/classDetail' }, { name: route.query.teacherName, path: '/afterWorkDetail' } ] as any); const search = () => { state.pagination.page = 1; getList(); console.log('search', state); }; const onReset = () => { state.searchForm = { keyword: '', trainingStatus: null as any }; timer.value = [ getNowDateAndMonday(new Date().getTime()), getNowDateAndSunday(new Date().getTime()) ]; search(); }; const getList = async () => { state.loading = true; try { const res = await getTrainingStudentList({ trainingId: route.query.trainingId, ...state.searchForm, ...state.pagination // ...getTimes(timer.value, ['startTime', 'endTime'], 'YYYY-MM-DD') }); state.tableList = res.data.rows; state.pagination.pageTotal = res.data.total; state.loading = false; } catch (e) { state.loading = false; console.log(e); } }; const getWorkInfo = async () => { console.log(route.query); try { const res = await getWorkDetail({ trainingId: route.query.trainingId }); state.workInfo = { ...res.data }; } 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: 'sex', render(row: any) { return (
{row.trainingStatus == 'UNSUBMITTED' ? (

未提交

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

不合格

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

合格

) : null}
); } }, { title: '操作', key: 'id', render(row: any, index: number) { return ( { lookDetail(row, index); }}> 详情 ); } } ]; }; const goToNext = () => { state.index++; state.activeRow = state.tableList[state.index - 1]; TrainingDetailsRef.value.getTrainingDetail(); }; const gotoPre = () => { state.index--; state.activeRow = state.tableList[state.index - 1]; TrainingDetailsRef.value.getTrainingDetail(); }; return () => (

{state.workInfo.teacherName}

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

(state.searchForm.keyword = val) }> {/* */} 搜索 重置
{/* ( <> ) }}> 新增学生 */}
goToNext()} onPre={() => gotoPre()} ref={TrainingDetailsRef} onClose={() => (state.detailVisiable = false)} total={state.tableList.length} current={state.index} activeRow={state.activeRow}>
); } });