新增e2e测试脚本,修复部分问题
This commit was merged in pull request #51.
This commit is contained in:
@@ -139,7 +139,7 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="预约人数" width="100">
|
||||
<template #default="{ row }">
|
||||
{{ row.currentMembers }} / {{ row.maxMembers }}
|
||||
{{ coachCourseMemberCounts[row.id!] ?? row.currentMembers }} / {{ row.maxMembers }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="location" label="上课地点" />
|
||||
@@ -220,7 +220,7 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="预约人数" width="100">
|
||||
<template #default="{ row }">
|
||||
{{ row.currentMembers }} / {{ row.maxMembers }}
|
||||
{{ coachCourseMemberCounts[row.id!] ?? row.currentMembers }} / {{ row.maxMembers }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="location" label="上课地点" />
|
||||
@@ -238,6 +238,7 @@ import { ref, reactive, computed, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Search } from '@element-plus/icons-vue'
|
||||
import { coachApi, type Coach, type CoachCreateRequest, type CoachUpdateRequest, type GroupCourse, type ViolationCountItem, type ViolationRecord } from '@/api/coach.api'
|
||||
import { groupCourseBookingApi } from '@/api/groupCourse.api'
|
||||
import { handleApiError } from '@/utils/errorHandler'
|
||||
import { formatDateTime } from '@/utils/dateFormat'
|
||||
|
||||
@@ -295,6 +296,7 @@ const coursesDialogVisible = ref(false)
|
||||
const coursesLoading = ref(false)
|
||||
const coachCourses = ref<GroupCourse[]>([])
|
||||
const selectedCoachName = ref('')
|
||||
const coachCourseMemberCounts = reactive<Record<number, number>>({})
|
||||
|
||||
// 团课状态映射
|
||||
const courseStatusMap: Record<number, { text: string; tag: string }> = {
|
||||
@@ -443,6 +445,7 @@ const handleViewCourses = async (row: Coach) => {
|
||||
coursesLoading.value = true
|
||||
try {
|
||||
coachCourses.value = await coachApi.getCourses(row.id)
|
||||
await fetchCoachRealMemberCounts(coachCourses.value)
|
||||
} catch (error) {
|
||||
handleApiError(error)
|
||||
} finally {
|
||||
@@ -450,6 +453,22 @@ const handleViewCourses = async (row: Coach) => {
|
||||
}
|
||||
}
|
||||
|
||||
const fetchCoachRealMemberCounts = async (courses: GroupCourse[]) => {
|
||||
const results = await Promise.allSettled(
|
||||
courses.map(course =>
|
||||
groupCourseBookingApi.getByCourseId(course.id!).then(bookings => ({
|
||||
courseId: course.id!,
|
||||
count: bookings.filter(b => b.status === '0' || b.status === '2').length,
|
||||
}))
|
||||
)
|
||||
)
|
||||
results.forEach(r => {
|
||||
if (r.status === 'fulfilled') {
|
||||
coachCourseMemberCounts[r.value.courseId] = r.value.count
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 违规次数标签颜色
|
||||
function getViolationTag(coachId: number) {
|
||||
const count = violationCounts[coachId] ?? 0
|
||||
@@ -485,6 +504,7 @@ const handleViewDetail = async (row: Coach) => {
|
||||
])
|
||||
detailViolations.value = violations
|
||||
detailCourses.value = courses
|
||||
await fetchCoachRealMemberCounts(courses)
|
||||
} catch (error) {
|
||||
handleApiError(error)
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user