index.tsx 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. import { defineComponent, reactive } from 'vue';
  2. import styles from './index.module.less';
  3. import {
  4. NAvatar,
  5. NButton,
  6. NCheckbox,
  7. NInput,
  8. NModal,
  9. NSpace,
  10. useMessage
  11. } from 'naive-ui';
  12. import commentBg from '../images/common-bg.png';
  13. import commentTop from '../images/common-top.png';
  14. import iconClose from '../images/icon-close-line.png';
  15. import defultHeade from '@/components/layout/images/teacherIcon.png';
  16. import { api_setComment } from '../../api';
  17. import dayjs from 'dayjs';
  18. import { storage } from '/src/utils/storage';
  19. export default defineComponent({
  20. name: 'commit-work',
  21. props: {
  22. /** 评语内容 */
  23. comment: {
  24. type: String,
  25. default: ''
  26. },
  27. workInfo: {
  28. type: Object,
  29. default: () => ({})
  30. }
  31. },
  32. emits: ['close', 'confrim'],
  33. setup(props, { emit }) {
  34. const message = useMessage();
  35. const state = reactive({
  36. removeVisiable1: false,
  37. comment: props.comment,
  38. btnLoading: false,
  39. commentRemind: true
  40. });
  41. const onSubmit = async () => {
  42. const isCommentRemind = storage.get('isCommentRemind');
  43. if (isCommentRemind != 1 && state.commentRemind) {
  44. state.removeVisiable1 = true;
  45. return;
  46. }
  47. if (!state.comment) {
  48. message.error('请输入评语');
  49. return;
  50. }
  51. state.btnLoading = true;
  52. try {
  53. await api_setComment({
  54. comment: state.comment,
  55. id: props.workInfo.studentLessonTrainingId
  56. });
  57. message.success('点评成功');
  58. emit('confrim');
  59. } catch {
  60. //
  61. }
  62. state.btnLoading = false;
  63. state.commentRemind = true;
  64. };
  65. const onSure = () => {
  66. if (state.commentRemind) {
  67. storage.set('isCommentRemind', 1);
  68. }
  69. state.removeVisiable1 = false;
  70. onSubmit();
  71. };
  72. return () => (
  73. <div class={styles.commonWork}>
  74. <img src={commentTop} class={styles.dingPng} alt="" />
  75. <img src={commentBg} class={styles.downMoveBg} alt="" />
  76. <img
  77. src={iconClose}
  78. class={styles.closeAble}
  79. onClick={() => {
  80. emit('close');
  81. }}
  82. alt=""
  83. />
  84. <h2>点评作业</h2>
  85. <div class={styles.header}>
  86. <NAvatar
  87. class={styles.navatar}
  88. round
  89. src={props.workInfo.studentAvatar || defultHeade}
  90. />
  91. <div class={styles.userInfo}>
  92. <h3>{props.workInfo.studentName}</h3>
  93. <p>
  94. 提交时间:{dayjs(props.workInfo.submitTime).format('YYYY-MM-DD')}
  95. </p>
  96. </div>
  97. </div>
  98. <NInput
  99. class={styles.textarea}
  100. type="textarea"
  101. rows={10}
  102. maxlength={500}
  103. showCount
  104. autosize={false}
  105. disabled={props.workInfo.isLook}
  106. v-model:value={state.comment}
  107. placeholder="请输入评语…"
  108. />
  109. {!props.workInfo.isLook && (
  110. <NSpace style={{ padding: '25px 0 0 0' }} justify="center">
  111. <NButton round type="default" onClick={() => emit('close')}>
  112. 取消
  113. </NButton>
  114. <NButton
  115. class={styles.submitAppBtn}
  116. round
  117. type="primary"
  118. loading={state.btnLoading}
  119. onClick={onSubmit}>
  120. 确定
  121. </NButton>
  122. </NSpace>
  123. )}
  124. <NModal
  125. v-model:show={state.removeVisiable1}
  126. preset="card"
  127. class={['modalTitle', styles.removeVisiable1]}
  128. title={'提交评语'}>
  129. <div class={styles.studentRemove}>
  130. <p>
  131. 评语提交后<span>不可修改或删除</span>,请确认是否提交
  132. </p>
  133. <div class={styles.selectBtn}>
  134. <NCheckbox v-model:checked={state.commentRemind}>
  135. 下次不再提醒
  136. </NCheckbox>
  137. </div>
  138. <NSpace class={styles.btnGroupModal} justify="center">
  139. <NButton round onClick={() => (state.removeVisiable1 = false)}>
  140. 取消
  141. </NButton>
  142. <NButton round type="primary" onClick={onSure}>
  143. 确定
  144. </NButton>
  145. </NSpace>
  146. </div>
  147. </NModal>
  148. </div>
  149. );
  150. }
  151. });