线上课添加、编辑分类单选

This commit is contained in:
禺狨 2023-03-21 18:50:21 +08:00
parent f824396b05
commit ef08db0bfd
3 changed files with 18 additions and 46 deletions

View File

@ -10,6 +10,7 @@ import {
Modal,
message,
Image,
Tooltip,
} from "antd";
import styles from "./create.module.less";
import { course, department } from "../../../api/index";
@ -66,6 +67,7 @@ export const CourseCreate: React.FC<PropInterface> = ({ open, onCancel }) => {
hasChapter: 0,
});
setThumb(defaultThumb1);
setType("open");
setChapterType(0);
setChapters([]);
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]);
}
}
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
.storeCourse(
values.title,
@ -133,7 +129,7 @@ export const CourseCreate: React.FC<PropInterface> = ({ open, onCancel }) => {
1,
values.isRequired,
dep_ids,
category_ids,
values.category_ids,
chapters,
treeData
)
@ -362,8 +358,7 @@ export const CourseCreate: React.FC<PropInterface> = ({ open, onCancel }) => {
<Cascader
style={{ width: 424 }}
options={categories}
multiple
maxTagCount="responsive"
changeOnSelect
placeholder="请选择课程分类"
/>
</Form.Item>
@ -384,7 +379,10 @@ export const CourseCreate: React.FC<PropInterface> = ({ open, onCancel }) => {
>
<Radio.Group onChange={getType}>
<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 value="elective"></Radio>
</Radio.Group>

View File

@ -10,6 +10,7 @@ import {
Modal,
message,
Image,
Tooltip,
} from "antd";
import styles from "./update.module.less";
import { course, department } from "../../../api/index";
@ -99,34 +100,13 @@ export const CourseUpdate: React.FC<PropInterface> = ({
} else {
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;
form.setFieldsValue({
title: res.data.course.title,
thumb: res.data.course.thumb,
dep_ids: depIds,
category_ids: categoryIds,
category_ids: res.data.category_ids,
isRequired: res.data.course.isRequired,
type: type,
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
.updateCourse(
id,
@ -191,7 +164,7 @@ export const CourseUpdate: React.FC<PropInterface> = ({
1,
values.isRequired,
dep_ids,
category_ids,
values.category_ids,
[],
[]
)
@ -255,8 +228,7 @@ export const CourseUpdate: React.FC<PropInterface> = ({
<Cascader
style={{ width: 424 }}
options={categories}
multiple
maxTagCount="responsive"
changeOnSelect
placeholder="请选择课程分类"
/>
</Form.Item>
@ -278,7 +250,9 @@ export const CourseUpdate: React.FC<PropInterface> = ({
<Radio.Group onChange={getType}>
<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 value="elective"></Radio>
</Radio.Group>

View File

@ -114,7 +114,7 @@ export const CoursePage = () => {
title: "课程分类",
dataIndex: "id",
render: (id: number) => (
<div className="d-flex">
<div className="float-left">
{course_category_ids[id].map((item: any, index: number) => {
return (
<span key={index}>
@ -131,7 +131,7 @@ export const CoursePage = () => {
title: "指派部门",
dataIndex: "id",
render: (id: number) => (
<div className="d-flex">
<div className="float-left">
{course_dep_ids[id] &&
course_dep_ids[id].map((item: any, index: number) => {
return (