import React, { useState, useEffect } from 'react'; import { FlowchartFormWrapper } from '@antv/xflow'; import { Position, Size, ColorPicker, InputNumberFiled, InputFiled, SelectField } from '../fields'; import { PREFIX } from '../constants'; import { connect } from 'dva'; import { UnityAction } from '@/utils/utils'; import { Button, Select, TreeSelect } from 'antd'; const { Option } = Select; export const enum TYPE { AUDIT = 1, INITIATOR, COPYMAN, } export const typeOption = [ { label: '审批人', value: TYPE.AUDIT }, { label: '发起人', value: TYPE.INITIATOR }, { label: '抄送人', value: TYPE.COPYMAN }, ]; export interface IConfig { label?: string; x?: number; y?: number; width?: number; height?: number; count?: number; fontSize?: number; fontFill?: string; fill?: string; stroke?: string; flow_id?: string; flow_node_id?: string; process_code?: string; type: TYPE; roleID: number; audits: { type: string; value: number; origin?: string | number; name?: string }[]; } const Component = (props: any) => { const defaultConfig = { type: TYPE.AUDIT, }; const { config, plugin = {}, depUserTree, roleList } = props; const { updateNode } = plugin; const [nodeConfig, setNodeConfig] = useState({ ...defaultConfig, ...config, }); const onNodeConfigChange = (key: string, value: number | string | object) => { if (key) { setNodeConfig({ ...nodeConfig, [key]: value, }); updateNode({ [key]: value, }); } else if (value instanceof Object) { setNodeConfig({ ...nodeConfig, ...value, }); updateNode({ ...value, }); } }; const handleTreeChange = (values: (string | number)[]) => { const newValues = values.map(cur => { if (typeof cur == 'string' && cur.includes('||')) { return { type: 'user', value: Number(cur.split('||')[0]), origin: cur }; } else { return { type: 'dep', value: cur, origin: cur }; } }); onNodeConfigChange('audits', newValues); }; const onSave = () => { UnityAction.emit('NODE_SAVE', nodeConfig); }; useEffect(() => { setNodeConfig({ ...defaultConfig, ...config, }); }, [config]); return (
内容
{ onNodeConfigChange('label', value); }} /> { onNodeConfigChange('type', value); }} options={typeOption} />
样式
{ onNodeConfigChange(key, value); }} /> { onNodeConfigChange(key, value); }} /> { onNodeConfigChange('fill', value); }} /> { onNodeConfigChange('stroke', value); }} /> { onNodeConfigChange('count', value); }} />
{ onNodeConfigChange('fontSize', value); }} /> { onNodeConfigChange('fontFill', value); }} />
{nodeConfig.type != TYPE.AUDIT ? ( item.origin)} style={{ width: '80%' }} placeholder="请选择" treeData={depUserTree} onChange={values => { handleTreeChange(values); }} /> ) : ( )}
); }; function RecthServe(props: any) { return ( {(config, plugin) => } ); } export default connect(({ xflow, flow }) => ({ auditList: xflow.auditList, depUserTree: flow.depUserTree, roleList: flow.roleList, }))(RecthServe);