mirror of
https://github.com/PlayEdu/backend
synced 2025-06-22 03:32:47 +08:00
课程新建组件化初步
This commit is contained in:
parent
7862efa0d4
commit
52a1920507
@ -58,6 +58,10 @@ code {
|
|||||||
margin-left: 15px;
|
margin-left: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ml-120 {
|
||||||
|
margin-left: 120px;
|
||||||
|
}
|
||||||
|
|
||||||
.mr-16 {
|
.mr-16 {
|
||||||
margin-right: 16px;
|
margin-right: 16px;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import {
|
import {
|
||||||
Space,
|
Space,
|
||||||
Switch,
|
Radio,
|
||||||
Button,
|
Button,
|
||||||
Drawer,
|
Drawer,
|
||||||
Form,
|
Form,
|
||||||
@ -30,6 +30,8 @@ export const CourseCreate: React.FC<PropInterface> = ({ open, onCancel }) => {
|
|||||||
const [departments, setDepartments] = useState<any>([]);
|
const [departments, setDepartments] = useState<any>([]);
|
||||||
const [categories, setCategories] = useState<any>([]);
|
const [categories, setCategories] = useState<any>([]);
|
||||||
const [thumb, setThumb] = useState<string>("");
|
const [thumb, setThumb] = useState<string>("");
|
||||||
|
const [type, setType] = useState<string>("open");
|
||||||
|
const [chapterType, setChapterType] = useState(0);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getParams();
|
getParams();
|
||||||
@ -42,6 +44,9 @@ export const CourseCreate: React.FC<PropInterface> = ({ open, onCancel }) => {
|
|||||||
thumb: "",
|
thumb: "",
|
||||||
dep_ids: [],
|
dep_ids: [],
|
||||||
category_ids: [],
|
category_ids: [],
|
||||||
|
type: "open",
|
||||||
|
desc: "",
|
||||||
|
hasChapter: 0,
|
||||||
});
|
});
|
||||||
setThumb("");
|
setThumb("");
|
||||||
}, [form, open]);
|
}, [form, open]);
|
||||||
@ -109,6 +114,14 @@ export const CourseCreate: React.FC<PropInterface> = ({ open, onCancel }) => {
|
|||||||
console.log("Failed:", errorInfo);
|
console.log("Failed:", errorInfo);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getType = (e: any) => {
|
||||||
|
setType(e.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const getChapterType = (e: any) => {
|
||||||
|
setChapterType(e.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Drawer
|
<Drawer
|
||||||
@ -161,10 +174,25 @@ export const CourseCreate: React.FC<PropInterface> = ({ open, onCancel }) => {
|
|||||||
placeholder="请选择课程分类"
|
placeholder="请选择课程分类"
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
label="课程类型"
|
||||||
|
name="type"
|
||||||
|
rules={[{ required: true, message: "请选择课程类型!" }]}
|
||||||
|
>
|
||||||
|
<Radio.Group onChange={getType}>
|
||||||
|
<Radio value="open">公开课</Radio>
|
||||||
|
<Radio value="elective">部门课</Radio>
|
||||||
|
</Radio.Group>
|
||||||
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label="指派部门"
|
label="指派部门"
|
||||||
name="dep_ids"
|
name="dep_ids"
|
||||||
rules={[{ required: true, message: "请选择课程指派部门!" }]}
|
rules={[
|
||||||
|
{
|
||||||
|
required: type === "elective" ? true : false,
|
||||||
|
message: "请选择课程指派部门!",
|
||||||
|
},
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
<Cascader
|
<Cascader
|
||||||
style={{ width: 424 }}
|
style={{ width: 424 }}
|
||||||
@ -193,6 +221,32 @@ export const CourseCreate: React.FC<PropInterface> = ({ open, onCancel }) => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
<Form.Item label="课程简介" name="desc">
|
||||||
|
<Input.TextArea
|
||||||
|
style={{ width: 424, height: 80 }}
|
||||||
|
allowClear
|
||||||
|
placeholder="请输入课程简介"
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
label="课时列表"
|
||||||
|
name="hasChapter"
|
||||||
|
rules={[{ required: true, message: "请选择课时列表!" }]}
|
||||||
|
>
|
||||||
|
<Radio.Group onChange={getChapterType}>
|
||||||
|
<Radio value={0}>无章节</Radio>
|
||||||
|
<Radio value={1}>有章节</Radio>
|
||||||
|
</Radio.Group>
|
||||||
|
</Form.Item>
|
||||||
|
{chapterType === 0 && (
|
||||||
|
<Form.Item>
|
||||||
|
<div className="ml-120">
|
||||||
|
<Button onClick={() => null} type="primary">
|
||||||
|
添加课时
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Form.Item>
|
||||||
|
)}
|
||||||
</Form>
|
</Form>
|
||||||
</div>
|
</div>
|
||||||
</Drawer>
|
</Drawer>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user