fix: 课程包管理详情 - 修复大整数 ID 精度丢失,使用 string 传递避免课程不存在

Made-with: Cursor
This commit is contained in:
zhonghua 2026-03-16 14:13:59 +08:00
parent 3918ccc9af
commit 8956f0b790
5 changed files with 16 additions and 16 deletions

View File

@ -157,9 +157,9 @@ export function getReviewList(params: CourseQueryParams): Promise<{
return api.getCoursePage1(toFindAllParams({ ...params, reviewOnly: true })).then(normalizePageResult) as any;
}
// 获取课程包详情
export function getCourse(id: number): Promise<any> {
return api.getCourse1(id) as any;
// 获取课程包详情id 支持 number | string避免大整数精度丢失
export function getCourse(id: number | string): Promise<any> {
return api.getCourse1(id as number) as any;
}
// 创建课程包
@ -168,13 +168,13 @@ export function createCourse(data: any): Promise<any> {
}
// 更新课程包
export function updateCourse(id: number, data: any): Promise<any> {
return api.updateCourse(id, data) as any;
export function updateCourse(id: number | string, data: any): Promise<any> {
return api.updateCourse(id as number, data) as any;
}
// 删除课程包
export function deleteCourse(id: number): Promise<any> {
return api.deleteCourse(id) as any;
export function deleteCourse(id: number | string): Promise<any> {
return api.deleteCourse(id as number) as any;
}
// 验证课程完整性 (暂时返回 true后端可能没有此接口)
@ -229,7 +229,7 @@ export function republishCourse(id: number): Promise<any> {
}
// 获取课程包统计数据 (暂时返回空对象)
export function getCourseStats(id: number): Promise<any> {
export function getCourseStats(id: number | string): Promise<any> {
return Promise.resolve({});
}

View File

@ -760,7 +760,7 @@ const viewStats = () => {
const deleteCourse = async () => {
try {
await courseApi.deleteCourse(+route.params.id);
await courseApi.deleteCourse(route.params.id as string);
message.success('删除成功');
router.push('/admin/courses');
} catch (error) {
@ -781,7 +781,7 @@ onMounted(async () => {
const fetchCourseDetail = async () => {
loading.value = true;
try {
const courseId = +route.params.id;
const courseId = route.params.id as string;
const data = await courseApi.getCourse(courseId);
course.value = data;

View File

@ -137,7 +137,7 @@ const router = useRouter();
const route = useRoute();
const isEdit = computed(() => !!route.params.id);
const courseId = computed(() => Number(route.params.id));
const courseId = computed(() => route.params.id as string | undefined);
const loading = ref(false);
const saving = ref(false);

View File

@ -274,19 +274,19 @@ const handleTableChange = (pag: any) => {
fetchCourses();
};
const viewCourse = (id: number) => {
const viewCourse = (id: number | string) => {
router.push(`/admin/courses/${id}`);
};
const editCourse = (id: number) => {
const editCourse = (id: number | string) => {
router.push(`/admin/courses/${id}/edit`);
};
const viewStats = (id: number) => {
const viewStats = (id: number | string) => {
router.push(`/admin/courses/${id}/stats`);
};
const deleteCourseHandler = async (id: number) => {
const deleteCourseHandler = async (id: number | string) => {
try {
await courseApi.deleteCourse(id);
message.success('删除成功');

View File

@ -252,7 +252,7 @@ onMounted(async () => {
const fetchCourseStats = async () => {
loading.value = true;
try {
const courseId = +route.params.id;
const courseId = route.params.id as string;
//
const statsData = await courseApi.getCourseStats(courseId);