studentTraomomhDetails.tsx 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. import {
  2. useMessage,
  3. NImage,
  4. NScrollbar,
  5. NSpin,
  6. NModal,
  7. NButton
  8. } from 'naive-ui';
  9. import { defineComponent, onMounted, reactive, ref } from 'vue';
  10. import styles from '@/views/classList/index.module.less';
  11. import TrainType from '@/views/attend-class/model/train-type';
  12. import defultHeade from '@/components/layout/images/teacherIcon.png';
  13. import noSub from '@/views/classList/images/nosub.png';
  14. import qualified from '@/views/classList/images/qualified.png';
  15. import unqualified from '@/views/classList/images/unqualified.png';
  16. import { evaluateDifficult } from '/src/utils/contants';
  17. import dayjs from 'dayjs';
  18. import { getTrainingStudentDetail } from '../../classList/api';
  19. import CommentWork from './comment-work';
  20. export default defineComponent({
  21. props: {
  22. activeRow: {
  23. type: Object,
  24. default: () => ({ id: '' })
  25. },
  26. total: {
  27. type: Number,
  28. default: 0
  29. },
  30. current: {
  31. type: Number,
  32. default: 0
  33. }
  34. },
  35. name: 'studentTraomomhDetails',
  36. emits: ['close'],
  37. setup(props, { emit, expose }) {
  38. const showModalMask = ref(false);
  39. const loading = ref(false);
  40. const teacherInfo = ref({
  41. teacherName: '',
  42. createTime: '',
  43. expireDate: '',
  44. teacherAvatar: '',
  45. studentLessonTrainingDetails: [] as any
  46. } as any);
  47. // const message = useMessage();
  48. // const foemsRef = ref();
  49. const typeFormat = (trainingType: string, configJson: any) => {
  50. let tList: string[] = [];
  51. if (trainingType === 'EVALUATION') {
  52. tList = [
  53. `${evaluateDifficult[configJson.evaluateDifficult]}`,
  54. configJson.practiceChapterBegin || configJson.practiceChapterEnd
  55. ? `${configJson.practiceChapterBegin}-${configJson.practiceChapterEnd}小节`
  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. loading.value = true;
  73. try {
  74. const res = await getTrainingStudentDetail({
  75. studentLessonTrainingId: id
  76. });
  77. const arr = res.data.studentLessonTrainingDetails.map((item: any) => {
  78. const tList = typeFormat(
  79. item.trainingType,
  80. JSON.parse(item.trainingContent)
  81. );
  82. return {
  83. ...item,
  84. coverImg: item.titleImg,
  85. allTimes: JSON.parse(item.trainingContent).trainingTimes,
  86. typeList: tList || []
  87. };
  88. });
  89. teacherInfo.value = {
  90. ...res.data,
  91. studentLessonTrainingDetails: arr
  92. };
  93. console.log(teacherInfo.value, ' teacherInfo.value');
  94. } catch (e) {
  95. console.log(e);
  96. }
  97. loading.value = false;
  98. };
  99. expose({ getTrainingDetail });
  100. onMounted(() => {
  101. getTrainingDetail(props.activeRow.id);
  102. });
  103. return () => (
  104. <div class={[styles.trainingDetails]}>
  105. <NSpin show={loading.value}>
  106. <div class={styles.studentList}>
  107. <div class={styles.studentHeaderWrap}>
  108. <div class={styles.studentHeader}>
  109. <div class={styles.studentHeaderBorder}>
  110. <NImage
  111. class={styles.studentHeaderImg}
  112. src={
  113. teacherInfo.value.teacherAvatar
  114. ? teacherInfo.value.teacherAvatar
  115. : defultHeade
  116. }
  117. previewDisabled></NImage>
  118. </div>
  119. </div>
  120. <div class={styles.workafterInfo}>
  121. <h4>
  122. {teacherInfo.value.teacherName}{' '}
  123. <div
  124. class={[
  125. styles.workafterInfoDot,
  126. styles.workafterTeacherInfoDot
  127. ]}>
  128. 老师
  129. </div>
  130. </h4>
  131. <p>
  132. 开始时间:
  133. {teacherInfo.value.createTime
  134. ? dayjs(new Date(teacherInfo.value.createTime)).format(
  135. 'YYYY-MM-DD HH:mm'
  136. )
  137. : '--'}{' '}
  138. | 结束时间:
  139. {teacherInfo.value.expireDate
  140. ? dayjs(new Date(teacherInfo.value.expireDate)).format(
  141. 'YYYY-MM-DD HH:mm'
  142. )
  143. : '--'}
  144. </p>
  145. </div>
  146. </div>
  147. {teacherInfo.value.trainingStatus == 'UNSUBMITTED' ? (
  148. <NImage
  149. previewDisabled
  150. class={styles.workStatus}
  151. src={noSub}></NImage>
  152. ) : null}
  153. {teacherInfo.value.trainingStatus == 'SUBMITTED' ? (
  154. <NImage
  155. previewDisabled
  156. class={styles.workStatus}
  157. src={unqualified}></NImage>
  158. ) : null}
  159. {teacherInfo.value.trainingStatus == 'TARGET' ? (
  160. <NImage
  161. previewDisabled
  162. class={styles.workStatus}
  163. src={qualified}></NImage>
  164. ) : null}
  165. </div>
  166. {teacherInfo.value.trainingStatus !== 'UNSUBMITTED' && (
  167. <NButton
  168. onClick={() => (showModalMask.value = true)}
  169. class={styles.commentBtnGroup}>
  170. <div class={styles.text}>
  171. <i class={teacherInfo.value.comment && styles.look}></i>
  172. {teacherInfo.value.comment ? '查看评语' : '点评作业'}
  173. </div>
  174. </NButton>
  175. )}
  176. <NScrollbar style="max-height:400px" trigger="none">
  177. <div class={styles.workList}>
  178. {teacherInfo.value.studentLessonTrainingDetails.map(
  179. (item: any) => (
  180. <TrainType
  181. style={{ marginBottom: '20px' }}
  182. isDisabled={true}
  183. isDelete={false}
  184. isCLassWork={false}
  185. item={item}></TrainType>
  186. )
  187. )}
  188. </div>
  189. </NScrollbar>
  190. </NSpin>
  191. <NModal v-model:show={showModalMask.value}>
  192. <CommentWork
  193. comment={teacherInfo.value.comment}
  194. workInfo={{
  195. isLook: teacherInfo.value.comment ? true : false,
  196. studentAvatar: teacherInfo.value.studentAvatar,
  197. studentName: teacherInfo.value.studentName,
  198. submitTime: teacherInfo.value.submitTime,
  199. studentLessonTrainingId: teacherInfo.value.studentLessonTrainingId
  200. }}
  201. onClose={() => (showModalMask.value = false)}
  202. onConfrim={() => {
  203. getTrainingDetail(props.activeRow.id);
  204. showModalMask.value = false;
  205. }}
  206. />
  207. </NModal>
  208. </div>
  209. );
  210. }
  211. });