config.data.ts
5.81 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
import { BasicColumn, FormSchema } from '/@/components/Table';
import { getOrganizationList } from '/@/api/system/system';
import { copyTransFun } from '/@/utils/fnUtils';
import type { FormSchema as QFormSchema } from '/@/components/Form/index';
import { CameraVideoUrl, CameraMaxLength } from '/@/utils/rules';
import { getStreamingMediaList } from '/@/api/camera/cameraManager';
import { h } from 'vue';
import SnHelpMessage from './SnHelpMessage.vue';
export enum AccessMode {
ManuallyEnter = 0,
Streaming = 1,
}
export enum PlayProtocol {
HTTP = 0,
HTTPS = 1,
}
export enum StreamType {
MASTER = 0,
CHILD = 1,
THIRD = 2,
}
// 表格列数据
export const columns: BasicColumn[] = [
{
title: '封面',
dataIndex: 'avatar',
width: 80,
slots: { customRender: 'img' },
},
{
title: '名字',
dataIndex: 'name',
width: 120,
},
{
title: '摄像头编号',
dataIndex: 'sn',
width: 120,
},
{
title: '视频流',
dataIndex: 'videoUrl',
width: 120,
},
{
title: '所属组织',
dataIndex: 'organizationName',
width: 160,
},
{
title: '添加时间',
dataIndex: 'createTime',
width: 180,
},
{
title: '更新时间',
dataIndex: 'updateTime',
width: 180,
},
];
// 查询字段
export const searchFormSchema: FormSchema[] = [
{
field: 'name',
label: '摄像头名字',
component: 'Input',
colProps: { span: 8 },
componentProps: {
maxLength: 36,
placeholder: '请输入摄像头名字',
},
},
];
/**
* @description 手动输入
*/
export const manuallyEnter: FormSchema[] = [
{
field: 'brand',
label: '视频厂家',
component: 'Input',
componentProps: {
placeholder: '请输入视频厂家',
},
},
{
field: 'sn',
label: '摄像头编号',
required: true,
component: 'Input',
rules: [...CameraVideoUrl, { required: true, message: '摄像头编号是必填项' }],
componentProps: {
placeholder: '请输入摄像头编号',
},
},
{
field: 'videoUrl',
label: '视频流',
required: true,
component: 'Input',
componentProps: {
placeholder: '请输入视频流',
maxLength: 255,
},
rules: [...CameraVideoUrl, { required: true, message: '视频流是必填项' }],
},
];
/**
* @description 流媒体获取
*/
export const streamingMediaAcquire: FormSchema[] = [
{
field: 'videoPlatformId',
label: '流媒体配置',
component: 'ApiSelect',
componentProps: {
placeholder: '请选择流媒体配置',
api: getStreamingMediaList,
labelField: 'host',
valueField: 'id',
},
},
{
field: 'streamType',
label: '码流',
component: 'RadioGroup',
defaultValue: StreamType.MASTER,
componentProps: {
placeholder: '请选择码流',
defaultValue: StreamType.MASTER,
options: [
{ label: '主码流', value: StreamType.MASTER },
{ label: '子码流', value: StreamType.CHILD },
{ label: '第三码流', value: StreamType.THIRD },
],
},
},
{
field: 'playProtocol',
label: '播放协议',
component: 'RadioGroup',
defaultValue: PlayProtocol.HTTP,
componentProps: {
placeholder: '请选择播放协议',
defaultValue: PlayProtocol.HTTP,
options: [
{ label: 'http', value: PlayProtocol.HTTP },
{ label: 'https', value: PlayProtocol.HTTPS },
],
},
},
{
field: 'sn',
label: h(SnHelpMessage) as any,
component: 'Input',
rules: [...CameraVideoUrl, { required: true, message: '摄像头编号是必填项' }],
componentProps: {
placeholder: '请输入监控点编号',
},
},
];
// 弹框配置项
export const formSchema: QFormSchema[] = [
{
field: 'avatar',
label: '视频封面',
slot: 'iconSelect',
component: 'Input',
},
{
field: 'name',
label: '视频名字',
required: true,
component: 'Input',
componentProps: {
placeholder: '请输入视频名字',
maxLength: 30,
},
rules: [...CameraMaxLength, { required: true, message: '视频名是必填项' }],
},
{
field: 'organizationId',
label: '所属组织',
required: true,
component: 'ApiTreeSelect',
componentProps: {
api: async () => {
const data = await getOrganizationList();
copyTransFun(data as any as any[]);
return data;
},
},
},
{
label: '视频流获取方式',
field: 'accessMode',
component: 'RadioGroup',
rules: [{ required: true, message: '视频流获取方式为必选项', type: 'number' }],
defaultValue: AccessMode.ManuallyEnter,
componentProps({ formActionType }) {
return {
defaultValue: AccessMode.ManuallyEnter,
placeholder: '请选择视频流获取方式',
options: [
{ label: '手动输入', value: AccessMode.ManuallyEnter },
{ label: '流媒体获取', value: AccessMode.Streaming },
],
onChange(event: { target: { value: number } }) {
formActionType.removeSchemaByFiled([
'videoPlatformId',
'streamType',
'playProtocol',
'sn',
'brand',
'videoUrl',
]);
const {
target: { value },
} = event;
if (value === AccessMode.ManuallyEnter) {
manuallyEnter.forEach((schema) =>
formActionType.appendSchemaByField(schema, undefined)
);
} else {
streamingMediaAcquire.forEach((schema) =>
formActionType.appendSchemaByField(schema, undefined)
);
formActionType.setFieldsValue({
streamType: StreamType.MASTER,
playProtocol: PlayProtocol.HTTP,
});
}
},
};
},
},
...manuallyEnter,
];