mirror of
https://github.com/PlayEdu/backend
synced 2025-07-21 04:09:40 +08:00
线上课新建分类,部门默认选中
This commit is contained in:
parent
9f4265ebe0
commit
5404afee98
@ -22,6 +22,8 @@ import { TreeHours } from "./hours";
|
||||
const { confirm } = Modal;
|
||||
|
||||
interface PropInterface {
|
||||
cateIds: any;
|
||||
depIds: any;
|
||||
open: boolean;
|
||||
onCancel: () => void;
|
||||
}
|
||||
@ -32,7 +34,12 @@ interface Option {
|
||||
children?: Option[];
|
||||
}
|
||||
|
||||
export const CourseCreate: React.FC<PropInterface> = ({ open, onCancel }) => {
|
||||
export const CourseCreate: React.FC<PropInterface> = ({
|
||||
cateIds,
|
||||
depIds,
|
||||
open,
|
||||
onCancel,
|
||||
}) => {
|
||||
const [form] = Form.useForm();
|
||||
const defaultThumb1 = getHost() + "thumb/thumb1.png";
|
||||
const defaultThumb2 = getHost() + "thumb/thumb2.png";
|
||||
@ -56,23 +63,27 @@ export const CourseCreate: React.FC<PropInterface> = ({ open, onCancel }) => {
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
let type = "open";
|
||||
if (depIds.length !== 0 && depIds[0] !== 0) {
|
||||
type = "elective";
|
||||
}
|
||||
form.setFieldsValue({
|
||||
title: "",
|
||||
thumb: defaultThumb1,
|
||||
dep_ids: [],
|
||||
category_ids: [],
|
||||
type: "open",
|
||||
dep_ids: depIds,
|
||||
category_ids: cateIds,
|
||||
type: type,
|
||||
isRequired: 1,
|
||||
short_desc: "",
|
||||
hasChapter: 0,
|
||||
});
|
||||
setThumb(defaultThumb1);
|
||||
setType("open");
|
||||
setType(type);
|
||||
setChapterType(0);
|
||||
setChapters([]);
|
||||
setHours([]);
|
||||
setTreeData([]);
|
||||
}, [form, open]);
|
||||
}, [form, open, cateIds, depIds]);
|
||||
|
||||
const getParams = () => {
|
||||
department.departmentList().then((res: any) => {
|
||||
@ -340,16 +351,6 @@ export const CourseCreate: React.FC<PropInterface> = ({ open, onCancel }) => {
|
||||
onFinishFailed={onFinishFailed}
|
||||
autoComplete="off"
|
||||
>
|
||||
<Form.Item
|
||||
label="课程名称"
|
||||
name="title"
|
||||
rules={[{ required: true, message: "请在此处输入课程名称!" }]}
|
||||
>
|
||||
<Input
|
||||
style={{ width: 424 }}
|
||||
placeholder="请在此处输入课程名称"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="课程分类"
|
||||
name="category_ids"
|
||||
@ -362,6 +363,16 @@ export const CourseCreate: React.FC<PropInterface> = ({ open, onCancel }) => {
|
||||
placeholder="请选择课程分类"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="课程名称"
|
||||
name="title"
|
||||
rules={[{ required: true, message: "请在此处输入课程名称!" }]}
|
||||
>
|
||||
<Input
|
||||
style={{ width: 424 }}
|
||||
placeholder="请在此处输入课程名称"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="必修选修"
|
||||
name="isRequired"
|
||||
|
@ -210,16 +210,6 @@ export const CourseUpdate: React.FC<PropInterface> = ({
|
||||
onFinishFailed={onFinishFailed}
|
||||
autoComplete="off"
|
||||
>
|
||||
<Form.Item
|
||||
label="课程名称"
|
||||
name="title"
|
||||
rules={[{ required: true, message: "请在此处输入课程名称!" }]}
|
||||
>
|
||||
<Input
|
||||
style={{ width: 424 }}
|
||||
placeholder="请在此处输入课程名称"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="课程分类"
|
||||
name="category_ids"
|
||||
@ -232,6 +222,16 @@ export const CourseUpdate: React.FC<PropInterface> = ({
|
||||
placeholder="请选择课程分类"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="课程名称"
|
||||
name="title"
|
||||
rules={[{ required: true, message: "请在此处输入课程名称!" }]}
|
||||
>
|
||||
<Input
|
||||
style={{ width: 424 }}
|
||||
placeholder="请在此处输入课程名称"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="必修选修"
|
||||
name="isRequired"
|
||||
|
@ -394,6 +394,8 @@ export const CoursePage = () => {
|
||||
rowKey={(record) => record.id}
|
||||
/>
|
||||
<CourseCreate
|
||||
cateIds={category_ids}
|
||||
depIds={dep_ids}
|
||||
open={createVisible}
|
||||
onCancel={() => {
|
||||
setCreateVisible(false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user