config.ts
2.8 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
import { doQueryRuleChainList } from '/@/api/device/deviceConfigApi';
import { FormSchema, useComponentRegister } from '/@/components/Form';
import { OrgTreeSelect } from '/@/views/common/OrgTreeSelect';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n(); // 加载国际化
useComponentRegister('OrgTreeSelect', OrgTreeSelect);
export enum FormFieldsEnum {
NAME = 'name',
ORGANIZATION_ID = 'organizationId',
DESCRIPTION = 'description',
RULE_CHAIN_ID = 'ruleChainId',
}
type GetFormSchemasParams = {
handleOnOrganizationChange: Fn;
handleOnOrganizationOptionsChange: Fn;
handleOnRuleChainChange: Fn;
handleOnRuleChainOptionsChange: Fn;
};
export const getFormSchemas = ({
handleOnOrganizationChange,
handleOnOrganizationOptionsChange,
handleOnRuleChainChange,
handleOnRuleChainOptionsChange,
}: GetFormSchemasParams): FormSchema[] => {
return [
{
field: FormFieldsEnum.NAME,
component: 'Input',
label: t('rule.linkedge.index.name'),
required: true,
componentProps: {
placeholder: `${t('rule.linkedge.index.pleaseEnter')}${t('rule.linkedge.index.name')}`,
maxLength: 36,
},
},
{
field: FormFieldsEnum.ORGANIZATION_ID,
component: 'OrgTreeSelect',
label: t('rule.linkedge.index.affiliatedOrganization'),
required: true,
componentProps: {
placeholder: `${t('rule.linkedge.index.pleaseEnter')}${t(
'rule.linkedge.index.affiliatedOrganization'
)}`,
onChange: handleOnOrganizationChange,
onOptionsChange: handleOnOrganizationOptionsChange,
},
},
{
field: FormFieldsEnum.RULE_CHAIN_ID,
label: t('deviceManagement.product.ruleChainText'),
component: 'ApiSelect',
required: true,
componentProps: {
api: async () => {
const result = await doQueryRuleChainList();
return result.map((item) => ({ ...item, label: item.name, value: item.id.id }));
},
placeholder: `${t('common.chooseText')}${t('deviceManagement.product.ruleChainText')}`,
onChange: handleOnRuleChainChange,
onOptionsChange: handleOnRuleChainOptionsChange,
},
},
{
field: FormFieldsEnum.DESCRIPTION,
component: 'InputTextArea',
label: t('rule.linkedge.index.description'),
componentProps: {
placeholder: `${t('rule.linkedge.index.pleaseEnter')}${t(
'rule.linkedge.index.description'
)}`,
},
},
{
field: 'flipFlop',
component: 'Input',
label: '',
slot: 'flipFlop',
},
{
field: 'executionCondition',
component: 'Input',
label: '',
slot: 'executionCondition',
},
{
field: 'executionAction',
component: 'Input',
label: '',
slot: 'executionAction',
},
];
};