|
@@ -40,6 +40,8 @@ type iProcessProps = {
|
|
|
approvalAccountDetail: API.ApprovalAccountDetail[]
|
|
|
}
|
|
|
|
|
|
+let cacheKeys: string[] = []
|
|
|
+
|
|
|
const Process: React.FC = props => {
|
|
|
const { institutionList } = props
|
|
|
const dispatch = useDispatch()
|
|
@@ -48,8 +50,7 @@ const Process: React.FC = props => {
|
|
|
approvalAccountDetail: null
|
|
|
})
|
|
|
|
|
|
- const {} = useRequest(queryApprovalAccountDetail, {
|
|
|
- // manual: true,
|
|
|
+ useRequest(queryApprovalAccountDetail, {
|
|
|
onSuccess: (result: API.ApprovalAccountDetail) => {
|
|
|
setState({
|
|
|
...state,
|
|
@@ -66,16 +67,6 @@ const Process: React.FC = props => {
|
|
|
}
|
|
|
})
|
|
|
|
|
|
- const { run: trysaveApprovalAccount } = useRequest(
|
|
|
- (params: Partial<API.UpdateRoleParams>) => saveApprovalAccount(params),
|
|
|
- {
|
|
|
- manual: true,
|
|
|
- onSuccess: () => {
|
|
|
- message.success('编辑成功')
|
|
|
- }
|
|
|
- }
|
|
|
- )
|
|
|
-
|
|
|
const renderTreeNodes = data =>
|
|
|
data.map(item => {
|
|
|
const newItem = { ...item }
|
|
@@ -90,7 +81,8 @@ const Process: React.FC = props => {
|
|
|
useEffect(() => {
|
|
|
if (!institutionList.length) {
|
|
|
dispatch({
|
|
|
- type: 'business/queryInstitution'
|
|
|
+ type: 'business/queryInstitution',
|
|
|
+ payload: { pageSize: 214000 }
|
|
|
})
|
|
|
}
|
|
|
// tryApprovalAccountDetail()
|
|
@@ -109,15 +101,23 @@ const Process: React.FC = props => {
|
|
|
return
|
|
|
}
|
|
|
// 收件人企事业id
|
|
|
- const institutionID = field.value
|
|
|
- if (institutionID) {
|
|
|
- const { code = -1, data } = await queryOrganizationalMembersList({ institutionID })
|
|
|
- if (code === consts.RET_CODE.SUCCESS) {
|
|
|
- form.setFieldState('receiver.receiverAccountIDs', field => {
|
|
|
+ const institutionID: undefined | string = field.value
|
|
|
+ institutionID &&
|
|
|
+ form.setFieldState('receiver.receiverAccountIDs', async field => {
|
|
|
+ const { code = -1, data } = await queryOrganizationalMembersList({ institutionID })
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
+ if (cacheKeys.some((key: string) => key.startsWith('receiver_'))) {
|
|
|
+ // 说明当前企事业id已变,需要将当前field的value置空
|
|
|
+ field.value = []
|
|
|
+ cacheKeys = cacheKeys
|
|
|
+ .filter(item => item.startsWith('receiver_'))
|
|
|
+ .concat(`receiver_${institutionID}`)
|
|
|
+ } else {
|
|
|
+ cacheKeys = cacheKeys.concat(`receiver_${institutionID}`)
|
|
|
+ }
|
|
|
field.dataSource = renderTreeNodes(data)
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ })
|
|
|
})
|
|
|
onFieldReact('fgLeader.fgLeaderInstitutionID', async field => {
|
|
|
if (!field.dataSource?.length) {
|
|
@@ -127,60 +127,90 @@ const Process: React.FC = props => {
|
|
|
}))
|
|
|
return
|
|
|
}
|
|
|
- const institutionID = field.value
|
|
|
- if (institutionID) {
|
|
|
- const { code = -1, data } = await queryOrganizationalMembersList({ institutionID })
|
|
|
- if (code === consts.RET_CODE.SUCCESS) {
|
|
|
- form.setFieldState('fgLeader.fgLeaderAccountIDs', field => {
|
|
|
+ const institutionID: undefined | string = field.value
|
|
|
+ institutionID &&
|
|
|
+ form.setFieldState('fgLeader.fgLeaderAccountIDs', async field => {
|
|
|
+ const { code = -1, data } = await queryOrganizationalMembersList({ institutionID })
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
+ if (cacheKeys.some((key: string) => key.startsWith('fgLeader_'))) {
|
|
|
+ // 说明当前企事业id已变,需要将当前field的value置空
|
|
|
+ field.value = []
|
|
|
+ cacheKeys = cacheKeys
|
|
|
+ .filter(item => item.startsWith('fgLeader_'))
|
|
|
+ .concat(`fgLeader_${institutionID}`)
|
|
|
+ } else {
|
|
|
+ cacheKeys = cacheKeys.concat(`fgLeader_${institutionID}`)
|
|
|
+ }
|
|
|
+
|
|
|
field.dataSource = renderTreeNodes(data)
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ })
|
|
|
})
|
|
|
onFieldReact('zxLeader.zxLeaderInstitutionID', async field => {
|
|
|
if (!field.dataSource?.length) {
|
|
|
field.dataSource = institutionList?.items?.map(item => ({ value: item.ID, label: item.name }))
|
|
|
return
|
|
|
}
|
|
|
- const institutionID = field.value
|
|
|
- if (institutionID) {
|
|
|
- const { code = -1, data } = await queryOrganizationalMembersList({ institutionID })
|
|
|
- if (code === consts.RET_CODE.SUCCESS) {
|
|
|
- form.setFieldState('zxLeader.zxLeaderAccountIDs', field => {
|
|
|
+ const institutionID: undefined | string = field.value
|
|
|
+ institutionID &&
|
|
|
+ form.setFieldState('zxLeader.zxLeaderAccountIDs', async field => {
|
|
|
+ const { code = -1, data } = await queryOrganizationalMembersList({ institutionID })
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
field.dataSource = renderTreeNodes(data)
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
+ if (cacheKeys.some((key: string) => key.startsWith('zxLeader_'))) {
|
|
|
+ // 说明当前企事业id已变,需要将当前field的value置空
|
|
|
+ field.value = []
|
|
|
+ cacheKeys = cacheKeys
|
|
|
+ .filter(item => item.startsWith('zxLeader_'))
|
|
|
+ .concat(`zxLeader_${institutionID}`)
|
|
|
+ } else {
|
|
|
+ cacheKeys = cacheKeys.concat(`zxLeader_${institutionID}`)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
})
|
|
|
onFieldReact('post.postInstitutionID', async field => {
|
|
|
if (!field.dataSource?.length) {
|
|
|
field.dataSource = institutionList?.items?.map(item => ({ value: item.ID, label: item.name }))
|
|
|
return
|
|
|
}
|
|
|
- const institutionID = field.value
|
|
|
- if (institutionID) {
|
|
|
- const { code = -1, data } = await queryOrganizationalMembersList({ institutionID })
|
|
|
- if (code === consts.RET_CODE.SUCCESS) {
|
|
|
- form.setFieldState('post.postAccountIDs', field => {
|
|
|
+ const institutionID: undefined | string = field.value
|
|
|
+ institutionID &&
|
|
|
+ form.setFieldState('post.postAccountIDs', async field => {
|
|
|
+ const { code = -1, data } = await queryOrganizationalMembersList({ institutionID })
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
+ if (cacheKeys.some((key: string) => key.startsWith('post_'))) {
|
|
|
+ // 说明当前企事业id已变,需要将当前field的value置空
|
|
|
+ field.value = []
|
|
|
+ cacheKeys = cacheKeys.filter(item => item.startsWith('post_')).concat(`post_${institutionID}`)
|
|
|
+ }
|
|
|
+ cacheKeys = cacheKeys.concat(`post_${institutionID}`)
|
|
|
field.dataSource = renderTreeNodes(data)
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ })
|
|
|
})
|
|
|
onFieldReact('archive.archiveInstitutionID', async field => {
|
|
|
if (!field.dataSource?.length) {
|
|
|
field.dataSource = institutionList?.items?.map(item => ({ value: item.ID, label: item.name }))
|
|
|
return
|
|
|
}
|
|
|
- const institutionID = field.value
|
|
|
- if (institutionID) {
|
|
|
- const { code = -1, data } = await queryOrganizationalMembersList({ institutionID })
|
|
|
- if (code === consts.RET_CODE.SUCCESS) {
|
|
|
- form.setFieldState('archive.archiveAccountIDs', field => {
|
|
|
+ const institutionID: undefined | string = field.value
|
|
|
+ institutionID &&
|
|
|
+ form.setFieldState('archive.archiveAccountIDs', async field => {
|
|
|
+ const { code = -1, data } = await queryOrganizationalMembersList({ institutionID })
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
+ if (cacheKeys.some((key: string) => key.startsWith('archive_'))) {
|
|
|
+ // 说明当前企事业id已变,需要将当前field的value置空
|
|
|
+ field.value = []
|
|
|
+ cacheKeys = cacheKeys
|
|
|
+ .filter(item => item.startsWith('archive_'))
|
|
|
+ .concat(`archive_${institutionID}`)
|
|
|
+ } else {
|
|
|
+ cacheKeys = cacheKeys.concat(`archive_${institutionID}`)
|
|
|
+ }
|
|
|
field.dataSource = renderTreeNodes(data)
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ })
|
|
|
})
|
|
|
}
|
|
|
})
|
|
@@ -203,14 +233,16 @@ const Process: React.FC = props => {
|
|
|
}
|
|
|
})
|
|
|
|
|
|
- const onFinish = (values: Record<string, any>) => {
|
|
|
+ const onFinish = async (values: Record<string, any>) => {
|
|
|
const keys = Object.keys(values)
|
|
|
const params = keys.reduce((prev, curr) => {
|
|
|
const obj = { ...prev, ...values[curr] }
|
|
|
return obj
|
|
|
}, {})
|
|
|
-
|
|
|
- trysaveApprovalAccount(params)
|
|
|
+ const { code = -1 } = await saveApprovalAccount(params)
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
+ message.success('编辑成功')
|
|
|
+ }
|
|
|
}
|
|
|
return (
|
|
|
<PageContainer title={false}>
|