index.tsx 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. import { PropType, defineComponent, reactive, watch } from 'vue';
  2. import styles from './index.module.less';
  3. import { Cell, Col, Icon, Image, Row } from 'vant';
  4. import iconStudent from '@/common/images/icon-student-default.png';
  5. import iconMember from '../images/icon-member.png';
  6. import img1 from './images/1.png';
  7. import img2 from './images/2.png';
  8. import img3 from './images/3.png';
  9. import MEmpty from '@/components/m-empty';
  10. export default defineComponent({
  11. name: 'detail-modal',
  12. props: {
  13. type: {
  14. type: String as PropType<'proctice' | 'evaluating'>,
  15. default: 'proctice'
  16. },
  17. title: {
  18. type: String,
  19. default: '学员练习详情'
  20. },
  21. detail: {
  22. type: Object,
  23. default: () => ({})
  24. }
  25. },
  26. setup(props) {
  27. const forms = reactive({
  28. detail: props.detail
  29. });
  30. watch(
  31. () => props.detail,
  32. () => {
  33. forms.detail = props.detail;
  34. }
  35. );
  36. return () => (
  37. <div class={styles.details}>
  38. <div class={styles.content}>
  39. <div class={styles.title}>{props.title}</div>
  40. <Cell center class={styles.userCell}>
  41. {{
  42. icon: () => (
  43. <div class={styles.iconGroup}>
  44. <Image
  45. src={forms.detail.avatar || iconStudent}
  46. class={styles.iconStudent}
  47. fit="cover"
  48. />
  49. {forms.detail.memberFlag && (
  50. <Icon name={iconMember} class={styles.iconMember} />
  51. )}
  52. </div>
  53. ),
  54. title: () => (
  55. <div class={styles.userInfo}>
  56. <p class={styles.name}>{forms.detail.username}</p>
  57. <span>{forms.detail.subjectName}</span>
  58. </div>
  59. ),
  60. value: () =>
  61. props.type === 'proctice' ? (
  62. <div
  63. class={[
  64. styles.after,
  65. forms.detail.finishFlag ? styles.success : styles.error
  66. ]}>
  67. {forms.detail.finishFlag ? '完成' : '未完成'}
  68. </div>
  69. ) : (
  70. <div
  71. class={[
  72. styles.after,
  73. forms.detail.trainingScore >= 60
  74. ? styles.success
  75. : styles.error
  76. ]}>
  77. {forms.detail.trainingScore || '--'}分
  78. </div>
  79. )
  80. }}
  81. </Cell>
  82. <div class={styles.tables}>
  83. {props.type === 'proctice' ? (
  84. <>
  85. <Row class={styles.thead}>
  86. <Col span={12} class={styles.col1}>
  87. 练习曲目
  88. </Col>
  89. <Col span={6} class={styles.col2}>
  90. 练习速度
  91. </Col>
  92. <Col span={6} class={styles.col3}>
  93. 次数/总计
  94. </Col>
  95. </Row>
  96. <div class={styles.tContainer}>
  97. {forms.detail.list.map((item: any) => (
  98. <Row class={[styles.tbody, 'van-hairline--top']}>
  99. <Col span={12} class={styles.col1}>
  100. {item.musicScoreName}
  101. </Col>
  102. <Col span={6} class={styles.col2}>
  103. <span class={styles.success}>{item.trainingSpeed}</span>
  104. 速度
  105. </Col>
  106. <Col span={6} class={styles.col3}>
  107. <span
  108. class={
  109. item.trainingTimes < item.times
  110. ? styles.error
  111. : styles.success
  112. }>
  113. {item.trainingTimes}
  114. </span>
  115. /{item.times}次
  116. </Col>
  117. </Row>
  118. ))}
  119. {forms.detail.list.length <= 0 && (
  120. <MEmpty
  121. description="暂无练习"
  122. style={{ paddingBottom: 0 }}
  123. />
  124. )}
  125. </div>
  126. </>
  127. ) : (
  128. <>
  129. <Row class={styles.thead}>
  130. <Col span={12} class={styles.col1}>
  131. 评测曲目
  132. </Col>
  133. <Col span={6} class={styles.col2}>
  134. 难度
  135. </Col>
  136. <Col span={6} class={styles.col3}>
  137. 得分/达标
  138. </Col>
  139. </Row>
  140. <div class={styles.tContainer}>
  141. {forms.detail.list.map((item: any) => (
  142. <Row class={[styles.tbody, 'van-hairline--top']}>
  143. <Col span={12} class={styles.col1}>
  144. {item.musicScoreName}
  145. </Col>
  146. <Col span={6} class={styles.col2}>
  147. {item.heardLevel === 'BEGINNER' && (
  148. <img src={img1} class={styles.img} />
  149. )}
  150. {item.heardLevel === 'ADVANCED' && (
  151. <img src={img2} class={styles.img} />
  152. )}
  153. {item.heardLevel === 'PERFORMER' && (
  154. <img src={img3} class={styles.img} />
  155. )}
  156. </Col>
  157. <Col span={6} class={styles.col3}>
  158. <span
  159. class={
  160. item.actualAvgScore < item.standardScore
  161. ? styles.error
  162. : styles.error
  163. }>
  164. {item.actualAvgScore || '--'}
  165. </span>
  166. /{item.standardScore}分
  167. </Col>
  168. </Row>
  169. ))}
  170. {forms.detail.list.length <= 0 && (
  171. <MEmpty
  172. description="暂无评测"
  173. style={{ paddingBottom: 0 }}
  174. />
  175. )}
  176. </div>
  177. </>
  178. )}
  179. </div>
  180. </div>
  181. </div>
  182. );
  183. }
  184. });