|  | @@ -2,8 +2,9 @@ import { buildUUID } from '@/utils/uuid'
 | 
												
													
														
															|  |  import { SolutionOutlined } from '@ant-design/icons'
 |  |  import { SolutionOutlined } from '@ant-design/icons'
 | 
												
													
														
															|  |  import { Button, Popover } from 'antd'
 |  |  import { Button, Popover } from 'antd'
 | 
												
													
														
															|  |  import React, { useMemo, useState, useContext } from 'react'
 |  |  import React, { useMemo, useState, useContext } from 'react'
 | 
												
													
														
															|  | 
 |  | +import type { EdgeProps } from 'react-flow-renderer'
 | 
												
													
														
															|  |  import { getBezierPath, getEdgeCenter, getMarkerEnd, useStoreState } from 'react-flow-renderer'
 |  |  import { getBezierPath, getEdgeCenter, getMarkerEnd, useStoreState } from 'react-flow-renderer'
 | 
												
													
														
															|  | -import { Actions, FlowContext } from '../../context'
 |  | 
 | 
												
													
														
															|  | 
 |  | +import { Actions, eId, FlowContext } from '../../context'
 | 
												
													
														
															|  |  import { generateElements, genreateElementEnum, getEdgeParams } from '../../utils'
 |  |  import { generateElements, genreateElementEnum, getEdgeParams } from '../../utils'
 | 
												
													
														
															|  |  import { addApprovalNode } from '@/services/api/project'
 |  |  import { addApprovalNode } from '@/services/api/project'
 | 
												
													
														
															|  |  import styles from './index.less'
 |  |  import styles from './index.less'
 | 
												
											
												
													
														
															|  | @@ -19,105 +20,7 @@ export enum SectorType {
 | 
												
													
														
															|  |    CONDITION = 'condition'
 |  |    CONDITION = 'condition'
 | 
												
													
														
															|  |  }
 |  |  }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | -const RenderMenu = ({ dataID, source, dispatch, elements, togglePopver, id, flowInstance }) => {
 |  | 
 | 
												
													
														
															|  | -  const { run: showLoading } = useLoading()
 |  | 
 | 
												
													
														
															|  | -  const setElements = els => {
 |  | 
 | 
												
													
														
															|  | -    dispatch({
 |  | 
 | 
												
													
														
															|  | -      type: Actions.SET_ELEMENTS,
 |  | 
 | 
												
													
														
															|  | -      payload: els
 |  | 
 | 
												
													
														
															|  | -    })
 |  | 
 | 
												
													
														
															|  | -  }
 |  | 
 | 
												
													
														
															|  | -  // const edit = () => {
 |  | 
 | 
												
													
														
															|  | -  // togglePopver(false)
 |  | 
 | 
												
													
														
															|  | -  // dispatch({
 |  | 
 | 
												
													
														
															|  | -  //   type: Actions.OPEN_MODAL,
 |  | 
 | 
												
													
														
															|  | -  //   payload: {
 |  | 
 | 
												
													
														
															|  | -  //     id: node.id,
 |  | 
 | 
												
													
														
															|  | -  //     type: 'relation'
 |  | 
 | 
												
													
														
															|  | -  //   }
 |  | 
 | 
												
													
														
															|  | -  // })
 |  | 
 | 
												
													
														
															|  | -  // }
 |  | 
 | 
												
													
														
															|  | -  // const remove = () => {
 |  | 
 | 
												
													
														
															|  | -  //   dispatch({
 |  | 
 | 
												
													
														
															|  | -  //     type: Actions.REMOVE_FLOW_NODE,
 |  | 
 | 
												
													
														
															|  | -  //     payload: node
 |  | 
 | 
												
													
														
															|  | -  //   })
 |  | 
 | 
												
													
														
															|  | -  // }
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -  const addAuditor = async () => {
 |  | 
 | 
												
													
														
															|  | -    const uid = buildUUID()
 |  | 
 | 
												
													
														
															|  | -    const newNode = {
 |  | 
 | 
												
													
														
															|  | -      id: uid,
 |  | 
 | 
												
													
														
															|  | -      type: 'input',
 |  | 
 | 
												
													
														
															|  | -      data: {}
 |  | 
 | 
												
													
														
															|  | -    }
 |  | 
 | 
												
													
														
															|  | -    const currentEdge = elements.find(item => item.id === id)
 |  | 
 | 
												
													
														
															|  | -    const newElements = generateElements(genreateElementEnum.ADD, elements)(newNode, currentEdge)
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -    const { code = -1 } = await addApprovalNode({
 |  | 
 | 
												
													
														
															|  | -      ID: dataID,
 |  | 
 | 
												
													
														
															|  | -      segmentBrotherID: source,
 |  | 
 | 
												
													
														
															|  | -      flowProcess: newElements,
 |  | 
 | 
												
													
														
															|  | -      segment: {
 |  | 
 | 
												
													
														
															|  | -        ID: uid,
 |  | 
 | 
												
													
														
															|  | -        name: '审批人',
 |  | 
 | 
												
													
														
															|  | -        sectorType: SectorType.APPROVAL
 |  | 
 | 
												
													
														
															|  | -      }
 |  | 
 | 
												
													
														
															|  | -    })
 |  | 
 | 
												
													
														
															|  | -    if (code === consts.RET_CODE.SUCCESS) {
 |  | 
 | 
												
													
														
															|  | -      setElements(newElements)
 |  | 
 | 
												
													
														
															|  | -      dispatch({
 |  | 
 | 
												
													
														
															|  | -        type: Actions.SET_FLOW_NODE,
 |  | 
 | 
												
													
														
															|  | -        payload: {
 |  | 
 | 
												
													
														
															|  | -          id: uid,
 |  | 
 | 
												
													
														
															|  | -          node: null
 |  | 
 | 
												
													
														
															|  | -        }
 |  | 
 | 
												
													
														
															|  | -      })
 |  | 
 | 
												
													
														
															|  | -      togglePopver(false)
 |  | 
 | 
												
													
														
															|  | -      setTimeout(() => {
 |  | 
 | 
												
													
														
															|  | -        showLoading()
 |  | 
 | 
												
													
														
															|  | -        flowInstance?.fitView()
 |  | 
 | 
												
													
														
															|  | -      }, 80)
 |  | 
 | 
												
													
														
															|  | -    }
 |  | 
 | 
												
													
														
															|  | -  }
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -  return (
 |  | 
 | 
												
													
														
															|  | -    // <Menu>
 |  | 
 | 
												
													
														
															|  | -    //   <Menu.Item key="1" onClick={addAuditor}>
 |  | 
 | 
												
													
														
															|  | -    //     <ClusterOutlined />
 |  | 
 | 
												
													
														
															|  | -    //     <span className="ml-1">审批人</span>
 |  | 
 | 
												
													
														
															|  | -    //   </Menu.Item>
 |  | 
 | 
												
													
														
															|  | -    //   {/* <Menu.Item key="2" onClick={remove}>
 |  | 
 | 
												
													
														
															|  | -    //     <ApartmentOutlined />
 |  | 
 | 
												
													
														
															|  | -    //     <span className="ml-1">条件分支</span>
 |  | 
 | 
												
													
														
															|  | -    //   </Menu.Item> */}
 |  | 
 | 
												
													
														
															|  | -    // </Menu>
 |  | 
 | 
												
													
														
															|  | -    <ul className="m-0 p-0 ">
 |  | 
 | 
												
													
														
															|  | -      <li>
 |  | 
 | 
												
													
														
															|  | -        <Button type="dashed" onClick={addAuditor} icon={<SolutionOutlined />}>
 |  | 
 | 
												
													
														
															|  | -          审批人
 |  | 
 | 
												
													
														
															|  | -        </Button>
 |  | 
 | 
												
													
														
															|  | -      </li>
 |  | 
 | 
												
													
														
															|  | -      {/* <li className="mt-2 condition">
 |  | 
 | 
												
													
														
															|  | -        <Button type="dashed" onClick={addAuditor} icon={<BranchesOutlined />}>
 |  | 
 | 
												
													
														
															|  | -          条件分支
 |  | 
 | 
												
													
														
															|  | -        </Button>
 |  | 
 | 
												
													
														
															|  | -      </li> */}
 |  | 
 | 
												
													
														
															|  | -    </ul>
 |  | 
 | 
												
													
														
															|  | -    //   <ul className="m-0 p-0">
 |  | 
 | 
												
													
														
															|  | -    //   <li className="rounded-2px border border-hex-d9d9d9 border-dashed text-hex-1890ff px-17px py-9px cursor-pointer">
 |  | 
 | 
												
													
														
															|  | -    //     <SolutionOutlined />
 |  | 
 | 
												
													
														
															|  | -    //     <span className="ml-9px">审批人</span>
 |  | 
 | 
												
													
														
															|  | -    //   </li>
 |  | 
 | 
												
													
														
															|  | -    //   <li className="mt-2 rounded-2px border border-hex-d9d9d9 border-dashed text-hex-52c41a px-17px py-9px cursor-pointer">
 |  | 
 | 
												
													
														
															|  | -    //     <BranchesOutlined />
 |  | 
 | 
												
													
														
															|  | -    //     <span className="ml-9px">条件分支</span>
 |  | 
 | 
												
													
														
															|  | -    //   </li>
 |  | 
 | 
												
													
														
															|  | -    // </ul>
 |  | 
 | 
												
													
														
															|  | -  )
 |  | 
 | 
												
													
														
															|  | -}
 |  | 
 | 
												
													
														
															|  | -
 |  | 
 | 
												
													
														
															|  | -export function CommonEdge(props) {
 |  | 
 | 
												
													
														
															|  | 
 |  | +export function CommonEdge(props: EdgeProps) {
 | 
												
													
														
															|  |    const {
 |  |    const {
 | 
												
													
														
															|  |      id,
 |  |      id,
 | 
												
													
														
															|  |      sourceX,
 |  |      sourceX,
 | 
												
											
												
													
														
															|  | @@ -133,8 +36,21 @@ export function CommonEdge(props) {
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  |    const [visible, setVisible] = useState(false)
 |  |    const [visible, setVisible] = useState(false)
 | 
												
													
														
															|  |    const { flowState, dispatch } = useContext(FlowContext)
 |  |    const { flowState, dispatch } = useContext(FlowContext)
 | 
												
													
														
															|  | -  const { elements, flowInstance, dataID, readPretty } = flowState
 |  | 
 | 
												
													
														
															|  | -  // source连接的node节点
 |  | 
 | 
												
													
														
															|  | 
 |  | +  const { elements, flowInstance, flowData, dataID, readPretty } = flowState
 | 
												
													
														
															|  | 
 |  | +  const { run: showLoading } = useLoading()
 | 
												
													
														
															|  | 
 |  | +  const setElements = els => {
 | 
												
													
														
															|  | 
 |  | +    dispatch({
 | 
												
													
														
															|  | 
 |  | +      type: Actions.SET_ELEMENTS,
 | 
												
													
														
															|  | 
 |  | +      payload: els
 | 
												
													
														
															|  | 
 |  | +    })
 | 
												
													
														
															|  | 
 |  | +  }
 | 
												
													
														
															|  | 
 |  | +  const showBtn =
 | 
												
													
														
															|  | 
 |  | +    target === eId
 | 
												
													
														
															|  | 
 |  | +      ? flowData
 | 
												
													
														
															|  | 
 |  | +          .get(source)
 | 
												
													
														
															|  | 
 |  | +          ?.accounts.every(item => !item.configure.includes(ConfigureType.NEXTSECTOR))
 | 
												
													
														
															|  | 
 |  | +      : true
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  |    const nodes = useStoreState(store => store.nodes)
 |  |    const nodes = useStoreState(store => store.nodes)
 | 
												
													
														
															|  |    const markerEnd = getMarkerEnd(arrowHeadType, markerEndId)
 |  |    const markerEnd = getMarkerEnd(arrowHeadType, markerEndId)
 | 
												
													
														
															|  |  
 |  |  
 | 
												
											
												
													
														
															|  | @@ -172,10 +88,47 @@ export function CommonEdge(props) {
 | 
												
													
														
															|  |      // alert(`remove ${id}`)
 |  |      // alert(`remove ${id}`)
 | 
												
													
														
															|  |    }
 |  |    }
 | 
												
													
														
															|  |  
 |  |  
 | 
												
													
														
															|  | 
 |  | +  const addAuditor = async () => {
 | 
												
													
														
															|  | 
 |  | +    const uid = buildUUID()
 | 
												
													
														
															|  | 
 |  | +    const newNode = {
 | 
												
													
														
															|  | 
 |  | +      id: uid,
 | 
												
													
														
															|  | 
 |  | +      type: 'input',
 | 
												
													
														
															|  | 
 |  | +      data: {}
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +    const currentEdge = elements.find(item => item.id === id)
 | 
												
													
														
															|  | 
 |  | +    const newElements = generateElements(genreateElementEnum.ADD, elements)(newNode, currentEdge)
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  | 
 |  | +    const { code = -1 } = await addApprovalNode({
 | 
												
													
														
															|  | 
 |  | +      ID: dataID,
 | 
												
													
														
															|  | 
 |  | +      segmentBrotherID: source,
 | 
												
													
														
															|  | 
 |  | +      flowProcess: newElements,
 | 
												
													
														
															|  | 
 |  | +      segment: {
 | 
												
													
														
															|  | 
 |  | +        ID: uid,
 | 
												
													
														
															|  | 
 |  | +        name: '审批人',
 | 
												
													
														
															|  | 
 |  | +        sectorType: SectorType.APPROVAL
 | 
												
													
														
															|  | 
 |  | +      }
 | 
												
													
														
															|  | 
 |  | +    })
 | 
												
													
														
															|  | 
 |  | +    if (code === consts.RET_CODE.SUCCESS) {
 | 
												
													
														
															|  | 
 |  | +      setElements(newElements)
 | 
												
													
														
															|  | 
 |  | +      dispatch({
 | 
												
													
														
															|  | 
 |  | +        type: Actions.SET_FLOW_NODE,
 | 
												
													
														
															|  | 
 |  | +        payload: {
 | 
												
													
														
															|  | 
 |  | +          id: uid,
 | 
												
													
														
															|  | 
 |  | +          node: null
 | 
												
													
														
															|  | 
 |  | +        }
 | 
												
													
														
															|  | 
 |  | +      })
 | 
												
													
														
															|  | 
 |  | +      togglePopver(false)
 | 
												
													
														
															|  | 
 |  | +      setTimeout(() => {
 | 
												
													
														
															|  | 
 |  | +        showLoading()
 | 
												
													
														
															|  | 
 |  | +        flowInstance?.fitView()
 | 
												
													
														
															|  | 
 |  | +      }, 80)
 | 
												
													
														
															|  | 
 |  | +    }
 | 
												
													
														
															|  | 
 |  | +  }
 | 
												
													
														
															|  | 
 |  | +
 | 
												
													
														
															|  |    return (
 |  |    return (
 | 
												
													
														
															|  |      <>
 |  |      <>
 | 
												
													
														
															|  |        <path id={id} style={style} className={styles.flowPath} d={d} markerEnd={markerEnd} />
 |  |        <path id={id} style={style} className={styles.flowPath} d={d} markerEnd={markerEnd} />
 | 
												
													
														
															|  | -      {!readPretty && (
 |  | 
 | 
												
													
														
															|  | 
 |  | +      {showBtn && !readPretty && (
 | 
												
													
														
															|  |          <foreignObject
 |  |          <foreignObject
 | 
												
													
														
															|  |            width={foreignObjectSize}
 |  |            width={foreignObjectSize}
 | 
												
													
														
															|  |            height={foreignObjectSize}
 |  |            height={foreignObjectSize}
 | 
												
											
												
													
														
															|  | @@ -183,15 +136,20 @@ export function CommonEdge(props) {
 | 
												
													
														
															|  |            y={edgeCenterY - foreignObjectSize / 2}>
 |  |            y={edgeCenterY - foreignObjectSize / 2}>
 | 
												
													
														
															|  |            <div className={styles.addIcon}>
 |  |            <div className={styles.addIcon}>
 | 
												
													
														
															|  |              <Popover
 |  |              <Popover
 | 
												
													
														
															|  | -              content={RenderMenu({
 |  | 
 | 
												
													
														
															|  | -                elements,
 |  | 
 | 
												
													
														
															|  | -                dispatch,
 |  | 
 | 
												
													
														
															|  | -                source,
 |  | 
 | 
												
													
														
															|  | -                togglePopver,
 |  | 
 | 
												
													
														
															|  | -                id,
 |  | 
 | 
												
													
														
															|  | -                flowInstance,
 |  | 
 | 
												
													
														
															|  | -                dataID
 |  | 
 | 
												
													
														
															|  | -              })}
 |  | 
 | 
												
													
														
															|  | 
 |  | +              content={
 | 
												
													
														
															|  | 
 |  | +                <ul className="m-0 p-0 ">
 | 
												
													
														
															|  | 
 |  | +                  <li>
 | 
												
													
														
															|  | 
 |  | +                    <Button type="dashed" onClick={addAuditor} icon={<SolutionOutlined />}>
 | 
												
													
														
															|  | 
 |  | +                      审批人
 | 
												
													
														
															|  | 
 |  | +                    </Button>
 | 
												
													
														
															|  | 
 |  | +                  </li>
 | 
												
													
														
															|  | 
 |  | +                  {/* <li className="mt-2 condition">
 | 
												
													
														
															|  | 
 |  | +        <Button type="dashed" onClick={addAuditor} icon={<BranchesOutlined />}>
 | 
												
													
														
															|  | 
 |  | +          条件分支
 | 
												
													
														
															|  | 
 |  | +        </Button>
 | 
												
													
														
															|  | 
 |  | +      </li> */}
 | 
												
													
														
															|  | 
 |  | +                </ul>
 | 
												
													
														
															|  | 
 |  | +              }
 | 
												
													
														
															|  |                trigger="click"
 |  |                trigger="click"
 | 
												
													
														
															|  |                placement="right"
 |  |                placement="right"
 | 
												
													
														
															|  |                visible={visible}
 |  |                visible={visible}
 |