config.data.ts
3.41 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import { ref } from 'vue';
import { BasicColumn, FormSchema } from '/@/components/Table';
import { screenLinkOrganizationGetApi } from '/@/api/ruleengine/ruleengineApi';
import { copyTransFun } from '/@/utils/fnUtils';
import { useComponentRegister } from '/@/components/Form';
import { OrgTreeSelect } from '/@/views/common/OrgTreeSelect';
useComponentRegister('OrgTreeSelect', OrgTreeSelect);
export type TOption = {
label: string;
value: string;
};
/**
* 所使用的枚举值
*/
export enum TriggerEnum {
IS_DEVICE_ACT = 'DEVICE_TRIGGER',
IS_TIME_ACT = 'SCHEDULE_TRIGGER',
IS_SCENE_ACT = 'SCENE_TRIGGER',
IS_HAND_ACT = 'HAND_ACT',
IS_MSG_NOTIFY = 'MSG_NOTIFY',
IS_DEVICE_STATUS = 'DEVICE_STATUS',
IS_TIME_ALL = 'SCHEDULE_TRIGGER',
}
export const isDevice = (type: string) => {
return type === TriggerEnum.IS_DEVICE_ACT;
};
export const isTime = (type: string) => {
return type === TriggerEnum.IS_TIME_ACT;
};
export const columns: BasicColumn[] = [
{
title: '场景联动名称',
dataIndex: 'name',
width: 200,
},
{
title: '触发方式',
dataIndex: 'triggerType',
format: (_: string, record: Recordable) => {
return record.triggers[0]?.triggerType == 'DEVICE_TRIGGER'
? '设备触发'
: record.triggers[0]?.triggerType == 'SCHEDULE_TRIGGER'
? '定时触发'
: record.triggers[0]?.triggerType == 'SCENE_TRIGGER'
? '场景触发'
: '手动触发';
},
width: 200,
},
{
title: '状态',
dataIndex: 'status',
width: 120,
slots: { customRender: 'status' },
},
{
title: '描述',
dataIndex: 'description',
width: 200,
},
{
title: '创建者',
dataIndex: 'creatorName',
width: 200,
},
{
title: '创建时间',
dataIndex: 'createTime',
width: 180,
},
];
export const organizationId = ref('');
export const formSchema: FormSchema[] = [
{
field: 'name',
label: '场景联动名称',
colProps: { span: 24 },
required: true,
component: 'Input',
componentProps: {
maxLength: 36,
placeholder: '请输入场景联动名称',
},
},
{
required: true,
field: 'organizationId',
label: '所属组织',
colProps: { span: 24 },
component: 'OrgTreeSelect',
componentProps: {
onChange(value) {
organizationId.value = value;
},
},
},
{
field: 'description',
label: '描述',
colProps: { span: 24 },
component: 'InputTextArea',
componentProps: {
maxLength: 255,
placeholder: '请输入描述',
},
},
];
export const searchFormSchema: FormSchema[] = [
{
field: 'organizationId',
label: '所属组织',
colProps: { span: 6 },
component: 'ApiTreeSelect',
componentProps: {
placeholder: '请选择组织',
api: async () => {
const data = await screenLinkOrganizationGetApi();
copyTransFun(data as any as any[]);
return data;
},
},
},
{
field: 'name',
label: '名称',
component: 'Input',
colProps: { span: 6 },
componentProps: {
maxLength: 36,
placeholder: '请输入场景联动名称',
},
},
{
field: 'status',
label: '状态',
component: 'Select',
componentProps: {
placeholder: '请选择状态',
options: [
{ label: '启用', value: '1' },
{ label: '禁用', value: '0' },
],
},
colProps: { span: 6 },
},
];