TrainingDetails.tsx 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. import {
  2. NButton,
  3. NSpace,
  4. useMessage,
  5. NForm,
  6. NFormItem,
  7. NSelect,
  8. NImage
  9. } from 'naive-ui';
  10. import { defineComponent, onMounted, reactive, ref } from 'vue';
  11. import { getTrainingStudentDetail } from '../api';
  12. import styles from '../index.module.less';
  13. import TrainType from '@/views/attend-class/model/train-type';
  14. import defultHeade from '@/components/layout/images/teacherIcon.png';
  15. import noSub from '../images/nosub.png';
  16. import qualified from '../images/qualified.png';
  17. import unqualified from '../images/unqualified.png';
  18. import { evaluateDifficult } from '/src/utils/contants';
  19. import dayjs from 'dayjs';
  20. export default defineComponent({
  21. props: {
  22. activeRow: {
  23. type: Object,
  24. default: () => ({ studentLessonTrainingId: '' })
  25. },
  26. total: {
  27. type: Number,
  28. default: 0
  29. },
  30. current: {
  31. type: Number,
  32. default: 0
  33. }
  34. },
  35. name: 'TrainingDetails',
  36. emits: ['close', 'next', 'pre'],
  37. setup(props, { emit, expose }) {
  38. const data = reactive({
  39. uploading: false
  40. });
  41. const studnetInfo = ref({
  42. studentName: '',
  43. submitTime: '',
  44. trainingStatus: '',
  45. studentAvatar: '',
  46. studentLessonTrainingDetails: [] as any
  47. } as any);
  48. const message = useMessage();
  49. const foemsRef = ref();
  50. const typeFormat = (trainingType: string, configJson: any) => {
  51. let tList: string[] = [];
  52. if (trainingType === 'EVALUATION') {
  53. tList = [
  54. `${evaluateDifficult[configJson.evaluateDifficult]}`,
  55. '全部小节',
  56. `速度${configJson.evaluateSpeed}`,
  57. `${configJson.trainingTimes}分合格`
  58. ];
  59. console.log('configJson.evaluateDifficult--', tList);
  60. } else {
  61. tList = [
  62. `${configJson.practiceChapterBegin}-${configJson.practiceChapterEnd}小节`,
  63. `速度${configJson.practiceSpeed}`,
  64. `${configJson.trainingTimes}分钟`
  65. ];
  66. console.log('configJson.evaluateDifficult', tList);
  67. }
  68. return tList;
  69. };
  70. const getTrainingDetail = async () => {
  71. try {
  72. const res = await getTrainingStudentDetail({
  73. studentLessonTrainingId: props.activeRow.studentLessonTrainingId
  74. });
  75. const arr = res.data.studentLessonTrainingDetails.map((item: any) => {
  76. const tList = typeFormat(
  77. item.trainingType,
  78. JSON.parse(item.trainingContent)
  79. );
  80. return {
  81. ...item,
  82. coverImg: item.titleImg,
  83. allTimes: JSON.parse(item.trainingContent).trainingTimes,
  84. typeList: tList || []
  85. };
  86. });
  87. studnetInfo.value = {
  88. ...res.data,
  89. studentLessonTrainingDetails: arr
  90. };
  91. console.log(studnetInfo.value.studentLessonTrainingDetails);
  92. } catch (e) {
  93. console.log(e);
  94. }
  95. };
  96. expose({ getTrainingDetail });
  97. onMounted(() => {
  98. getTrainingDetail();
  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. studnetInfo.value.studentAvatar
  110. ? studnetInfo.value.studentAvatar
  111. : defultHeade
  112. }
  113. previewDisabled></NImage>
  114. </div>
  115. </div>
  116. <div class={styles.workafterInfo}>
  117. <h4>
  118. {studnetInfo.value.studentName}{' '}
  119. <div class={styles.workafterInfoDot}>学生</div>
  120. </h4>
  121. <p>
  122. 提交时间:
  123. {studnetInfo.value.submitTime
  124. ? dayjs(new Date(studnetInfo.value.submitTime)).format(
  125. 'YYYY-MM-DD'
  126. )
  127. : '--'}
  128. </p>
  129. </div>
  130. </div>
  131. {studnetInfo.value.trainingStatus == 'UNSUBMITTED' ? (
  132. <NImage
  133. previewDisabled
  134. class={styles.workStatus}
  135. src={noSub}></NImage>
  136. ) : null}
  137. {studnetInfo.value.trainingStatus == 'SUBMITTED' ? (
  138. <NImage
  139. previewDisabled
  140. class={styles.workStatus}
  141. src={unqualified}></NImage>
  142. ) : null}
  143. {studnetInfo.value.trainingStatus == 'TARGET' ? (
  144. <NImage
  145. previewDisabled
  146. class={styles.workStatus}
  147. src={qualified}></NImage>
  148. ) : null}
  149. </div>
  150. <div class={styles.workList}>
  151. {studnetInfo.value.studentLessonTrainingDetails.map((item: any) => (
  152. <TrainType
  153. isDisabled={true}
  154. isDelete={false}
  155. item={item}></TrainType>
  156. ))}
  157. </div>
  158. <NSpace class={styles.btnGroups} justify="space-between">
  159. <div class={styles.allTotal}>
  160. {props.current}/{props.total}名学生
  161. </div>
  162. <div>
  163. <NSpace>
  164. <NButton
  165. disabled={props.current <= 1}
  166. round
  167. type="primary"
  168. onClick={() => {
  169. emit('pre');
  170. }}>
  171. 上一名
  172. </NButton>
  173. <NButton
  174. disabled={props.current >= props.total}
  175. round
  176. type="primary"
  177. onClick={() => {
  178. emit('next');
  179. }}>
  180. 下一名
  181. </NButton>
  182. </NSpace>
  183. </div>
  184. </NSpace>
  185. </div>
  186. );
  187. }
  188. });