import { defineComponent, onMounted, reactive, ref } from 'vue'; import styles from './index.module.less'; import { NInput, NScrollbar, NSelect, NSpin, NThing } from 'naive-ui'; import { useRouter } from 'vue-router'; import { BOOK_DATA } from '/src/views/natural-resources/model/add-teaching'; import { classGroupPage, courseScheduleStart } from '../../api'; import { useThrottleFn } from '@vueuse/core'; import TheEmpty from '/src/components/TheEmpty'; import { usePrepareStore } from '/src/store/modules/prepareLessons'; const classList: any = []; for (let i = 1; i <= 40; i++) { classList.push({ label: i + '班', value: i }); } export default defineComponent({ name: 'attend-class', emits: ['close'], setup(props, { emit }) { const prepareStore = usePrepareStore(); const router = useRouter(); const forms = reactive({ keyword: null, currentGradeNum: null, currentClass: null }); const list = ref([] as any); const loading = ref(false); // 开始上课 const onAttendClass = async (item: any) => { try { await courseScheduleStart({ lessonCoursewareKnowledgeDetailId: prepareStore.selectKey, classGroupId: item.id }); emit('close'); const { href } = router.resolve({ path: '/attend-class', query: { type: 'class', classGroupId: item.id, subjectId: prepareStore.getSubjectId, detailId: prepareStore.getSelectKey } }); window.open(href, +new Date() + ''); } catch { // } }; const getList = async () => { loading.value = true; try { const { data } = await classGroupPage({ page: 1, rows: 99, ...forms }); list.value = data.rows || []; } catch { // } loading.value = false; }; const throttleFn = useThrottleFn(() => getList(), 500); onMounted(() => { getList(); }); return () => (
{ if (e.code === 'Enter') { throttleFn(); } }} onClear={() => throttleFn()}> {{ prefix: () => ( throttleFn()}> ) }} throttleFn()} /> throttleFn()} />
{list.value.map((item: any) => (
onAttendClass(item)}> {{ header: () => (
{item.name} {item.preStudentNum}人
), default: () => item.lastStudy && (
{item.lastStudy}
) }}
))} {!loading.value && list.value.length <= 0 && }
); } });