studentTraomomhDetails.tsx 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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. } catch (e) {
  94. console.log(e);
  95. }
  96. loading.value = false;
  97. };
  98. expose({ getTrainingDetail });
  99. onMounted(() => {
  100. getTrainingDetail(props.activeRow.id);
  101. });
  102. return () => (
  103. <div class={[styles.trainingDetails]}>
  104. <NSpin show={loading.value}>
  105. <div class={styles.studentList}>
  106. <div class={styles.studentHeaderWrap}>
  107. <div class={styles.studentHeader}>
  108. <div class={styles.studentHeaderBorder}>
  109. <NImage
  110. class={styles.studentHeaderImg}
  111. src={
  112. teacherInfo.value.teacherAvatar
  113. ? teacherInfo.value.teacherAvatar
  114. : defultHeade
  115. }
  116. previewDisabled></NImage>
  117. </div>
  118. </div>
  119. <div class={styles.workafterInfo}>
  120. <h4>
  121. {teacherInfo.value.teacherName}{' '}
  122. <div
  123. class={[
  124. styles.workafterInfoDot,
  125. styles.workafterTeacherInfoDot
  126. ]}>
  127. 老师
  128. </div>
  129. </h4>
  130. <p>
  131. 开始时间:
  132. {teacherInfo.value.createTime
  133. ? dayjs(new Date(teacherInfo.value.createTime)).format(
  134. 'YYYY-MM-DD'
  135. )
  136. : '--'}{' '}
  137. | 结束时间:
  138. {teacherInfo.value.expireDate
  139. ? dayjs(new Date(teacherInfo.value.expireDate)).format(
  140. 'YYYY-MM-DD'
  141. )
  142. : '--'}
  143. </p>
  144. </div>
  145. </div>
  146. {teacherInfo.value.trainingStatus == 'UNSUBMITTED' ? (
  147. <NImage
  148. previewDisabled
  149. class={styles.workStatus}
  150. src={noSub}></NImage>
  151. ) : null}
  152. {teacherInfo.value.trainingStatus == 'SUBMITTED' ? (
  153. <NImage
  154. previewDisabled
  155. class={styles.workStatus}
  156. src={unqualified}></NImage>
  157. ) : null}
  158. {teacherInfo.value.trainingStatus == 'TARGET' ? (
  159. <NImage
  160. previewDisabled
  161. class={styles.workStatus}
  162. src={qualified}></NImage>
  163. ) : null}
  164. </div>
  165. {teacherInfo.value.trainingStatus !== 'UNSUBMITTED' && (
  166. <NButton
  167. onClick={() => (showModalMask.value = true)}
  168. class={styles.commentBtnGroup}>
  169. <div class={styles.text}>
  170. <i class={teacherInfo.value.comment && styles.look}></i>
  171. {teacherInfo.value.comment ? '查看评语' : '点评作业'}
  172. </div>
  173. </NButton>
  174. )}
  175. <NScrollbar style="max-height:400px" trigger="none">
  176. <div class={styles.workList}>
  177. {teacherInfo.value.studentLessonTrainingDetails.map(
  178. (item: any) => (
  179. <TrainType
  180. style={{ marginBottom: '20px' }}
  181. isDisabled={true}
  182. isDelete={false}
  183. isCLassWork={false}
  184. item={item}></TrainType>
  185. )
  186. )}
  187. </div>
  188. </NScrollbar>
  189. </NSpin>
  190. <NModal v-model:show={showModalMask.value}>
  191. <CommentWork
  192. comment={teacherInfo.value.comment}
  193. workInfo={{
  194. isLook: teacherInfo.value.comment ? true : false,
  195. studentName: teacherInfo.value.studentName,
  196. submitTime: teacherInfo.value.submitTime,
  197. studentLessonTrainingId: teacherInfo.value.studentLessonTrainingId
  198. }}
  199. onClose={() => (showModalMask.value = false)}
  200. onConfrim={() => {
  201. getTrainingDetail(props.activeRow.id);
  202. showModalMask.value = false;
  203. }}
  204. />
  205. </NModal>
  206. </div>
  207. );
  208. }
  209. });