mirror of
https://github.com/PlayEdu/backend
synced 2025-09-11 03:23:38 +08:00
线上课添加、编辑分类单选
This commit is contained in:
parent
f824396b05
commit
ef08db0bfd
@ -10,6 +10,7 @@ import {
|
|||||||
Modal,
|
Modal,
|
||||||
message,
|
message,
|
||||||
Image,
|
Image,
|
||||||
|
Tooltip,
|
||||||
} from "antd";
|
} from "antd";
|
||||||
import styles from "./create.module.less";
|
import styles from "./create.module.less";
|
||||||
import { course, department } from "../../../api/index";
|
import { course, department } from "../../../api/index";
|
||||||
@ -66,6 +67,7 @@ export const CourseCreate: React.FC<PropInterface> = ({ open, onCancel }) => {
|
|||||||
hasChapter: 0,
|
hasChapter: 0,
|
||||||
});
|
});
|
||||||
setThumb(defaultThumb1);
|
setThumb(defaultThumb1);
|
||||||
|
setType("open");
|
||||||
setChapterType(0);
|
setChapterType(0);
|
||||||
setChapters([]);
|
setChapters([]);
|
||||||
setHours([]);
|
setHours([]);
|
||||||
@ -119,12 +121,6 @@ export const CourseCreate: React.FC<PropInterface> = ({ open, onCancel }) => {
|
|||||||
dep_ids.push(values.dep_ids[i][values.dep_ids[i].length - 1]);
|
dep_ids.push(values.dep_ids[i][values.dep_ids[i].length - 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let category_ids: any[] = [];
|
|
||||||
for (let j = 0; j < values.category_ids.length; j++) {
|
|
||||||
category_ids.push(
|
|
||||||
values.category_ids[j][values.category_ids[j].length - 1]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
course
|
course
|
||||||
.storeCourse(
|
.storeCourse(
|
||||||
values.title,
|
values.title,
|
||||||
@ -133,7 +129,7 @@ export const CourseCreate: React.FC<PropInterface> = ({ open, onCancel }) => {
|
|||||||
1,
|
1,
|
||||||
values.isRequired,
|
values.isRequired,
|
||||||
dep_ids,
|
dep_ids,
|
||||||
category_ids,
|
values.category_ids,
|
||||||
chapters,
|
chapters,
|
||||||
treeData
|
treeData
|
||||||
)
|
)
|
||||||
@ -362,8 +358,7 @@ export const CourseCreate: React.FC<PropInterface> = ({ open, onCancel }) => {
|
|||||||
<Cascader
|
<Cascader
|
||||||
style={{ width: 424 }}
|
style={{ width: 424 }}
|
||||||
options={categories}
|
options={categories}
|
||||||
multiple
|
changeOnSelect
|
||||||
maxTagCount="responsive"
|
|
||||||
placeholder="请选择课程分类"
|
placeholder="请选择课程分类"
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
@ -384,7 +379,10 @@ export const CourseCreate: React.FC<PropInterface> = ({ open, onCancel }) => {
|
|||||||
>
|
>
|
||||||
<Radio.Group onChange={getType}>
|
<Radio.Group onChange={getType}>
|
||||||
<Radio value="open">
|
<Radio value="open">
|
||||||
公开课 <i className="iconfont icon-icon-tips c-gray ml-8" />
|
公开课
|
||||||
|
<Tooltip placement="top" title="公开课所有学员可见">
|
||||||
|
<i className="iconfont icon-icon-tips c-gray ml-8" />
|
||||||
|
</Tooltip>
|
||||||
</Radio>
|
</Radio>
|
||||||
<Radio value="elective">部门课</Radio>
|
<Radio value="elective">部门课</Radio>
|
||||||
</Radio.Group>
|
</Radio.Group>
|
||||||
|
@ -10,6 +10,7 @@ import {
|
|||||||
Modal,
|
Modal,
|
||||||
message,
|
message,
|
||||||
Image,
|
Image,
|
||||||
|
Tooltip,
|
||||||
} from "antd";
|
} from "antd";
|
||||||
import styles from "./update.module.less";
|
import styles from "./update.module.less";
|
||||||
import { course, department } from "../../../api/index";
|
import { course, department } from "../../../api/index";
|
||||||
@ -99,34 +100,13 @@ export const CourseUpdate: React.FC<PropInterface> = ({
|
|||||||
} else {
|
} else {
|
||||||
depIds = res.data.dep_ids;
|
depIds = res.data.dep_ids;
|
||||||
}
|
}
|
||||||
let box2 = res.data.category_ids;
|
|
||||||
let categoryIds: any[] = [];
|
|
||||||
if (box2.length > 0) {
|
|
||||||
for (let i = 0; i < box2.length; i++) {
|
|
||||||
let item = checkChild(cats, box2[i]);
|
|
||||||
let arr: any[] = [];
|
|
||||||
if (item === undefined) {
|
|
||||||
arr.push(box2[i]);
|
|
||||||
} else if (item.parent_chain === "") {
|
|
||||||
arr.push(box2[i]);
|
|
||||||
} else {
|
|
||||||
let new_arr = item.parent_chain.split(",");
|
|
||||||
new_arr.map((num: any) => {
|
|
||||||
arr.push(Number(num));
|
|
||||||
});
|
|
||||||
arr.push(box2[i]);
|
|
||||||
}
|
|
||||||
categoryIds.push(arr);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
categoryIds = res.data.category_ids;
|
|
||||||
}
|
|
||||||
let chapterType = res.data.chapters.length > 0 ? 1 : 0;
|
let chapterType = res.data.chapters.length > 0 ? 1 : 0;
|
||||||
form.setFieldsValue({
|
form.setFieldsValue({
|
||||||
title: res.data.course.title,
|
title: res.data.course.title,
|
||||||
thumb: res.data.course.thumb,
|
thumb: res.data.course.thumb,
|
||||||
dep_ids: depIds,
|
dep_ids: depIds,
|
||||||
category_ids: categoryIds,
|
category_ids: res.data.category_ids,
|
||||||
isRequired: res.data.course.isRequired,
|
isRequired: res.data.course.isRequired,
|
||||||
type: type,
|
type: type,
|
||||||
short_desc: res.data.course.short_desc,
|
short_desc: res.data.course.short_desc,
|
||||||
@ -175,13 +155,6 @@ export const CourseUpdate: React.FC<PropInterface> = ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let category_ids: any[] = [];
|
|
||||||
for (let j = 0; j < values.category_ids.length; j++) {
|
|
||||||
category_ids.push(
|
|
||||||
values.category_ids[j][values.category_ids[j].length - 1]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
course
|
course
|
||||||
.updateCourse(
|
.updateCourse(
|
||||||
id,
|
id,
|
||||||
@ -191,7 +164,7 @@ export const CourseUpdate: React.FC<PropInterface> = ({
|
|||||||
1,
|
1,
|
||||||
values.isRequired,
|
values.isRequired,
|
||||||
dep_ids,
|
dep_ids,
|
||||||
category_ids,
|
values.category_ids,
|
||||||
[],
|
[],
|
||||||
[]
|
[]
|
||||||
)
|
)
|
||||||
@ -255,8 +228,7 @@ export const CourseUpdate: React.FC<PropInterface> = ({
|
|||||||
<Cascader
|
<Cascader
|
||||||
style={{ width: 424 }}
|
style={{ width: 424 }}
|
||||||
options={categories}
|
options={categories}
|
||||||
multiple
|
changeOnSelect
|
||||||
maxTagCount="responsive"
|
|
||||||
placeholder="请选择课程分类"
|
placeholder="请选择课程分类"
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
@ -278,7 +250,9 @@ export const CourseUpdate: React.FC<PropInterface> = ({
|
|||||||
<Radio.Group onChange={getType}>
|
<Radio.Group onChange={getType}>
|
||||||
<Radio value="open">
|
<Radio value="open">
|
||||||
公开课
|
公开课
|
||||||
<i className="iconfont icon-icon-tips c-gray ml-8" />
|
<Tooltip placement="top" title="公开课所有学员可见">
|
||||||
|
<i className="iconfont icon-icon-tips c-gray ml-8" />
|
||||||
|
</Tooltip>
|
||||||
</Radio>
|
</Radio>
|
||||||
<Radio value="elective">部门课</Radio>
|
<Radio value="elective">部门课</Radio>
|
||||||
</Radio.Group>
|
</Radio.Group>
|
||||||
|
@ -114,7 +114,7 @@ export const CoursePage = () => {
|
|||||||
title: "课程分类",
|
title: "课程分类",
|
||||||
dataIndex: "id",
|
dataIndex: "id",
|
||||||
render: (id: number) => (
|
render: (id: number) => (
|
||||||
<div className="d-flex">
|
<div className="float-left">
|
||||||
{course_category_ids[id].map((item: any, index: number) => {
|
{course_category_ids[id].map((item: any, index: number) => {
|
||||||
return (
|
return (
|
||||||
<span key={index}>
|
<span key={index}>
|
||||||
@ -131,7 +131,7 @@ export const CoursePage = () => {
|
|||||||
title: "指派部门",
|
title: "指派部门",
|
||||||
dataIndex: "id",
|
dataIndex: "id",
|
||||||
render: (id: number) => (
|
render: (id: number) => (
|
||||||
<div className="d-flex">
|
<div className="float-left">
|
||||||
{course_dep_ids[id] &&
|
{course_dep_ids[id] &&
|
||||||
course_dep_ids[id].map((item: any, index: number) => {
|
course_dep_ids[id].map((item: any, index: number) => {
|
||||||
return (
|
return (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user