classTrainingDetails.tsx 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. import {
  2. NButton,
  3. NSpace,
  4. useMessage,
  5. NForm,
  6. NFormItem,
  7. NSelect,
  8. NImage,
  9. NScrollbar
  10. } from 'naive-ui';
  11. import { defineComponent, onMounted, reactive, ref } from 'vue';
  12. import { getTrainingClassDetail } from '../api';
  13. import styles from '../index.module.less';
  14. import TrainType from '@/views/attend-class/model/train-type';
  15. import defultHeade from '@/components/layout/images/teacherIcon.png';
  16. import noSub from '../images/nosub.png';
  17. import qualified from '../images/qualified.png';
  18. import unqualified from '../images/unqualified.png';
  19. import { evaluateDifficult } from '/src/utils/contants';
  20. import dayjs from 'dayjs';
  21. export default defineComponent({
  22. props: {
  23. activeRow: {
  24. type: Object,
  25. default: () => ({ id: '' })
  26. },
  27. total: {
  28. type: Number,
  29. default: 0
  30. },
  31. current: {
  32. type: Number,
  33. default: 0
  34. }
  35. },
  36. name: 'classTrainingDetails',
  37. emits: ['close'],
  38. setup(props, { emit, expose }) {
  39. const data = reactive({
  40. uploading: false
  41. });
  42. const teacherInfo = ref({
  43. teacherName: '',
  44. createTime: '',
  45. expireDate: '',
  46. teacherAvatar: '',
  47. studentLessonTrainingDetails: [] as any
  48. } as any);
  49. const message = useMessage();
  50. const foemsRef = ref();
  51. const typeFormat = (trainingType: string, configJson: any) => {
  52. let tList: string[] = [];
  53. if (trainingType === 'EVALUATION') {
  54. tList = [
  55. `${evaluateDifficult[configJson.evaluateDifficult]}`,
  56. '全部小节',
  57. // `速度${configJson.evaluateSpeed}`,
  58. `${configJson.trainingTimes}分合格`
  59. ];
  60. console.log('configJson.evaluateDifficult--', tList);
  61. } else {
  62. tList = [
  63. `${configJson.practiceChapterBegin}-${configJson.practiceChapterEnd}小节`,
  64. `速度${configJson.practiceSpeed}`,
  65. `${configJson.trainingTimes}分钟`
  66. ];
  67. console.log('configJson.evaluateDifficult', tList);
  68. }
  69. return tList;
  70. };
  71. const getTrainingDetail = async (id: any) => {
  72. try {
  73. const res = await getTrainingClassDetail({
  74. trainingId: id
  75. });
  76. const arr = res.data.studentLessonTrainingDetails.map((item: any) => {
  77. const tList = typeFormat(
  78. item.trainingType,
  79. JSON.parse(item.trainingContent)
  80. );
  81. return {
  82. ...item,
  83. coverImg: item.titleImg,
  84. allTimes: JSON.parse(item.trainingContent).trainingTimes,
  85. typeList: tList || []
  86. };
  87. });
  88. teacherInfo.value = {
  89. ...res.data,
  90. studentLessonTrainingDetails: arr
  91. };
  92. } catch (e) {
  93. console.log(e);
  94. }
  95. };
  96. expose({ getTrainingDetail });
  97. onMounted(() => {
  98. getTrainingDetail(props.activeRow.id);
  99. });
  100. return () => (
  101. <div class={[styles.trainingDetails]}>
  102. <div class={styles.studentList}>
  103. <div class={styles.studentHeaderWrap}>
  104. <div class={styles.studentHeader}>
  105. <div class={styles.studentHeaderBorder}>
  106. <NImage
  107. class={styles.studentHeaderImg}
  108. src={
  109. teacherInfo.value.teacherAvatar
  110. ? teacherInfo.value.teacherAvatar
  111. : defultHeade
  112. }
  113. previewDisabled></NImage>
  114. </div>
  115. </div>
  116. <div class={styles.workafterInfo}>
  117. <h4>
  118. {teacherInfo.value.teacherName}{' '}
  119. <div
  120. class={[
  121. styles.workafterInfoDot,
  122. styles.workafterTeacherInfoDot
  123. ]}>
  124. 老师
  125. </div>
  126. </h4>
  127. <p>
  128. 开始时间:
  129. {teacherInfo.value.createTime
  130. ? dayjs(new Date(teacherInfo.value.createTime)).format(
  131. 'YYYY-MM-DD'
  132. )
  133. : '--'}{' '}
  134. | 结束时间:
  135. {dayjs(new Date(teacherInfo.value.expireDate)).format(
  136. 'YYYY-MM-DD'
  137. )}
  138. </p>
  139. </div>
  140. </div>
  141. </div>
  142. <NScrollbar style="max-height:400px" trigger="none">
  143. <div class={styles.workList}>
  144. {teacherInfo.value.studentLessonTrainingDetails.map((item: any) => (
  145. <TrainType
  146. style={{ marginBottom: '20px' }}
  147. isDisabled={true}
  148. isDelete={false}
  149. isCLassWork={true}
  150. item={item}></TrainType>
  151. ))}
  152. </div>
  153. </NScrollbar>
  154. </div>
  155. );
  156. }
  157. });