import { Search } from '@element-plus/icons-vue' import { defineComponent, toRefs, reactive, onMounted, ref, watch } from 'vue' import { ElButton, ElForm, ElFormItem, ElInput, ElSelect, ElOption, ElIcon } from 'element-plus' // import white from './while.module.less' import classes from './index.module.less' import request from '@/helpers/request' import searchIcon from './images/searchIcon.png' export default defineComponent({ name: 'searchInput', props: { title: { type: String, default: '' }, isWhile: { type: Boolean, default: true }, searchVal: { type: Object, default: {} }, holder: { type: String, default: '搜一搜你想练习的曲目' } }, emits: ['startSearch'], setup(props, conent) { const state = reactive({ title: props.title, search: props.searchVal.search, subject: null as null | number | string, subjectList: [], holder: props.holder }) watch( () => props.searchVal, searchVal => { // console.log(searchVal,'searchVal') state.search = searchVal.search ? searchVal.search : '' state.subject = Number(props.searchVal.subject || props.searchVal.lessonSubject) ? Number(props.searchVal.subject|| props.searchVal.lessonSubject) : '' }, { deep: true } ) const getSubjectList = async () => { console.log('调用') try { const res = await request.get( '/api-website/open/subject/queryPage', {params:{rows:9999,page:1}} ) state.subjectList = res.data.rows } catch (e) { console.log(e) } } const startSearch = () => { conent.emit('startSearch', { search: state.search, subject: state.subject }) } onMounted(() => { getSubjectList() }) // let classStyle = classes return () => ( <> {/* props.isWhile ? classStyle.While : '' */}
}} > {state.subjectList.map((item: any) => ( ))}
{ // if (e.keyCode === 13) { // startSearch() // } // }} >
搜索
) } })