import OSearch from '@/components/o-search' import OEmpty from '@/components/o-empty' import dayjs from 'dayjs' import OFullRefresh from '@/components/o-full-refresh' import { Icon, Popover, DatePicker, DatePickerColumnType, Popup, List, PullRefresh, ActionSheet, showToast, Sticky, Picker } from 'vant' import { defineComponent, reactive, ref, onMounted, watch } from 'vue' import { useRouter } from 'vue-router' import styles from './attent-student.module.less' import request from '@/helpers/request' import { state as globalState } from '@/state' import StudentAttItem from '../modals/studentAtt-item' export default defineComponent({ name: 'attend-student', props: { toHeight: { type: Number, default: 0 } }, setup(props, { emit }) { const router = useRouter() const state = reactive({ showPopoverTime: false, showPopoverOrchestra: false, showPopoverSubject: false, actions: [] as any, subjects: [] as any, currentDate: [dayjs().format('YYYY'), dayjs().format('MM')] }) const forms = reactive({ time: state.currentDate[0] + '' + state.currentDate[1], timeName: state.currentDate[0] + '年' + state.currentDate[1] + '月', orchestraId: '', orchestraName: '全部乐团', subjectId: '', subjectName: '全部声部', page: 1, rows: 20 }) const toTop = ref(props.toHeight) const minDate = ref(new Date(dayjs().subtract(10, 'year').format('YYYY-MM-DD'))) const maxDate = ref(new Date(dayjs().add(10, 'year').format('YYYY-MM-DD'))) const columnsType = ref(['year', 'month']) const refreshing = ref(false) const loading = ref(false) const finished = ref(false) const showContact = ref(false) const list = ref([]) const getList = async () => { loading.value = true try { if (refreshing.value) { // forms.page = 1 list.value = [] refreshing.value = false } const res = await request.post( '/api-school/courseScheduleStudentAttendance/studentAttendance', { data: { ...forms } } ) if (list.value.length > 0 && res.data.pages === 1) { return } // forms.page = res.data.current + 1 list.value = res.data showContact.value = list.value.length > 0 // console.log(showContact.value, ' showContact.value ') loading.value = false finished.value = true } catch (e: any) { // console.log(e, 'e') const message = e.message showToast(message) showContact.value = false finished.value = true } } const checkTimer = (val: any) => { forms.time = val.selectedValues[0] + val.selectedValues[1] forms.timeName = val.selectedValues[0] + '年' + val.selectedValues[1] + '月' state.showPopoverTime = false getList() } const checkOrchestra = (val: any) => { const selectedOptions = val.selectedOptions[0] || {} forms.orchestraId = selectedOptions.value forms.orchestraName = selectedOptions.name state.showPopoverOrchestra = false refreshing.value = true getList() } const checkSubject = (val: any) => { const selectedOptions = val.selectedOptions[0] || {} forms.subjectId = selectedOptions.value forms.subjectName = selectedOptions.name state.showPopoverSubject = false refreshing.value = true getList() } const getOrchestraList = async () => { try { const res = await request.post('/api-teacher/orchestra/page', { data: { page: 1, rows: 9999, status: 'DONE' } }) state.actions = res.data.rows.map((item) => { return { name: item.name, value: item.id as string } }) } catch (e: any) { const message = e.message showToast(message) } } const getSubjects = async () => { try { const res = await request.post('/api-school/subjectBasicConfig/page', { data: { page: 1, rows: 9999 } }) state.subjects = res.data.rows.map((item) => { return { name: item.subjectName, value: item.subjectId as string } }) state.subjects.unshift({ name: '全部声部', value: '' }) } catch (e: any) { const message = e.message showToast(message) } } onMounted(() => { getSubjects() getOrchestraList() getList() }) watch( () => props.toHeight, (val: number) => { toTop.value = val } ) const onRefresh = () => { finished.value = false // 重新加载数据 // 将 loading 设置为 true,表示处于加载状态 loading.value = true getList() } return () => (
{/* */}
{ state.showPopoverTime = true }} >

{forms.timeName}

{ state.showPopoverOrchestra = true }} >

{forms.orchestraName}

{ state.showPopoverSubject = true }} >

{forms.subjectName}

{/*
*/} {showContact.value ? ( {list.value.map((item: any) => ( ))} ) : ( )} { state.showPopoverTime = false }} onConfirm={checkTimer} v-model={state.currentDate} title="选择年月" minDate={minDate.value} maxDate={maxDate.value} columnsType={columnsType.value} /> {/* */} (state.showPopoverOrchestra = false)} onConfirm={(val: any) => checkOrchestra(val)} columnsFieldNames={{ text: 'name', value: 'value' }} /> (state.showPopoverSubject = false)} onConfirm={(val: any) => checkSubject(val)} columnsFieldNames={{ text: 'name', value: 'value' }} />
) } })