|
@@ -1,11 +1,33 @@
|
|
|
import { PageContainer } from '@ant-design/pro-layout'
|
|
|
import { useDispatch, connect } from 'umi'
|
|
|
-import { message, Select, TreeSelect } from 'antd'
|
|
|
+import { message } from 'antd'
|
|
|
import React, { useState, useEffect } from 'react'
|
|
|
import LeftMenu from './components/LeftMenu'
|
|
|
+import { createForm, onFieldReact } from '@formily/core'
|
|
|
+import { createSchemaField } from '@formily/react'
|
|
|
+import {
|
|
|
+ FormItem,
|
|
|
+ Input,
|
|
|
+ Switch,
|
|
|
+ Select,
|
|
|
+ FormGrid,
|
|
|
+ FormLayout,
|
|
|
+ Form,
|
|
|
+ Radio,
|
|
|
+ Checkbox,
|
|
|
+ NumberPicker,
|
|
|
+ Password,
|
|
|
+ DatePicker,
|
|
|
+ TimePicker,
|
|
|
+ TreeSelect,
|
|
|
+ FormButtonGroup,
|
|
|
+ Submit
|
|
|
+} from '@formily/antd'
|
|
|
+import { schema } from './schema'
|
|
|
import { queryOrganizationalMembersList } from '@/services/api/institution'
|
|
|
import { useRequest } from '@umijs/max'
|
|
|
-import { saveApprovalAccount } from '@/services/api/schema'
|
|
|
+import consts from '@/utils/consts'
|
|
|
+import { queryApprovalAccountDetail, saveApprovalAccount } from '@/services/api/schema'
|
|
|
|
|
|
export enum LeftMenuEnum {
|
|
|
BUDGET = '1'
|
|
@@ -23,8 +45,8 @@ export enum InstitutionEnum {
|
|
|
|
|
|
type ProcessUserProps = {
|
|
|
name: Nullable<string>
|
|
|
- institutionID: Nullable<string>
|
|
|
organizationListNew: API.OrganizationalStructureListItem[]
|
|
|
+ approvalAccountDetail: API.ApprovalAccountDetail[]
|
|
|
}
|
|
|
|
|
|
const ProcessUser = props => {
|
|
@@ -33,15 +55,15 @@ const ProcessUser = props => {
|
|
|
const [state, setState] = useState<ProcessUserProps>({
|
|
|
activeKey: LeftMenuEnum.BUDGET,
|
|
|
name: null,
|
|
|
- institutionID: null,
|
|
|
- organizationListNew: []
|
|
|
+ organizationListNew: [],
|
|
|
+ approvalAccountDetail: []
|
|
|
})
|
|
|
- console.log(state.institutionID)
|
|
|
+ console.log(state.approvalAccountDetail.data)
|
|
|
|
|
|
- const { run: tryOrganizationList } = useRequest(queryOrganizationalMembersList, {
|
|
|
+ const { run: tryApprovalAccountDetail } = useRequest(queryApprovalAccountDetail, {
|
|
|
manual: true,
|
|
|
onSuccess: result => {
|
|
|
- setState({ ...state, organizationListNew: result })
|
|
|
+ setState({ ...state, approvalAccountDetail: result })
|
|
|
}
|
|
|
})
|
|
|
|
|
@@ -55,13 +77,6 @@ const ProcessUser = props => {
|
|
|
}
|
|
|
)
|
|
|
|
|
|
- const handleInstitutionSelect = value => {
|
|
|
- // console.log(value)
|
|
|
- // debugger
|
|
|
- setState({ ...state, institutionID: value })
|
|
|
- // tryOrganizationList({ institutionID: value })
|
|
|
- }
|
|
|
-
|
|
|
const renderTreeNodes = data =>
|
|
|
data.map(item => {
|
|
|
const newItem = { ...item }
|
|
@@ -73,24 +88,189 @@ const ProcessUser = props => {
|
|
|
return newItem
|
|
|
})
|
|
|
|
|
|
- const handleApprovalonChange = async value => {
|
|
|
- if (value) {
|
|
|
- await trysaveApprovalAccount({
|
|
|
- accountIDs: value,
|
|
|
- name: state.name,
|
|
|
- institutionID: state.institutionID
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
useEffect(() => {
|
|
|
if (!institutionList.length) {
|
|
|
dispatch({
|
|
|
type: 'business/queryInstitution'
|
|
|
})
|
|
|
- // tryOrganizationList(state.institutionID)
|
|
|
}
|
|
|
+ tryApprovalAccountDetail()
|
|
|
}, [])
|
|
|
+
|
|
|
+ const AA = state.approvalAccountDetail.data
|
|
|
+ ?.filter(item => item.name === 'zxLeader')
|
|
|
+ .map(item => item.accountIDs)
|
|
|
+ console.log(AA)
|
|
|
+
|
|
|
+ const form = createForm({
|
|
|
+ initialValues: {
|
|
|
+ receiver: {
|
|
|
+ receiverInstitutionID: state.approvalAccountDetail.data
|
|
|
+ ?.filter(item => item.name === 'receiver')
|
|
|
+ .map(item => item.institutionID)
|
|
|
+ .toString()
|
|
|
+ // receiverAccountIDs: state.approvalAccountDetail.data
|
|
|
+ // ?.filter(item => item.name === 'receiver')
|
|
|
+ // .map(item => item.accountIDs)
|
|
|
+ },
|
|
|
+ fgLeader: {
|
|
|
+ fgLeaderInstitutionID: state.approvalAccountDetail.data
|
|
|
+ ?.filter(item => item.name === 'fgLeader')
|
|
|
+ .map(item => item.institutionID)
|
|
|
+ .toString()
|
|
|
+ // fgLeaderAccountIDs: state.approvalAccountDetail.data
|
|
|
+ // ?.filter(item => item.name === 'fgLeader')
|
|
|
+ // .map(item => item.accountIDs)
|
|
|
+ },
|
|
|
+ zxLeader: {
|
|
|
+ zxLeaderInstitutionID: state.approvalAccountDetail.data
|
|
|
+ ?.filter(item => item.name === 'zxLeader')
|
|
|
+ .map(item => item.institutionID)
|
|
|
+ .toString()
|
|
|
+ // zxLeaderAccountIDs: state.approvalAccountDetail.data
|
|
|
+ // ?.filter(item => item.name === 'zxLeader')
|
|
|
+ // .map(item => item.accountIDs)
|
|
|
+ },
|
|
|
+ post: {
|
|
|
+ postInstitutionID: state.approvalAccountDetail.data
|
|
|
+ ?.filter(item => item.name === 'post')
|
|
|
+ .map(item => item.institutionID)
|
|
|
+ .toString()
|
|
|
+ // postAccountIDs: state.approvalAccountDetail.data
|
|
|
+ // ?.filter(item => item.name === 'post')
|
|
|
+ // .map(item => item.accountIDs)
|
|
|
+ },
|
|
|
+ archive: {
|
|
|
+ archiveInstitutionID: state.approvalAccountDetail.data
|
|
|
+ ?.filter(item => item.name === 'archive')
|
|
|
+ .map(item => item.institutionID)
|
|
|
+ .toString()
|
|
|
+ // archiveAccountIDs: state.approvalAccountDetail.data
|
|
|
+ // ?.filter(item => item.name === 'archive')
|
|
|
+ // .map(item => item.accountIDs)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ effects() {
|
|
|
+ onFieldReact('receiver.receiverInstitutionID', async field => {
|
|
|
+ if (!field.dataSource?.length) {
|
|
|
+ // 将企事业列表直接赋予当前字段
|
|
|
+ field.dataSource = institutionList?.items?.map(item => ({
|
|
|
+ value: item.ID,
|
|
|
+ label: item.name
|
|
|
+ }))
|
|
|
+ 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 => {
|
|
|
+ field.dataSource = renderTreeNodes(data).filter(item => item.children?.length)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ onFieldReact('fgLeader.fgLeaderInstitutionID', 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('fgLeader.fgLeaderAccountIDs', field => {
|
|
|
+ field.dataSource = renderTreeNodes(data).filter(item => item.children?.length)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ 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 => {
|
|
|
+ field.dataSource = renderTreeNodes(data).filter(item => item.children?.length)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ 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 => {
|
|
|
+ field.dataSource = renderTreeNodes(data).filter(item => item.children?.length)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ 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 => {
|
|
|
+ field.dataSource = renderTreeNodes(data).filter(item => item.children?.length)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ const SchemaField = createSchemaField({
|
|
|
+ components: {
|
|
|
+ FormLayout,
|
|
|
+ FormItem,
|
|
|
+ FormGrid,
|
|
|
+ Input,
|
|
|
+ Switch,
|
|
|
+ Select,
|
|
|
+ Radio,
|
|
|
+ Checkbox,
|
|
|
+ NumberPicker,
|
|
|
+ Password,
|
|
|
+ DatePicker,
|
|
|
+ TimePicker,
|
|
|
+ TreeSelect
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ const onFinish = values => {
|
|
|
+ console.log(values)
|
|
|
+
|
|
|
+ // trysaveApprovalAccount({
|
|
|
+ // archiveAccountIDs: values.archive.archiveAccountIDs,
|
|
|
+ // archiveInstitutionID: values.archive.archiveInstitutionID,
|
|
|
+ // fgLeaderAccountIDs: values.fgLeader.fgLeaderAccountIDs,
|
|
|
+ // fgLeaderInstitutionID: values.fgLeader.fgLeaderInstitutionID,
|
|
|
+ // postAccountIDs: values.post.postAccountIDs,
|
|
|
+ // postInstitutionID: values.post.postInstitutionID,
|
|
|
+ // receiverAccountIDs: values.receiver.receiverAccountIDs,
|
|
|
+ // receiverInstitutionID: values.receiver.receiverInstitutionID,
|
|
|
+ // zxLeaderAccountIDs: values.zxLeader.zxLeaderAccountIDs,
|
|
|
+ // zxLeaderInstitutionID: values.zxLeader.zxLeaderInstitutionID
|
|
|
+ // })
|
|
|
+ }
|
|
|
return (
|
|
|
<PageContainer title={false}>
|
|
|
<div className="h-full w-full flex flex-row">
|
|
@@ -103,137 +283,13 @@ const ProcessUser = props => {
|
|
|
<div className="w-6/7 ml-8 bg-white p-6 rounded-20px">
|
|
|
<div className="flex flex-row mb-5 w-full text-xl">流程用户设置</div>
|
|
|
<div className="max-w-800px">
|
|
|
- <div className="flex justify-start items-center mb-4">
|
|
|
- <div className="w-20">收件员:</div>
|
|
|
- <div>
|
|
|
- <Select
|
|
|
- style={{ width: 250 }}
|
|
|
- placeholder="请选择单位"
|
|
|
- // defaultValue={{ value: '56b9fc0f-02d8-446e-be13-ad705be31d11' }}
|
|
|
- onSelect={handleInstitutionSelect}
|
|
|
- onClick={() => {
|
|
|
- setState({ ...state, name: InstitutionEnum.RECEIVER })
|
|
|
- }}
|
|
|
- options={institutionList?.items?.map(item => ({ value: item.ID, label: item.name }))}
|
|
|
- />
|
|
|
- </div>
|
|
|
- <div className="ml-2">
|
|
|
- <TreeSelect
|
|
|
- style={{ width: 250 }}
|
|
|
- placeholder="请选择用户"
|
|
|
- treeDefaultExpandAll
|
|
|
- treeNodeFilterProp="label"
|
|
|
- multiple
|
|
|
- maxTagCount="responsive"
|
|
|
- // defaultValue={[{ title: 'ceshixinjian1', value: '14db339b-3675-4a47-a23d-ecacbc9e0385' }]}
|
|
|
- onChange={handleApprovalonChange}
|
|
|
- treeData={renderTreeNodes(state.organizationListNew).filter(item => item.children?.length)}
|
|
|
- />
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div className="flex justify-start items-center mb-4">
|
|
|
- <div className="w-20">分管领导:</div>
|
|
|
- <div>
|
|
|
- <Select
|
|
|
- style={{ width: 250 }}
|
|
|
- placeholder="请选择单位"
|
|
|
- onChange={handleInstitutionSelect}
|
|
|
- onClick={() => {
|
|
|
- setState({ ...state, name: InstitutionEnum.FGLEADER })
|
|
|
- }}
|
|
|
- options={institutionList?.items?.map(item => ({ value: item.ID, label: item.name }))}
|
|
|
- />
|
|
|
- </div>
|
|
|
- <div className="ml-2">
|
|
|
- <TreeSelect
|
|
|
- style={{ width: 250 }}
|
|
|
- placeholder="请选择用户"
|
|
|
- treeDefaultExpandAll
|
|
|
- treeNodeFilterProp="label"
|
|
|
- multiple
|
|
|
- maxTagCount="responsive"
|
|
|
- onChange={handleApprovalonChange}
|
|
|
- treeData={renderTreeNodes(state.organizationListNew).filter(item => item.children?.length)}
|
|
|
- />
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div className="flex justify-start items-center mb-4">
|
|
|
- <div className="w-20">中心领导:</div>
|
|
|
- <div>
|
|
|
- <Select
|
|
|
- style={{ width: 250 }}
|
|
|
- placeholder="请选择单位"
|
|
|
- onChange={handleInstitutionSelect}
|
|
|
- onClick={() => {
|
|
|
- setState({ ...state, name: InstitutionEnum.ZXLEADER })
|
|
|
- }}
|
|
|
- options={institutionList?.items?.map(item => ({ value: item.ID, label: item.name }))}
|
|
|
- />
|
|
|
- </div>
|
|
|
- <div className="ml-2">
|
|
|
- <TreeSelect
|
|
|
- style={{ width: 250 }}
|
|
|
- placeholder="请选择用户"
|
|
|
- treeDefaultExpandAll
|
|
|
- treeNodeFilterProp="label"
|
|
|
- multiple
|
|
|
- maxTagCount="responsive"
|
|
|
- onChange={handleApprovalonChange}
|
|
|
- treeData={renderTreeNodes(state.organizationListNew).filter(item => item.children?.length)}
|
|
|
- />
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div className="flex justify-start items-center mb-4">
|
|
|
- <div className="w-20">发文:</div>
|
|
|
- <div>
|
|
|
- <Select
|
|
|
- style={{ width: 250 }}
|
|
|
- placeholder="请选择单位"
|
|
|
- onChange={handleInstitutionSelect}
|
|
|
- onClick={() => {
|
|
|
- setState({ ...state, name: InstitutionEnum.POST })
|
|
|
- }}
|
|
|
- options={institutionList?.items?.map(item => ({ value: item.ID, label: item.name }))}
|
|
|
- />
|
|
|
- </div>
|
|
|
- <div className="ml-2">
|
|
|
- <TreeSelect
|
|
|
- style={{ width: 250 }}
|
|
|
- placeholder="请选择用户"
|
|
|
- treeDefaultExpandAll
|
|
|
- treeNodeFilterProp="label"
|
|
|
- multiple
|
|
|
- maxTagCount="responsive"
|
|
|
- onChange={handleApprovalonChange}
|
|
|
- treeData={renderTreeNodes(state.organizationListNew).filter(item => item.children?.length)}
|
|
|
- />
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div className="flex justify-start items-center mb-4">
|
|
|
- <div className="w-20">归档:</div>
|
|
|
- <div>
|
|
|
- <Select
|
|
|
- style={{ width: 250 }}
|
|
|
- placeholder="请选择单位"
|
|
|
- onChange={handleInstitutionSelect}
|
|
|
- onClick={() => {
|
|
|
- setState({ ...state, name: InstitutionEnum.ARCHIVE })
|
|
|
- }}
|
|
|
- options={institutionList?.items?.map(item => ({ value: item.ID, label: item.name }))}
|
|
|
- />
|
|
|
- </div>
|
|
|
- <div className="ml-2">
|
|
|
- <TreeSelect
|
|
|
- style={{ width: 250 }}
|
|
|
- placeholder="请选择用户"
|
|
|
- treeDefaultExpandAll
|
|
|
- treeNodeFilterProp="label"
|
|
|
- multiple
|
|
|
- maxTagCount="responsive"
|
|
|
- onChange={handleApprovalonChange}
|
|
|
- treeData={renderTreeNodes(state.organizationListNew).filter(item => item.children?.length)}
|
|
|
- />
|
|
|
- </div>
|
|
|
+ <div className="w-600px">
|
|
|
+ <Form form={form} labelCol={12}>
|
|
|
+ <SchemaField schema={schema} />
|
|
|
+ <FormButtonGroup>
|
|
|
+ <Submit onSubmit={onFinish}>提交</Submit>
|
|
|
+ </FormButtonGroup>
|
|
|
+ </Form>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|