TrainingDetails.tsx 9.3 KB

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