import OSticky from '@/components/o-sticky' import { useRect } from '@vant/use' import { Button, Sticky, Tab, Tabs } from 'vant' import { defineComponent, onMounted, reactive, ref, watch } from 'vue' import ClassList from './component/class-list' import ManageList from './component/manage-list' import StudentList from './component/student-list' import TeacherList from './component/teacher-list/teacher-list' import styles from './index.module.less' export default defineComponent({ name: 'select-send', props: { selectList: { type: Object, default: {} }, selectStatus: { type: Boolean, default: false } }, emits: ['close', 'confirm', 'update:selectList'], setup(props, { emit, expose }) { const state = reactive({ height: 'auto' as any, tabValue: 'class', selectClass: [] as any, selectStudent: [] as any, selectTeacher: [] as any, selectManage: [] as any }) const onSubmit = async () => { const params = { class: state.selectClass, student: state.selectStudent, teacher: state.selectTeacher, school: state.selectManage } emit('close') emit('update:selectList', params) emit('confirm', params) } watch( () => props.selectList, () => { console.log('watch', props.selectList) resetSelectItems() }, { deep: true } ) const resetSelectItems = () => { const list = props.selectList || {} state.selectClass = list.class || [] state.selectTeacher = list.teacher || [] state.selectManage = list.manage || [] state.selectStudent = list.student || [] } onMounted(() => { const { height } = useRect(document.querySelector('.van-tab') as HTMLElement) state.height = height resetSelectItems() console.log(state, 'select') }) return () => (
) } })