From e35700684dbe173c955f1698f948e7ef81b9972a Mon Sep 17 00:00:00 2001 From: unknown <18119604035@163.com> Date: Thu, 3 Aug 2023 11:53:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=84=E7=BC=96=E8=BE=91=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0loading?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/course/compenents/update.tsx | 30 ++++++++++++------- src/pages/department/compenents/update.tsx | 17 +++++++++-- src/pages/member/compenents/update.tsx | 22 +++++++++----- .../compenents/update-dialog/index.tsx | 17 +++++++++-- .../resource-category/compenents/update.tsx | 17 +++++++++-- .../videos/compenents/update-dialog/index.tsx | 17 +++++++++-- .../administrator/compenents/update.tsx | 15 ++++++++-- .../system/adminroles/compenents/update.tsx | 24 +++++++++++++-- 8 files changed, 125 insertions(+), 34 deletions(-) diff --git a/src/pages/course/compenents/update.tsx b/src/pages/course/compenents/update.tsx index e892e6d..60356ab 100644 --- a/src/pages/course/compenents/update.tsx +++ b/src/pages/course/compenents/update.tsx @@ -7,9 +7,9 @@ import { Form, TreeSelect, Input, - Modal, message, Image, + Spin, } from "antd"; import styles from "./update.module.less"; import { useSelector } from "react-redux"; @@ -28,6 +28,7 @@ export const CourseUpdate: React.FC = ({ onCancel, }) => { const [form] = Form.useForm(); + const [init, setInit] = useState(true); const courseDefaultThumbs = useSelector( (state: any) => state.systemConfig.value.courseDefaultThumbs ); @@ -41,18 +42,16 @@ export const CourseUpdate: React.FC = ({ const [type, setType] = useState("open"); useEffect(() => { - if (open) { - getParams(); - getCategory(); - } - }, [form, open]); - - useEffect(() => { + setInit(true); if (id === 0) { return; } - getDetail(); - }, [id, open]); + if (open) { + getParams(); + getCategory(); + getDetail(); + } + }, [form, id, open]); const getCategory = () => { course.createCourse().then((res: any) => { @@ -91,6 +90,7 @@ export const CourseUpdate: React.FC = ({ }); setType(type); setThumb(res.data.course.thumb); + setInit(false); }); }; @@ -185,7 +185,15 @@ export const CourseUpdate: React.FC = ({ } width={634} > -
+ {init && ( +
+ +
+ )} +
= ({ onCancel, }) => { const [form] = Form.useForm(); + const [init, setInit] = useState(true); const [loading, setLoading] = useState(true); const [departments, setDepartments] = useState([]); const [parent_id, setParentId] = useState(0); const [sort, setSort] = useState(0); useEffect(() => { + setInit(true); if (open) { getParams(); } @@ -64,6 +66,7 @@ export const DepartmentUpdate: React.FC = ({ }); setParentId(data.parent_id); setSort(data.sort); + setInit(false); }); }; @@ -140,7 +143,15 @@ export const DepartmentUpdate: React.FC = ({ onCancel={() => onCancel()} maskClosable={false} > -
+ {init && ( +
+ +
+ )} +
= ({ onCancel, }) => { const [form] = Form.useForm(); + const [init, setInit] = useState(true); const [loading, setLoading] = useState(true); const [departments, setDepartments] = useState([]); const memberDefaultAvatar = useSelector( @@ -32,20 +33,18 @@ export const MemberUpdate: React.FC = ({ const [avatar, setAvatar] = useState(memberDefaultAvatar); useEffect(() => { + setInit(true); if (id == 0) { return; } - getDetail(); - }, [id, open]); - - useEffect(() => { if (open) { getParams(); form.setFieldsValue({ password: "", }); + getDetail(); } - }, [form, open]); + }, [form, id, open]); const getParams = () => { if (id === 0) { @@ -71,6 +70,7 @@ export const MemberUpdate: React.FC = ({ idCard: user.id_card, dep_ids: res.data.dep_ids, }); + setInit(false); }); }; @@ -145,7 +145,15 @@ export const MemberUpdate: React.FC = ({ onCancel={() => onCancel()} maskClosable={false} > -
+ {init && ( +
+ +
+ )} +
= ({ }) => { const [form] = Form.useForm(); const [loading, setLoading] = useState(true); + const [init, setInit] = useState(true); const [categories, setCategories] = useState([]); useEffect(() => { + setInit(true); if (id === 0) { return; } @@ -27,7 +29,7 @@ export const CoursewareUpdateDialog: React.FC = ({ getCategory(); getDetail(); } - }, [id, open]); + }, [form, id, open]); const getCategory = () => { resourceCategory.resourceCategoryList().then((res: any) => { @@ -46,6 +48,7 @@ export const CoursewareUpdateDialog: React.FC = ({ name: data.name, category_id: res.data.category_ids, }); + setInit(false); }); }; @@ -107,7 +110,15 @@ export const CoursewareUpdateDialog: React.FC = ({ onCancel={() => onCancel()} maskClosable={false} > -
+ {init && ( +
+ +
+ )} +
= ({ onCancel, }) => { const [form] = Form.useForm(); + const [init, setInit] = useState(true); const [loading, setLoading] = useState(true); const [categories, setCategories] = useState([]); const [parent_id, setParentId] = useState(0); const [sort, setSort] = useState(0); useEffect(() => { + setInit(true); if (open) { getParams(); } @@ -64,6 +66,7 @@ export const ResourceCategoryUpdate: React.FC = ({ }); setParentId(data.parent_id); setSort(data.sort); + setInit(false); }); }; @@ -138,7 +141,15 @@ export const ResourceCategoryUpdate: React.FC = ({ onCancel={() => onCancel()} maskClosable={false} > -
+ {init && ( +
+ +
+ )} +
= ({ }) => { const [form] = Form.useForm(); const [loading, setLoading] = useState(true); + const [init, setInit] = useState(true); const [categories, setCategories] = useState([]); useEffect(() => { + setInit(true); if (id === 0) { return; } @@ -27,7 +29,7 @@ export const VideosUpdateDialog: React.FC = ({ getCategory(); getDetail(); } - }, [id, open]); + }, [form, id, open]); const getCategory = () => { resourceCategory.resourceCategoryList().then((res: any) => { @@ -46,6 +48,7 @@ export const VideosUpdateDialog: React.FC = ({ name: data.name, category_id: res.data.category_ids, }); + setInit(false); }); }; @@ -100,7 +103,15 @@ export const VideosUpdateDialog: React.FC = ({ onCancel={() => onCancel()} maskClosable={false} > -
+ {init && ( +
+ +
+ )} +
= ({ onCancel, }) => { const [form] = Form.useForm(); + const [init, setInit] = useState(true); const [loading, setLoading] = useState(true); const [roles, setRoles] = useState([]); @@ -27,6 +28,7 @@ export const SystemAdministratorUpdate: React.FC = ({ }, [refresh, open]); useEffect(() => { + setInit(true); if (id === 0) { return; } @@ -58,6 +60,7 @@ export const SystemAdministratorUpdate: React.FC = ({ is_ban_login: user.is_ban_login, roleIds: res.data.role_ids, }); + setInit(false); }); }; @@ -104,7 +107,15 @@ export const SystemAdministratorUpdate: React.FC = ({ onCancel={() => onCancel()} maskClosable={false} > -
+ {init && ( +
+ +
+ )} +
= ({ onCancel, }) => { const [form] = Form.useForm(); + const [init, setInit] = useState(true); const [loading, setLoading] = useState(true); const [permissions, setPermissions] = useState([]); const [actions, setActions] = useState([]); @@ -32,6 +42,7 @@ export const SystemAdminrolesUpdate: React.FC = ({ }, [open]); useEffect(() => { + setInit(true); if (id === undefined) { return; } @@ -136,6 +147,7 @@ export const SystemAdminrolesUpdate: React.FC = ({ permission_ids: res.data.perm_data, action_ids: res.data.perm_action, }); + setInit(false); }); }; @@ -181,7 +193,15 @@ export const SystemAdminrolesUpdate: React.FC = ({ } width={634} > -
+ {init && ( +
+ +
+ )} +