index.tsx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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) {
  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. };
  64. const onSure = () => {
  65. if (state.commentRemind) {
  66. storage.set('isCommentRemind', 1);
  67. }
  68. state.removeVisiable1 = false;
  69. onSubmit();
  70. };
  71. return () => (
  72. <div class={styles.commonWork}>
  73. <img src={commentTop} class={styles.dingPng} alt="" />
  74. <img src={commentBg} class={styles.downMoveBg} alt="" />
  75. <img
  76. src={iconClose}
  77. class={styles.closeAble}
  78. onClick={() => {
  79. emit('close');
  80. }}
  81. alt=""
  82. />
  83. <h2>点评作业</h2>
  84. <div class={styles.header}>
  85. <NAvatar
  86. class={styles.navatar}
  87. round
  88. src={props.workInfo.studentAvatar || defultHeade}
  89. />
  90. <div class={styles.userInfo}>
  91. <h3>{props.workInfo.studentName}</h3>
  92. <p>
  93. 提交时间:{dayjs(props.workInfo.submitTime).format('YYYY-MM-DD')}
  94. </p>
  95. </div>
  96. </div>
  97. <NInput
  98. class={styles.textarea}
  99. type="textarea"
  100. rows={10}
  101. maxlength={500}
  102. showCount
  103. autosize={false}
  104. disabled={props.workInfo.isLook}
  105. v-model:value={state.comment}
  106. placeholder="请输入评语…"
  107. />
  108. {!props.workInfo.isLook && (
  109. <NSpace style={{ padding: '25px 0 0 0' }} justify="center">
  110. <NButton round type="default" onClick={() => emit('close')}>
  111. 取消
  112. </NButton>
  113. <NButton
  114. class={styles.submitAppBtn}
  115. round
  116. type="primary"
  117. loading={state.btnLoading}
  118. onClick={onSubmit}>
  119. 确定
  120. </NButton>
  121. </NSpace>
  122. )}
  123. <NModal
  124. v-model:show={state.removeVisiable1}
  125. preset="card"
  126. class={['modalTitle', styles.removeVisiable1]}
  127. title={'提交评语'}>
  128. <div class={styles.studentRemove}>
  129. <p>
  130. 评语提交后<span>不可修改或删除</span>,请确认是否提交
  131. </p>
  132. <div class={styles.selectBtn}>
  133. <NCheckbox v-model:checked={state.commentRemind}>
  134. 下次不再提醒
  135. </NCheckbox>
  136. </div>
  137. <NSpace class={styles.btnGroupModal} justify="center">
  138. <NButton round onClick={() => (state.removeVisiable1 = false)}>
  139. 取消
  140. </NButton>
  141. <NButton round type="primary" onClick={onSure}>
  142. 确定
  143. </NButton>
  144. </NSpace>
  145. </div>
  146. </NModal>
  147. </div>
  148. );
  149. }
  150. });