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, ActionSheet } 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' import { useRect } from '@vant/use' // {"subjectId":null,"search":"","sort":"starGrade ASC,expTime DESC,subjectPrice DESC"} const actions = [ { name: '不限制', value: '', color: 'var(--van-primary)' }, { name: '单价最高', value: 'subjectPrice DESC', color: '#333' }, { name: '单价最低', value: 'subjectPrice ASC', color: '#333' }, { name: '课时数最多', value: 'expTime DESC', color: '#333' }, { name: '评分最高', value: 'starGrade DESC', color: '#333' } ] 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' }, dataLoading: false, params: { search: '', sort: '', subjectName: '', isScreen: false, subjectId: null as any, page: 1, rows: 20 }, show: false, height: 'auto' as any } }, 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 {} const { height } = useRect((this as any).$refs.headers) this.height = height this.getList() }, methods: { onSearch(_search?: any) { this.params.search = _search this.onSort() }, onSort() { this.params.page = 1 this.list = [] this.dataShow = true // 判断是否有数据 this.loading = false this.finished = false this.searchStatus = false this.getList() }, onSheetSelect(item: any) { actions.forEach((v: any) => { v.color = '#333' if (v.value === item.value) { v.color = 'var(--van-primary)' } }) this.params.sort = item.value this.show = false this.onSort() }, async getList() { try { if (this.dataLoading) { return } this.dataLoading = true const res = await request.post( '/api-student/courseSchedule/teacherList', { data: { ...this.params } } ) this.dataLoading = false this.loading = false 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 { this.dataShow = false this.finished = true } } }, render() { return (