|  | @@ -16,13 +16,14 @@ import { usePrepareStore } from '/src/store/modules/prepareLessons';
 | 
	
		
			
				|  |  |  import { useCatchStore } from '/src/store/modules/catchData';
 | 
	
		
			
				|  |  |  import TheEmpty from '/src/components/TheEmpty';
 | 
	
		
			
				|  |  |  import {
 | 
	
		
			
				|  |  | +  courseScheduleStart,
 | 
	
		
			
				|  |  |    queryCourseware,
 | 
	
		
			
				|  |  |    saveCourseware,
 | 
	
		
			
				|  |  |    teacherKnowledgeMaterialDelete
 | 
	
		
			
				|  |  |  } from '../../../api';
 | 
	
		
			
				|  |  |  import Draggable from 'vuedraggable';
 | 
	
		
			
				|  |  |  import iconDelete from '../../../images/icon-delete.png';
 | 
	
		
			
				|  |  | -import { useRoute, useRouter } from 'vue-router';
 | 
	
		
			
				|  |  | +import { onBeforeRouteUpdate, useRoute, useRouter } from 'vue-router';
 | 
	
		
			
				|  |  |  import deepClone from '/src/helpers/deep-clone';
 | 
	
		
			
				|  |  |  import CardPreview from '/src/components/card-preview';
 | 
	
		
			
				|  |  |  import PreviewWindow from '/src/views/preview-window';
 | 
	
	
		
			
				|  | @@ -173,10 +174,10 @@ export default defineComponent({
 | 
	
		
			
				|  |  |          forms.drag = false;
 | 
	
		
			
				|  |  |          message.success('编辑成功');
 | 
	
		
			
				|  |  |          forms.removeVisiable = false;
 | 
	
		
			
				|  |  | -        prepareStore.setCoursewareList(deepClone(forms.coursewareList));
 | 
	
		
			
				|  |  |          prepareStore.setIsEditResource(false);
 | 
	
		
			
				|  |  |          // 重置临时删除编号
 | 
	
		
			
				|  |  |          forms.removeIds = [];
 | 
	
		
			
				|  |  | +        await getList();
 | 
	
		
			
				|  |  |        } catch {
 | 
	
		
			
				|  |  |          //
 | 
	
		
			
				|  |  |        }
 | 
	
	
		
			
				|  | @@ -253,21 +254,49 @@ export default defineComponent({
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |      };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    onMounted(async () => {
 | 
	
		
			
				|  |  | -      // 获取教材分类列表
 | 
	
		
			
				|  |  | -      await catchStore.getSubjects();
 | 
	
		
			
				|  |  | +    watch(
 | 
	
		
			
				|  |  | +      () => prepareStore.getSubjectList,
 | 
	
		
			
				|  |  | +      () => {
 | 
	
		
			
				|  |  | +        checkSubjectIds();
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    );
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -      const subjectList = catchStore.getSubjectList;
 | 
	
		
			
				|  |  | +    const checkSubjectIds = () => {
 | 
	
		
			
				|  |  | +      const subjectList = prepareStore.getSubjectList;
 | 
	
		
			
				|  |  | +      // console.log(subjectList, 'subjectList');
 | 
	
		
			
				|  |  |        // 并且没有声部时才会更新
 | 
	
		
			
				|  |  |        if (subjectList.length > 0) {
 | 
	
		
			
				|  |  |          // 判断浏览器上面是否有
 | 
	
		
			
				|  |  | -        if (forms.subjectId) {
 | 
	
		
			
				|  |  | +        const index = subjectList.findIndex(
 | 
	
		
			
				|  |  | +          (subject: any) => subject.id == forms.subjectId
 | 
	
		
			
				|  |  | +        );
 | 
	
		
			
				|  |  | +        // 并且声部在列表中
 | 
	
		
			
				|  |  | +        if (forms.subjectId && index >= 0) {
 | 
	
		
			
				|  |  |            prepareStore.setSubjectId(forms.subjectId);
 | 
	
		
			
				|  |  |          } else if (!prepareStore.getSubjectId) {
 | 
	
		
			
				|  |  |            // 判断是否有缓存
 | 
	
		
			
				|  |  |            prepareStore.setSubjectId(subjectList[0].id);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    watch(
 | 
	
		
			
				|  |  | +      () => route.query,
 | 
	
		
			
				|  |  | +      async () => {
 | 
	
		
			
				|  |  | +        forms.className = route.query.name as any;
 | 
	
		
			
				|  |  | +        forms.classGroupId = route.query.classGroupId as any;
 | 
	
		
			
				|  |  | +        forms.subjectId = route.query.subjectId
 | 
	
		
			
				|  |  | +          ? Number(route.query.subjectId)
 | 
	
		
			
				|  |  | +          : null;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        checkSubjectIds();
 | 
	
		
			
				|  |  | +        await getList();
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    );
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    onMounted(async () => {
 | 
	
		
			
				|  |  | +      // 获取教材分类列表
 | 
	
		
			
				|  |  | +      checkSubjectIds();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |        await getList();
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -300,6 +329,7 @@ export default defineComponent({
 | 
	
		
			
				|  |  |                  type="error"
 | 
	
		
			
				|  |  |                  onClick={() => {
 | 
	
		
			
				|  |  |                    forms.drag = false;
 | 
	
		
			
				|  |  | +                  forms.isEdit = false;
 | 
	
		
			
				|  |  |                    prepareStore.setIsEditResource(false);
 | 
	
		
			
				|  |  |                    forms.removeIds = [];
 | 
	
		
			
				|  |  |                    getList();
 | 
	
	
		
			
				|  | @@ -310,6 +340,7 @@ export default defineComponent({
 | 
	
		
			
				|  |  |                  type="error"
 | 
	
		
			
				|  |  |                  onClick={() => {
 | 
	
		
			
				|  |  |                    forms.removeVisiable1 = true;
 | 
	
		
			
				|  |  | +                  forms.isEdit = true;
 | 
	
		
			
				|  |  |                  }}>
 | 
	
		
			
				|  |  |                  清空资源
 | 
	
		
			
				|  |  |                </NButton>
 | 
	
	
		
			
				|  | @@ -342,7 +373,7 @@ export default defineComponent({
 | 
	
		
			
				|  |  |                  <NSelect
 | 
	
		
			
				|  |  |                    placeholder="选择声部"
 | 
	
		
			
				|  |  |                    class={styles.btnSubjectList}
 | 
	
		
			
				|  |  | -                  options={catchStore.getSubjectList}
 | 
	
		
			
				|  |  | +                  options={prepareStore.getSubjectList}
 | 
	
		
			
				|  |  |                    labelField="name"
 | 
	
		
			
				|  |  |                    valueField="id"
 | 
	
		
			
				|  |  |                    value={prepareStore.getSubjectId}
 | 
	
	
		
			
				|  | @@ -426,7 +457,7 @@ export default defineComponent({
 | 
	
		
			
				|  |  |                      </Draggable>
 | 
	
		
			
				|  |  |                    ) : (
 | 
	
		
			
				|  |  |                      <div class={styles.list}>
 | 
	
		
			
				|  |  | -                      {forms.coursewareList.map((item: any, index: number) => (
 | 
	
		
			
				|  |  | +                      {forms.coursewareList.map((item: any) => (
 | 
	
		
			
				|  |  |                          <CardType
 | 
	
		
			
				|  |  |                            class={[styles.itemContent, 'handle']}
 | 
	
		
			
				|  |  |                            isShowCollect={false}
 | 
	
	
		
			
				|  | @@ -462,7 +493,7 @@ export default defineComponent({
 | 
	
		
			
				|  |  |                {...{ id: 'lessons-3' }}
 | 
	
		
			
				|  |  |                type="primary"
 | 
	
		
			
				|  |  |                class={styles.btnClassStart}
 | 
	
		
			
				|  |  | -              onClick={() => {
 | 
	
		
			
				|  |  | +              onClick={async () => {
 | 
	
		
			
				|  |  |                  let count = 0;
 | 
	
		
			
				|  |  |                  forms.coursewareList.forEach((item: any) => {
 | 
	
		
			
				|  |  |                    if (!item.removeFlag) {
 | 
	
	
		
			
				|  | @@ -473,8 +504,40 @@ export default defineComponent({
 | 
	
		
			
				|  |  |                    message.error('课件不能为空');
 | 
	
		
			
				|  |  |                    return;
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -                forms.showAttendClass = true;
 | 
	
		
			
				|  |  | -                forms.attendClassType = 'select';
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                if (forms.classGroupId) {
 | 
	
		
			
				|  |  | +                  // 开始上课
 | 
	
		
			
				|  |  | +                  await courseScheduleStart({
 | 
	
		
			
				|  |  | +                    lessonCoursewareKnowledgeDetailId: prepareStore.selectKey,
 | 
	
		
			
				|  |  | +                    classGroupId: forms.classGroupId
 | 
	
		
			
				|  |  | +                  });
 | 
	
		
			
				|  |  | +                  if (window.matchMedia('(display-mode: standalone)').matches) {
 | 
	
		
			
				|  |  | +                    state.application = window.matchMedia(
 | 
	
		
			
				|  |  | +                      '(display-mode: standalone)'
 | 
	
		
			
				|  |  | +                    ).matches;
 | 
	
		
			
				|  |  | +                    forms.previewModal = true;
 | 
	
		
			
				|  |  | +                    forms.previewParams = {
 | 
	
		
			
				|  |  | +                      type: 'class',
 | 
	
		
			
				|  |  | +                      classGroupId: forms.classGroupId,
 | 
	
		
			
				|  |  | +                      subjectId: prepareStore.getSubjectId,
 | 
	
		
			
				|  |  | +                      detailId: prepareStore.getSelectKey
 | 
	
		
			
				|  |  | +                    };
 | 
	
		
			
				|  |  | +                  } else {
 | 
	
		
			
				|  |  | +                    const { href } = router.resolve({
 | 
	
		
			
				|  |  | +                      path: '/attend-class',
 | 
	
		
			
				|  |  | +                      query: {
 | 
	
		
			
				|  |  | +                        type: 'class',
 | 
	
		
			
				|  |  | +                        classGroupId: forms.classGroupId,
 | 
	
		
			
				|  |  | +                        subjectId: prepareStore.getSubjectId,
 | 
	
		
			
				|  |  | +                        detailId: prepareStore.getSelectKey
 | 
	
		
			
				|  |  | +                      }
 | 
	
		
			
				|  |  | +                    });
 | 
	
		
			
				|  |  | +                    window.open(href, +new Date() + '');
 | 
	
		
			
				|  |  | +                  }
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                  forms.showAttendClass = true;
 | 
	
		
			
				|  |  | +                  forms.attendClassType = 'select';
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |                }}>
 | 
	
		
			
				|  |  |                开始上课
 | 
	
		
			
				|  |  |              </NButton>
 | 
	
	
		
			
				|  | @@ -514,7 +577,15 @@ export default defineComponent({
 | 
	
		
			
				|  |  |                console.log(item, 'confirm');
 | 
	
		
			
				|  |  |                forms.className = item.name;
 | 
	
		
			
				|  |  |                forms.classGroupId = item.classGroupId;
 | 
	
		
			
				|  |  | +              forms.subjectId = item.subjectId;
 | 
	
		
			
				|  |  |                forms.showAttendClass = false;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +              checkSubjectIds();
 | 
	
		
			
				|  |  | +              // 声部切换时
 | 
	
		
			
				|  |  | +              eventGlobal.emit('onChangeClass', {
 | 
	
		
			
				|  |  | +                lastUseCoursewareId: item.lastUseCoursewareId,
 | 
	
		
			
				|  |  | +                unit: item.unit
 | 
	
		
			
				|  |  | +              });
 | 
	
		
			
				|  |  |              }}
 | 
	
		
			
				|  |  |            />
 | 
	
		
			
				|  |  |          </NModal>
 | 
	
	
		
			
				|  | @@ -590,11 +661,15 @@ export default defineComponent({
 | 
	
		
			
				|  |  |            <SubjectSync
 | 
	
		
			
				|  |  |              subjectId={prepareStore.getSubjectId as any}
 | 
	
		
			
				|  |  |              onClose={() => (forms.subjectSyncVisiable = false)}
 | 
	
		
			
				|  |  | -            onConfirm={(subjectIds: any) => {
 | 
	
		
			
				|  |  | +            onConfirm={async (subjectIds: any) => {
 | 
	
		
			
				|  |  |                //
 | 
	
		
			
				|  |  | -              console.log(subjectIds, 'subjectIds');
 | 
	
		
			
				|  |  | -              forms.editSubjectIds = subjectIds.join(',');
 | 
	
		
			
				|  |  | -              onOverEdit();
 | 
	
		
			
				|  |  | +              try {
 | 
	
		
			
				|  |  | +                forms.editSubjectIds = subjectIds.join(',');
 | 
	
		
			
				|  |  | +                await onOverEdit();
 | 
	
		
			
				|  |  | +                forms.subjectSyncVisiable = false;
 | 
	
		
			
				|  |  | +              } catch {
 | 
	
		
			
				|  |  | +                //
 | 
	
		
			
				|  |  | +              }
 | 
	
		
			
				|  |  |              }}
 | 
	
		
			
				|  |  |            />
 | 
	
		
			
				|  |  |          </NModal>
 |