|
@@ -1,10 +1,24 @@
|
|
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, Radio, RadioChangeEvent, Select, TreeSelect } from 'antd';
|
|
|
|
|
|
+import {
|
|
|
|
+ Button,
|
|
|
|
+ Radio,
|
|
|
|
+ RadioChangeEvent,
|
|
|
|
+ Select,
|
|
|
|
+ TreeSelect,
|
|
|
|
+ InputNumber,
|
|
|
|
+} from 'antd';
|
|
|
|
|
|
const { Option } = Select;
|
|
const { Option } = Select;
|
|
|
|
|
|
@@ -36,15 +50,26 @@ export interface IConfig {
|
|
flow_node_id?: string;
|
|
flow_node_id?: string;
|
|
process_code?: string;
|
|
process_code?: string;
|
|
type: TYPE;
|
|
type: TYPE;
|
|
- initiator: { type: string; value: number; origin?: string | number; name?: string }[];
|
|
|
|
|
|
+ initiator: {
|
|
|
|
+ type: string;
|
|
|
|
+ value: number;
|
|
|
|
+ origin?: string | number;
|
|
|
|
+ name?: string;
|
|
|
|
+ }[];
|
|
//审批人目前只支持单选角色或者单选人
|
|
//审批人目前只支持单选角色或者单选人
|
|
- audits: { type: string; value: number; origin?: string | number; name?: string }[];
|
|
|
|
|
|
+ audits: {
|
|
|
|
+ type: string;
|
|
|
|
+ value: number;
|
|
|
|
+ origin?: string | number;
|
|
|
|
+ name?: string;
|
|
|
|
+ }[];
|
|
}
|
|
}
|
|
|
|
|
|
export const enum IDTYPE {
|
|
export const enum IDTYPE {
|
|
DEP = 'dep',
|
|
DEP = 'dep',
|
|
USER = 'user',
|
|
USER = 'user',
|
|
ROLE = 'role',
|
|
ROLE = 'role',
|
|
|
|
+ LEADER = 'leader',
|
|
}
|
|
}
|
|
|
|
|
|
const Component = (props: any) => {
|
|
const Component = (props: any) => {
|
|
@@ -82,16 +107,32 @@ const Component = (props: any) => {
|
|
};
|
|
};
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
- const bool = nodeConfig.audits?.some(item => item.type == IDTYPE.USER) ? 0 : 1;
|
|
|
|
|
|
+ let bool = 1;
|
|
|
|
+ if (nodeConfig.audits?.length > 0)
|
|
|
|
+ switch (nodeConfig.audits[0].type) {
|
|
|
|
+ case IDTYPE.USER:
|
|
|
|
+ bool = 0;
|
|
|
|
+ break;
|
|
|
|
+ case IDTYPE.ROLE:
|
|
|
|
+ bool = 1;
|
|
|
|
+ break;
|
|
|
|
+ case IDTYPE.LEADER:
|
|
|
|
+ bool = 2;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
console.log(bool);
|
|
console.log(bool);
|
|
setIsRole(bool);
|
|
setIsRole(bool);
|
|
}, []);
|
|
}, []);
|
|
console.log('===================', nodeConfig);
|
|
console.log('===================', nodeConfig);
|
|
|
|
|
|
const handleTreeChange = (values: (string | number)[]) => {
|
|
const handleTreeChange = (values: (string | number)[]) => {
|
|
- const newValues = values.map(cur => {
|
|
|
|
|
|
+ const newValues = values.map((cur) => {
|
|
if (typeof cur == 'string' && cur.includes('||')) {
|
|
if (typeof cur == 'string' && cur.includes('||')) {
|
|
- return { type: IDTYPE.USER, value: Number(cur.split('||')[0]), origin: cur };
|
|
|
|
|
|
+ return {
|
|
|
|
+ type: IDTYPE.USER,
|
|
|
|
+ value: Number(cur.split('||')[0]),
|
|
|
|
+ origin: cur,
|
|
|
|
+ };
|
|
} else {
|
|
} else {
|
|
return { type: IDTYPE.DEP, value: cur, origin: cur };
|
|
return { type: IDTYPE.DEP, value: cur, origin: cur };
|
|
}
|
|
}
|
|
@@ -99,9 +140,10 @@ const Component = (props: any) => {
|
|
onNodeConfigChange('initiator', newValues);
|
|
onNodeConfigChange('initiator', newValues);
|
|
};
|
|
};
|
|
|
|
|
|
- const onSave = () => {
|
|
|
|
- UnityAction.emit('NODE_SAVE', nodeConfig);
|
|
|
|
- };
|
|
|
|
|
|
+ // const onSave = () => {
|
|
|
|
+ // UnityAction.emit('NODE_SAVE', nodeConfig);
|
|
|
|
+ // };
|
|
|
|
+
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
setNodeConfig({
|
|
setNodeConfig({
|
|
...defaultConfig,
|
|
...defaultConfig,
|
|
@@ -109,6 +151,79 @@ const Component = (props: any) => {
|
|
});
|
|
});
|
|
}, [config]);
|
|
}, [config]);
|
|
|
|
|
|
|
|
+ const renderAuditSelect = (key: Number) => {
|
|
|
|
+ switch (key) {
|
|
|
|
+ case 0:
|
|
|
|
+ return (
|
|
|
|
+ <>
|
|
|
|
+ <label>审批人</label>
|
|
|
|
+ <Select
|
|
|
|
+ showSearch
|
|
|
|
+ style={{ width: '100%' }}
|
|
|
|
+ value={nodeConfig.audits?.map((item) => item.value)}
|
|
|
|
+ onChange={(value) => {
|
|
|
|
+ onNodeConfigChange('audits', [
|
|
|
|
+ { type: IDTYPE.USER, value: Number(value) },
|
|
|
|
+ ]);
|
|
|
|
+ }}
|
|
|
|
+ filterOption={(input, option) =>
|
|
|
|
+ option.props.children.indexOf(input) >= 0
|
|
|
|
+ }
|
|
|
|
+ >
|
|
|
|
+ {(userList || []).map((item) => (
|
|
|
|
+ <Option key={item.ID} value={item.ID}>
|
|
|
|
+ {item.CName}
|
|
|
|
+ </Option>
|
|
|
|
+ ))}
|
|
|
|
+ </Select>
|
|
|
|
+ </>
|
|
|
|
+ );
|
|
|
|
+ case 1:
|
|
|
|
+ return (
|
|
|
|
+ <>
|
|
|
|
+ <label>审批角色</label>
|
|
|
|
+ <Select
|
|
|
|
+ showSearch
|
|
|
|
+ style={{ width: '100%' }}
|
|
|
|
+ value={nodeConfig.audits?.map((item) => item.value)}
|
|
|
|
+ filterOption={(input, option) =>
|
|
|
|
+ option.props.children.indexOf(input) >= 0
|
|
|
|
+ }
|
|
|
|
+ onChange={(value) => {
|
|
|
|
+ onNodeConfigChange('audits', [
|
|
|
|
+ { type: IDTYPE.ROLE, value: Number(value) },
|
|
|
|
+ ]);
|
|
|
|
+ }}
|
|
|
|
+ >
|
|
|
|
+ {roleList &&
|
|
|
|
+ roleList.map((item) => (
|
|
|
|
+ <Option key={item.ID} value={item.ID}>
|
|
|
|
+ {item.Name}
|
|
|
|
+ </Option>
|
|
|
|
+ ))}
|
|
|
|
+ </Select>
|
|
|
|
+ </>
|
|
|
|
+ );
|
|
|
|
+ case 2:
|
|
|
|
+ return (
|
|
|
|
+ <>
|
|
|
|
+ <label>多级审批</label>
|
|
|
|
+ <InputNumber
|
|
|
|
+ style={{ width: '100%' }}
|
|
|
|
+ value={
|
|
|
|
+ nodeConfig.audits?.length > 0 ? nodeConfig.audits[0].value : 0
|
|
|
|
+ }
|
|
|
|
+ onChange={(value) => {
|
|
|
|
+ onNodeConfigChange('audits', [
|
|
|
|
+ { type: IDTYPE.LEADER, value: Number(value) },
|
|
|
|
+ ]);
|
|
|
|
+ }}
|
|
|
|
+ />
|
|
|
|
+ </>
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
return (
|
|
return (
|
|
<div className={`${PREFIX}-panel-body`}>
|
|
<div className={`${PREFIX}-panel-body`}>
|
|
<div className={`${PREFIX}-panel-group`}>
|
|
<div className={`${PREFIX}-panel-group`}>
|
|
@@ -116,14 +231,14 @@ const Component = (props: any) => {
|
|
<InputField
|
|
<InputField
|
|
label="标题"
|
|
label="标题"
|
|
value={nodeConfig.label}
|
|
value={nodeConfig.label}
|
|
- onChange={value => {
|
|
|
|
|
|
+ onChange={(value) => {
|
|
onNodeConfigChange('label', value);
|
|
onNodeConfigChange('label', value);
|
|
}}
|
|
}}
|
|
/>
|
|
/>
|
|
<SelectField
|
|
<SelectField
|
|
label="节点类型"
|
|
label="节点类型"
|
|
value={nodeConfig.type}
|
|
value={nodeConfig.type}
|
|
- onChange={value => {
|
|
|
|
|
|
+ onChange={(value) => {
|
|
onNodeConfigChange('type', value);
|
|
onNodeConfigChange('type', value);
|
|
}}
|
|
}}
|
|
options={typeOption}
|
|
options={typeOption}
|
|
@@ -162,7 +277,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);
|
|
}}
|
|
}}
|
|
/>
|
|
/>
|
|
@@ -171,7 +286,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);
|
|
}}
|
|
}}
|
|
/>
|
|
/>
|
|
@@ -184,16 +299,19 @@ const Component = (props: any) => {
|
|
</div>
|
|
</div>
|
|
{nodeConfig.type != TYPE.AUDIT && (
|
|
{nodeConfig.type != TYPE.AUDIT && (
|
|
<div className="group">
|
|
<div className="group">
|
|
- <label>{typeOption.find(item => item.value == nodeConfig.type)?.label || '-'}</label>
|
|
|
|
|
|
+ <label>
|
|
|
|
+ {typeOption.find((item) => item.value == nodeConfig.type)
|
|
|
|
+ ?.label || '-'}
|
|
|
|
+ </label>
|
|
<TreeSelect
|
|
<TreeSelect
|
|
showSearch
|
|
showSearch
|
|
multiple
|
|
multiple
|
|
allowClear
|
|
allowClear
|
|
- value={nodeConfig.initiator?.map(item => item.origin)}
|
|
|
|
|
|
+ value={nodeConfig.initiator?.map((item) => item.origin)}
|
|
style={{ width: '80%' }}
|
|
style={{ width: '80%' }}
|
|
placeholder="请选择"
|
|
placeholder="请选择"
|
|
treeData={depUserTree}
|
|
treeData={depUserTree}
|
|
- onChange={values => {
|
|
|
|
|
|
+ onChange={(values) => {
|
|
handleTreeChange(values);
|
|
handleTreeChange(values);
|
|
}}
|
|
}}
|
|
/>
|
|
/>
|
|
@@ -213,56 +331,16 @@ const Component = (props: any) => {
|
|
>
|
|
>
|
|
<Radio value={1}>发起人自选</Radio>
|
|
<Radio value={1}>发起人自选</Radio>
|
|
<Radio value={0}>指定人</Radio>
|
|
<Radio value={0}>指定人</Radio>
|
|
|
|
+ <Radio value={2}>部门主管</Radio>
|
|
</Radio.Group>
|
|
</Radio.Group>
|
|
- <div className="group">
|
|
|
|
- {isRole ? (
|
|
|
|
- <>
|
|
|
|
- <label>审批角色</label>
|
|
|
|
- <Select
|
|
|
|
- showSearch
|
|
|
|
- style={{ width: '100%' }}
|
|
|
|
- value={nodeConfig.audits?.map(item => item.value)}
|
|
|
|
- filterOption={(input, option) => option.props.children.indexOf(input) >= 0}
|
|
|
|
- onChange={value => {
|
|
|
|
- onNodeConfigChange('audits', [{ type: IDTYPE.ROLE, value: Number(value) }]);
|
|
|
|
- }}
|
|
|
|
- >
|
|
|
|
- {roleList &&
|
|
|
|
- roleList.map(item => (
|
|
|
|
- <Option key={item.ID} value={item.ID}>
|
|
|
|
- {item.Name}
|
|
|
|
- </Option>
|
|
|
|
- ))}
|
|
|
|
- </Select>
|
|
|
|
- </>
|
|
|
|
- ) : (
|
|
|
|
- <>
|
|
|
|
- <label>审批人</label>
|
|
|
|
- <Select
|
|
|
|
- showSearch
|
|
|
|
- style={{ width: '100%' }}
|
|
|
|
- value={nodeConfig.audits?.map(item => item.value)}
|
|
|
|
- onChange={value => {
|
|
|
|
- onNodeConfigChange('audits', [{ type: IDTYPE.USER, value: Number(value) }]);
|
|
|
|
- }}
|
|
|
|
- filterOption={(input, option) => option.props.children.indexOf(input) >= 0}
|
|
|
|
- >
|
|
|
|
- {(userList || []).map(item => (
|
|
|
|
- <Option key={item.ID} value={item.ID}>
|
|
|
|
- {item.CName}
|
|
|
|
- </Option>
|
|
|
|
- ))}
|
|
|
|
- </Select>
|
|
|
|
- </>
|
|
|
|
- )}
|
|
|
|
- </div>
|
|
|
|
|
|
+ <div className="group">{renderAuditSelect(isRole)}</div>
|
|
</div>
|
|
</div>
|
|
)}
|
|
)}
|
|
</div>
|
|
</div>
|
|
|
|
|
|
- <Button style={{ marginTop: 20 }} type="primary" onClick={onSave}>
|
|
|
|
|
|
+ {/* <Button style={{ marginTop: 20 }} type="primary" onClick={onSave}>
|
|
保存
|
|
保存
|
|
- </Button>
|
|
|
|
|
|
+ </Button> */}
|
|
</div>
|
|
</div>
|
|
);
|
|
);
|
|
};
|
|
};
|
|
@@ -270,7 +348,9 @@ 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>
|
|
);
|
|
);
|
|
}
|
|
}
|