import { defineComponent } from 'vue' import styles from './index.module.less' import ColHeader from '@/components/col-header' import { Button, Icon, Popup, RadioGroup, Sticky, Radio, Tag, List } from 'vant' import ColSearch from '@/components/col-search' import PracticeItem from './practice-item' import request from '@/helpers/request' import ColResult from '@/components/col-result' import AllSearch from './model/all-search' import OrganSearch from './model/organ-search' import { state } from '@/state' export default defineComponent({ name: 'practiceClass', data() { return { openStatus: false, searchStatus: false, subjectList: [], list: [], dataShow: true, // 判断是否有数据 loading: false, finished: false, searchType: 'organ' as 'organ' | 'all', tempSort: { starGrade: 'ALL', expTime: 'ALL', subjectPrice: 'ALL' }, params: { search: '', sort: '', subjectName: '', subjectId: null as any, page: 1, rows: 20 } } }, async mounted() { this.params.subjectId = state.user.data?.subjectId || null this.params.subjectName = state.user.data?.subjectName || '' try { const res = await request.get('/api-student/subject/subjectSelect') this.subjectList = res.data || [] } catch {} this.getList() }, methods: { onSearch(_search?: any) { this.params.search = _search this.onSort() }, onSort(type?: any) { const popupParams = type || this.tempSort let str: any = [] for (let i in popupParams) { if (popupParams[i] !== 'ALL') { str.push(`${i} ${popupParams[i]}`) } } this.params.sort = str.join(',') this.params.page = 1 this.list = [] this.dataShow = true // 判断是否有数据 this.loading = false this.finished = false this.searchStatus = false this.getList() }, async getList() { try { const res = await request.post( '/api-student/courseSchedule/teacherList', { data: { ...this.params } } ) const result = res.data || {} // 处理重复请求数据 if (this.list.length > 0 && result.pageNo === 1) { return } this.list = this.list.concat(result.rows || []) this.finished = result.pageNo >= result.totalPage this.params.page = result.pageNo + 1 this.dataShow = this.list.length > 0 } catch {} } }, render() { return ( <>
{/* */}
{ this.searchStatus = !this.searchStatus this.searchType = 'all' }} > 筛选
{this.dataShow ? ( {this.list.map((item: any) => ( { this.$router.push({ path: '/teacherHome', query: { teacherId: item.teacherId, tabs: 'practice' } }) }} /> ))} ) : ( )} (this.searchStatus = false)} onClosed={() => (this.openStatus = false)} > {this.searchType === 'all' && } {this.searchType === 'organ' && this.openStatus && ( )} ) } })