|
@@ -1,9 +1,11 @@
|
|
|
-import React, { useEffect, useState } from 'react'
|
|
|
+import React, { useContext, useEffect, useMemo, useState } from 'react'
|
|
|
import { ParticipantMode } from '../../enum'
|
|
|
import { ConfigureType } from '../../enum'
|
|
|
import { queryAccountList } from '@/services/api/institution'
|
|
|
import { Col, Collapse, Row, Select, Switch } from 'antd'
|
|
|
import { useRequest } from 'umi'
|
|
|
+import { eId, FlowContext } from '../../context'
|
|
|
+import { isEdge, isNode } from 'react-flow-renderer'
|
|
|
|
|
|
type ParticipantCardProps = {
|
|
|
defaultData: {
|
|
@@ -17,14 +19,6 @@ type ParticipantCardProps = {
|
|
|
updateAction: (values: Recordable<string>) => void
|
|
|
}
|
|
|
|
|
|
-const configureArr = [
|
|
|
- // ConfigureType.ADDSIGN,
|
|
|
- ConfigureType.ASSISTAUDIT,
|
|
|
- ConfigureType.RETURN
|
|
|
- // ConfigureType.REVOKE,
|
|
|
- // ConfigureType.SKIP
|
|
|
-]
|
|
|
-
|
|
|
const configureItemTitle = {
|
|
|
[ConfigureType.ADDSIGN]: {
|
|
|
name: '允许加签',
|
|
@@ -45,6 +39,10 @@ const configureItemTitle = {
|
|
|
[ConfigureType.SKIP]: {
|
|
|
name: '允许跳过',
|
|
|
short: '跳'
|
|
|
+ },
|
|
|
+ [ConfigureType.NEXTSECTOR]: {
|
|
|
+ name: '允许添加下一环节',
|
|
|
+ short: '环'
|
|
|
}
|
|
|
}
|
|
|
const ParticipantCard: React.FC<ParticipantCardProps> = ({
|
|
@@ -52,24 +50,50 @@ const ParticipantCard: React.FC<ParticipantCardProps> = ({
|
|
|
defaultData,
|
|
|
institutionList
|
|
|
}) => {
|
|
|
- const [staffList, setStaffList] = useState([])
|
|
|
+ const { flowState } = useContext(FlowContext)
|
|
|
+ const { modalConfig: { nodeID = null } = {}, elements } = flowState
|
|
|
+ const curNode = elements.filter(item => isNode(item)).find(item => item.id === nodeID)
|
|
|
+ const lastEdge = elements.filter(item => isEdge(item)).find(item => item.target === eId)
|
|
|
+
|
|
|
+ const [state, setState] = useState({
|
|
|
+ configureArr: [
|
|
|
+ // ConfigureType.ADDSIGN,
|
|
|
+ ConfigureType.ASSISTAUDIT,
|
|
|
+ ConfigureType.RETURN
|
|
|
+ // ConfigureType.REVOKE,
|
|
|
+ // ConfigureType.SKIP
|
|
|
+ ],
|
|
|
+ staffList: []
|
|
|
+ })
|
|
|
const { run: tryUpdateStaffList } = useRequest(
|
|
|
dataID => queryAccountList({ current: 1, pageSize: 214000, dataID, enable: ['true'] }),
|
|
|
{
|
|
|
manual: true,
|
|
|
onSuccess(result) {
|
|
|
- setStaffList(result.items.map(item => ({ label: item.name, value: item.ID })))
|
|
|
+ setState({
|
|
|
+ ...state,
|
|
|
+ staffList: result.items.map(item => ({ label: item.name, value: item.ID }))
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
)
|
|
|
|
|
|
useEffect(() => {
|
|
|
- if (defaultData.ID && defaultData.institutionID && !staffList?.length) {
|
|
|
+ if (defaultData.ID && defaultData.institutionID && !state.staffList?.length) {
|
|
|
tryUpdateStaffList(defaultData.institutionID)
|
|
|
}
|
|
|
}, [])
|
|
|
|
|
|
- if (defaultData.ID && !staffList?.length) return null
|
|
|
+ useEffect(() => {
|
|
|
+ if ([ParticipantMode.ACCOUNT].includes(defaultData.participantMode)) {
|
|
|
+ // 当前的node元素
|
|
|
+ // 最后一个edge及诶单
|
|
|
+ if (lastEdge && curNode && lastEdge.source === curNode.id) {
|
|
|
+ setState({ ...state, configureArr: [...state.configureArr, ConfigureType.NEXTSECTOR] })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, [defaultData.participantMode, curNode, lastEdge])
|
|
|
+ if (defaultData.ID && !state.staffList?.length) return null
|
|
|
return (
|
|
|
<>
|
|
|
<div className="children:mb-4">
|
|
@@ -101,7 +125,7 @@ const ParticipantCard: React.FC<ParticipantCardProps> = ({
|
|
|
<Select
|
|
|
className="w-full"
|
|
|
defaultValue={defaultData.ID}
|
|
|
- options={staffList}
|
|
|
+ options={state.staffList}
|
|
|
onChange={(_, options) => {
|
|
|
updateAction({ ...defaultData, ID: options?.value, name: options?.label })
|
|
|
}}
|
|
@@ -132,7 +156,7 @@ const ParticipantCard: React.FC<ParticipantCardProps> = ({
|
|
|
}
|
|
|
key="1">
|
|
|
<Row>
|
|
|
- {configureArr.map(item => (
|
|
|
+ {state.configureArr.map(item => (
|
|
|
<Col span={8} key={item}>
|
|
|
<div className="py-2 flex flex-row items-center ">
|
|
|
<div className="mr-2">{configureItemTitle[item]?.name}</div>
|