diff --git a/src/api/staffInfo/index.js b/src/api/staffInfo/index.js index e9491b8..b23ea7c 100644 --- a/src/api/staffInfo/index.js +++ b/src/api/staffInfo/index.js @@ -31,7 +31,9 @@ export const staffInfoRemove = declareRequest( export const staffInfoResetPassword = declareRequest( "staffInfoLoading", - safeAction(async ({ id }) => apiPost("/safetyEval/org-personnel/reset-password", { data: asId(id) })), + safeAction(async ({ id, resetPassword }) => + apiPost("/safetyEval/org-personnel/reset-password", { data: {id, resetPassword} }), + ), ); export const queryBasicDisciplineMajor = declareRequest( diff --git a/src/pages/Container/EnterpriseInfo/PersonnelInfo/List/index.js b/src/pages/Container/EnterpriseInfo/PersonnelInfo/List/index.js index e585489..f695ea6 100644 --- a/src/pages/Container/EnterpriseInfo/PersonnelInfo/List/index.js +++ b/src/pages/Container/EnterpriseInfo/PersonnelInfo/List/index.js @@ -45,6 +45,7 @@ function PersonnelInfoPage(props) { const [formModalOpen, setFormModalOpen] = useState(false); const [viewModalOpen, setViewModalOpen] = useState(false); const [importModalOpen, setImportModalOpen] = useState(false); + const [resetPasswordModalOpen, setResetPasswordModalOpen] = useState(false); const [currentId, setCurrentId] = useState(""); const [searchForm] = Form.useForm(); const [deptOptions, setDeptOptions] = useState([]); @@ -115,18 +116,8 @@ function PersonnelInfoPage(props) { }; const onResetPassword = (id) => { - Modal.confirm({ - title: "提示", - content: "密码将会重置,您是否确认重置密码?", - okText: "是", - cancelText: "否", - onOk: async () => { - const res = await props.staffInfoResetPassword({ id }); - if (res?.success !== false) { - message.success("重置成功"); - } - }, - }); + setCurrentId(id); + setResetPasswordModalOpen(true); }; return ( @@ -336,6 +327,17 @@ function PersonnelInfoPage(props) { onSuccess={handleSearch} /> )} + {resetPasswordModalOpen && ( + { + setResetPasswordModalOpen(false); + setCurrentId(""); + }} + /> + )} ); } @@ -1061,6 +1063,57 @@ function StaffImportModal({ open, onCancel, onSuccess }) { ); } +function ResetPasswordModal({ open, currentId, staffInfoResetPassword, onCancel }) { + const [form] = Form.useForm(); + const [submitting, setSubmitting] = useState(false); + + const handleCancel = () => { + form.resetFields(); + onCancel(); + }; + + const handleSubmit = async (values) => { + try { + setSubmitting(true); + const res = await staffInfoResetPassword({ + id: currentId, + resetPassword: values.resetPassword, + }); + if (res?.success !== false) { + message.success("重置成功"); + handleCancel(); + } + } finally { + setSubmitting(false); + } + }; + + return ( + +
+ + + +
+
+ ); +} + export default Connect( [NS_STAFF_INFO, NS_ORG_DEPARTMENT], true,