import { defineComponent, onMounted, ref } from 'vue'; import styles from './index.module.less'; import { NButton, NSpace, useMessage } from 'naive-ui'; import { useCatchStore } from '/src/store/modules/catchData'; import iconSelect from '../../images/icon-select.png'; import { usePrepareStore } from '/src/store/modules/prepareLessons'; export default defineComponent({ name: 'subject-sync', props: { subjectId: { type: [String, Number], default: '' } }, emits: ['close', 'confirm'], setup(props, { emit }) { const catchStore = useCatchStore(); const prepareStore = usePrepareStore(); const message = useMessage(); const selectSubjectIds = ref([] as any); const subjectList = ref([] as any); const onSubmit = () => { if (selectSubjectIds.value.length <= 0) { message.error('至少选择一个声部进行同步'); return; } emit('confirm', selectSubjectIds.value); }; onMounted(async () => { // 获取教材分类列表 await catchStore.getSubjects(); const baseAllSubjectList = catchStore.getSubjectList; const teachingSubjectList = prepareStore.getSubjectList; // 教材自带声部; const tempSubjectList: any = []; baseAllSubjectList.forEach((subject: any) => { const index = teachingSubjectList.findIndex( (t: any) => t.id == subject.id ); if (index != -1) { tempSubjectList.push(subject); } }); subjectList.value = tempSubjectList; if (props.subjectId) { selectSubjectIds.value = [Number(props.subjectId)]; } }); return () => (
{subject.name}