|
@@ -1,6 +1,6 @@
|
|
|
import {
|
|
|
+ computed,
|
|
|
defineComponent,
|
|
|
- nextTick,
|
|
|
onMounted,
|
|
|
reactive,
|
|
|
ref,
|
|
@@ -10,22 +10,19 @@ import styles from './index.module.less';
|
|
|
import {
|
|
|
NButton,
|
|
|
NTooltip,
|
|
|
- NCarousel,
|
|
|
NIcon,
|
|
|
NImage,
|
|
|
- NInput,
|
|
|
NModal,
|
|
|
NScrollbar,
|
|
|
- NSelect,
|
|
|
- NSpace,
|
|
|
NSpin,
|
|
|
NTabPane,
|
|
|
NTabs,
|
|
|
- useMessage
|
|
|
+ useMessage,
|
|
|
+ NPopselect
|
|
|
} from 'naive-ui';
|
|
|
import { usePrepareStore } from '/src/store/modules/prepareLessons';
|
|
|
import add from '@/views/studentList/images/add.png';
|
|
|
-import iconSlideRight from '../../../images/icon-slide-right.png';
|
|
|
+// import iconSlideRight from '../../../images/icon-slide-right.png';
|
|
|
import CoursewareType from '../../../model/courseware-type';
|
|
|
import TheEmpty from '/src/components/TheEmpty';
|
|
|
import RelatedClass from '../../../model/related-class';
|
|
@@ -35,8 +32,6 @@ import AttendClass from '/src/views/prepare-lessons/model/attend-class';
|
|
|
import {
|
|
|
api_addByOpenCourseware,
|
|
|
api_teacherChapterLessonCoursewareRemove,
|
|
|
- api_queryOpenCoursewareByPage,
|
|
|
- api_updateCoursewareInfo,
|
|
|
teacherChapterLessonCoursewareList,
|
|
|
courseScheduleStart
|
|
|
} from '../../../api';
|
|
@@ -71,8 +66,8 @@ export default defineComponent({
|
|
|
leftWidth: '100%',
|
|
|
rightWidth: '0',
|
|
|
messageLoading: false,
|
|
|
- subjectId: route.query.subjectId
|
|
|
- ? Number(route.query.subjectId)
|
|
|
+ instrumentId: route.query.instrumentId
|
|
|
+ ? Number(route.query.instrumentId)
|
|
|
: localStorageSubjectId
|
|
|
? Number(localStorageSubjectId)
|
|
|
: '',
|
|
@@ -100,10 +95,11 @@ export default defineComponent({
|
|
|
previewParams: {
|
|
|
type: '',
|
|
|
courseId: '',
|
|
|
- subjectId: '',
|
|
|
+ instrumentId: '',
|
|
|
detailId: ''
|
|
|
} as any,
|
|
|
- workVisiable: false
|
|
|
+ workVisiable: false,
|
|
|
+ wikiCategoryIdChild: null
|
|
|
});
|
|
|
|
|
|
const getCoursewareList = async () => {
|
|
@@ -113,7 +109,7 @@ export default defineComponent({
|
|
|
if (!prepareStore.getSelectKey) return (forms.loading = false);
|
|
|
|
|
|
const { data } = await teacherChapterLessonCoursewareList({
|
|
|
- subjectId: prepareStore.getSubjectId,
|
|
|
+ instrumentId: prepareStore.getInstrumentId,
|
|
|
coursewareDetailKnowledgeId: prepareStore.getSelectKey
|
|
|
});
|
|
|
if (!Array.isArray(data)) {
|
|
@@ -145,7 +141,7 @@ export default defineComponent({
|
|
|
|
|
|
// 监听选择的key 左侧选择了其它的课
|
|
|
watch(
|
|
|
- () => [prepareStore.getSelectKey, prepareStore.getSubjectId],
|
|
|
+ () => [prepareStore.getSelectKey, prepareStore.getInstrumentId],
|
|
|
async () => {
|
|
|
eventGlobal.emit('openCoursewareChanged');
|
|
|
await getCoursewareList();
|
|
@@ -156,22 +152,22 @@ export default defineComponent({
|
|
|
);
|
|
|
|
|
|
watch(
|
|
|
- () => prepareStore.getSubjectList,
|
|
|
+ () => prepareStore.getInstrumentList,
|
|
|
() => {
|
|
|
- checkSubjectIds();
|
|
|
+ checkInstrumentIds();
|
|
|
}
|
|
|
);
|
|
|
|
|
|
- const checkSubjectIds = () => {
|
|
|
- const subjectList = prepareStore.getSubjectList;
|
|
|
+ const checkInstrumentIds = () => {
|
|
|
+ const instrumentsList = prepareStore.getSingleInstrumentList;
|
|
|
|
|
|
// 并且没有声部时才会更新
|
|
|
- if (subjectList.length > 0) {
|
|
|
+ if (instrumentsList.length > 0) {
|
|
|
const prepareLessonCourseWareSubjectIsNull = sessionStorage.getItem(
|
|
|
'prepareLessonCourseWareSubjectIsNull'
|
|
|
);
|
|
|
if (prepareLessonCourseWareSubjectIsNull === 'true') {
|
|
|
- prepareStore.setSubjectId('');
|
|
|
+ prepareStore.setInstrumentId('');
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -180,57 +176,72 @@ export default defineComponent({
|
|
|
'prepareLessonSubjectId'
|
|
|
);
|
|
|
// // 先取 上次上课声部,在取班级声部 最后取缓存
|
|
|
- let subjectId = null;
|
|
|
+ let instrumentId = null;
|
|
|
let index = -1;
|
|
|
if (forms.courseScheduleSubjectId) {
|
|
|
// 判断浏览器上面是否有
|
|
|
- index = subjectList.findIndex(
|
|
|
+ index = instrumentsList.findIndex(
|
|
|
(subject: any) => subject.id == forms.courseScheduleSubjectId
|
|
|
);
|
|
|
if (index >= 0) {
|
|
|
- subjectId = Number(forms.courseScheduleSubjectId);
|
|
|
+ instrumentId = Number(forms.courseScheduleSubjectId);
|
|
|
}
|
|
|
}
|
|
|
// 判断班级上面声部 & 还没有声部
|
|
|
- if (forms.subjectId && !subjectId) {
|
|
|
+ if (forms.instrumentId && !instrumentId) {
|
|
|
// 判断浏览器上面是否有
|
|
|
- index = subjectList.findIndex(
|
|
|
- (subject: any) => subject.id == forms.subjectId
|
|
|
+ index = instrumentsList.findIndex(
|
|
|
+ (subject: any) => subject.id == forms.instrumentId
|
|
|
);
|
|
|
if (index >= 0) {
|
|
|
- subjectId = Number(forms.subjectId);
|
|
|
+ instrumentId = Number(forms.instrumentId);
|
|
|
}
|
|
|
}
|
|
|
// 缓存声部 & 还没有声部
|
|
|
- if (localStorageSubjectId && !subjectId) {
|
|
|
+ if (localStorageSubjectId && !instrumentId) {
|
|
|
// 判断浏览器上面是否有
|
|
|
- index = subjectList.findIndex(
|
|
|
+ index = instrumentsList.findIndex(
|
|
|
(subject: any) => subject.id == localStorageSubjectId
|
|
|
);
|
|
|
if (index >= 0) {
|
|
|
- subjectId = Number(localStorageSubjectId);
|
|
|
+ instrumentId = Number(localStorageSubjectId);
|
|
|
}
|
|
|
}
|
|
|
// 判断是否选择为空
|
|
|
- if (subjectId && index >= 0) {
|
|
|
- prepareStore.setSubjectId(subjectId);
|
|
|
- // forms.subjectId = subjectId;
|
|
|
+ if (instrumentId && index >= 0) {
|
|
|
+ prepareStore.setSubjectId(instrumentId);
|
|
|
+ // forms.instrumentId = instrumentId;
|
|
|
} else {
|
|
|
// 判断是否有缓存
|
|
|
- // prepareStore.setSubjectId(subjectList[0].id);
|
|
|
- // forms.subjectId = subjectList[0].id;
|
|
|
+ // prepareStore.setSubjectId(instrumentsList[0].id);
|
|
|
+ // forms.instrumentId = instrumentsList[0].id;
|
|
|
}
|
|
|
|
|
|
// 保存
|
|
|
localStorage.setItem(
|
|
|
'prepareLessonSubjectId',
|
|
|
- prepareStore.getSubjectId as any
|
|
|
+ prepareStore.getInstrumentId as any
|
|
|
);
|
|
|
|
|
|
subjectRef.value?.syncBarPosition();
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ const getInitInstrumentId = () => {
|
|
|
+ let instrumentId: any = '';
|
|
|
+ prepareStore.getInstrumentList.forEach((item: any) => {
|
|
|
+ if (Array.isArray(item.instruments)) {
|
|
|
+ item.instruments.forEach((child: any) => {
|
|
|
+ if (child.id === prepareStore.getInstrumentId) {
|
|
|
+ instrumentId = child.id;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (instrumentId) {
|
|
|
+ forms.wikiCategoryIdChild = instrumentId;
|
|
|
+ }
|
|
|
+ };
|
|
|
const subjectRef = ref();
|
|
|
onMounted(async () => {
|
|
|
useResizeObserver(
|
|
@@ -251,35 +262,20 @@ export default defineComponent({
|
|
|
);
|
|
|
|
|
|
prepareStore.setClassGroupId(route.query.classGroupId as any);
|
|
|
- if (!prepareStore.getSubjectId) {
|
|
|
+ if (!prepareStore.getInstrumentId) {
|
|
|
// 获取教材分类列表
|
|
|
- checkSubjectIds();
|
|
|
+ checkInstrumentIds();
|
|
|
+ } else {
|
|
|
+ getInitInstrumentId();
|
|
|
}
|
|
|
|
|
|
await getCoursewareList();
|
|
|
|
|
|
- // console.log(props.addParam, 'addCourseware');
|
|
|
if (props.addParam.isAdd) {
|
|
|
forms.addVisiable = true;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- // 重命名
|
|
|
- // const onEditTitleSubmit = async () => {
|
|
|
- // try {
|
|
|
- // await api_updateCoursewareInfo({
|
|
|
- // id: forms.selectItem.id,
|
|
|
- // name: forms.editTitle
|
|
|
- // });
|
|
|
- // message.success('修改成功');
|
|
|
- // getCoursewareList();
|
|
|
- // // getOpenCoursewareList()
|
|
|
- // forms.editTitleVisiable = false;
|
|
|
- // } catch {
|
|
|
- // //
|
|
|
- // }
|
|
|
- // };
|
|
|
-
|
|
|
// 删除
|
|
|
const onRemove = async () => {
|
|
|
forms.messageLoading = true;
|
|
@@ -330,7 +326,7 @@ export default defineComponent({
|
|
|
forms.previewParams = {
|
|
|
type: 'preview',
|
|
|
courseId: id,
|
|
|
- subjectId: prepareStore.getSubjectId,
|
|
|
+ instrumentId: prepareStore.getInstrumentId,
|
|
|
detailId: prepareStore.getSelectKey,
|
|
|
lessonCourseId: prepareStore.getBaseCourseware.id
|
|
|
};
|
|
@@ -340,7 +336,7 @@ export default defineComponent({
|
|
|
query: {
|
|
|
type: 'preview',
|
|
|
courseId: id,
|
|
|
- subjectId: prepareStore.getSubjectId,
|
|
|
+ instrumentId: prepareStore.getInstrumentId,
|
|
|
detailId: prepareStore.getSelectKey,
|
|
|
lessonCourseId: prepareStore.getBaseCourseware.id
|
|
|
}
|
|
@@ -352,7 +348,7 @@ export default defineComponent({
|
|
|
const onStartClass = async (
|
|
|
item: any,
|
|
|
classGroupId: any,
|
|
|
- subjectId?: any
|
|
|
+ instrumentId?: any
|
|
|
) => {
|
|
|
if (classGroupId) {
|
|
|
// 开始上课
|
|
@@ -360,7 +356,7 @@ export default defineComponent({
|
|
|
lessonCoursewareKnowledgeDetailId: prepareStore.selectKey,
|
|
|
classGroupId: classGroupId,
|
|
|
useChapterLessonCoursewareId: item.id
|
|
|
- // subjectId: prepareStore.getSubjectId
|
|
|
+ // instrumentId: prepareStore.getInstrumentId
|
|
|
});
|
|
|
if (window.matchMedia('(display-mode: standalone)').matches) {
|
|
|
state.application = window.matchMedia(
|
|
@@ -372,7 +368,7 @@ export default defineComponent({
|
|
|
type: 'class',
|
|
|
classGroupId: classGroupId,
|
|
|
courseId: item.id,
|
|
|
- subjectId: subjectId || route.query.subjectId,
|
|
|
+ instrumentId: instrumentId || route.query.instrumentId,
|
|
|
detailId: prepareStore.getSelectKey,
|
|
|
classId: res.data,
|
|
|
lessonCourseId: prepareStore.getBaseCourseware.id,
|
|
@@ -385,7 +381,7 @@ export default defineComponent({
|
|
|
type: 'class',
|
|
|
classGroupId: classGroupId,
|
|
|
courseId: item.id,
|
|
|
- subjectId: prepareStore.getSubjectId,
|
|
|
+ instrumentId: prepareStore.getInstrumentId,
|
|
|
detailId: prepareStore.getSelectKey,
|
|
|
classId: res.data,
|
|
|
lessonCourseId: prepareStore.getBaseCourseware.id,
|
|
@@ -401,14 +397,32 @@ export default defineComponent({
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- // const carouselRef = ref();
|
|
|
- // const onChangeSlide = (type: 'left' | 'right') => {
|
|
|
- // if (type === 'left') {
|
|
|
- // carouselRef.value?.prev();
|
|
|
- // } else if (type === 'right') {
|
|
|
- // carouselRef.value?.next();
|
|
|
- // }
|
|
|
- // };
|
|
|
+ const selectChildObj = (item: any, index: number) => {
|
|
|
+ const obj: any = {};
|
|
|
+ item?.forEach((child: any) => {
|
|
|
+ if (child.id === forms.wikiCategoryIdChild) {
|
|
|
+ obj.selected = true;
|
|
|
+ obj.name = child.name;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return obj;
|
|
|
+ };
|
|
|
+
|
|
|
+ const tabInstrumentValue = computed(() => {
|
|
|
+ let instrumentId: any = prepareStore.getInstrumentId
|
|
|
+ ? prepareStore.getInstrumentId
|
|
|
+ : '';
|
|
|
+ prepareStore.getInstrumentList.forEach((item: any) => {
|
|
|
+ if (Array.isArray(item.instruments)) {
|
|
|
+ item.instruments.forEach((child: any) => {
|
|
|
+ if (child.id === prepareStore.getInstrumentId) {
|
|
|
+ instrumentId = item.id + '';
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return instrumentId;
|
|
|
+ });
|
|
|
return () => (
|
|
|
<div
|
|
|
class={[
|
|
@@ -425,15 +439,16 @@ export default defineComponent({
|
|
|
paneClass={styles.paneTitle}
|
|
|
justifyContent="start"
|
|
|
paneWrapperClass={styles.paneWrapperContainer}
|
|
|
- value={
|
|
|
- prepareStore.getSubjectId
|
|
|
- ? prepareStore.getSubjectId?.toString()
|
|
|
- : ''
|
|
|
- }
|
|
|
- onUpdate:value={val => {
|
|
|
- prepareStore.setSubjectId(val);
|
|
|
- // 保存
|
|
|
- forms.subjectId = val;
|
|
|
+ value={tabInstrumentValue.value}
|
|
|
+ onUpdate:value={(val: any) => {
|
|
|
+ prepareStore.getInstrumentList.forEach((item: any) => {
|
|
|
+ if (item.id.toString() === val.toString()) {
|
|
|
+ prepareStore.setInstrumentId(val);
|
|
|
+ // 保存
|
|
|
+ forms.instrumentId = val;
|
|
|
+ forms.wikiCategoryIdChild = null;
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
if (!val) {
|
|
|
sessionStorage.setItem(
|
|
@@ -463,14 +478,54 @@ export default defineComponent({
|
|
|
</NButton>
|
|
|
)
|
|
|
}}>
|
|
|
- {[{ name: '全部声部', id: '' }, ...prepareStore.getSubjectList].map(
|
|
|
- (item: any) => (
|
|
|
- <NTabPane
|
|
|
- name={`${item.id}`}
|
|
|
- tab={item.name}
|
|
|
- displayDirective="if"></NTabPane>
|
|
|
- )
|
|
|
- )}
|
|
|
+ {[
|
|
|
+ { name: '全部乐器', id: '' },
|
|
|
+ ...prepareStore.getFormatInstrumentList
|
|
|
+ ].map((item: any, index: number) => (
|
|
|
+ <NTabPane
|
|
|
+ name={`${item.id}`}
|
|
|
+ tab={item.name}
|
|
|
+ disabled={item.instruments?.length > 0}
|
|
|
+ displayDirective="if">
|
|
|
+ {{
|
|
|
+ tab: () =>
|
|
|
+ item.instruments?.length > 0 ? (
|
|
|
+ <NPopselect
|
|
|
+ options={item.instruments}
|
|
|
+ trigger="hover"
|
|
|
+ v-model:value={forms.wikiCategoryIdChild}
|
|
|
+ onUpdate:value={(val: any) => {
|
|
|
+ // onSearch();
|
|
|
+ prepareStore.setInstrumentId(val);
|
|
|
+ // 保存
|
|
|
+ forms.instrumentId = val;
|
|
|
+
|
|
|
+ if (!val) {
|
|
|
+ sessionStorage.setItem(
|
|
|
+ 'prepareLessonCourseWareSubjectIsNull',
|
|
|
+ val ? 'false' : 'true'
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ key={item.id}
|
|
|
+ class={styles.popSelect}>
|
|
|
+ <span
|
|
|
+ class={[
|
|
|
+ styles.textBtn,
|
|
|
+ selectChildObj(item.instruments, index).selected &&
|
|
|
+ styles.textBtnActive
|
|
|
+ ]}>
|
|
|
+ {selectChildObj(item.instruments, index).name ||
|
|
|
+ item.name}
|
|
|
+ <i class={styles.iconArrow}></i>
|
|
|
+ </span>
|
|
|
+ </NPopselect>
|
|
|
+ ) : (
|
|
|
+ item.name
|
|
|
+ )
|
|
|
+ }}
|
|
|
+ </NTabPane>
|
|
|
+ ))}
|
|
|
</NTabs>
|
|
|
<NSpin show={forms.loading}>
|
|
|
<NScrollbar class={styles.coursewarePresets}>
|
|
@@ -576,8 +631,8 @@ export default defineComponent({
|
|
|
blockScroll={false}>
|
|
|
<RelatedClass
|
|
|
tableList={forms.tableList}
|
|
|
- subjectList={prepareStore.getSubjectList}
|
|
|
- subjectId={prepareStore.getSubjectId as any}
|
|
|
+ instrumentList={prepareStore.getInstrumentList}
|
|
|
+ instrumentId={prepareStore.getInstrumentId as any}
|
|
|
coursewareDetailKnowledgeId={prepareStore.getSelectKey}
|
|
|
onClose={() => (forms.showRelatedClass = false)}
|
|
|
onAdd={(item: any) => onAddCourseware(item)}
|
|
@@ -697,7 +752,7 @@ export default defineComponent({
|
|
|
onStartClass(
|
|
|
forms.attendClassItem,
|
|
|
item.classGroupId,
|
|
|
- item.subjectId
|
|
|
+ item.instrumentId
|
|
|
);
|
|
|
}}
|
|
|
/>
|