create.config.ts
4.24 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import { h } from 'vue';
import {
DirectionEnum,
DirectionNameEnum,
EntityTypeEnum,
EntityTypeNameEnum,
} from '../../../enum/form';
import {
CreateRelationFieldsEnum,
CreateRelationFieldsNameEnum,
} from '../../../enum/formField/action';
import { FormSchema } from '/@/components/Form';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n();
export const formSchemas: FormSchema[] = [
{
field: CreateRelationFieldsEnum.DIRECTION,
component: 'Select',
label: h('span', t(CreateRelationFieldsNameEnum.DIRECTION)),
required: true,
componentProps: {
options: Object.keys(DirectionEnum).map((value) => ({
label: DirectionNameEnum[value],
value,
})),
getPopupContainer: () => document.body,
placeholder: `请选择${CreateRelationFieldsNameEnum.DIRECTION}`,
},
},
{
field: CreateRelationFieldsEnum.ENTITY_TYPE,
component: 'Select',
label: h('span', t(CreateRelationFieldsNameEnum.ENTITY_TYPE)),
colProps: { span: 8 },
required: true,
componentProps: {
options: Object.keys(EntityTypeEnum).map((value) => ({
label: EntityTypeNameEnum[value],
value,
})),
getPopupContainer: () => document.body,
placeholder: `请选择${CreateRelationFieldsNameEnum.ENTITY_TYPE}`,
},
},
{
field: CreateRelationFieldsEnum.ENTITY_NAME_PATTERN,
component: 'Input',
label: h('span', t(CreateRelationFieldsNameEnum.ENTITY_NAME_PATTERN)),
colProps: { span: 8 },
required: true,
helpMessage: [
'Hint: use ${metadataKey} for value from metadata, $[messageKey] for value from message body',
],
componentProps: {
placeholder: `请输入${CreateRelationFieldsNameEnum.ENTITY_NAME_PATTERN}`,
},
},
{
field: CreateRelationFieldsEnum.ENTITY_TYPE_PATTERN,
component: 'Input',
label: h('span', t(CreateRelationFieldsNameEnum.ENTITY_TYPE_PATTERN)),
colProps: { span: 8 },
required: true,
helpMessage: [
'Hint: use ${metadataKey} for value from metadata, $[messageKey] for value from message body',
],
show: ({ model }) => {
const type = model[CreateRelationFieldsEnum.ENTITY_TYPE];
return [EntityTypeEnum.ASSET, EntityTypeEnum.DEVICE].includes(type);
},
componentProps: {
placeholder: `请选择${CreateRelationFieldsNameEnum.ENTITY_TYPE_PATTERN}`,
},
},
{
field: CreateRelationFieldsEnum.RELATION_TYPE,
component: 'Input',
label: h('span', t(CreateRelationFieldsNameEnum.RELATION_TYPE)),
helpMessage: [
'Hint: use ${metadataKey} for value from metadata, $[messageKey] for value from message body',
],
componentProps: {
placeholder: `请输入${CreateRelationFieldsNameEnum.RELATION_TYPE}`,
},
},
{
field: CreateRelationFieldsEnum.CREATE_ENTITY_IF_NOT_EXISTS,
component: 'Checkbox',
label: h('span', t(CreateRelationFieldsNameEnum.CREATE_ENTITY_IF_NOT_EXISTS)),
helpMessage: '',
show: ({ model }) => {
const type = model[CreateRelationFieldsEnum.ENTITY_TYPE];
return [EntityTypeEnum.ASSET, EntityTypeEnum.DEVICE, EntityTypeEnum.CUSTOMER].includes(type);
},
renderComponentContent: () => ({
default: () => 'Create a new entity set above if it does not exist.',
}),
},
{
field: CreateRelationFieldsEnum.REMOVE_CURRENT_RELATIONS,
component: 'Checkbox',
label: h('span', t(CreateRelationFieldsNameEnum.REMOVE_CURRENT_RELATIONS)),
renderComponentContent: () => ({
default: () =>
'Removes current relations from the originator of the incoming message based on direction and type.',
}),
},
{
field: CreateRelationFieldsEnum.CHANGE_ORIGINATOR_TO_RELATED_ENTITY,
component: 'Checkbox',
label: h('span', t(CreateRelationFieldsNameEnum.CHANGE_ORIGINATOR_TO_RELATED_ENTITY)),
renderComponentContent: () => ({
default: () => 'Used to process submitted message as a message from another entity.',
}),
},
{
field: CreateRelationFieldsEnum.ENTITY_CACHE_EXPIRATION,
component: 'InputNumber',
label: h('span', t(CreateRelationFieldsNameEnum.ENTITY_CACHE_EXPIRATION)),
required: true,
componentProps: {
min: 0,
placeholder: `请输入${CreateRelationFieldsNameEnum.ENTITY_CACHE_EXPIRATION}`,
},
},
];