import MSticky from '@/components/m-sticky'; import { useRect } from '@vant/use'; import { Button, Tab, Tabs } from 'vant'; import { defineComponent, onMounted, reactive, watch } from 'vue'; import styles from './index.module.less'; import MHeader from '@/components/m-header'; import GroupChat from './components/group-chat'; import Contacts from './components/contacts'; export default defineComponent({ name: 'select-send', props: { selectObject: { type: Object, default: () => ({}) }, selectStatus: { type: Boolean, default: false } }, emits: ['close', 'update:selectObject', 'confirm'], setup(props, { emit }) { const state = reactive({ headerHeight: 0, height: 0, bottomHeight: 0, tabValue: 'groupChat', selectGroupChat: [] as any, selectContacts: [] as any }); const onSubmit = async () => { const params = { groupChat: state.selectGroupChat, contacts: state.selectContacts }; emit('close'); console.log(params, 'selectSend'); emit('update:selectObject', params); emit('confirm', params); }; watch( () => props.selectObject, () => { resetSelectItems(); }, { deep: true } ); const resetSelectItems = () => { const list = props.selectObject || {}; state.selectGroupChat = list.groupChat || []; state.selectContacts = list.contacts || []; }; onMounted(() => { const { height } = useRect( document.querySelector('.van-tab') as HTMLElement ); state.height = height; resetSelectItems(); console.log(state, 'select'); }); return () => (
{ state.headerHeight = height; }}> { state.bottomHeight = height; }}>
); } });