index.tsx 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. import { defineComponent } from 'vue'
  2. import styles from './index.module.less'
  3. import ColHeader from '@/components/col-header'
  4. import { Button, Icon, Popup, RadioGroup, Sticky, Radio, Tag, List } from 'vant'
  5. import ColSearch from '@/components/col-search'
  6. import PracticeItem from './practice-item'
  7. import request from '@/helpers/request'
  8. import ColResult from '@/components/col-result'
  9. import AllSearch from './model/all-search'
  10. import OrganSearch from './model/organ-search'
  11. import { state } from '@/state'
  12. export default defineComponent({
  13. name: 'practiceClass',
  14. data() {
  15. return {
  16. openStatus: false,
  17. searchStatus: false,
  18. subjectList: [],
  19. list: [],
  20. dataShow: true, // 判断是否有数据
  21. loading: false,
  22. finished: false,
  23. searchType: 'organ' as 'organ' | 'all',
  24. tempSort: {
  25. starGrade: 'ALL',
  26. expTime: 'ALL',
  27. subjectPrice: 'ALL'
  28. },
  29. params: {
  30. search: '',
  31. sort: '',
  32. subjectName: '',
  33. subjectId: null as any,
  34. page: 1,
  35. rows: 20
  36. }
  37. }
  38. },
  39. async mounted() {
  40. this.params.subjectId = state.user.data?.subjectId || null
  41. this.params.subjectName = state.user.data?.subjectName || ''
  42. try {
  43. const res = await request.get('/api-student/subject/subjectSelect')
  44. this.subjectList = res.data || []
  45. } catch {}
  46. this.getList()
  47. },
  48. methods: {
  49. onSearch(_search?: any) {
  50. this.params.search = _search
  51. this.onSort()
  52. },
  53. onSort(type?: any) {
  54. const popupParams = type || this.tempSort
  55. let str: any = []
  56. for (let i in popupParams) {
  57. if (popupParams[i] !== 'ALL') {
  58. str.push(`${i} ${popupParams[i]}`)
  59. }
  60. }
  61. this.params.sort = str.join(',')
  62. this.params.page = 1
  63. this.list = []
  64. this.dataShow = true // 判断是否有数据
  65. this.loading = false
  66. this.finished = false
  67. this.searchStatus = false
  68. this.getList()
  69. },
  70. async getList() {
  71. try {
  72. const res = await request.post(
  73. '/api-student/courseSchedule/teacherList',
  74. {
  75. data: {
  76. ...this.params
  77. }
  78. }
  79. )
  80. const result = res.data || {}
  81. // 处理重复请求数据
  82. if (this.list.length > 0 && result.pageNo === 1) {
  83. return
  84. }
  85. this.list = this.list.concat(result.rows || [])
  86. this.finished = result.pageNo >= result.totalPage
  87. this.params.page = result.pageNo + 1
  88. this.dataShow = this.list.length > 0
  89. } catch {}
  90. }
  91. },
  92. render() {
  93. return (
  94. <>
  95. <Sticky style={{ background: 'var(--van-primary)' }}>
  96. <ColHeader
  97. title="陪练课"
  98. isFixed={false}
  99. border={false}
  100. backIconColor="white"
  101. background="var(--van-primary)"
  102. color="#fff"
  103. />
  104. <ColSearch
  105. placeholder="请输入老师名称/课程名称"
  106. inputBackground="white"
  107. background="var(--van-primary)"
  108. onSearch={this.onSearch}
  109. />
  110. <div class={styles.filterSection}>
  111. <div>
  112. <Button
  113. class={[styles.btn]}
  114. type="primary"
  115. size="small"
  116. round
  117. plain
  118. onClick={() => {
  119. this.searchStatus = !this.searchStatus
  120. this.openStatus = !this.openStatus
  121. this.searchType = 'organ'
  122. }}
  123. >
  124. {this.params.subjectName}
  125. <Icon
  126. classPrefix="iconfont"
  127. name="down"
  128. size={8}
  129. style={{ marginLeft: '4px' }}
  130. color="var(--van-primary)"
  131. />
  132. </Button>
  133. {/* <Button class={[styles.btn]} size="small" round plain>
  134. 30天内未约满
  135. </Button> */}
  136. </div>
  137. <div>
  138. <div
  139. class={styles.dataItem}
  140. onClick={() => {
  141. this.searchStatus = !this.searchStatus
  142. this.searchType = 'all'
  143. }}
  144. >
  145. 筛选
  146. <Icon
  147. classPrefix="iconfont"
  148. name="down"
  149. size={8}
  150. style={{ marginLeft: '4px' }}
  151. color="var(--van-primary)"
  152. />
  153. </div>
  154. </div>
  155. </div>
  156. </Sticky>
  157. {this.dataShow ? (
  158. <List
  159. v-model:loading={this.loading}
  160. finished={this.finished}
  161. finishedText=" "
  162. immediateCheck={false}
  163. class={[styles.practiceList, 'mb12']}
  164. onLoad={this.getList}
  165. >
  166. {this.list.map((item: any) => (
  167. <PracticeItem
  168. item={item}
  169. onClick={() => {
  170. this.$router.push({
  171. path: '/teacherHome',
  172. query: {
  173. teacherId: item.teacherId,
  174. tabs: 'practice'
  175. }
  176. })
  177. }}
  178. />
  179. ))}
  180. </List>
  181. ) : (
  182. <ColResult
  183. btnStatus={false}
  184. classImgSize="SMALL"
  185. tips="暂无陪练老师"
  186. />
  187. )}
  188. <Popup
  189. show={this.searchStatus}
  190. position="bottom"
  191. round
  192. closeable
  193. safe-area-inset-bottom
  194. onClose={() => (this.searchStatus = false)}
  195. onClosed={() => (this.openStatus = false)}
  196. >
  197. {this.searchType === 'all' && <AllSearch onSort={this.onSort} />}
  198. {this.searchType === 'organ' && this.openStatus && (
  199. <OrganSearch
  200. subjectList={this.subjectList}
  201. onSort={this.onSort}
  202. v-model={this.params.subjectId}
  203. v-model:subjectName={this.params.subjectName}
  204. />
  205. )}
  206. </Popup>
  207. </>
  208. )
  209. }
  210. })