hookehuyr

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

实现教师端作业审核功能,包括审核弹窗和状态显示
<!--
* @Date: 2025-05-29 15:34:17
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-06-20 13:38:10
* @LastEditTime: 2025-06-24 16:40:27
* @FilePath: /mlaj/src/views/teacher/checkinPage.vue
* @Description: 文件描述
-->
......@@ -155,18 +155,18 @@
<span class="like-count ml-1">{{ post.likes }}</span>
</div>
<!-- 右侧:点评 -->
<!-- <div class="flex items-center cursor-pointer" @click="openCommentPopup(post)">
<!-- 右侧:审核操作 -->
<div class="flex items-center cursor-pointer" @click="openAuditDialog(post)">
<van-icon
name="comment-o"
:color="post.is_commented ? '#10b981' : '#999'"
:name="post.is_audit ? 'passed' : 'close'"
:color="post.is_audit ? '#10b981' : '#f56c6c'"
size="18"
class="mr-1"
/>
<span class="text-sm" :class="post.is_commented ? 'text-green-600' : 'text-gray-500'">
{{ post.is_commented ? '已点评' : '点评' }}
<span class="text-sm" :class="post.is_audit ? 'text-green-600' : 'text-red-500'">
{{ post.is_audit ? '已通过' : '未通过' }}
</span>
</div> -->
</div>
</div>
</div>
</van-list>
......@@ -229,7 +229,7 @@
<script setup>
import { ref, onBeforeUnmount, onMounted, computed } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { showConfirmDialog, showSuccessToast, showFailToast, showLoadingToast } from 'vant';
import { showConfirmDialog, showSuccessToast, showFailToast, showLoadingToast, showToast } from 'vant';
import AppLayout from "@/components/layout/AppLayout.vue";
import FrostedGlass from "@/components/ui/FrostedGlass.vue";
import VideoPlayer from "@/components/ui/VideoPlayer.vue";
......@@ -247,6 +247,10 @@ useTitle(route.meta.title);
const showCommentPopup = ref(false)
const currentCommentPost = ref(null)
// 审核相关
const showAuditDialog = ref(false)
const currentAuditPost = ref(null)
const value1 = ref(0);
const value2 = ref('a');
const value3 = ref('v');
......@@ -632,6 +636,67 @@ const closeCommentPopup = () => {
}
/**
* 打开审核确认弹框
* @param {Object} post - 帖子对象
*/
const openAuditDialog = (post) => {
currentAuditPost.value = post
// showAuditDialog.value = true
showConfirmDialog({
title: '温馨提示',
closeOnClickOverlay: true,
cancelButtonText: '不通过',
confirmButtonText: '通过',
confirmButtonColor: '#4caf50',
cancelButtonColor: 'red',
message:
'是否确认审核通过?',
})
.then(() => {
// on confirm
handleAudit(true)
})
.catch(() => {
// on cancel
handleAudit(false)
});
}
/**
* 关闭审核确认弹框
*/
const closeAuditDialog = () => {
showAuditDialog.value = false
currentAuditPost.value = null
}
/**
* 处理审核操作
* @param {boolean} isApproved - 是否审核通过
*/
const handleAudit = async (isApproved) => {
try {
// 这里可以调用API进行审核操作
console.log('审核操作:', {
postId: currentAuditPost.value.id,
isApproved: isApproved
})
// 更新本地状态
currentAuditPost.value.is_audit = isApproved
// 显示成功提示
showToast(isApproved ? '审核通过' : '审核不通过')
// 关闭弹框
closeAuditDialog()
} catch (error) {
console.error('审核操作失败:', error)
showToast('操作失败,请重试')
}
}
/**
* 格式化点评时间
* @param {string} timeString - 时间字符串
* @returns {string} 格式化后的时间
......@@ -806,7 +871,7 @@ const formatData = (data) => {
is_liked: item.is_like,
is_my: item.is_my,
file_type: item.file_type,
is_commented: item.is_commented || Math.random() > 0.5, // 随机设置是否已点评,用于测试
is_audit: item.is_audit || Math.random() > 0.5, // 随机设置是否已点评,用于测试
comment: item.comment || (Math.random() > 0.5 ? {
rating: Math.floor(Math.random() * 5) + 1,
content: ['作业完成得很好,继续保持!', '需要更加仔细一些,注意细节。', '表现优秀,值得表扬!', '还有进步空间,加油!'][Math.floor(Math.random() * 4)],
......