mirror of
https://github.com/PlayEdu/backend
synced 2025-06-10 05:15:56 +08:00
学员、线上课编辑优化
This commit is contained in:
parent
d817df35bf
commit
cea64b2e1c
@ -24,17 +24,6 @@ export const CourseUpdatePage: React.FC = () => {
|
|||||||
getCategory();
|
getCategory();
|
||||||
}, [params.cid]);
|
}, [params.cid]);
|
||||||
|
|
||||||
const getParams = (cats: any) => {
|
|
||||||
department.departmentList().then((res: any) => {
|
|
||||||
const departments = res.data.departments;
|
|
||||||
if (JSON.stringify(departments) !== "{}") {
|
|
||||||
const new_arr: Option[] = checkArr(departments, 0);
|
|
||||||
setDepartments(new_arr);
|
|
||||||
}
|
|
||||||
getDetail(departments, cats);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const getCategory = () => {
|
const getCategory = () => {
|
||||||
course.createCourse().then((res: any) => {
|
course.createCourse().then((res: any) => {
|
||||||
const categories = res.data.categories;
|
const categories = res.data.categories;
|
||||||
@ -47,24 +36,15 @@ export const CourseUpdatePage: React.FC = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const checkArr = (departments: any[], id: number) => {
|
const getParams = (cats: any) => {
|
||||||
const arr = [];
|
department.departmentList().then((res: any) => {
|
||||||
for (let i = 0; i < departments[id].length; i++) {
|
const departments = res.data.departments;
|
||||||
if (!departments[departments[id][i].id]) {
|
if (JSON.stringify(departments) !== "{}") {
|
||||||
arr.push({
|
const new_arr: Option[] = checkArr(departments, 0);
|
||||||
label: departments[id][i].name,
|
setDepartments(new_arr);
|
||||||
value: departments[id][i].id,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
const new_arr: Option[] = checkArr(departments, departments[id][i].id);
|
|
||||||
arr.push({
|
|
||||||
label: departments[id][i].name,
|
|
||||||
value: departments[id][i].id,
|
|
||||||
children: new_arr,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
getDetail(departments, cats);
|
||||||
return arr;
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const getDetail = (deps: any, cats: any) => {
|
const getDetail = (deps: any, cats: any) => {
|
||||||
@ -132,6 +112,26 @@ export const CourseUpdatePage: React.FC = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const checkArr = (departments: any[], id: number) => {
|
||||||
|
const arr = [];
|
||||||
|
for (let i = 0; i < departments[id].length; i++) {
|
||||||
|
if (!departments[departments[id][i].id]) {
|
||||||
|
arr.push({
|
||||||
|
label: departments[id][i].name,
|
||||||
|
value: departments[id][i].id,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const new_arr: Option[] = checkArr(departments, departments[id][i].id);
|
||||||
|
arr.push({
|
||||||
|
label: departments[id][i].name,
|
||||||
|
value: departments[id][i].id,
|
||||||
|
children: new_arr,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
};
|
||||||
|
|
||||||
const onFinish = (values: any) => {
|
const onFinish = (values: any) => {
|
||||||
console.log("Success:", values);
|
console.log("Success:", values);
|
||||||
let id = Number(params.cid);
|
let id = Number(params.cid);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user