123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- import { defineComponent, onMounted, reactive, ref, toRef } from 'vue';
- import styles from './index.module.less';
- import { NInput, NModal, 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';
- import { state } from '/src/state';
- import { nextTick } from 'process';
- import UpdateSubject from '/src/views/classList/modals/updateSubject';
- const classList: any = [];
- for (let i = 1; i <= 40; i++) {
- classList.push({ label: i + '班', value: i });
- }
- export default defineComponent({
- name: 'attend-class',
- props: {
- // change 切换班级 select 直接进入上课
- type: {
- type: String,
- default: 'change'
- }
- },
- emits: ['close', 'preview', 'confirm'],
- setup(props, { emit }) {
- // const { type } = toRef(props);
- const prepareStore = usePrepareStore();
- const forms = reactive({
- showSubjectClass: false,
- activeRow: {} as any,
- keyword: null,
- currentGradeNum: null,
- currentClass: null
- });
- const list = ref([] as any);
- const loading = ref(false);
- // 开始上课
- const onAttendClass = async (item: any) => {
- // console.log(item, 'onAttendClass');
- try {
- // 判断是否是切换班级
- if (props.type == 'change') {
- if (item.subjectId) {
- emit('confirm', {
- lastUseCoursewareId: item.lessonCoursewareId,
- unit: item.lessonCoursewareKnowledgeDetailId,
- subjectId: item.subjectId,
- courseScheduleSubjectId: item.courseScheduleSubjectId,
- name: item.name, // 班级名称
- classGroupId: item.id, // 班级编号
- preStudentNum: item.preStudentNum
- });
- } else {
- forms.showSubjectClass = true;
- forms.activeRow = item;
- }
- return;
- }
- const res = await courseScheduleStart({
- lessonCoursewareKnowledgeDetailId: prepareStore.selectKey,
- classGroupId: item.id,
- subjectId: prepareStore.getSubjectId
- });
- emit('close');
- emit('preview', {
- type: 'class',
- classId: res.data, // 上课编号
- classGroupId: item.id,
- subjectId: prepareStore.getSubjectId,
- detailId: prepareStore.getSelectKey,
- lessonCourseId: prepareStore.getBaseCourseware.id,
- preStudentNum: item.preStudentNum
- });
- if (window.matchMedia('(display-mode: standalone)').matches) {
- state.application = window.matchMedia(
- '(display-mode: standalone)'
- ).matches;
- setTimeout(() => {
- fscreen();
- }, 200);
- }
- } catch {
- //
- }
- };
- const fscreen = () => {
- const el: any = document.documentElement;
- const documentDom: any = document;
- const isFullscreen =
- documentDom.fullScreen ||
- documentDom.mozFullScreen ||
- documentDom.webkitIsFullScreen;
- if (!isFullscreen) {
- //进入全屏
- (el.requestFullscreen && el.requestFullscreen()) ||
- (el.mozRequestFullScreen && el.mozRequestFullScreen()) ||
- (el.webkitRequestFullscreen && el.webkitRequestFullscreen()) ||
- (el.msRequestFullscreen && el.msRequestFullscreen());
- } else {
- //退出全屏
- documentDom.exitFullscreen
- ? documentDom.exitFullscreen()
- : documentDom.mozCancelFullScreen
- ? documentDom.mozCancelFullScreen()
- : documentDom.webkitExitFullscreen
- ? documentDom.webkitExitFullscreen()
- : '';
- }
- };
- const getList = async () => {
- loading.value = true;
- try {
- const { data } = await classGroupPage({
- page: 1,
- rows: 99,
- upgradeFlag: true,
- ...forms
- });
- const result = data.rows || [];
- const temp: any = [];
- result.forEach((item: any) => {
- // 判断班级里面有学生的
- // if (item.preStudentNum > 0) {
- temp.push(item);
- // }
- });
- list.value = temp;
- } catch {
- //
- }
- loading.value = false;
- };
- const throttleFn = useThrottleFn(() => getList(), 500);
- onMounted(() => {
- getList();
- });
- return () => (
- <div class={styles.attendClass}>
- <div class={styles.attendClassSearch}>
- <NInput
- placeholder="请输入班级名称"
- clearable
- v-model:value={forms.keyword}
- onKeyup={(e: KeyboardEvent) => {
- if (e.code === 'Enter') {
- throttleFn();
- }
- }}
- onClear={() => throttleFn()}>
- {{
- prefix: () => (
- <span
- class="icon-search-input"
- onClick={() => throttleFn()}></span>
- )
- }}
- </NInput>
- <NSelect
- placeholder="全部年级"
- clearable
- options={
- [{ label: '全部年级', value: null }, ...BOOK_DATA.grades] as any
- }
- v-model:value={forms.currentGradeNum}
- onUpdate:value={() => throttleFn()}
- />
- <NSelect
- placeholder="全部班级"
- clearable
- options={[{ label: '全部班级', value: null }, ...classList]}
- v-model:value={forms.currentClass}
- onUpdate:value={() => throttleFn()}
- />
- </div>
- <NScrollbar class={styles.classList}>
- <NSpin show={loading.value}>
- <div
- class={[
- styles.listSection,
- !loading.value && list.value.length <= 0
- ? styles.emptySection
- : ''
- ]}>
- {list.value.map((item: any) => (
- <div onClick={() => onAttendClass(item)}>
- <NThing class={[styles.thingItem, 'isFull']}>
- {{
- header: () => (
- <>
- <div class={styles.title}>
- {item.name} {item.preStudentNum}人
- </div>
- <div
- class={[
- styles.subjects,
- item.subjectName ? '' : styles.noSubjects
- ]}>
- {item.subjectName ? item.subjectName : '暂无声部'}
- </div>
- </>
- ),
- default: () =>
- item.lastStudy && (
- <div class={styles.content}>{item.lastStudy}</div>
- )
- }}
- </NThing>
- </div>
- ))}
- {!loading.value && list.value.length <= 0 && <TheEmpty />}
- </div>
- </NSpin>
- </NScrollbar>
- <NModal
- v-model:show={forms.showSubjectClass}
- style={{ width: '500px' }}
- preset="card"
- class={['modalTitle background']}
- title={'修改声部'}>
- {forms.showSubjectClass ? (
- <UpdateSubject
- activeRow={forms.activeRow}
- onGetList={() => getList()}
- onConfirm={(item: any) => {
- //
- emit('confirm', item);
- }}
- onClose={() => (forms.showSubjectClass = false)}
- />
- ) : null}
- </NModal>
- </div>
- );
- }
- });
|