displayComponent.tsx
2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import React, { memo } from 'react';
import { Button, Typography } from 'antd';
import { useAction } from '@qx/flow';
const { Text } = Typography;
import type { IDisplayComponent, INode } from '@qx/flow';
const paramsEnums: Record<string, string> = {
STRING: '文本',
NUMBER: '数字',
TIME: '日期',
BOOL: '布尔',
OBJECT: '对象',
ARRAY: '数组',
ANNEX: '附件',
PIC: '图片',
FORM: '表单',
USER: '人员',
ORG: '部门',
};
const DisplayComponent: React.FC<DisplayComponentProps> = (props) => {
const { node, nodes } = props;
const handleChangeName = (newValue: string) => {
node.name = newValue;
props.onChange?.([...nodes]);
};
const { clickNode } = useAction();
return (
<div className="qx-flow-default-node">
<div className="qx-flow-default-node__header">
<span className="qx-flow-default-node__title">
<span className="qx-flow-default-node__title--icon">
{/* <Icon /> */}
</span>
<span className="qx-flow-default-node__title--name">{node.name}</span>
</span>
</div>
{!!node?.data?.params?.length ? (
<>
<div className="qx-flow-default-node__content">
{props?.node?.data?.params.map((_v: any) => {
return (
<Text
style={{
width: '100%',
lineHeight: '22px',
}}
ellipsis={{
tooltip: `${paramsEnums?.[_v.type || '']} ${
_v.title || '未命名'
}`,
}}
>
{paramsEnums?.[_v.type || '']} {_v.title || '未命名'}
</Text>
);
})}
</div>
</>
) : (
<Button
style={{ marginTop: 8 }}
type="link"
size="small"
// onClick={() => clickNode()}
>
设置入参
</Button>
)}
</div>
);
};
interface DisplayComponentProps extends IDisplayComponent {
onChange?: (nodes: INode[]) => void;
}
export default memo(DisplayComponent);