Browse Source

添加作业

lex 1 year ago
parent
commit
754c114f89

+ 1 - 1
public/version.json

@@ -1 +1 @@
-{ "version": 1706889915155 }
+{"version":1707104471251}

+ 7 - 3
src/views/classList/components/afterWorkDetail.tsx

@@ -97,7 +97,6 @@ export default defineComponent({
       }
     };
     const getWorkInfo = async () => {
-      console.log(route.query);
       try {
         const res = await getWorkDetail({ trainingId: route.query.trainingId });
         state.workInfo = { ...res.data };
@@ -206,10 +205,15 @@ export default defineComponent({
               <h4>{state.workInfo.teacherName}</h4>
               <p>
                 布置时间:
-                {dayjs(state.workInfo.createTime).format('YYYY-MM-DD')} |{' '}
+                {state.workInfo.createTime
+                  ? dayjs(state.workInfo.createTime).format('YYYY-MM-DD')
+                  : '--'}{' '}
+                |{' '}
                 <span>
                   截止时间:
-                  {dayjs(state.workInfo.expireDate).format('YYYY-MM-DD')}
+                  {state.workInfo.expireDate
+                    ? dayjs(state.workInfo.expireDate).format('YYYY-MM-DD')
+                    : '--'}
                 </span>
               </p>
             </div>

+ 33 - 1
src/views/classList/modals/TrainingDetails.tsx

@@ -7,7 +7,8 @@ import {
   NSelect,
   NImage,
   NScrollbar,
-  NSpin
+  NSpin,
+  NModal
 } from 'naive-ui';
 import { defineComponent, onMounted, reactive, ref } from 'vue';
 import { getTrainingStudentDetail } from '../api';
@@ -19,6 +20,7 @@ import qualified from '../images/qualified.png';
 import unqualified from '../images/unqualified.png';
 import { evaluateDifficult } from '/src/utils/contants';
 import dayjs from 'dayjs';
+import CommentWork from '../../studentList/modals/comment-work';
 export default defineComponent({
   props: {
     activeRow: {
@@ -46,6 +48,7 @@ export default defineComponent({
       studentAvatar: '',
       studentLessonTrainingDetails: [] as any
     } as any);
+    const showModalMask = ref(false);
     const message = useMessage();
     const foemsRef = ref();
     const typeFormat = (trainingType: string, configJson: any) => {
@@ -156,6 +159,18 @@ export default defineComponent({
                 src={qualified}></NImage>
             ) : null}
           </div>
+
+          {studnetInfo.value.trainingStatus !== 'UNSUBMITTED' && (
+            <NButton
+              onClick={() => (showModalMask.value = true)}
+              class={styles.commentBtnGroup}>
+              <div class={styles.text}>
+                <i class={studnetInfo.value.comment && styles.look}></i>
+
+                {studnetInfo.value.comment ? '查看评语' : '点评作业'}
+              </div>
+            </NButton>
+          )}
           <NScrollbar style="max-height:400px" trigger="none">
             <div class={styles.workList}>
               {studnetInfo.value.studentLessonTrainingDetails.map(
@@ -199,6 +214,23 @@ export default defineComponent({
             </div>
           </NSpace>
         </NSpin>
+
+        <NModal v-model:show={showModalMask.value}>
+          <CommentWork
+            comment={studnetInfo.value.comment}
+            workInfo={{
+              isLook: studnetInfo.value.comment ? true : false,
+              studentName: studnetInfo.value.studentName,
+              submitTime: studnetInfo.value.submitTime,
+              studentLessonTrainingId: studnetInfo.value.studentLessonTrainingId
+            }}
+            onClose={() => (showModalMask.value = false)}
+            onConfrim={() => {
+              getTrainingDetail(props.activeRow.id);
+              showModalMask.value = false;
+            }}
+          />
+        </NModal>
       </div>
     );
   }

+ 9 - 0
src/views/studentList/api.ts

@@ -57,3 +57,12 @@ export const schoolDetail = (params: any) => {
     params
   });
 };
+
+/**
+ * 设置评语
+ */
+export const api_setComment = (params: any) => {
+  return request.post('/edu-app/lessonTraining/setComment', {
+    data: params
+  });
+};

+ 57 - 0
src/views/studentList/modals/comment-work/index.module.less

@@ -125,4 +125,61 @@
     }
 
   }
+}
+
+.removeVisiable1 {
+  width: 473px;
+
+  :global {
+    .n-card-header {
+      font-size: max(22px, 16Px);
+    }
+  }
+
+  .studentRemove {
+    padding: 20px 40px 0;
+
+    p {
+      font-size: max(18px, 14Px);
+      color: #777777;
+      line-height: 30px;
+
+      span {
+        color: #EA4132;
+      }
+    }
+
+    .selectBtn {
+      display: flex;
+      justify-content: center;
+      padding-top: 13px;
+      padding-bottom: 8px;
+
+
+      :global {
+        .n-checkbox {
+          display: flex;
+          align-items: center;
+          --n-border-radius: 50% !important;
+        }
+
+        .n-checkbox__label {
+          font-size: max(16px, 12Px);
+          color: #777777;
+          line-height: 24px;
+        }
+      }
+    }
+  }
+
+  .btnGroupModal {
+    padding: 32px 0;
+
+    :global {
+      .n-button {
+        height: 47px;
+        min-width: 156px;
+      }
+    }
+  }
 }

+ 108 - 13
src/views/studentList/modals/comment-work/index.tsx

@@ -1,15 +1,73 @@
-import { defineComponent } from 'vue';
+import { defineComponent, reactive } from 'vue';
 import styles from './index.module.less';
-import { NAvatar, NButton, NInput, NSpace } from 'naive-ui';
+import {
+  NAvatar,
+  NButton,
+  NCheckbox,
+  NInput,
+  NModal,
+  NSpace,
+  useMessage
+} from 'naive-ui';
 import commentBg from '../images/common-bg.png';
 import commentTop from '../images/common-top.png';
 import iconClose from '../images/icon-close-line.png';
 import defultHeade from '@/components/layout/images/teacherIcon.png';
+import { api_setComment } from '../../api';
+import dayjs from 'dayjs';
+import { storage } from '/src/utils/storage';
 
 export default defineComponent({
   name: 'commit-work',
-  emits: ['close'],
+  props: {
+    /** 评语内容 */
+    comment: {
+      type: String,
+      default: ''
+    },
+    workInfo: {
+      type: Object,
+      default: () => ({})
+    }
+  },
+  emits: ['close', 'confrim'],
   setup(props, { emit }) {
+    const message = useMessage();
+
+    const state = reactive({
+      removeVisiable1: false,
+      comment: props.comment,
+      btnLoading: false,
+      commentRemind: true
+    });
+    const onSubmit = async () => {
+      const isCommentRemind = storage.get('isCommentRemind');
+      if (isCommentRemind != 1) {
+        state.removeVisiable1 = true;
+        return;
+      }
+      state.btnLoading = true;
+      try {
+        await api_setComment({
+          comment: state.comment,
+          id: props.workInfo.studentLessonTrainingId
+        });
+
+        message.success('点评成功');
+        emit('confrim');
+      } catch {
+        //
+      }
+      state.btnLoading = false;
+    };
+
+    const onSure = () => {
+      if (state.commentRemind) {
+        storage.set('isCommentRemind', 1);
+      }
+      state.removeVisiable1 = false;
+      onSubmit();
+    };
     return () => (
       <div class={styles.commonWork}>
         <img src={commentTop} class={styles.dingPng} alt="" />
@@ -27,8 +85,10 @@ export default defineComponent({
         <div class={styles.header}>
           <NAvatar class={styles.navatar} round src={defultHeade} />
           <div class={styles.userInfo}>
-            <h3>胡小小</h3>
-            <p>提交时间:2024-01-23</p>
+            <h3>{props.workInfo.studentName}</h3>
+            <p>
+              提交时间:{dayjs(props.workInfo.submitTime).format('YYYY-MM-DD')}
+            </p>
           </div>
         </div>
 
@@ -39,17 +99,52 @@ export default defineComponent({
           maxlength={500}
           showCount
           autosize={false}
+          disabled={props.workInfo.isLook}
+          v-model:value={state.comment}
           placeholder="请输入评语…"
         />
 
-        <NSpace style={{ padding: '25px 0 0 0' }} justify="center">
-          <NButton round type="default" onClick={() => emit('close')}>
-            取消
-          </NButton>
-          <NButton class={styles.submitAppBtn} round type="primary">
-            确定
-          </NButton>
-        </NSpace>
+        {!props.workInfo.isLook && (
+          <NSpace style={{ padding: '25px 0 0 0' }} justify="center">
+            <NButton round type="default" onClick={() => emit('close')}>
+              取消
+            </NButton>
+            <NButton
+              class={styles.submitAppBtn}
+              round
+              type="primary"
+              loading={state.btnLoading}
+              onClick={onSubmit}>
+              确定
+            </NButton>
+          </NSpace>
+        )}
+
+        <NModal
+          v-model:show={state.removeVisiable1}
+          preset="card"
+          class={['modalTitle', styles.removeVisiable1]}
+          title={'提交评语'}>
+          <div class={styles.studentRemove}>
+            <p>
+              评语提交后<span>不可修改或删除</span>,请确认是否提交
+            </p>
+            <div class={styles.selectBtn}>
+              <NCheckbox v-model:checked={state.commentRemind}>
+                下次不在提醒
+              </NCheckbox>
+            </div>
+
+            <NSpace class={styles.btnGroupModal} justify="center">
+              <NButton round onClick={() => (state.removeVisiable1 = false)}>
+                取消
+              </NButton>
+              <NButton round type="primary" onClick={onSure}>
+                确定
+              </NButton>
+            </NSpace>
+          </div>
+        </NModal>
       </div>
     );
   }

+ 25 - 9
src/views/studentList/modals/studentTraomomhDetails.tsx

@@ -169,14 +169,17 @@ export default defineComponent({
             ) : null}
           </div>
 
-          <NButton
-            onClick={() => (showModalMask.value = true)}
-            class={styles.commentBtnGroup}>
-            <div class={styles.text}>
-              <i class={styles.look}></i>
-              点评作业
-            </div>
-          </NButton>
+          {teacherInfo.value.trainingStatus !== 'UNSUBMITTED' && (
+            <NButton
+              onClick={() => (showModalMask.value = true)}
+              class={styles.commentBtnGroup}>
+              <div class={styles.text}>
+                <i class={teacherInfo.value.comment && styles.look}></i>
+
+                {teacherInfo.value.comment ? '查看评语' : '点评作业'}
+              </div>
+            </NButton>
+          )}
 
           <NScrollbar style="max-height:400px" trigger="none">
             <div class={styles.workList}>
@@ -195,7 +198,20 @@ export default defineComponent({
         </NSpin>
 
         <NModal v-model:show={showModalMask.value}>
-          <CommentWork onClose={() => (showModalMask.value = false)} />
+          <CommentWork
+            comment={teacherInfo.value.comment}
+            workInfo={{
+              isLook: teacherInfo.value.comment ? true : false,
+              studentName: teacherInfo.value.studentName,
+              submitTime: teacherInfo.value.submitTime,
+              studentLessonTrainingId: teacherInfo.value.studentLessonTrainingId
+            }}
+            onClose={() => (showModalMask.value = false)}
+            onConfrim={() => {
+              getTrainingDetail(props.activeRow.id);
+              showModalMask.value = false;
+            }}
+          />
         </NModal>
       </div>
     );

+ 2 - 2
vite.config.ts

@@ -23,9 +23,9 @@ function resolve(dir: string) {
 }
 // https://vitejs.dev/config/
 // https://github.com/vitejs/vite/issues/1930 .env
-const proxyUrl = 'https://dev.kt.colexiu.com/';
+// const proxyUrl = 'https://dev.kt.colexiu.com/';
 // const proxyUrl = 'https://test.lexiaoya.cn';
-// const proxyUrl = 'http://192.168.3.14:7989';
+const proxyUrl = 'http://192.168.3.14:7989';
 const now = new Date().getTime();
 export default defineConfig(() => {
   return {