wuzhen update

This commit is contained in:
wuzhen committed 2025-09-07 18:17:50 +08:00
1 parent edaf8dbacf
commit 48da578546
86 files changed
+2101 -1849

No files matched your search

+63 -115
View File
@@ -12,19 +12,9 @@
</el-col>
<el-col :span="6">
<el-form-item label="活动类型" prop="activityType">
<el-select
v-model="queryParams.activityType"
placeholder="请选择活动类型"
clearable
style="width: 100%"
>
<el-select v-model="queryParams.activityType" placeholder="请选择活动类型" clearable style="width: 100%">
<el-option label="全部" value="" />
<el-option
v-for="dict in stgl_activity_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
<el-option v-for="dict in stgl_activity_type" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
</el-col>
@@ -44,7 +34,7 @@
</el-form-item>
</el-col> -->
</el-row>
<el-row>
<el-col :span="24" class="search-btn-container">
<el-form-item>
@@ -106,7 +96,7 @@
</el-table-column>
<el-table-column label="报名状态" align="center" prop="myRegistrationStatus" width="100">
<template #default="scope">
<el-tag
<el-tag
:type="scope.row.myRegistrationStatus === '1' ? 'success' : scope.row.myRegistrationStatus === '2' ? 'danger' : 'warning'"
size="small"
>
@@ -217,7 +207,9 @@
<span class="rating-text">{{ detailForm.myRatingScore }}</span>
</div>
</el-descriptions-item>
<el-descriptions-item label="评分时间" v-if="detailForm.myRatingTime">{{ parseTime(detailForm.myRatingTime, '{y}-{m}-{d} {h}:{i}') }}</el-descriptions-item>
<el-descriptions-item label="评分时间" v-if="detailForm.myRatingTime">{{
parseTime(detailForm.myRatingTime, '{y}-{m}-{d} {h}:{i}')
}}</el-descriptions-item>
<el-descriptions-item label="活动平均评分" v-if="detailForm.averageRating">
<div class="rating-cell">
<el-rate :model-value="detailForm.averageRating" disabled size="small" />
@@ -305,10 +297,7 @@
</el-table-column>
<el-table-column label="身份" align="center" width="80">
<template #default="{ row }">
<el-tag
:type="row.isLeader === 1 ? 'success' : 'info'"
size="small"
>
<el-tag :type="row.isLeader === 1 ? 'success' : 'info'" size="small">
{{ row.isLeader === 1 ? '队长' : '队员' }}
</el-tag>
</template>
@@ -321,14 +310,12 @@
</div>
<div v-else class="no-team-info">
<el-empty description="未找到队伍信息" :image-size="60">
<el-button type="primary" size="small" @click="getTeamInfo(detailForm.id)">
重新获取
</el-button>
<el-button type="primary" size="small" @click="getTeamInfo(detailForm.id)"> 重新获取 </el-button>
</el-empty>
</div>
</div>
</div>
<template #footer>
<div class="dialog-footer">
<el-button @click="detailOpen = false">关 闭</el-button>
@@ -382,10 +369,10 @@
</el-dialog>
<!-- 签到对话框 -->
<el-dialog
title="活动签到"
v-model="attendanceOpen"
width="560px"
<el-dialog
title="活动签到"
v-model="attendanceOpen"
width="560px"
append-to-body
:close-on-click-modal="false"
:close-on-press-escape="true"
@@ -393,25 +380,11 @@
>
<div class="attendance-content">
<div class="attendance-actions">
<el-button
type="primary"
size="large"
:loading="signInLoading"
:disabled="!canSignIn"
@click="handleSignIn"
class="action-btn"
>
<el-button type="primary" size="large" :loading="signInLoading" :disabled="!canSignIn" @click="handleSignIn" class="action-btn">
{{ signInButtonText }}
</el-button>
<el-button
type="warning"
size="large"
:loading="signOutLoading"
:disabled="!canSignOut"
@click="handleSignOut"
class="action-btn"
>
<el-button type="warning" size="large" :loading="signOutLoading" :disabled="!canSignOut" @click="handleSignOut" class="action-btn">
签 退
</el-button>
</div>
@@ -420,24 +393,10 @@
<div class="attendance-records" v-if="attendanceRecords.length > 0">
<div class="records-header">
<span class="records-title">签到记录</span>
<el-button
type="text"
size="small"
@click="refreshRecords"
:loading="recordsLoading"
>
刷新
</el-button>
<el-button type="text" size="small" @click="refreshRecords" :loading="recordsLoading"> 刷新 </el-button>
</div>
<el-table
:data="attendanceRecords"
stripe
size="small"
class="records-table"
v-loading="recordsLoading"
:max-height="getTableMaxHeight()"
>
<el-table :data="attendanceRecords" stripe size="small" class="records-table" v-loading="recordsLoading" :max-height="getTableMaxHeight()">
<el-table-column prop="signInTime" label="签到时间" width="200">
<template #default="{ row }">
{{ formatDateTime(row.signInTime) }}
@@ -451,10 +410,7 @@
<el-table-column prop="status" label="状态" width="100">
<template #default="{ row }">
<el-tag
:type="row.signOutTime ? 'success' : 'warning'"
size="small"
>
<el-tag :type="row.signOutTime ? 'success' : 'warning'" size="small">
{{ row.signOutTime ? '已完成' : '进行中' }}
</el-tag>
</template>
@@ -549,23 +505,23 @@ const getList = async () => {
const params = Object.fromEntries(
Object.entries(queryParams.value).filter(([_, value]) => value !== '' && value !== undefined && value !== null)
);
// 直接使用getMyActivities接口,后端已经处理了所有情况(包括用户作为队员参与的活动)
const res = await getMyActivities(params);
const activities = res.data || [];
// 按报名时间排序
activities.sort((a, b) => {
const timeA = a.myRegistrationTime ? new Date(a.myRegistrationTime).getTime() : 0;
const timeB = b.myRegistrationTime ? new Date(b.myRegistrationTime).getTime() : 0;
return timeB - timeA; // 降序排列
});
activityList.value = activities;
console.log('我的活动列表数据:', {
totalCount: activities.length,
activities: activities.map(activity => ({
activities: activities.map((activity) => ({
id: activity.id,
activityName: activity.activityName,
registrationType: activity.registrationType,
@@ -580,8 +536,6 @@ const getList = async () => {
}
};
/** 搜索按钮操作 */
const handleQuery = () => {
getList();
@@ -597,7 +551,7 @@ const resetQuery = () => {
const handleView = async (row: MyActivityVO) => {
detailForm.value = { ...row };
detailOpen.value = true;
// 如果是团队报名,获取队伍信息
if (row.registrationType === '2') {
await getTeamInfo(row.id);
@@ -609,7 +563,7 @@ const handleView = async (row: MyActivityVO) => {
/** 获取队伍信息 */
const getTeamInfo = async (activityId: string | number) => {
if (!activityId) return;
teamInfoLoading.value = true;
try {
const res = await getTeamsByActivityId(activityId);
@@ -621,7 +575,7 @@ const getTeamInfo = async (activityId: string | number) => {
teamInfo.value = null;
return;
}
const currentUserTeam = res.data.find((team: StglActivityTeamInfoVo) => {
// 检查是否为队长
if (team.leaderStudentNo === userInfo.userName) {
@@ -639,9 +593,9 @@ const getTeamInfo = async (activityId: string | number) => {
}
return false;
});
teamInfo.value = currentUserTeam || null;
if (currentUserTeam) {
console.log('获取到队伍信息:', {
teamName: currentUserTeam.teamName,
@@ -681,14 +635,12 @@ const parseTeamMembers = (teamMembersStr: string): any[] => {
}
};
/** 活动评分按钮操作 */
const handleRate = async (row: MyActivityVO) => {
try {
// 获取当前用户详细信息
const userInfo = await getCurrentUserDetailInfo();
ratingForm.value = {
activityId: row.id,
activityName: row.activityName,
@@ -699,7 +651,7 @@ const handleRate = async (row: MyActivityVO) => {
experienceScore: 0,
ratingComment: ''
};
console.log('评分表单数据:', ratingForm.value);
ratingOpen.value = true;
} catch (error) {
@@ -711,7 +663,7 @@ const handleRate = async (row: MyActivityVO) => {
/** 提交评分 */
const submitRating = async () => {
if (!ratingFormRef.value) return;
await ratingFormRef.value.validate(async (valid: boolean) => {
if (valid) {
ratingLoading.value = true;
@@ -821,8 +773,8 @@ const attendanceHistory = ref<any[]>([]);
const currentAttendance = ref<any>(null);
// 签到记录相关数据
const attendanceRecords = ref<any[]>([])
const recordsLoading = ref(false)
const attendanceRecords = ref<any[]>([]);
const recordsLoading = ref(false);
// 计算属性 - 简化状态判断
const canSignIn = computed(() => {
@@ -830,37 +782,35 @@ const canSignIn = computed(() => {
if (!currentAttendance.value) {
return true; // 没有记录时可以签到
}
// 如果最新记录已签到已签退,则可以重新签到
if (currentAttendance.value.signInStatus === 1 && currentAttendance.value.signOutStatus === 1) {
return true;
}
// 如果最新记录已签到未签退,则不能签到
if (currentAttendance.value.signInStatus === 1 && currentAttendance.value.signOutStatus === 0) {
return false;
}
// 其他情况允许签到
return true;
});
const canSignOut = computed(() => {
// 如果有记录且已签到未签退,则可以签退
return currentAttendance.value &&
currentAttendance.value.signInStatus === 1 &&
currentAttendance.value.signOutStatus === 0;
return currentAttendance.value && currentAttendance.value.signInStatus === 1 && currentAttendance.value.signOutStatus === 0;
});
const signInButtonText = computed(() => {
if (!currentAttendance.value) {
return '签到';
}
if (currentAttendance.value.signInStatus === 1 && currentAttendance.value.signOutStatus === 0) {
return '已签到';
}
return '签到';
});
@@ -868,7 +818,7 @@ const signInButtonText = computed(() => {
const handleAttendance = async (row: MyActivityVO) => {
try {
const userInfo = await getCurrentUserDetailInfo();
// 填充活动信息
attendanceForm.value = {
activityId: row.id,
@@ -929,13 +879,13 @@ const handleSignIn = async () => {
};
await createSignInRecord(signInData);
// 签到成功消息
proxy?.$modal.msgSuccess('签到成功');
// 刷新签到状态和历史记录
await refreshAttendanceData();
// 强制更新计算属性
nextTick(() => {
console.log('签到后状态更新:', {
@@ -980,7 +930,7 @@ const handleSignOut = async () => {
// 刷新签到状态和历史记录
await refreshAttendanceData();
// 强制更新计算属性
nextTick(() => {
console.log('签退后状态更新:', {
@@ -1003,19 +953,17 @@ const refreshAttendanceData = async () => {
try {
// 获取最新的签到记录
const recordRes = await getAllAttendanceRecords(attendanceForm.value.activityId, attendanceForm.value.studentNo);
if (recordRes.data && recordRes.data.length > 0) {
// 按创建时间排序,取最新的一条作为当前记录
const sortedRecords = recordRes.data.sort((a: any, b: any) =>
new Date(b.createTime).getTime() - new Date(a.createTime).getTime()
);
const sortedRecords = recordRes.data.sort((a: any, b: any) => new Date(b.createTime).getTime() - new Date(a.createTime).getTime());
currentAttendance.value = sortedRecords[0];
attendanceHistory.value = sortedRecords;
// 同时更新签到记录表格数据
attendanceRecords.value = sortedRecords;
console.log('获取到签到记录:', {
total: sortedRecords.length,
current: currentAttendance.value,
@@ -1030,7 +978,7 @@ const refreshAttendanceData = async () => {
// 强制触发计算属性重新计算
await nextTick();
console.log('刷新签到数据完成:', {
history: attendanceHistory.value,
current: currentAttendance.value,
@@ -1050,7 +998,7 @@ const refreshAttendanceData = async () => {
/** 刷新签到记录 */
const refreshRecords = async () => {
if (!attendanceForm.value.activityId || !attendanceForm.value.studentNo) return;
recordsLoading.value = true;
try {
await refreshAttendanceData();
@@ -1093,14 +1041,14 @@ const getTableMaxHeight = () => {
const calculateDuration = (signInTime: string, signOutTime: string): string => {
if (!signInTime) return '-';
if (!signOutTime) return '进行中';
const start = new Date(signInTime);
const end = new Date(signOutTime);
const diffMs = end.getTime() - start.getTime();
const hours = Math.floor(diffMs / (1000 * 60 * 60));
const minutes = Math.floor((diffMs % (1000 * 60 * 60)) / (1000 * 60));
if (hours > 0) {
return `${hours}小时${minutes}分钟`;
} else {
@@ -1111,9 +1059,9 @@ const calculateDuration = (signInTime: string, signOutTime: string): string => {
/** 提取指导老师姓名 */
const getInstructorNames = (instructors: string | any[]): string => {
if (!instructors) return '暂无';
let instructorArray: any[] = [];
// 如果是字符串,尝试解析JSON
if (typeof instructors === 'string') {
try {
@@ -1127,12 +1075,12 @@ const getInstructorNames = (instructors: string | any[]): string => {
} else {
return '暂无';
}
if (!instructorArray || instructorArray.length === 0) return '暂无';
return instructorArray
.map(instructor => instructor.name || instructor.nickName || '未知')
.filter(name => name && name !== '未知')
.map((instructor) => instructor.name || instructor.nickName || '未知')
.filter((name) => name && name !== '未知')
.join('、');
};
@@ -1423,4 +1371,4 @@ onMounted(() => {
display: flex;
justify-content: center;
}
</style>
</style>
+1 -10
View File
@@ -17,16 +17,9 @@
</el-col>
<el-col :span="6">
<el-form-item label="名称" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入名称"
clearable
style="width: 100%"
@keyup.enter="handleQuery"
/>
<el-input v-model="queryParams.name" placeholder="请输入名称" clearable style="width: 100%" @keyup.enter="handleQuery" />
</el-form-item>
</el-col>
</el-row>
<el-row>
@@ -228,8 +221,6 @@ const getRegistrationTypeTag = (type: string) => {
return tagMap[type as keyof typeof tagMap] || ('info' as const);
};
/** 获取当前状态标签样式 */
const getCurrentStatusTag = (status: string) => {
const tagMap = {