classTrainingDetails.tsx 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. configJson.practiceChapterBegin || configJson.practiceChapterEnd
  57. ? `${configJson.practiceChapterBegin}-${configJson.practiceChapterEnd}小节`
  58. : '全部小节',
  59. // `速度${configJson.evaluateSpeed}`,
  60. `${configJson.trainingTimes}分合格`
  61. ];
  62. // console.log('configJson.evaluateDifficult--', tList);
  63. } else {
  64. tList = [
  65. `${configJson.practiceChapterBegin}-${configJson.practiceChapterEnd}小节`,
  66. `速度${configJson.practiceSpeed}`,
  67. `${configJson.trainingTimes}分钟`
  68. ];
  69. // console.log('configJson.evaluateDifficult', tList);
  70. }
  71. return tList;
  72. };
  73. const getTrainingDetail = async (id: any) => {
  74. try {
  75. const res = await getTrainingClassDetail({
  76. trainingId: id
  77. });
  78. const arr = res.data.studentLessonTrainingDetails.map((item: any) => {
  79. const tList = typeFormat(
  80. item.trainingType,
  81. JSON.parse(item.trainingContent)
  82. );
  83. return {
  84. ...item,
  85. coverImg: item.titleImg,
  86. allTimes: JSON.parse(item.trainingContent).trainingTimes,
  87. typeList: tList || []
  88. };
  89. });
  90. teacherInfo.value = {
  91. ...res.data,
  92. studentLessonTrainingDetails: arr
  93. };
  94. } catch (e) {
  95. console.log(e);
  96. }
  97. };
  98. expose({ getTrainingDetail });
  99. onMounted(() => {
  100. getTrainingDetail(props.activeRow.id);
  101. });
  102. return () => (
  103. <div class={[styles.trainingDetails]}>
  104. <div class={styles.studentList}>
  105. <div class={styles.studentHeaderWrap}>
  106. <div class={styles.studentHeader}>
  107. <div class={styles.studentHeaderBorder}>
  108. <NImage
  109. class={styles.studentHeaderImg}
  110. src={
  111. teacherInfo.value.teacherAvatar
  112. ? teacherInfo.value.teacherAvatar
  113. : defultHeade
  114. }
  115. previewDisabled></NImage>
  116. </div>
  117. </div>
  118. <div class={styles.workafterInfo}>
  119. <h4>
  120. {teacherInfo.value.teacherName}{' '}
  121. <div
  122. class={[
  123. styles.workafterInfoDot,
  124. styles.workafterTeacherInfoDot
  125. ]}>
  126. 老师
  127. </div>
  128. </h4>
  129. <p>
  130. 开始时间:
  131. {teacherInfo.value.createTime
  132. ? dayjs(new Date(teacherInfo.value.createTime)).format(
  133. 'YYYY-MM-DD'
  134. )
  135. : '--'}{' '}
  136. | 结束时间:
  137. {dayjs(new Date(teacherInfo.value.expireDate)).format(
  138. 'YYYY-MM-DD'
  139. )}
  140. </p>
  141. </div>
  142. </div>
  143. </div>
  144. <NScrollbar style="max-height:400px" trigger="none">
  145. <div class={styles.workList}>
  146. {teacherInfo.value.studentLessonTrainingDetails.map((item: any) => (
  147. <TrainType
  148. style={{ marginBottom: '20px' }}
  149. isDisabled={true}
  150. isDelete={false}
  151. isCLassWork={true}
  152. item={item}></TrainType>
  153. ))}
  154. </div>
  155. </NScrollbar>
  156. </div>
  157. );
  158. }
  159. });