|
@@ -19,6 +19,8 @@ import type { InstitutionsModelState } from '../../model'
|
|
|
|
|
|
import 'antd/lib/tree-select/style/index'
|
|
|
import { ModalType } from '@/utils/enum'
|
|
|
+import { ModalForm, ProFormText } from '@ant-design/pro-form'
|
|
|
+import { changeAccountPsw } from '@/services/api/user'
|
|
|
|
|
|
type StaffModalProps = ConnectProps & {
|
|
|
visible: boolean
|
|
@@ -55,6 +57,13 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+ const { run: tryChangePsw } = useRequest(changeAccountPsw, {
|
|
|
+ manual: true,
|
|
|
+ onSuccess: () => {
|
|
|
+ message.success('修改成功')
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
const { run: tryAddAccount } = useRequest(addAccount, {
|
|
|
manual: true,
|
|
|
onSuccess: () => {
|
|
@@ -242,9 +251,59 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
|
|
|
/>
|
|
|
)}
|
|
|
<div className="ml-120px">
|
|
|
+ {type === ModalType.UPDATE ? (
|
|
|
+ <ModalForm
|
|
|
+ title="修改密码"
|
|
|
+ isKeyPressSubmit
|
|
|
+ trigger={<Button type="primary">重置密码</Button>}
|
|
|
+ onFinish={async values => {
|
|
|
+ try {
|
|
|
+ await tryChangePsw({ ...values, ID: defaultFormData?.dataID })
|
|
|
+ return true
|
|
|
+ } catch (error) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <ProFormText.Password
|
|
|
+ label="新密码"
|
|
|
+ name="newPassword"
|
|
|
+ rules={[
|
|
|
+ { required: true, message: '请输入新密码' },
|
|
|
+ () => ({
|
|
|
+ validator(_, value) {
|
|
|
+ if (!value) {
|
|
|
+ return Promise.resolve()
|
|
|
+ }
|
|
|
+ if (!/(?=.*[a-zA-Z])(?=.*\d).{8,16}/.test(value)) {
|
|
|
+ return Promise.reject(new Error('密码长度最小8位且是数字和英文的组合'))
|
|
|
+ }
|
|
|
+ return Promise.resolve()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ ]}
|
|
|
+ />
|
|
|
+ <ProFormText.Password
|
|
|
+ label="确认新密码"
|
|
|
+ name="confirmPassword"
|
|
|
+ rules={[
|
|
|
+ { required: true, message: '请输入新密码' },
|
|
|
+ ({ getFieldValue }) => ({
|
|
|
+ validator(_, value) {
|
|
|
+ if (!value || getFieldValue('newPassword') === value) {
|
|
|
+ return Promise.resolve()
|
|
|
+ }
|
|
|
+ return Promise.reject(new Error('两次输入的密码不一致!'))
|
|
|
+ }
|
|
|
+ })
|
|
|
+ ]}
|
|
|
+ />
|
|
|
+ </ModalForm>
|
|
|
+ ) : null}
|
|
|
{type !== ModalType.PREVIEW && (
|
|
|
<Button
|
|
|
type="primary"
|
|
|
+ className="ml-2"
|
|
|
onClick={() => {
|
|
|
form.submit()
|
|
|
}}
|
|
@@ -253,30 +312,6 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
|
|
|
</Button>
|
|
|
)}
|
|
|
</div>
|
|
|
- {/* <Form>
|
|
|
- {schema && (
|
|
|
- <FormRender
|
|
|
- form={form}
|
|
|
- schema={schema}
|
|
|
- onFinish={onFinish}
|
|
|
- onMount={onMount}
|
|
|
- readOnly={type === ModalType.PREVIEW ? true : false}
|
|
|
- widgets={{ site: SiteInput }}
|
|
|
- watch={watch}
|
|
|
- />
|
|
|
- )}
|
|
|
- <div className="ml-120px">
|
|
|
- {type !== ModalType.PREVIEW && (
|
|
|
- <Button
|
|
|
- type="primary"
|
|
|
- onClick={() => {
|
|
|
- form.submit()
|
|
|
- }}>
|
|
|
- 提交
|
|
|
- </Button>
|
|
|
- )}
|
|
|
- </div>
|
|
|
- </Form> */}
|
|
|
</div>
|
|
|
)
|
|
|
}
|