exercis-detail.tsx 8.8 KB

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