exercis-detail.tsx 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. import OHeader from '@/components/o-header'
  2. import OSticky from '@/components/o-sticky'
  3. import dayjs from 'dayjs'
  4. import {
  5. Icon,
  6. Popover,
  7. DatePicker,
  8. DatePickerColumnType,
  9. Popup,
  10. List,
  11. PullRefresh,
  12. showToast,
  13. Dialog
  14. } from 'vant'
  15. import DetailItem from './modals/detail-item'
  16. import { defineComponent, reactive, ref } from 'vue'
  17. import { useRouter } from 'vue-router'
  18. import styles from './exercis-detail.module.less'
  19. import request from '@/helpers/request'
  20. import questIcon from '../images/quest-icon.png'
  21. import defaultIcon from '@/school/images/default-icon.jpg'
  22. export default defineComponent({
  23. name: 'exercis-detail',
  24. setup() {
  25. const router = useRouter()
  26. const state = reactive({
  27. showPopoverTime: false,
  28. showPopoverOrchestra: false,
  29. currentDate: [dayjs().format('YYYY'), dayjs().format('MM')],
  30. actions: [
  31. { text: '全部乐团', color: 'var(--van-primary-color)' },
  32. { text: '交付团' },
  33. { text: '晋升团' }
  34. ]
  35. })
  36. const forms = reactive({
  37. practiceMonth: state.currentDate[0] + '' + state.currentDate[1],
  38. practiceMonthName: state.currentDate[0] + '年' + state.currentDate[1] + '月',
  39. orchestraId: '',
  40. orchestraName: '',
  41. page: 1,
  42. rows: 20
  43. })
  44. const showTip = ref(false)
  45. const minDate = ref(new Date(dayjs().subtract(5, 'year').format('YYYY-MM-DD')))
  46. const maxDate = ref(new Date(dayjs().add(5, 'year').format('YYYY-MM-DD')))
  47. const columnsType = ref<DatePickerColumnType[]>(['year', 'month'])
  48. const refreshing = ref(false)
  49. const loading = ref(false)
  50. const finished = ref(false)
  51. const showContact = ref(false)
  52. const list = ref([])
  53. const getList = async () => {
  54. loading.value = true
  55. try {
  56. const res = await request.post('/api-school/student/page', {
  57. data: { ...forms }
  58. })
  59. if (refreshing.value) {
  60. // list.value = []
  61. refreshing.value = false
  62. }
  63. if (list.value.length > 0 && res.data.pageNo === 1) {
  64. return
  65. }
  66. showContact.value = list.value.length > 0
  67. forms.page = res.data.current + 1
  68. list.value = list.value.concat(res.data.rows || [])
  69. loading.value = false
  70. finished.value = res.data.current >= res.data.pages
  71. } catch (e: any) {
  72. // console.log(e, 'e')
  73. const message = e.message
  74. showToast(message)
  75. showContact.value = false
  76. finished.value = true
  77. }
  78. }
  79. const onBack = () => {
  80. console.log('返回')
  81. }
  82. const checkTimer = (val: any) => {
  83. forms.practiceMonth = val.selectedValues[0] + val.selectedValues[1]
  84. forms.practiceMonthName = val.selectedValues[0] + '年' + val.selectedValues[1] + '月'
  85. state.showPopoverTime = false
  86. getList()
  87. }
  88. const onRefresh = () => {
  89. finished.value = false
  90. // 重新加载数据
  91. // 将 loading 设置为 true,表示处于加载状态
  92. loading.value = true
  93. getList()
  94. }
  95. return () => (
  96. <>
  97. <OSticky position="top" background="#F8F8F8">
  98. <div class={styles.topWrap}>
  99. <OHeader isBack={true} onHeaderBack={onBack} border={false} background={'transparent'}>
  100. {{
  101. right: () => (
  102. <Icon
  103. name={questIcon}
  104. size={22}
  105. color="#333"
  106. onClick={() => {
  107. showTip.value = true
  108. }}
  109. />
  110. )
  111. }}
  112. </OHeader>
  113. <div class={styles.topInfo}>
  114. <div class={styles.topInfoLeft}>
  115. <div class={styles.headWrap}>
  116. <img src={defaultIcon} alt="" />
  117. </div>
  118. <div class={styles.infoMsg}>
  119. <p>邓同学</p>
  120. <div class={styles.tag}>长笛</div>
  121. </div>
  122. </div>
  123. <div class={styles.topInfoRight}>
  124. <div class={styles.infoDay}>
  125. <p class={styles.infoDayMain}>
  126. 10 <span>天</span>
  127. </p>
  128. <p class={styles.infoDaysub}>练习天数</p>
  129. </div>
  130. <div class={styles.infoTime}>
  131. <p class={styles.infoDayMain}>
  132. 260 <span>分钟</span>
  133. </p>
  134. <p class={styles.infoDaysub}>练习天数</p>
  135. </div>
  136. </div>
  137. </div>
  138. <div class={styles.chioseWrap}>
  139. <div style={{ padding: '12px 13px', background: 'transparent' }}>
  140. <div
  141. class={styles.searchBand}
  142. onClick={() => {
  143. state.showPopoverTime = true
  144. }}
  145. >
  146. {forms.practiceMonthName}
  147. <Icon name={state.showPopoverTime ? 'arrow-up' : 'arrow-down'} />
  148. </div>
  149. </div>
  150. <div style={{ padding: '12px 13px', background: 'transparent' }}>
  151. <Popover
  152. v-model:show={state.showPopoverOrchestra}
  153. actions={state.actions}
  154. showArrow={false}
  155. placement="bottom-start"
  156. offset={[0, 12]}
  157. >
  158. {{
  159. reference: () => (
  160. <div class={styles.searchBand}>
  161. 全部乐团
  162. <Icon name={state.showPopoverOrchestra ? 'arrow-up' : 'arrow-down'} />
  163. </div>
  164. )
  165. }}
  166. </Popover>
  167. </div>
  168. </div>
  169. </div>
  170. </OSticky>
  171. <PullRefresh v-model={refreshing.value} onRefresh={onRefresh}>
  172. <List
  173. v-model:loading={loading.value}
  174. finished={finished.value}
  175. finished-text="没有更多了"
  176. onLoad={getList}
  177. >
  178. {list.value.map((item: any) => (
  179. <DetailItem item={item} />
  180. ))}
  181. </List>
  182. </PullRefresh>
  183. <Popup v-model:show={state.showPopoverTime} position="bottom" style="{ height: '30%' }">
  184. <DatePicker
  185. onCancel={() => {
  186. state.showPopoverTime = false
  187. }}
  188. onConfirm={checkTimer}
  189. v-model={state.currentDate}
  190. title="选择年月"
  191. minDate={minDate.value}
  192. maxDate={maxDate.value}
  193. columnsType={columnsType.value}
  194. />
  195. </Popup>
  196. <Dialog
  197. class="exercisDetailDialog"
  198. v-model:show={showTip.value}
  199. title="提示框"
  200. confirmButtonText="我知道了"
  201. vSlots={{
  202. title: () => (
  203. <div class={styles.DialogTitle}>
  204. <span></span>
  205. <p>什么是练习数据</p>
  206. </div>
  207. ),
  208. default: () => (
  209. <div class={styles.DialogConent}>
  210. <p>
  211. 练习数据是学生通过云教练自主练习的数据统计,可根据时间段查询学生的练习天数和练习时长{' '}
  212. </p>
  213. <p>练习天数:当天又曲目播放或测评记录即算练习</p>
  214. <p>练习时长:曲目播放和曲目测评的时长总和</p>
  215. </div>
  216. )
  217. }}
  218. ></Dialog>
  219. </>
  220. )
  221. }
  222. })