|  | @@ -1,13 +1,21 @@
 | 
											
												
													
														|  |  import React, { useState, useEffect, useMemo } from 'react';
 |  |  import React, { useState, useEffect, useMemo } from 'react';
 | 
											
												
													
														|  |  import { FlowchartFormWrapper } from '@antv/xflow';
 |  |  import { FlowchartFormWrapper } from '@antv/xflow';
 | 
											
												
													
														|  | -import { Position, Size, ColorPicker, InputNumberField, InputField, SelectField } from '../fields';
 |  | 
 | 
											
												
													
														|  | 
 |  | +import {
 | 
											
												
													
														|  | 
 |  | +  Position,
 | 
											
												
													
														|  | 
 |  | +  Size,
 | 
											
												
													
														|  | 
 |  | +  ColorPicker,
 | 
											
												
													
														|  | 
 |  | +  InputNumberField,
 | 
											
												
													
														|  | 
 |  | +  InputField,
 | 
											
												
													
														|  | 
 |  | +  SelectField,
 | 
											
												
													
														|  | 
 |  | +} from '../fields';
 | 
											
												
													
														|  |  import { PREFIX } from '../constants';
 |  |  import { PREFIX } from '../constants';
 | 
											
												
													
														|  | -import { connect } from "umi";
 |  | 
 | 
											
												
													
														|  | 
 |  | +import { connect } from 'umi';
 | 
											
												
													
														|  |  import { UnityAction } from '@/utils/utils';
 |  |  import { UnityAction } from '@/utils/utils';
 | 
											
												
													
														|  | -import { Button } from 'antd';
 |  | 
 | 
											
												
													
														|  | 
 |  | +import { Button, Card } from 'antd';
 | 
											
												
													
														|  |  import AddCondition from '../../components/judgeModal';
 |  |  import AddCondition from '../../components/judgeModal';
 | 
											
												
													
														|  |  import RenderJudge, { JudgeType } from '../../components/judgeComponent';
 |  |  import RenderJudge, { JudgeType } from '../../components/judgeComponent';
 | 
											
												
													
														|  |  import { TYPE } from '../auditNode/mapServe';
 |  |  import { TYPE } from '../auditNode/mapServe';
 | 
											
												
													
														|  | 
 |  | +import { CloseOutlined, PlusOutlined } from '@ant-design/icons';
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  // export const enum TYPE {
 |  |  // export const enum TYPE {
 | 
											
												
													
														|  |  //   AUDIT,
 |  |  //   AUDIT,
 | 
											
										
											
												
													
														|  | @@ -39,7 +47,10 @@ export interface IConfig {
 | 
											
												
													
														|  |    flow_node_id?: string;
 |  |    flow_node_id?: string;
 | 
											
												
													
														|  |    process_code?: string;
 |  |    process_code?: string;
 | 
											
												
													
														|  |    type: TYPE;
 |  |    type: TYPE;
 | 
											
												
													
														|  | 
 |  | +  // 条件  【此字段存在是为了兼容旧格式】
 | 
											
												
													
														|  |    formItems: string;
 |  |    formItems: string;
 | 
											
												
													
														|  | 
 |  | +  // 条件组 【新版用此字段】 formItems和formItemsOr同时只能存在一个
 | 
											
												
													
														|  | 
 |  | +  formItemsOr: string[];
 | 
											
												
													
														|  |    priority?: number; //优先级
 |  |    priority?: number; //优先级
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -56,7 +67,7 @@ export interface FormItem {
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  const Component = (props: any) => {
 |  |  const Component = (props: any) => {
 | 
											
												
													
														|  | -  const { config, plugin = {}, formItems } = props;
 |  | 
 | 
											
												
													
														|  | 
 |  | +  const { config, plugin = {}, formData } = props;
 | 
											
												
													
														|  |    const { updateNode } = plugin;
 |  |    const { updateNode } = plugin;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |    // const formData: FormItem[] = [
 |  |    // const formData: FormItem[] = [
 | 
											
										
											
												
													
														|  | @@ -114,6 +125,8 @@ const Component = (props: any) => {
 | 
											
												
													
														|  |    const [nodeConfig, setNodeConfig] = useState<IConfig>({
 |  |    const [nodeConfig, setNodeConfig] = useState<IConfig>({
 | 
											
												
													
														|  |      ...config,
 |  |      ...config,
 | 
											
												
													
														|  |    });
 |  |    });
 | 
											
												
													
														|  | 
 |  | +  const formItemsGroup = nodeConfig.formItemsOr || [];
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |    const onNodeConfigChange = (key: string, value: number | string | object) => {
 |  |    const onNodeConfigChange = (key: string, value: number | string | object) => {
 | 
											
												
													
														|  |      if (key) {
 |  |      if (key) {
 | 
											
												
													
														|  |        setNodeConfig({
 |  |        setNodeConfig({
 | 
											
										
											
												
													
														|  | @@ -140,6 +153,72 @@ const Component = (props: any) => {
 | 
											
												
													
														|  |      UnityAction.emit('NODE_SAVE', nodeConfig);
 |  |      UnityAction.emit('NODE_SAVE', nodeConfig);
 | 
											
												
													
														|  |    };
 |  |    };
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +  const onAddConditionGroup = () => {
 | 
											
												
													
														|  | 
 |  | +    onNodeConfigChange('formItemsOr', [...formItemsGroup, '[]']);
 | 
											
												
													
														|  | 
 |  | +  };
 | 
											
												
													
														|  | 
 |  | +  const onRemoveConditionGroup = (index: number) => {
 | 
											
												
													
														|  | 
 |  | +    let tempGroup = [...formItemsGroup];
 | 
											
												
													
														|  | 
 |  | +    tempGroup.splice(index, 1);
 | 
											
												
													
														|  | 
 |  | +    onNodeConfigChange('formItemsOr', [...tempGroup]);
 | 
											
												
													
														|  | 
 |  | +  };
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +  const onAddCondition = (values: FormItem[], index: number) => {
 | 
											
												
													
														|  | 
 |  | +    const getFormItemsStr = (formItems: string) => {
 | 
											
												
													
														|  | 
 |  | +      let newFormItems: FormItem[] = [];
 | 
											
												
													
														|  | 
 |  | +      let oldFormItems = JSON.parse(formItems || '[]');
 | 
											
												
													
														|  | 
 |  | +      values.forEach((item) => {
 | 
											
												
													
														|  | 
 |  | +        let id = item.props.id;
 | 
											
												
													
														|  | 
 |  | +        // 判断是否含有旧的item
 | 
											
												
													
														|  | 
 |  | +        let oldItem = oldFormItems.find(
 | 
											
												
													
														|  | 
 |  | +          (formItem: FormItem) => formItem.props.id == id,
 | 
											
												
													
														|  | 
 |  | +        );
 | 
											
												
													
														|  | 
 |  | +        if (oldItem) {
 | 
											
												
													
														|  | 
 |  | +          newFormItems.push(oldItem);
 | 
											
												
													
														|  | 
 |  | +        } else {
 | 
											
												
													
														|  | 
 |  | +          newFormItems.push(item);
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +      });
 | 
											
												
													
														|  | 
 |  | +      return JSON.stringify(newFormItems);
 | 
											
												
													
														|  | 
 |  | +    };
 | 
											
												
													
														|  | 
 |  | +    let tempGroup = [...formItemsGroup];
 | 
											
												
													
														|  | 
 |  | +    // 更新条件组
 | 
											
												
													
														|  | 
 |  | +    tempGroup[index] = getFormItemsStr(tempGroup[index]);
 | 
											
												
													
														|  | 
 |  | +    onNodeConfigChange('formItemsOr', tempGroup);
 | 
											
												
													
														|  | 
 |  | +  };
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +  const renderCondition = () => {
 | 
											
												
													
														|  | 
 |  | +    let Cards: any = [];
 | 
											
												
													
														|  | 
 |  | +    formItemsGroup.forEach((formItems: string, index: number) => {
 | 
											
												
													
														|  | 
 |  | +      Cards.push(
 | 
											
												
													
														|  | 
 |  | +        <Card
 | 
											
												
													
														|  | 
 |  | +          key={index}
 | 
											
												
													
														|  | 
 |  | +          title={`条件组${index + 1}`}
 | 
											
												
													
														|  | 
 |  | +          extra={
 | 
											
												
													
														|  | 
 |  | +            <CloseOutlined onClick={() => onRemoveConditionGroup(index)} />
 | 
											
												
													
														|  | 
 |  | +          }
 | 
											
												
													
														|  | 
 |  | +        >
 | 
											
												
													
														|  | 
 |  | +          <AddCondition
 | 
											
												
													
														|  | 
 |  | +            items={formData}
 | 
											
												
													
														|  | 
 |  | +            formItems={formItems}
 | 
											
												
													
														|  | 
 |  | +            onOk={(values: FormItem[]) => onAddCondition(values, index)}
 | 
											
												
													
														|  | 
 |  | +          />
 | 
											
												
													
														|  | 
 |  | +          <RenderJudge
 | 
											
												
													
														|  | 
 |  | +            formItems={formItems}
 | 
											
												
													
														|  | 
 |  | +            onChange={(values: FormItem[]) => {
 | 
											
												
													
														|  | 
 |  | +              let tempGroup = [...formItemsGroup];
 | 
											
												
													
														|  | 
 |  | +              tempGroup[index] = JSON.stringify(values);
 | 
											
												
													
														|  | 
 |  | +              onNodeConfigChange('formItemsOr', tempGroup);
 | 
											
												
													
														|  | 
 |  | +            }}
 | 
											
												
													
														|  | 
 |  | +          />
 | 
											
												
													
														|  | 
 |  | +        </Card>,
 | 
											
												
													
														|  | 
 |  | +      );
 | 
											
												
													
														|  | 
 |  | +      if (index != formItemsGroup.length - 1) {
 | 
											
												
													
														|  | 
 |  | +        Cards.push(<div>或</div>);
 | 
											
												
													
														|  | 
 |  | +      }
 | 
											
												
													
														|  | 
 |  | +    });
 | 
											
												
													
														|  | 
 |  | +    return Cards;
 | 
											
												
													
														|  | 
 |  | +  };
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |    useEffect(() => {
 |  |    useEffect(() => {
 | 
											
												
													
														|  |      setNodeConfig({
 |  |      setNodeConfig({
 | 
											
												
													
														|  |        ...config,
 |  |        ...config,
 | 
											
										
											
												
													
														|  | @@ -153,7 +232,7 @@ const Component = (props: any) => {
 | 
											
												
													
														|  |          <InputField
 |  |          <InputField
 | 
											
												
													
														|  |            label="标题"
 |  |            label="标题"
 | 
											
												
													
														|  |            value={nodeConfig.label}
 |  |            value={nodeConfig.label}
 | 
											
												
													
														|  | -          onChange={value => {
 |  | 
 | 
											
												
													
														|  | 
 |  | +          onChange={(value) => {
 | 
											
												
													
														|  |              onNodeConfigChange('label', value);
 |  |              onNodeConfigChange('label', value);
 | 
											
												
													
														|  |            }}
 |  |            }}
 | 
											
												
													
														|  |          />
 |  |          />
 | 
											
										
											
												
													
														|  | @@ -191,7 +270,7 @@ const Component = (props: any) => {
 | 
											
												
													
														|  |          <InputNumberField
 |  |          <InputNumberField
 | 
											
												
													
														|  |            label="消息数量"
 |  |            label="消息数量"
 | 
											
												
													
														|  |            value={nodeConfig.count}
 |  |            value={nodeConfig.count}
 | 
											
												
													
														|  | -          onChange={value => {
 |  | 
 | 
											
												
													
														|  | 
 |  | +          onChange={(value) => {
 | 
											
												
													
														|  |              onNodeConfigChange('count', value);
 |  |              onNodeConfigChange('count', value);
 | 
											
												
													
														|  |            }}
 |  |            }}
 | 
											
												
													
														|  |          />
 |  |          />
 | 
											
										
											
												
													
														|  | @@ -200,7 +279,7 @@ const Component = (props: any) => {
 | 
											
												
													
														|  |              label="字号"
 |  |              label="字号"
 | 
											
												
													
														|  |              value={nodeConfig.fontSize}
 |  |              value={nodeConfig.fontSize}
 | 
											
												
													
														|  |              width={68}
 |  |              width={68}
 | 
											
												
													
														|  | -            onChange={value => {
 |  | 
 | 
											
												
													
														|  | 
 |  | +            onChange={(value) => {
 | 
											
												
													
														|  |                onNodeConfigChange('fontSize', value);
 |  |                onNodeConfigChange('fontSize', value);
 | 
											
												
													
														|  |              }}
 |  |              }}
 | 
											
												
													
														|  |            />
 |  |            />
 | 
											
										
											
												
													
														|  | @@ -215,37 +294,16 @@ const Component = (props: any) => {
 | 
											
												
													
														|  |            label="优先级"
 |  |            label="优先级"
 | 
											
												
													
														|  |            value={nodeConfig.priority}
 |  |            value={nodeConfig.priority}
 | 
											
												
													
														|  |            width={68}
 |  |            width={68}
 | 
											
												
													
														|  | -          onChange={value => {
 |  | 
 | 
											
												
													
														|  | 
 |  | +          onChange={(value) => {
 | 
											
												
													
														|  |              onNodeConfigChange('priority', value);
 |  |              onNodeConfigChange('priority', value);
 | 
											
												
													
														|  |            }}
 |  |            }}
 | 
											
												
													
														|  |          />
 |  |          />
 | 
											
												
													
														|  | -        <AddCondition
 |  | 
 | 
											
												
													
														|  | -          items={formItems}
 |  | 
 | 
											
												
													
														|  | -          formItems={nodeConfig.formItems}
 |  | 
 | 
											
												
													
														|  | -          onOk={(values: FormItem[]) => {
 |  | 
 | 
											
												
													
														|  | -            console.log('===formItems===', values);
 |  | 
 | 
											
												
													
														|  | -            let newFormItems = [];
 |  | 
 | 
											
												
													
														|  | -            let oldFormItems = JSON.parse(nodeConfig.formItems || '[]');
 |  | 
 | 
											
												
													
														|  | -            values.forEach(item => {
 |  | 
 | 
											
												
													
														|  | -              let id = item.props.id;
 |  | 
 | 
											
												
													
														|  | -              // 判断是否含有旧的item
 |  | 
 | 
											
												
													
														|  | -              let oldItem = oldFormItems.find(formItem => formItem.props.id == id);
 |  | 
 | 
											
												
													
														|  | -              if (oldItem) {
 |  | 
 | 
											
												
													
														|  | -                newFormItems.push(oldItem);
 |  | 
 | 
											
												
													
														|  | -              } else {
 |  | 
 | 
											
												
													
														|  | -                newFormItems.push(item);
 |  | 
 | 
											
												
													
														|  | -              }
 |  | 
 | 
											
												
													
														|  | -            });
 |  | 
 | 
											
												
													
														|  | -            onNodeConfigChange('formItems', JSON.stringify(newFormItems));
 |  | 
 | 
											
												
													
														|  | -          }}
 |  | 
 | 
											
												
													
														|  | -        />
 |  | 
 | 
											
												
													
														|  | -        <RenderJudge
 |  | 
 | 
											
												
													
														|  | -          formItems={nodeConfig.formItems}
 |  | 
 | 
											
												
													
														|  | -          onChange={(values: FormItem[]) => {
 |  | 
 | 
											
												
													
														|  | -            console.log('===formItems===', values);
 |  | 
 | 
											
												
													
														|  | -            onNodeConfigChange('formItems', JSON.stringify(values));
 |  | 
 | 
											
												
													
														|  | -          }}
 |  | 
 | 
											
												
													
														|  | -        />
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        <Button icon={<PlusOutlined />} onClick={() => onAddConditionGroup()}>
 | 
											
												
													
														|  | 
 |  | +          新增条件组
 | 
											
												
													
														|  | 
 |  | +        </Button>
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +        {renderCondition()}
 | 
											
												
													
														|  |        </div>
 |  |        </div>
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |        <Button style={{ marginTop: 20 }} type="primary" onClick={onSave}>
 |  |        <Button style={{ marginTop: 20 }} type="primary" onClick={onSave}>
 | 
											
										
											
												
													
														|  | @@ -258,11 +316,14 @@ const Component = (props: any) => {
 | 
											
												
													
														|  |  function RecthServe(props: any) {
 |  |  function RecthServe(props: any) {
 | 
											
												
													
														|  |    return (
 |  |    return (
 | 
											
												
													
														|  |      <FlowchartFormWrapper {...props}>
 |  |      <FlowchartFormWrapper {...props}>
 | 
											
												
													
														|  | -      {(config, plugin) => <Component {...props} plugin={plugin} config={config} />}
 |  | 
 | 
											
												
													
														|  | 
 |  | +      {(config, plugin) => (
 | 
											
												
													
														|  | 
 |  | +        <Component {...props} plugin={plugin} config={config} />
 | 
											
												
													
														|  | 
 |  | +      )}
 | 
											
												
													
														|  |      </FlowchartFormWrapper>
 |  |      </FlowchartFormWrapper>
 | 
											
												
													
														|  |    );
 |  |    );
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -export default connect(({ xflow }) => ({ auditList: xflow.auditList, formItems: xflow.formData }))(
 |  | 
 | 
											
												
													
														|  | -  RecthServe
 |  | 
 | 
											
												
													
														|  | -);
 |  | 
 | 
											
												
													
														|  | 
 |  | +export default connect(({ xflow }: any) => ({
 | 
											
												
													
														|  | 
 |  | +  auditList: xflow.auditList,
 | 
											
												
													
														|  | 
 |  | +  formData: xflow.formData,
 | 
											
												
													
														|  | 
 |  | +}))(RecthServe);
 |