TrainingDetails.tsx 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. import {
  2. NButton,
  3. NSpace,
  4. useMessage,
  5. NImage,
  6. NScrollbar,
  7. NSpin,
  8. NModal
  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. import CommentWork from '../../studentList/modals/comment-work';
  21. import WorkItem from '../work-item';
  22. export default defineComponent({
  23. props: {
  24. activeRow: {
  25. type: Object,
  26. default: () => ({ studentLessonTrainingId: '' })
  27. },
  28. total: {
  29. type: Number,
  30. default: 0
  31. },
  32. current: {
  33. type: Number,
  34. default: 0
  35. }
  36. },
  37. name: 'TrainingDetails',
  38. emits: ['close', 'next', 'pre'],
  39. setup(props, { emit, expose }) {
  40. const loading = ref(false);
  41. const studnetInfo = ref({
  42. studentName: '',
  43. submitTime: '',
  44. trainingStatus: '',
  45. studentAvatar: '',
  46. studentLessonTrainingDetails: [] as any
  47. } as any);
  48. const showModalMask = ref(false);
  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. loading.value = true;
  75. try {
  76. const res = await getTrainingStudentDetail({
  77. studentLessonTrainingId: id
  78. });
  79. const arr = res.data.studentLessonTrainingDetails.map((item: any) => {
  80. const tList = typeFormat(
  81. item.trainingType,
  82. JSON.parse(item.trainingContent)
  83. );
  84. return {
  85. ...item,
  86. coverImg: item.titleImg,
  87. fileList: (item.fileJsonList && item.fileJsonList[0]) || {},
  88. allTimes: JSON.parse(item.trainingContent).trainingTimes,
  89. typeList: tList || []
  90. };
  91. });
  92. studnetInfo.value = {
  93. ...res.data,
  94. studentLessonTrainingDetails: arr
  95. };
  96. } catch (e) {
  97. console.log(e);
  98. }
  99. loading.value = false;
  100. };
  101. expose({ getTrainingDetail });
  102. onMounted(() => {
  103. getTrainingDetail(props.activeRow.studentLessonTrainingId);
  104. });
  105. return () => (
  106. <div class={[styles.trainingDetails]}>
  107. <NSpin show={loading.value}>
  108. <div class={styles.studentList}>
  109. <div class={styles.studentHeaderWrap}>
  110. <div class={styles.studentHeader}>
  111. <div class={styles.studentHeaderBorder}>
  112. <NImage
  113. class={styles.studentHeaderImg}
  114. src={
  115. studnetInfo.value.studentAvatar
  116. ? studnetInfo.value.studentAvatar
  117. : defultHeade
  118. }
  119. previewDisabled></NImage>
  120. </div>
  121. </div>
  122. <div class={styles.workafterInfo}>
  123. <h4>
  124. {studnetInfo.value.studentName}{' '}
  125. <div class={styles.workafterInfoDot}>学生</div>
  126. </h4>
  127. <p>
  128. 提交时间:
  129. {studnetInfo.value.submitTime
  130. ? dayjs(new Date(studnetInfo.value.submitTime)).format(
  131. 'YYYY-MM-DD'
  132. )
  133. : '--'}
  134. </p>
  135. </div>
  136. {studnetInfo.value.trainingStatus == 'UNSUBMITTED' ? (
  137. <NImage
  138. previewDisabled
  139. class={styles.workStatus}
  140. src={noSub}></NImage>
  141. ) : null}
  142. {studnetInfo.value.trainingStatus == 'SUBMITTED' ? (
  143. <NImage
  144. previewDisabled
  145. class={styles.workStatus}
  146. src={unqualified}></NImage>
  147. ) : null}
  148. {studnetInfo.value.trainingStatus == 'TARGET' ? (
  149. <NImage
  150. previewDisabled
  151. class={styles.workStatus}
  152. src={qualified}></NImage>
  153. ) : null}
  154. </div>
  155. {studnetInfo.value.expireFlag && (
  156. <NButton
  157. onClick={() => (showModalMask.value = true)}
  158. class={styles.commentBtnGroup}>
  159. <div class={styles.text}>
  160. <i class={studnetInfo.value.comment && styles.look}></i>
  161. {studnetInfo.value.comment ? '修改点评' : '点评作业'}
  162. </div>
  163. </NButton>
  164. )}
  165. </div>
  166. {!studnetInfo.value.fileExpireFlag && (
  167. <div class={styles.expireDateTip}>
  168. <i class={styles.expireDateIcon}></i>
  169. <span>
  170. 作业截止{studnetInfo.value.fileExpireDay || 0}
  171. 天后,学生上传的文件将过期,请及时查看
  172. </span>
  173. </div>
  174. )}
  175. <NScrollbar style="max-height:400px;min-height: 300px" trigger="none">
  176. <div class={styles.workList}>
  177. {studnetInfo.value.studentLessonTrainingDetails.map(
  178. (item: any) => (
  179. <WorkItem style={{ marginBottom: '20px' }} item={item} />
  180. )
  181. )}
  182. </div>
  183. {studnetInfo.value.comment && (
  184. <div class={styles.commentSection}>
  185. <h3>
  186. <i class={styles.iconComment}></i>
  187. <i class={styles.myText}></i>
  188. </h3>
  189. <div class={styles.commentContent}>
  190. {studnetInfo.value.comment}
  191. </div>
  192. </div>
  193. )}
  194. </NScrollbar>
  195. <NSpace
  196. class={[styles.btnGroups, styles.nextWrap]}
  197. justify="space-between">
  198. <div class={styles.allTotal}>
  199. {props.current}/{props.total}名学生
  200. </div>
  201. <div>
  202. <NSpace>
  203. <NButton
  204. disabled={props.current <= 1}
  205. round
  206. type="primary"
  207. onClick={() => {
  208. emit('pre');
  209. }}>
  210. 上一名
  211. </NButton>
  212. <NButton
  213. disabled={props.current >= props.total}
  214. round
  215. type="primary"
  216. onClick={() => {
  217. emit('next');
  218. }}>
  219. 下一名
  220. </NButton>
  221. </NSpace>
  222. </div>
  223. </NSpace>
  224. </NSpin>
  225. <NModal v-model:show={showModalMask.value}>
  226. <CommentWork
  227. comment={studnetInfo.value.comment}
  228. workInfo={{
  229. isLook: studnetInfo.value.comment ? true : false,
  230. studentAvatar: studnetInfo.value.studentAvatar,
  231. studentName: studnetInfo.value.studentName,
  232. submitTime: studnetInfo.value.submitTime,
  233. studentLessonTrainingId: studnetInfo.value.studentLessonTrainingId
  234. }}
  235. onClose={() => (showModalMask.value = false)}
  236. onConfrim={() => {
  237. getTrainingDetail(props.activeRow.studentLessonTrainingId);
  238. showModalMask.value = false;
  239. }}
  240. />
  241. </NModal>
  242. </div>
  243. );
  244. }
  245. });