线上课新建分类,部门默认选中

This commit is contained in:
禺狨 2023-03-22 14:29:58 +08:00
parent 9f4265ebe0
commit 5404afee98
3 changed files with 39 additions and 26 deletions

View File

@ -22,6 +22,8 @@ import { TreeHours } from "./hours";
const { confirm } = Modal; const { confirm } = Modal;
interface PropInterface { interface PropInterface {
cateIds: any;
depIds: any;
open: boolean; open: boolean;
onCancel: () => void; onCancel: () => void;
} }
@ -32,7 +34,12 @@ interface Option {
children?: 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 [form] = Form.useForm();
const defaultThumb1 = getHost() + "thumb/thumb1.png"; const defaultThumb1 = getHost() + "thumb/thumb1.png";
const defaultThumb2 = getHost() + "thumb/thumb2.png"; const defaultThumb2 = getHost() + "thumb/thumb2.png";
@ -56,23 +63,27 @@ export const CourseCreate: React.FC<PropInterface> = ({ open, onCancel }) => {
}, []); }, []);
useEffect(() => { useEffect(() => {
let type = "open";
if (depIds.length !== 0 && depIds[0] !== 0) {
type = "elective";
}
form.setFieldsValue({ form.setFieldsValue({
title: "", title: "",
thumb: defaultThumb1, thumb: defaultThumb1,
dep_ids: [], dep_ids: depIds,
category_ids: [], category_ids: cateIds,
type: "open", type: type,
isRequired: 1, isRequired: 1,
short_desc: "", short_desc: "",
hasChapter: 0, hasChapter: 0,
}); });
setThumb(defaultThumb1); setThumb(defaultThumb1);
setType("open"); setType(type);
setChapterType(0); setChapterType(0);
setChapters([]); setChapters([]);
setHours([]); setHours([]);
setTreeData([]); setTreeData([]);
}, [form, open]); }, [form, open, cateIds, depIds]);
const getParams = () => { const getParams = () => {
department.departmentList().then((res: any) => { department.departmentList().then((res: any) => {
@ -340,16 +351,6 @@ export const CourseCreate: React.FC<PropInterface> = ({ open, onCancel }) => {
onFinishFailed={onFinishFailed} onFinishFailed={onFinishFailed}
autoComplete="off" autoComplete="off"
> >
<Form.Item
label="课程名称"
name="title"
rules={[{ required: true, message: "请在此处输入课程名称!" }]}
>
<Input
style={{ width: 424 }}
placeholder="请在此处输入课程名称"
/>
</Form.Item>
<Form.Item <Form.Item
label="课程分类" label="课程分类"
name="category_ids" name="category_ids"
@ -362,6 +363,16 @@ export const CourseCreate: React.FC<PropInterface> = ({ open, onCancel }) => {
placeholder="请选择课程分类" placeholder="请选择课程分类"
/> />
</Form.Item> </Form.Item>
<Form.Item
label="课程名称"
name="title"
rules={[{ required: true, message: "请在此处输入课程名称!" }]}
>
<Input
style={{ width: 424 }}
placeholder="请在此处输入课程名称"
/>
</Form.Item>
<Form.Item <Form.Item
label="必修选修" label="必修选修"
name="isRequired" name="isRequired"

View File

@ -210,16 +210,6 @@ export const CourseUpdate: React.FC<PropInterface> = ({
onFinishFailed={onFinishFailed} onFinishFailed={onFinishFailed}
autoComplete="off" autoComplete="off"
> >
<Form.Item
label="课程名称"
name="title"
rules={[{ required: true, message: "请在此处输入课程名称!" }]}
>
<Input
style={{ width: 424 }}
placeholder="请在此处输入课程名称"
/>
</Form.Item>
<Form.Item <Form.Item
label="课程分类" label="课程分类"
name="category_ids" name="category_ids"
@ -232,6 +222,16 @@ export const CourseUpdate: React.FC<PropInterface> = ({
placeholder="请选择课程分类" placeholder="请选择课程分类"
/> />
</Form.Item> </Form.Item>
<Form.Item
label="课程名称"
name="title"
rules={[{ required: true, message: "请在此处输入课程名称!" }]}
>
<Input
style={{ width: 424 }}
placeholder="请在此处输入课程名称"
/>
</Form.Item>
<Form.Item <Form.Item
label="必修选修" label="必修选修"
name="isRequired" name="isRequired"

View File

@ -394,6 +394,8 @@ export const CoursePage = () => {
rowKey={(record) => record.id} rowKey={(record) => record.id}
/> />
<CourseCreate <CourseCreate
cateIds={category_ids}
depIds={dep_ids}
open={createVisible} open={createVisible}
onCancel={() => { onCancel={() => {
setCreateVisible(false); setCreateVisible(false);