Merge pull request !5 from 白书科技/fix/0905
This commit is contained in:
白书科技 2023-09-05 10:09:23 +00:00 committed by Gitee
commit fd4bc958cc
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
10 changed files with 65 additions and 15 deletions

View File

@ -13,7 +13,7 @@
.menu-box { .menu-box {
width: 200px; width: 200px;
height: 100%; height: calc(100% - 74px);
overflow-y: auto; overflow-y: auto;
overflow-x: hidden; overflow-x: hidden;
} }

View File

@ -51,7 +51,7 @@ export const CourseCreate: React.FC<PropInterface> = ({
const defaultThumb1 = courseDefaultThumbs[0]; const defaultThumb1 = courseDefaultThumbs[0];
const defaultThumb2 = courseDefaultThumbs[1]; const defaultThumb2 = courseDefaultThumbs[1];
const defaultThumb3 = courseDefaultThumbs[2]; const defaultThumb3 = courseDefaultThumbs[2];
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(false);
const [departments, setDepartments] = useState<Option[]>([]); const [departments, setDepartments] = useState<Option[]>([]);
const [categories, setCategories] = useState<Option[]>([]); const [categories, setCategories] = useState<Option[]>([]);
const [thumb, setThumb] = useState(""); const [thumb, setThumb] = useState("");
@ -220,6 +220,9 @@ export const CourseCreate: React.FC<PropInterface> = ({
}; };
const onFinish = (values: any) => { const onFinish = (values: any) => {
if (loading) {
return;
}
let dep_ids: any[] = []; let dep_ids: any[] = [];
if (type === "elective") { if (type === "elective") {
dep_ids = values.dep_ids; dep_ids = values.dep_ids;
@ -228,6 +231,7 @@ export const CourseCreate: React.FC<PropInterface> = ({
message.error("请配置课时"); message.error("请配置课时");
return; return;
} }
setLoading(true);
course course
.storeCourse( .storeCourse(
values.title, values.title,
@ -242,8 +246,12 @@ export const CourseCreate: React.FC<PropInterface> = ({
attachmentData attachmentData
) )
.then((res: any) => { .then((res: any) => {
setLoading(false);
message.success("保存成功!"); message.success("保存成功!");
onCancel(); onCancel();
})
.catch((e) => {
setLoading(false);
}); });
}; };
@ -480,7 +488,11 @@ export const CourseCreate: React.FC<PropInterface> = ({
footer={ footer={
<Space className="j-r-flex"> <Space className="j-r-flex">
<Button onClick={() => onCancel()}> </Button> <Button onClick={() => onCancel()}> </Button>
<Button onClick={() => form.submit()} type="primary"> <Button
loading={loading}
onClick={() => form.submit()}
type="primary"
>
</Button> </Button>
</Space> </Space>

View File

@ -44,7 +44,7 @@ export const CourseUpdate: React.FC<PropInterface> = ({
const defaultThumb1 = courseDefaultThumbs[0]; const defaultThumb1 = courseDefaultThumbs[0];
const defaultThumb2 = courseDefaultThumbs[1]; const defaultThumb2 = courseDefaultThumbs[1];
const defaultThumb3 = courseDefaultThumbs[2]; const defaultThumb3 = courseDefaultThumbs[2];
const [loading, setLoading] = useState<boolean>(true); const [loading, setLoading] = useState(false);
const [departments, setDepartments] = useState<Option[]>([]); const [departments, setDepartments] = useState<Option[]>([]);
const [categories, setCategories] = useState<Option[]>([]); const [categories, setCategories] = useState<Option[]>([]);
const [thumb, setThumb] = useState(""); const [thumb, setThumb] = useState("");
@ -148,10 +148,14 @@ export const CourseUpdate: React.FC<PropInterface> = ({
}; };
const onFinish = (values: any) => { const onFinish = (values: any) => {
if (loading) {
return;
}
let dep_ids: any[] = []; let dep_ids: any[] = [];
if (type === "elective") { if (type === "elective") {
dep_ids = values.dep_ids; dep_ids = values.dep_ids;
} }
setLoading(true);
course course
.updateCourse( .updateCourse(
id, id,
@ -167,8 +171,12 @@ export const CourseUpdate: React.FC<PropInterface> = ({
values.published_at values.published_at
) )
.then((res: any) => { .then((res: any) => {
setLoading(false);
message.success("保存成功!"); message.success("保存成功!");
onCancel(); onCancel();
})
.catch((e) => {
setLoading(false);
}); });
}; };
@ -191,7 +199,11 @@ export const CourseUpdate: React.FC<PropInterface> = ({
footer={ footer={
<Space className="j-r-flex"> <Space className="j-r-flex">
<Button onClick={() => onCancel()}> </Button> <Button onClick={() => onCancel()}> </Button>
<Button onClick={() => form.submit()} type="primary"> <Button
loading={loading}
onClick={() => form.submit()}
type="primary"
>
</Button> </Button>
</Space> </Space>

View File

@ -19,7 +19,7 @@ export const DepartmentCreate: React.FC<PropInterface> = ({
onCancel, onCancel,
}) => { }) => {
const [form] = Form.useForm(); const [form] = Form.useForm();
const [loading, setLoading] = useState<boolean>(true); const [loading, setLoading] = useState(false);
const [departments, setDepartments] = useState<any>([]); const [departments, setDepartments] = useState<any>([]);
const [parent_id, setParentId] = useState<number>(0); const [parent_id, setParentId] = useState<number>(0);
@ -78,11 +78,19 @@ export const DepartmentCreate: React.FC<PropInterface> = ({
}; };
const onFinish = (values: any) => { const onFinish = (values: any) => {
if (loading) {
return;
}
setLoading(true);
department department
.storeDepartment(values.name, parent_id || 0, 0) .storeDepartment(values.name, parent_id || 0, 0)
.then((res: any) => { .then((res: any) => {
setLoading(false);
message.success("保存成功!"); message.success("保存成功!");
onCancel(); onCancel();
})
.catch((e) => {
setLoading(false);
}); });
}; };

View File

@ -22,7 +22,7 @@ export const DepartmentUpdate: React.FC<PropInterface> = ({
}) => { }) => {
const [form] = Form.useForm(); const [form] = Form.useForm();
const [init, setInit] = useState(true); const [init, setInit] = useState(true);
const [loading, setLoading] = useState<boolean>(true); const [loading, setLoading] = useState(false);
const [departments, setDepartments] = useState<any>([]); const [departments, setDepartments] = useState<any>([]);
const [parent_id, setParentId] = useState<number>(0); const [parent_id, setParentId] = useState<number>(0);
const [sort, setSort] = useState<number>(0); const [sort, setSort] = useState<number>(0);
@ -93,11 +93,19 @@ export const DepartmentUpdate: React.FC<PropInterface> = ({
}; };
const onFinish = (values: any) => { const onFinish = (values: any) => {
if (loading) {
return;
}
setLoading(true);
department department
.updateDepartment(id, values.name, parent_id || 0, sort) .updateDepartment(id, values.name, parent_id || 0, sort)
.then((res: any) => { .then((res: any) => {
setLoading(false);
message.success("保存成功!"); message.success("保存成功!");
onCancel(); onCancel();
})
.catch((e) => {
setLoading(false);
}); });
}; };

View File

@ -389,7 +389,6 @@ const DepartmentPage = () => {
blockNode blockNode
onDragEnter={onDragEnter} onDragEnter={onDragEnter}
onDrop={onDrop} onDrop={onDrop}
defaultExpandAll={true}
switcherIcon={<i className="iconfont icon-icon-fold c-gray" />} switcherIcon={<i className="iconfont icon-icon-fold c-gray" />}
/> />
)} )}

View File

@ -122,26 +122,22 @@ const ResourceCoursewarePage = () => {
{ {
title: "课件格式", title: "课件格式",
dataIndex: "type", dataIndex: "type",
width: 204,
render: (type: string) => <span>{type}</span>, render: (type: string) => <span>{type}</span>,
}, },
{ {
title: "课件大小", title: "课件大小",
dataIndex: "size", dataIndex: "size",
width: 204,
render: (size: number) => <span>{(size / 1024 / 1024).toFixed(2)}M</span>, render: (size: number) => <span>{(size / 1024 / 1024).toFixed(2)}M</span>,
}, },
{ {
title: "创建人", title: "创建人",
dataIndex: "admin_id", dataIndex: "admin_id",
width: 204,
render: (text: number) => render: (text: number) =>
JSON.stringify(adminUsers) !== "{}" && <span>{adminUsers[text]}</span>, JSON.stringify(adminUsers) !== "{}" && <span>{adminUsers[text]}</span>,
}, },
{ {
title: "创建时间", title: "创建时间",
dataIndex: "created_at", dataIndex: "created_at",
width: 204,
render: (text: string) => <span>{dateFormat(text)}</span>, render: (text: string) => <span>{dateFormat(text)}</span>,
}, },
{ {

View File

@ -19,7 +19,7 @@ export const ResourceCategoryCreate: React.FC<PropInterface> = ({
onCancel, onCancel,
}) => { }) => {
const [form] = Form.useForm(); const [form] = Form.useForm();
const [loading, setLoading] = useState<boolean>(true); const [loading, setLoading] = useState(false);
const [categories, setCategories] = useState<any>([]); const [categories, setCategories] = useState<any>([]);
const [parent_id, setParentId] = useState<number>(0); const [parent_id, setParentId] = useState<number>(0);
@ -78,11 +78,19 @@ export const ResourceCategoryCreate: React.FC<PropInterface> = ({
}; };
const onFinish = (values: any) => { const onFinish = (values: any) => {
if (loading) {
return;
}
setLoading(true);
resourceCategory resourceCategory
.storeResourceCategory(values.name, parent_id || 0, 0) .storeResourceCategory(values.name, parent_id || 0, 0)
.then((res: any) => { .then((res: any) => {
setLoading(false);
message.success("保存成功!"); message.success("保存成功!");
onCancel(); onCancel();
})
.catch((e) => {
setLoading(false);
}); });
}; };

View File

@ -22,7 +22,7 @@ export const ResourceCategoryUpdate: React.FC<PropInterface> = ({
}) => { }) => {
const [form] = Form.useForm(); const [form] = Form.useForm();
const [init, setInit] = useState(true); const [init, setInit] = useState(true);
const [loading, setLoading] = useState<boolean>(true); const [loading, setLoading] = useState(false);
const [categories, setCategories] = useState<any>([]); const [categories, setCategories] = useState<any>([]);
const [parent_id, setParentId] = useState<number>(0); const [parent_id, setParentId] = useState<number>(0);
const [sort, setSort] = useState<number>(0); const [sort, setSort] = useState<number>(0);
@ -91,11 +91,19 @@ export const ResourceCategoryUpdate: React.FC<PropInterface> = ({
}; };
const onFinish = (values: any) => { const onFinish = (values: any) => {
if (loading) {
return;
}
setLoading(true);
resourceCategory resourceCategory
.updateResourceCategory(id, values.name, parent_id || 0, sort) .updateResourceCategory(id, values.name, parent_id || 0, sort)
.then((res: any) => { .then((res: any) => {
setLoading(false);
message.success("保存成功!"); message.success("保存成功!");
onCancel(); onCancel();
})
.catch((e) => {
setLoading(false);
}); });
}; };

View File

@ -399,7 +399,6 @@ const ResourceCategoryPage = () => {
blockNode blockNode
onDragEnter={onDragEnter} onDragEnter={onDragEnter}
onDrop={onDrop} onDrop={onDrop}
defaultExpandAll={true}
switcherIcon={<i className="iconfont icon-icon-fold c-gray" />} switcherIcon={<i className="iconfont icon-icon-fold c-gray" />}
/> />
)} )}