import { Cell, Checkbox, CheckboxGroup, Icon, Image, Sticky } from 'vant'; import { defineComponent, onMounted, reactive, ref, watch } from 'vue'; import styles from '../index.module.less'; import class1 from '../images/ic_group_list_mussic_team_stu.png'; import class2 from '../images/ic_group_list_vip.png'; import class3 from '../images/icon_repertoire_play.png'; import class4 from '../images/icon_training.png'; import class5 from '../images/icon-edu.png'; import MSearch from '@/components/m-search'; import activeButtonIcon from '@/common/images/icon-check-active.png'; import inactiveButtonIcon from '@/common/images/icon-check.png'; import request from '@/helpers/request'; import MEmpty from '@/components/m-empty'; export default defineComponent({ name: 'group-chat', props: { height: { type: [Number], default: 0 }, bottomHeight: { type: [String, Number], default: 0 }, headerHeight: { type: [Number], default: 0 }, selectItem: { type: Array, default: () => [] } }, emits: ['update:selectItem'], setup(props, { emit }) { const checkboxRefs = ref([] as any); const forms = reactive({ keyword: '', height: props.height, list: [], check: [] as any, dataShow: true }); const formatterImage = (type: string) => { if (type === 'TRAINING') { return class4; } else if (type === 'REPERTOIRE_PLAY') { return class3; } else if (type === 'VIP' || type === 'COMM') { return class2; } else if (type === 'SCHOOL') { return class5; } else { return class1; } }; const onToggle = (index: number) => { // checkboxRefs.value[index].toggle(); const list: any = []; forms.list.forEach((item: any) => { if (forms.check.includes(item.id)) { list.push({ id: item.id, value: item.name, text: item.tags, avatar: item.img || formatterImage(item.type) }); } }); emit('update:selectItem', list); }; watch( () => props.height, () => { forms.height = props.height; // console.log(forms.height); } ); watch( () => props.selectItem, () => { initSelectItem(); }, { deep: true } ); const initSelectItem = () => { const selectItem = props.selectItem || []; const temp: any = []; selectItem.forEach((item: any) => { temp.push(item.id); }); forms.check = temp; }; const getList = async () => { try { const { data } = await request.post( '/api-web/imGroup/schoolQueryGroupList', { data: { keyword: forms.keyword } } ); forms.list = data || []; } catch { // } finally { forms.dataShow = forms.list.length > 0 ? true : false; } }; onMounted(() => { getList(); }); return () => (
{ forms.keyword = val; forms.dataShow = true; await getList(); }} /> {forms.dataShow ? ( forms.list.map((item: any, index: number) => ( onToggle(index)} class={styles.popupCell}> {{ icon: () => ( ), title: () => (
{item.name}
{item.tags}
), 'right-icon': () => ( (checkboxRefs.value[index] = e)} onClick={(e: MouseEvent) => { e.preventDefault(); e.stopPropagation(); onToggle(index); }} v-slots={{ icon: (props: any) => ( ) }} /> ) }}
)) ) : ( )}
); } });