|
@@ -1,11 +1,11 @@
|
|
|
import StepSetting from './StepSetting'
|
|
|
import RelatedMatter from './RelatedMatter'
|
|
|
import MatterPermission from './MatterPermission'
|
|
|
-import { Button, Form, Tabs } from 'antd'
|
|
|
-import { useContext, useEffect } from 'react'
|
|
|
+import { Button, Form, Tabs, Tag } from 'antd'
|
|
|
+import { useContext, useEffect, useState } from 'react'
|
|
|
import { FlowContext } from '../../../context'
|
|
|
import { Edge, isNode } from 'react-flow-renderer'
|
|
|
-import { updateNodeData } from '../../Edge/utils'
|
|
|
+import { findNodeById, updateNodeData } from '../../Edge/utils'
|
|
|
|
|
|
type AuditorProps = {
|
|
|
nodeId: string
|
|
@@ -19,8 +19,9 @@ type AuditorProps = {
|
|
|
const Auditor: React.FC<AuditorProps> = ({ nodeId, nodeData: { name, participantInfo } }) => {
|
|
|
const [form] = Form.useForm()
|
|
|
|
|
|
+ const [stepMatters, setStepMatters] = useState(participantInfo?.stepMatters || [])
|
|
|
const {
|
|
|
- flowStore: { executorList, process, drawer, elements },
|
|
|
+ flowStore: { dataID, executorList, process, drawer, elements, matterList },
|
|
|
dispatch
|
|
|
} = useContext(FlowContext)
|
|
|
|
|
@@ -28,7 +29,7 @@ const Auditor: React.FC<AuditorProps> = ({ nodeId, nodeData: { name, participant
|
|
|
const initalValues = {
|
|
|
name,
|
|
|
executorID: participantInfo?.executor?.ID,
|
|
|
- dynamicSteps: participantInfo?.executor?.dynamicSteps
|
|
|
+ dynamicSteps: participantInfo?.dynamicSteps
|
|
|
}
|
|
|
form.setFieldsValue(initalValues)
|
|
|
}, [])
|
|
@@ -40,6 +41,43 @@ const Auditor: React.FC<AuditorProps> = ({ nodeId, nodeData: { name, participant
|
|
|
.filter((item, idx) => item.data?.name && item.id !== nodeId && idx > currStepIdx)
|
|
|
.map(item => ({ label: item.data.name, value: item.id }))
|
|
|
|
|
|
+ const renderStepSettingExtraNode = () => {
|
|
|
+ if (participantInfo?.dynamicID) {
|
|
|
+ const step = elements.find(item => item.id === participantInfo.dynamicID)
|
|
|
+ return (
|
|
|
+ step && (
|
|
|
+ <div>
|
|
|
+ 当前执行者由
|
|
|
+ <Tag style={{ margin: '0 8px' }}>{step.data?.name}</Tag>
|
|
|
+ 配置
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const toggleMatter = (matterID: string, perms?: Record<string, string[]>) => {
|
|
|
+ if (stepMatters.find(item => item.matterID === matterID)) {
|
|
|
+ // perms存在说明是更新事项权限
|
|
|
+ if (perms) {
|
|
|
+ setStepMatters(
|
|
|
+ stepMatters.map(item => {
|
|
|
+ if (item.matterID === matterID) {
|
|
|
+ return { ...item, ...perms }
|
|
|
+ }
|
|
|
+ return item
|
|
|
+ })
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ setStepMatters(stepMatters.filter(item => item.matterID !== matterID))
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ setStepMatters([...stepMatters, { matterID, ...perms }])
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log(stepMatters)
|
|
|
+
|
|
|
const items = [
|
|
|
{
|
|
|
label: '步骤设置',
|
|
@@ -47,37 +85,76 @@ const Auditor: React.FC<AuditorProps> = ({ nodeId, nodeData: { name, participant
|
|
|
children: (
|
|
|
<StepSetting
|
|
|
executorOptions={executorList.map(item => ({ label: item.name, value: item.ID }))}
|
|
|
- disabled={participantInfo?.executor?.ID === '业务发起人'}
|
|
|
+ disabled={participantInfo?.dynamicID || participantInfo?.executor?.ID === '业务发起人'}
|
|
|
form={form}
|
|
|
+ extra={renderStepSettingExtraNode()}
|
|
|
stepOptions={stepOptions}
|
|
|
/>
|
|
|
)
|
|
|
},
|
|
|
- { label: '关联事项', key: 'relatedMatter', children: <RelatedMatter /> },
|
|
|
- { label: '事项权限', key: 'matterPermission', children: <MatterPermission /> }
|
|
|
+ {
|
|
|
+ label: '关联事项',
|
|
|
+ key: 'relatedMatter',
|
|
|
+ children: (
|
|
|
+ <RelatedMatter
|
|
|
+ defaultValue={stepMatters.map(item => item.matterID)}
|
|
|
+ dataID={dataID}
|
|
|
+ matterList={matterList}
|
|
|
+ toggleMatter={toggleMatter}
|
|
|
+ />
|
|
|
+ )
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '事项权限',
|
|
|
+ key: 'matterPermission',
|
|
|
+ children: (
|
|
|
+ <MatterPermission defaultValue={stepMatters} matterList={matterList} toggleMatter={toggleMatter} />
|
|
|
+ )
|
|
|
+ }
|
|
|
]
|
|
|
|
|
|
const onConfirm = () => {
|
|
|
form
|
|
|
.validateFields()
|
|
|
.then(values => {
|
|
|
- const needUpdatedNode = {
|
|
|
- id: nodeId,
|
|
|
- data: {
|
|
|
- name: values.name,
|
|
|
- participantInfo: {
|
|
|
- approvalWay: 'account',
|
|
|
- executor: {
|
|
|
- ID: values.executorID,
|
|
|
- configure: ['return']
|
|
|
- },
|
|
|
- dynamicSteps: values.dynamicSteps || []
|
|
|
+ const needUpdatedNodes = [
|
|
|
+ {
|
|
|
+ id: nodeId,
|
|
|
+ data: {
|
|
|
+ name: values.name,
|
|
|
+ participantInfo: {
|
|
|
+ approvalWay: 'account',
|
|
|
+ executor: {
|
|
|
+ ID: values.executorID,
|
|
|
+ configure: ['return']
|
|
|
+ },
|
|
|
+ dynamicSteps: values.dynamicSteps || [],
|
|
|
+ stepMatters
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ ]
|
|
|
+ values.dynamicSteps?.forEach((dynamicStep: { stepID: string; executorID: string }) => {
|
|
|
+ const node = findNodeById(process, dynamicStep.stepID)
|
|
|
+ node &&
|
|
|
+ needUpdatedNodes.push({
|
|
|
+ ...node,
|
|
|
+ data: {
|
|
|
+ ...node.data,
|
|
|
+ participantInfo: {
|
|
|
+ ...node.data?.participantInfo,
|
|
|
+ dynamicID: nodeId,
|
|
|
+ executor: { ...node.data?.participantInfo?.executor, ID: dynamicStep.executorID }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ console.log(needUpdatedNodes)
|
|
|
+
|
|
|
dispatch({
|
|
|
type: 'set_flow_process',
|
|
|
- payload: updateNodeData(process, needUpdatedNode)
|
|
|
+ payload: updateNodeData(process, needUpdatedNodes)
|
|
|
})
|
|
|
drawer.close()
|
|
|
})
|