hookehuyr

feat(teacher): 添加作业审核功能

实现教师端作业审核功能,包括审核弹窗和状态显示
1 <!-- 1 <!--
2 * @Date: 2025-05-29 15:34:17 2 * @Date: 2025-05-29 15:34:17
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-06-20 13:38:10 4 + * @LastEditTime: 2025-06-24 16:40:27
5 * @FilePath: /mlaj/src/views/teacher/checkinPage.vue 5 * @FilePath: /mlaj/src/views/teacher/checkinPage.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -155,18 +155,18 @@ ...@@ -155,18 +155,18 @@
155 <span class="like-count ml-1">{{ post.likes }}</span> 155 <span class="like-count ml-1">{{ post.likes }}</span>
156 </div> 156 </div>
157 157
158 - <!-- 右侧:点评 --> 158 + <!-- 右侧:审核操作 -->
159 - <!-- <div class="flex items-center cursor-pointer" @click="openCommentPopup(post)"> 159 + <div class="flex items-center cursor-pointer" @click="openAuditDialog(post)">
160 <van-icon 160 <van-icon
161 - name="comment-o" 161 + :name="post.is_audit ? 'passed' : 'close'"
162 - :color="post.is_commented ? '#10b981' : '#999'" 162 + :color="post.is_audit ? '#10b981' : '#f56c6c'"
163 size="18" 163 size="18"
164 class="mr-1" 164 class="mr-1"
165 /> 165 />
166 - <span class="text-sm" :class="post.is_commented ? 'text-green-600' : 'text-gray-500'"> 166 + <span class="text-sm" :class="post.is_audit ? 'text-green-600' : 'text-red-500'">
167 - {{ post.is_commented ? '已点评' : '点评' }} 167 + {{ post.is_audit ? '已通过' : '未通过' }}
168 </span> 168 </span>
169 - </div> --> 169 + </div>
170 </div> 170 </div>
171 </div> 171 </div>
172 </van-list> 172 </van-list>
...@@ -229,7 +229,7 @@ ...@@ -229,7 +229,7 @@
229 <script setup> 229 <script setup>
230 import { ref, onBeforeUnmount, onMounted, computed } from 'vue' 230 import { ref, onBeforeUnmount, onMounted, computed } from 'vue'
231 import { useRoute, useRouter } from 'vue-router' 231 import { useRoute, useRouter } from 'vue-router'
232 -import { showConfirmDialog, showSuccessToast, showFailToast, showLoadingToast } from 'vant'; 232 +import { showConfirmDialog, showSuccessToast, showFailToast, showLoadingToast, showToast } from 'vant';
233 import AppLayout from "@/components/layout/AppLayout.vue"; 233 import AppLayout from "@/components/layout/AppLayout.vue";
234 import FrostedGlass from "@/components/ui/FrostedGlass.vue"; 234 import FrostedGlass from "@/components/ui/FrostedGlass.vue";
235 import VideoPlayer from "@/components/ui/VideoPlayer.vue"; 235 import VideoPlayer from "@/components/ui/VideoPlayer.vue";
...@@ -247,6 +247,10 @@ useTitle(route.meta.title); ...@@ -247,6 +247,10 @@ useTitle(route.meta.title);
247 const showCommentPopup = ref(false) 247 const showCommentPopup = ref(false)
248 const currentCommentPost = ref(null) 248 const currentCommentPost = ref(null)
249 249
250 +// 审核相关
251 +const showAuditDialog = ref(false)
252 +const currentAuditPost = ref(null)
253 +
250 const value1 = ref(0); 254 const value1 = ref(0);
251 const value2 = ref('a'); 255 const value2 = ref('a');
252 const value3 = ref('v'); 256 const value3 = ref('v');
...@@ -632,6 +636,67 @@ const closeCommentPopup = () => { ...@@ -632,6 +636,67 @@ const closeCommentPopup = () => {
632 } 636 }
633 637
634 /** 638 /**
639 + * 打开审核确认弹框
640 + * @param {Object} post - 帖子对象
641 + */
642 +const openAuditDialog = (post) => {
643 + currentAuditPost.value = post
644 + // showAuditDialog.value = true
645 + showConfirmDialog({
646 + title: '温馨提示',
647 + closeOnClickOverlay: true,
648 + cancelButtonText: '不通过',
649 + confirmButtonText: '通过',
650 + confirmButtonColor: '#4caf50',
651 + cancelButtonColor: 'red',
652 + message:
653 + '是否确认审核通过?',
654 + })
655 + .then(() => {
656 + // on confirm
657 + handleAudit(true)
658 + })
659 + .catch(() => {
660 + // on cancel
661 + handleAudit(false)
662 + });
663 +}
664 +
665 +/**
666 + * 关闭审核确认弹框
667 + */
668 +const closeAuditDialog = () => {
669 + showAuditDialog.value = false
670 + currentAuditPost.value = null
671 +}
672 +
673 +/**
674 + * 处理审核操作
675 + * @param {boolean} isApproved - 是否审核通过
676 + */
677 +const handleAudit = async (isApproved) => {
678 + try {
679 + // 这里可以调用API进行审核操作
680 + console.log('审核操作:', {
681 + postId: currentAuditPost.value.id,
682 + isApproved: isApproved
683 + })
684 +
685 + // 更新本地状态
686 + currentAuditPost.value.is_audit = isApproved
687 +
688 + // 显示成功提示
689 + showToast(isApproved ? '审核通过' : '审核不通过')
690 +
691 + // 关闭弹框
692 + closeAuditDialog()
693 + } catch (error) {
694 + console.error('审核操作失败:', error)
695 + showToast('操作失败,请重试')
696 + }
697 +}
698 +
699 +/**
635 * 格式化点评时间 700 * 格式化点评时间
636 * @param {string} timeString - 时间字符串 701 * @param {string} timeString - 时间字符串
637 * @returns {string} 格式化后的时间 702 * @returns {string} 格式化后的时间
...@@ -806,7 +871,7 @@ const formatData = (data) => { ...@@ -806,7 +871,7 @@ const formatData = (data) => {
806 is_liked: item.is_like, 871 is_liked: item.is_like,
807 is_my: item.is_my, 872 is_my: item.is_my,
808 file_type: item.file_type, 873 file_type: item.file_type,
809 - is_commented: item.is_commented || Math.random() > 0.5, // 随机设置是否已点评,用于测试 874 + is_audit: item.is_audit || Math.random() > 0.5, // 随机设置是否已点评,用于测试
810 comment: item.comment || (Math.random() > 0.5 ? { 875 comment: item.comment || (Math.random() > 0.5 ? {
811 rating: Math.floor(Math.random() * 5) + 1, 876 rating: Math.floor(Math.random() * 5) + 1,
812 content: ['作业完成得很好,继续保持!', '需要更加仔细一些,注意细节。', '表现优秀,值得表扬!', '还有进步空间,加油!'][Math.floor(Math.random() * 4)], 877 content: ['作业完成得很好,继续保持!', '需要更加仔细一些,注意细节。', '表现优秀,值得表扬!', '还有进步空间,加油!'][Math.floor(Math.random() * 4)],
......