import { 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'; export default defineComponent({ name: 'homewrok-record-detail', setup() { const route = useRoute(); const state = reactive({ searchForm: { keyword: '', trainingStatus: '' as any }, loading: false, pagination: { page: 1, rows: 10, pageTotal: 4 }, 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: '', trainingStatus: '' as any }; search(); }; const getList = async () => { state.loading = true; try { const res = await api_trainingStudentList({ trainingId: route.query.id, ...state.searchForm, ...state.pagination }); 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 () => { 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; // } if (child.trainingType === 'PRACTICE' && child.musicName) { pTitle += pTitle ? '、《' + child.musicName + '》' : '练习曲目《' + child.musicName + '》'; } if (child.trainingType === 'EVALUATION' && child.musicName) { eTitle += eTitle ? '、《' + child.musicName + '》' : '评测曲目《' + child.musicName + '》'; } }); } result.pTitle = pTitle; result.eTitle = eTitle; state.workInfo = result; } 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 (
未提交
) : null} {row.trainingStatus == 'SUBMITTED' ? (不合格
) : null} {row.trainingStatus == 'TARGET' ? (合格
) : null}布置时间: {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.pTitle}
)} {state.workInfo.eTitle && ({state.workInfo.eTitle}
)}