Browse Source

将完成任务切分

dusenyao 2 years ago
parent
commit
7033e4b696

+ 65 - 0
src/api/course.js

@@ -667,3 +667,68 @@ export function SubmitTaskHomework_Student(data) {
     data
   });
 }
+
+/**
+ * 提交任务资料完成情况(学员提交)
+ * @param {Object} data
+ */
+export function SubmitTask_MaterialFinish_Student(data) {
+  return request({
+    method: 'post',
+    url: process.env.VUE_APP_LearnWebSI,
+    params: getRequestParams('teaching-task_manager-SubmitTask_MaterialFinish_Student'),
+    data
+  });
+}
+
+/**
+ * 提交任务作业文件(学员提交)
+ * @param {Object} data
+ */
+export function SubmitTask_HomeworkFile_Student(data) {
+  return request({
+    method: 'post',
+    url: process.env.VUE_APP_LearnWebSI,
+    params: getRequestParams('teaching-task_manager-SubmitTask_HomeworkFile_Student'),
+    data
+  });
+}
+
+/**
+ * 提交任务消息回复(学员提交)
+ * @param {Object} data
+ */
+export function SubmitTask_MessageReply_Student(data) {
+  return request({
+    method: 'post',
+    url: process.env.VUE_APP_LearnWebSI,
+    params: getRequestParams('teaching-task_manager-SubmitTask_MessageReply_Student'),
+    data
+  });
+}
+
+/**
+ * 删除任务作业文件
+ * @param {Object} data
+ */
+export function DeleteTask_HomeworkFile(data) {
+  return request({
+    method: 'post',
+    url: process.env.VUE_APP_LearnWebSI,
+    params: getRequestParams('teaching-task_manager-DeleteTask_HomeworkFile'),
+    data
+  });
+}
+
+/**
+ * 删除任务消息回复
+ * @param {Object} data
+ */
+export function DeleteTask_MessageReply(data) {
+  return request({
+    method: 'post',
+    url: process.env.VUE_APP_LearnWebSI,
+    params: getRequestParams('teaching-task_manager-DeleteTask_MessageReply'),
+    data
+  });
+}

BIN
src/assets/file/base.png


+ 0 - 1
src/layouts/components/BreadCrumb.vue

@@ -33,7 +33,6 @@ import { useRoute } from 'vue-router/composables';
 const route = useRoute();
 let routerList = ref([]);
 const isShow = computed(() => routerList.value.length > 0);
-console.log(isShow.value);
 
 const emits = defineEmits(['update:isShowNav']);
 

+ 12 - 1
src/views/new_task_view/components/common/FileView.vue

@@ -53,10 +53,12 @@
           class="file-item"
         >
           <div class="file-item-image">
-            <div class="file-operation">
+            <div class="file-operation student">
               <svg-icon icon-class="course-preview" @click="showFileVisible(file_name, file_id)" />
               <span class="vertical-bar"></span>
               <svg-icon icon-class="course-download" @click="downloadFileUrl(file_id, file_name)" />
+              <span class="vertical-bar"></span>
+              <svg-icon icon-class="delete-current" @click="deleteHomework(file_id)" />
             </div>
             <img :src="getFileImage(getFileType(file_name))" />
           </div>
@@ -94,6 +96,10 @@ const props = defineProps({
   addHomework: {
     type: Function,
     default: () => {}
+  },
+  deleteHomework: {
+    type: Function,
+    default: () => {}
   }
 });
 
@@ -155,6 +161,7 @@ function getFileImage(type) {
   if (/^docx?$/.test(type)) {
     return require('@/assets/file/word.png');
   }
+  return require('@/assets/file/base.png');
 }
 
 const showFileVisible = inject('showFileVisible');
@@ -270,6 +277,10 @@ function uploadHomework(file) {
           column-gap: 16px;
           align-items: center;
           justify-content: center;
+
+          &.student {
+            column-gap: 8px;
+          }
         }
       }
     }

+ 5 - 0
src/views/new_task_view/components/common/SubtaskItem.vue

@@ -43,6 +43,7 @@
           :accessory-list="file_list"
           :homework-list="homework_list"
           :add-homework="addHomework(i)"
+          :delete-homework="deleteHomework(i)"
         />
         <MessageView
           v-if="info_block_type === taskClassify[3].type"
@@ -93,6 +94,10 @@ defineProps({
   deleteMessageItem: {
     type: Function,
     default: () => {}
+  },
+  deleteHomework: {
+    type: Function,
+    default: () => {}
   }
 });
 

+ 1 - 1
src/views/new_task_view/components/layouts/LeftSidebar.vue

@@ -24,7 +24,7 @@
           </div>
           <div
             v-for="({ name: subtaskName }, subtask_index) in child_task_list"
-            :key="`sidebar-subtask-${subtask_index}`"
+            :key="`sidebar-subtask-${index}-${subtask_index}`"
             :class="['task-list-subtask', curSelectMark === `${type}-${index}-${subtask_index}` ? 'active' : '']"
           >
             <span class="task-index" @click="setSelectMark(type, index, subtask_index)">

+ 211 - 15
src/views/new_task_view/components/student/index.vue

@@ -44,6 +44,7 @@
             :accessory-list="accessory_list"
             :homework-list="homework_list"
             :add-homework="curry(taskAddHomework)(taskIndex)"
+            :delete-homework="curry(deleteTaskHomework)(taskIndex)"
           />
 
           <MessageView
@@ -66,6 +67,7 @@
             :add-exam-answer="curry(addSubtaskAnswer)(taskIndex)(i)"
             :add-message-item="curry(addSubtaskMessageItem)(taskIndex)(i)"
             :delete-message-item="curry(deleteSubtaskMessageItem)(taskIndex)(i)"
+            :delete-homework="curry(deleteSubtaskHomework)(taskIndex)(i)"
           />
         </template>
       </div>
@@ -86,6 +88,14 @@ import { useShowFile } from '@/common/show_file/index';
 import { previewDateTransform } from '@/utils/course';
 import { taskClassify } from '@/views/teacher/create_course/step_three/components/data/constant';
 import { curry } from '@/utils/common';
+import {
+  SubmitTask_MaterialFinish_Student,
+  SubmitTask_HomeworkFile_Student,
+  SubmitTask_MessageReply_Student,
+  DeleteTask_HomeworkFile,
+  DeleteTask_MessageReply
+} from '@/api/course';
+import { MessageBox } from 'element-ui';
 
 import ShowFile from '@/common/show_file/index.vue';
 import FileView from '../common/FileView.vue';
@@ -98,41 +108,227 @@ let { visible, curFileId, curFileName, dialogShowFileClose } = useShowFile();
 let taskList = inject('taskList');
 let taskType = inject('taskType');
 
-// 添加作业
+/**
+ * 添加任务作业
+ * @param {Number} index 任务索引
+ * @param {Object} file 文件数据
+ */
 function taskAddHomework(index, file) {
-  taskList.value[index].homework_list.push(file);
+  SubmitTask_HomeworkFile_Student({
+    task_id: taskList.value[index].id,
+    info_block_id: '',
+    file_id: file.file_id
+  }).then(({ status }) => {
+    if (status === 1) {
+      taskList.value[index].homework_list.push(file);
+    }
+  });
 }
 
+/**
+ * 添加子任务作业
+ * @param {Number} index 任务索引
+ * @param {Number} subIndex 子任务索引
+ * @param {Number} infoIndex 信息块索引
+ * @param {Object} file 文件数据
+ */
 function subtaskAddHomework(index, subIndex, infoIndex, file) {
-  taskList.value[index].child_task_list[subIndex].info_block_list[infoIndex].homework_list.push(file);
+  const infoBlockItem = taskList.value[index].child_task_list[subIndex].info_block_list[infoIndex];
+  SubmitTask_HomeworkFile_Student({
+    task_id: taskList.value[index].id,
+    info_block_id: infoBlockItem.id,
+    file_id: file.file_id
+  }).then(({ status }) => {
+    if (status === 1) {
+      infoBlockItem.homework_list.push(file);
+    }
+  });
+}
+
+/**
+ * 删除任务作业
+ * @param {Number} index 任务索引
+ * @param {String} file_id 文件id
+ */
+function deleteTaskHomework(index, file_id) {
+  MessageBox.confirm('您确定要删除该作业吗?', '提示', {
+    confirmButtonText: '确定',
+    cancelButtonText: '取消',
+    type: 'warning'
+  }).then(() => {
+    DeleteTask_HomeworkFile({
+      task_id: taskList.value[index].id,
+      info_block_id: '',
+      file_id
+    }).then(({ status }) => {
+      if (status === 1) {
+        taskList.value[index].homework_list = taskList.value[index].homework_list.filter(
+          (item) => item.file_id !== file_id
+        );
+      }
+    });
+  });
+}
+
+/**
+ * 删除子任务作业
+ * @param {Number} index 任务索引
+ * @param {Number} subIndex 子任务索引
+ * @param {Number} infoIndex 信息块索引
+ * @param {String} file_id 文件id
+ */
+function deleteSubtaskHomework(index, subIndex, infoIndex, file_id) {
+  MessageBox.confirm('您确定要删除该作业吗?', '提示', {
+    confirmButtonText: '确定',
+    cancelButtonText: '取消',
+    type: 'warning'
+  }).then(() => {
+    const infoBlockItem = taskList.value[index].child_task_list[subIndex].info_block_list[infoIndex];
+    DeleteTask_HomeworkFile({
+      task_id: taskList.value[index].id,
+      info_block_id: infoBlockItem.id,
+      file_id
+    }).then(({ status }) => {
+      if (status === 1) {
+        infoBlockItem.homework_list = infoBlockItem.homework_list.filter((item) => item.file_id !== file_id);
+      }
+    });
+  });
 }
 
-// 课件添加答案
-function addExamAnswer(index, courseIndex, answer) {
-  taskList.value[index].courseware_list[courseIndex].exam_answer = answer;
+/**
+ * 课件添加答案
+ * @param {Number} index 任务索引
+ * @param {Number} courseIndex 课件索引
+ * @param {Object} exam_answer 答案
+ */
+function addExamAnswer(index, courseIndex, exam_answer) {
+  const coursewareItem = taskList.value[index].courseware_list[courseIndex];
+  SubmitTask_MaterialFinish_Student({
+    task_id: taskList.value[index].id,
+    info_block_id: '',
+    material_id: coursewareItem.courseware_id,
+    material_type: 'COURSEWARE',
+    exam_answer
+  }).then(({ status }) => {
+    if (status === 1) {
+      coursewareItem.exam_answer = exam_answer;
+    }
+  });
 }
 
-function addSubtaskAnswer(index, subIndex, infoIndex, courseIndex, answer) {
-  taskList.value[index].child_task_list[subIndex].info_block_list[infoIndex].courseware_list[courseIndex].exam_answer =
-    answer;
+/**
+ * 子任务课件添加答案
+ * @param {Number} index 任务索引
+ * @param {Number} subIndex 子任务索引
+ * @param {Number} infoIndex 信息块索引
+ * @param {Number} courseIndex 课件索引
+ * @param {Object} exam_answer 答案
+ */
+function addSubtaskAnswer(index, subIndex, infoIndex, courseIndex, exam_answer) {
+  const infoBlockItem = taskList.value[index].child_task_list[subIndex].info_block_list[infoIndex];
+  SubmitTask_MaterialFinish_Student({
+    task_id: taskList.value[index].id,
+    info_block_id: infoBlockItem.id,
+    material_id: infoBlockItem.courseware_list[courseIndex].courseware_id,
+    material_type: 'COURSEWARE',
+    exam_answer
+  }).then(({ status }) => {
+    if (status === 1) {
+      infoBlockItem.courseware_list[courseIndex].exam_answer = exam_answer;
+    }
+  });
 }
 
-// 添加消息列表项
+/**
+ * 添加消息列表项
+ * @param {Number} index 任务索引
+ * @param {Object} data 消息数据
+ */
 function addMessageItem(index, data) {
-  taskList.value[index].message_list.push(data);
+  SubmitTask_MessageReply_Student({
+    task_id: taskList.value[index].id,
+    is_task_remark: false,
+    info_block_id: '',
+    text: data.text,
+    file_id: data.file_id,
+    message_type: data.message_type
+  }).then(({ status, id }) => {
+    if (status === 1) {
+      taskList.value[index].message_list.push({ id, ...data });
+    }
+  });
 }
 
+/**
+ * 添加子任务消息列表项
+ * @param {Number} index 任务索引
+ * @param {Number} subIndex 子任务索引
+ * @param {Number} infoIndex 信息块索引
+ * @param {Object} data 消息数据
+ */
 function addSubtaskMessageItem(index, subIndex, infoIndex, data) {
-  taskList.value[index].child_task_list[subIndex].info_block_list[infoIndex].message_list.push(data);
+  const infoBlockItem = taskList.value[index].child_task_list[subIndex].info_block_list[infoIndex];
+  SubmitTask_MessageReply_Student({
+    task_id: taskList.value[index].id,
+    is_task_remark: false,
+    info_block_id: infoBlockItem.id,
+    text: data.text,
+    file_id: data.file_id,
+    message_type: data.message_type
+  }).then(({ status, id }) => {
+    if (status === 1) {
+      infoBlockItem.message_list.push({ id, ...data });
+    }
+  });
 }
 
-// 删除消息列表项
+/**
+ * 删除消息列表项
+ * @param {Number} index 任务索引
+ * @param {Number} i 消息索引
+ */
 function deleteMessageItem(index, i) {
-  taskList.value[index].message_list.splice(i, 1);
+  MessageBox.confirm('您确定要删除该消息吗?', '提示', {
+    confirmButtonText: '确定',
+    cancelButtonText: '取消',
+    type: 'warning'
+  }).then(() => {
+    const messageList = taskList.value[index].message_list;
+    DeleteTask_MessageReply({
+      task_id: taskList.value[index].id,
+      message_id: messageList[i].id
+    }).then(({ status }) => {
+      if (status === 1) {
+        messageList.splice(i, 1);
+      }
+    });
+  });
 }
 
+/**
+ * 删除子任务消息列表项
+ * @param {Number} index 任务索引
+ * @param {Number} subIndex 子任务索引
+ * @param {Number} infoIndex 信息块索引
+ * @param {Number} i 消息索引
+ */
 function deleteSubtaskMessageItem(index, subIndex, infoIndex, i) {
-  taskList.value[index].child_task_list[subIndex].info_block_list[infoIndex].message_list.splice(i, 1);
+  MessageBox.confirm('您确定要删除该消息吗?', '提示', {
+    confirmButtonText: '确定',
+    cancelButtonText: '取消',
+    type: 'warning'
+  }).then(() => {
+    const subtaskMessageList = taskList.value[index].child_task_list[subIndex].info_block_list[infoIndex].message_list;
+    DeleteTask_MessageReply({
+      task_id: taskList.value[index].id,
+      message_id: subtaskMessageList[i].id
+    }).then(({ status }) => {
+      if (status === 1) {
+        subtaskMessageList.splice(i, 1);
+      }
+    });
+  });
 }
 </script>
 

+ 2 - 2
src/views/new_task_view/index.vue

@@ -13,7 +13,7 @@
     <div class="title">
       <div class="csitem-name">{{ taskData.cs_item_name }}</div>
       <div class="title-button primary" @click="saveCSItem">
-        <svg-icon icon-class="preserve" /><span class="button-name">{{ isTeacher ? '保存' : '提交任务' }}</span>
+        <svg-icon icon-class="preserve" /><span class="button-name">{{ isTeacher ? '保存' : '完成任务' }}</span>
       </div>
     </div>
 
@@ -86,7 +86,7 @@ const { visible_video, sendVideo } = videoRecording();
 useOtherPausePlay();
 
 function saveCSItem() {
-  isTeacher ? teacherSubmit() : studentSubmit();
+  // isTeacher ? teacherSubmit() : studentSubmit();
 }
 
 function teacherSubmit() {}

+ 1 - 1
src/views/teacher/create_course/step_three/components/layouts/LeftSidebar.vue

@@ -19,7 +19,7 @@
           </div>
           <div
             v-for="({ name: subtaskName }, subtask_index) in child_task_list"
-            :key="`sidebar-subtask-${subtask_index}`"
+            :key="`sidebar-subtask-${index}-${subtask_index}`"
             :class="['task-list-subtask', curSelectMark === `${type}-${index}-${subtask_index}` ? 'active' : '']"
           >
             <span class="task-index" @click="setSelectMark(type, index, subtask_index)">