|
@@ -1,4 +1,4 @@
|
|
-import React, { useEffect } from 'react'
|
|
|
|
|
|
+import React, { useEffect, useState } from 'react'
|
|
import { message, Button, Form } from 'antd'
|
|
import { message, Button, Form } from 'antd'
|
|
import { connect, useRequest } from 'umi'
|
|
import { connect, useRequest } from 'umi'
|
|
import consts from '@/utils/consts'
|
|
import consts from '@/utils/consts'
|
|
@@ -53,6 +53,9 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
|
|
}) => {
|
|
}) => {
|
|
const form = useForm()
|
|
const form = useForm()
|
|
|
|
|
|
|
|
+ const [state, setState] = useState({
|
|
|
|
+ accountDetail: {}
|
|
|
|
+ })
|
|
const { run: tryUpdateAccount } = useRequest(updateAccount, {
|
|
const { run: tryUpdateAccount } = useRequest(updateAccount, {
|
|
manual: true,
|
|
manual: true,
|
|
onSuccess: () => {
|
|
onSuccess: () => {
|
|
@@ -67,17 +70,14 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
|
|
- const { run: tryGetAccountDetail } = useRequest(queryAccountDetail, {
|
|
|
|
|
|
+ const { run: tryGetAccountDetail } = useRequest((ID: string) => queryAccountDetail(ID), {
|
|
manual: true,
|
|
manual: true,
|
|
- onSuccess: () => {
|
|
|
|
|
|
+ onSuccess: result => {
|
|
setState({ ...state, accountDetail: result })
|
|
setState({ ...state, accountDetail: result })
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
- if (type === ModalType.PREVIEW) {
|
|
|
|
- tryGetAccountDetail({ ID: dataId })
|
|
|
|
- }
|
|
|
|
if (visible) {
|
|
if (visible) {
|
|
if (!schema) {
|
|
if (!schema) {
|
|
dispatch({
|
|
dispatch({
|
|
@@ -138,7 +138,9 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
|
|
|
|
|
|
const onMount = () => {
|
|
const onMount = () => {
|
|
if (!defaultFormData?.dataID) {
|
|
if (!defaultFormData?.dataID) {
|
|
- form.setValues(type === ModalType.ADD ? {} : { ...defaultFormData })
|
|
|
|
|
|
+ if (type === ModalType.UPDATE) {
|
|
|
|
+ form.setValues({ ...defaultFormData })
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
form.setValues(
|
|
form.setValues(
|
|
type === ModalType.ADD
|
|
type === ModalType.ADD
|
|
@@ -174,6 +176,15 @@ const StaffDrawer: React.FC<StaffModalProps> = ({
|
|
})
|
|
})
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
+ if (dataId) {
|
|
|
|
+ queryAccountDetail({ ID: dataId }).then(accountDetail => {
|
|
|
|
+ if (accountDetail) {
|
|
|
|
+ if (type === ModalType.PREVIEW) {
|
|
|
|
+ form.setValues({ ...accountDetail.data })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
if (defaultFormData?.institutionID) {
|
|
if (defaultFormData?.institutionID) {
|
|
queryOrganizationalStructureList({
|
|
queryOrganizationalStructureList({
|
|
dataID: defaultFormData?.institutionID,
|
|
dataID: defaultFormData?.institutionID,
|