import { defineComponent, onMounted, reactive, ref } from 'vue'; import styles from './index.module.less'; import { NButton, NForm, NFormItem, NSpace } from 'naive-ui'; import TheSearch from '/src/components/TheSearch'; import { resourceTypeArray } from '/src/utils/searchArray'; import { useCatchStore } from '/src/store/modules/catchData'; export default defineComponent({ name: 'search-group', emits: ['search'], setup(props, { emit }) { const catchStore = useCatchStore(); const resourceList = ref([] as any[]); const forms = reactive({ type: '', // keyword: '', bookVersionId: null, subjectId: null }); const onSearch = () => { emit('search', forms); }; onMounted(async () => { resourceList.value = [ { label: '全部', value: '' }, ...resourceTypeArray ]; // 获取教材分类列表 await catchStore.getMusicSheetCategory(); // 获取声部列表 await catchStore.getSubjects(); }); return () => (
{resourceList.value.map((item: any) => ( { forms.type = item.value; onSearch(); }}> {item.label} ))}
{forms.type === 'MUSIC' && ( {catchStore.getAllMusicCategories.map((music: any) => ( { forms.bookVersionId = music.id; onSearch(); }}> {music.name} ))} )} {catchStore.getSubjectAllList.map((subject: any) => ( { forms.subjectId = subject.id; onSearch(); }}> {subject.name} ))} { forms.keyword = val; onSearch(); }} />
); } });