matrix_components 2.0.395 → 2.0.400

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,656 +0,0 @@
1
- <template>
2
- <div class="demo-container">
3
- <div class="control-panel">
4
- <h3>动态表单组件演示</h3>
5
- <!-- 配置文件选择 -->
6
- <el-form :model="state" ref="formRef" label-position="left">
7
- <el-button type="primary" @click="getFormData">获取表单数据</el-button>
8
- <el-button type="default" @click="resetFormData">重置表单</el-button>
9
- <br />
10
- <span style="color: red"> 结果:{{ state.formData }} </span>
11
- <br />
12
- <br />
13
- <NsFormTitle title="模型参数">
14
- <NsForm
15
- ref="row1Ref"
16
- :readOnly="state.readOnly"
17
- backgroundColor="#fff"
18
- :model="state.model"
19
- :rows="state.rows"
20
- formPropKey="rows"
21
- labelColor="#606266"
22
- labelWidth="150"
23
- gapH="20px"
24
- gapV="10px"
25
- ></NsForm>
26
- </NsFormTitle>
27
- <NsFormTitle title="视频配置">
28
- <NsForm
29
- ref="row2Ref"
30
- :readOnly="state.readOnly"
31
- backgroundColor="#fff"
32
- :model="state.model"
33
- :rows="state.rows2"
34
- formPropKey="rows2"
35
- labelColor="#606266"
36
- labelWidth="150"
37
- gapH="20px"
38
- gapV="10px"
39
- ></NsForm>
40
- </NsFormTitle>
41
- <NsFormTitle title="结果保存">
42
- <NsForm
43
- ref="row3Ref"
44
- :readOnly="state.readOnly"
45
- backgroundColor="#fff"
46
- :model="state.model"
47
- :rows="state.rows3"
48
- formPropKey="rows3"
49
- labelColor="#606266"
50
- labelWidth="150"
51
- gapH="20px"
52
- gapV="10px"
53
- ></NsForm>
54
- </NsFormTitle>
55
- <NsFormTitle title="级联选择器测试">
56
- <NsForm
57
- ref="row4Ref"
58
- :readOnly="state.readOnly"
59
- backgroundColor="#fff"
60
- :model="state.model"
61
- :rows="state.rows4"
62
- formPropKey="rows4"
63
- labelColor="#606266"
64
- labelWidth="150"
65
- gapH="20px"
66
- gapV="10px"
67
- ></NsForm>
68
- </NsFormTitle>
69
- </el-form>
70
- </div>
71
- </div>
72
- </template>
73
-
74
- <script setup lang="ts">
75
- import { ElInput, ElMessage, ElRadioGroup, ElCascader, ElSwitch } from 'element-plus'
76
- import { h, onMounted, reactive, ref } from 'vue'
77
- import { cloneDeep } from 'lodash-es'
78
- import { nextTick } from 'vue'
79
-
80
- const props = defineProps({
81
- readOnly: {
82
- type: Boolean,
83
- default: false
84
- },
85
- row: {
86
- type: Object,
87
- default: () => ({}),
88
- },
89
- })
90
-
91
- const formRef = ref()
92
- const row1Ref = ref()
93
- const row2Ref = ref()
94
- const row3Ref = ref()
95
- const row4Ref = ref()
96
-
97
- const state = reactive({
98
- formData: {},
99
- readOnly: props.readOnly,
100
- model: props.readOnly ? '' : 'vertical',
101
- rows: [
102
- [
103
- {
104
- key: "isEnable",
105
- label: "是否启用",
106
- value: false,
107
- component: ElSwitch,
108
- params: {
109
- rules: [
110
- {
111
- required: true,
112
- message: "请选择",
113
- },
114
- ],
115
- width: 60,
116
- 'inline-prompt': true,
117
- 'active-text':"启用",
118
- 'inactive-text':"禁用",
119
- },
120
- },
121
- ],
122
- [
123
- {
124
- key: 'confidence',
125
- label: '置信度',
126
- value: 'aaa',
127
- component: ElInput,
128
- params: {
129
- rules: [
130
- {
131
- required: true,
132
- message: '请输入',
133
- },
134
- ],
135
- },
136
- },
137
- {
138
- key: 'iou',
139
- label: '交并比',
140
- value: '',
141
- component: ElInput,
142
- params: {
143
- 'v-length.range': {
144
- min: 0,
145
- max: 1,
146
- maxLength: 3,
147
- },
148
- rules: [
149
- {
150
- required: true,
151
- message: '请输入',
152
- },
153
- ],
154
- },
155
- },
156
- ],
157
- ],
158
- rows2: [
159
- [
160
- {
161
- key: 'timeInterval',
162
- label: '时间间隔(秒)',
163
- value: '',
164
- component: ElInput,
165
- params: {
166
- 'v-length.range': {
167
- min: 0,
168
- max: 6000,
169
- int: true,
170
- },
171
- rules: [
172
- {
173
- required: true,
174
- message: '请输入',
175
- },
176
- ],
177
- },
178
- },
179
- {
180
- key: 'stuck_threshold',
181
- label: '视频帧卡顿(秒)',
182
- value: '',
183
- component: ElInput,
184
- params: {
185
- 'v-length.range': {
186
- min: 0,
187
- max: 1000,
188
- int: true,
189
- },
190
- rules: [
191
- {
192
- required: true,
193
- message: '请输入',
194
- },
195
- ],
196
- },
197
- },
198
- ],
199
- [
200
- {
201
- key: 'max_retries',
202
- label: '最大重连次数',
203
- value: '',
204
- component: ElInput,
205
- params: {
206
- 'v-length.range': {
207
- min: 0,
208
- max: 100,
209
- int: true,
210
- },
211
- rules: [
212
- {
213
- required: true,
214
- message: '请输入',
215
- },
216
- ],
217
- },
218
- },
219
- {
220
- value: ' ',
221
- },
222
- ],
223
- ],
224
- rows3: [
225
- [
226
- {
227
- key: 'save_video',
228
- label: '是否保存视频',
229
- value: false,
230
- component: ElRadioGroup,
231
- params: {
232
- rules: [
233
- {
234
- required: true,
235
- message: '请选择',
236
- trigger: 'change',
237
- },
238
- ],
239
- options: [
240
- {
241
- value: true,
242
- label: '是',
243
- },
244
- {
245
- value: false,
246
- label: '否',
247
- },
248
- ],
249
- },
250
- },
251
- {
252
- key: 'pre_buffer_second',
253
- label: '帧前缓存(秒)',
254
- value: '',
255
- component: ElInput,
256
- params: {
257
- 'v-length.range': {
258
- min: 0,
259
- max: 1000,
260
- int: true,
261
- },
262
- rules: [
263
- {
264
- required: true,
265
- message: '请输入',
266
- },
267
- ],
268
- },
269
- },
270
- ],
271
- [
272
- {
273
- key: 'det_area_mode',
274
- label: '检测区域工作模式',
275
- value: 'normal',
276
- component: ElRadioGroup,
277
- events: {
278
- change: detAreaModeChange,
279
- },
280
- params: {
281
- rules: [
282
- {
283
- required: true,
284
- message: '请选择',
285
- trigger: 'change',
286
- },
287
- ],
288
- options: [
289
- {
290
- value: 'normal',
291
- label: '常规检测(normal)',
292
- },
293
- {
294
- value: 'abnormal',
295
- label: '非常规检测(abnormal)',
296
- },
297
- ],
298
- },
299
- },
300
- ],
301
- ],
302
- rows4: [
303
- [
304
- {
305
- key: 'region',
306
- label: '地区选择',
307
- value: ['beijing', 'chaoyang'],
308
- component: ElCascader,
309
- params: {
310
- rules: [
311
- {
312
- required: true,
313
- message: '请选择地区',
314
- trigger: 'change',
315
- },
316
- ],
317
- props: {
318
- showPrefix: false,
319
- checkStrictly: true,
320
- checkOnClickNode: true,
321
- },
322
- options: [
323
- {
324
- value: 'beijing',
325
- label: '北京市',
326
- children: [
327
- {
328
- value: 'chaoyang',
329
- label: '朝阳区',
330
- children: [
331
- {
332
- value: 'chaoyangmen',
333
- label: '朝阳门街道',
334
- },
335
- ],
336
- },
337
- {
338
- value: 'haidian',
339
- label: '海淀区',
340
- },
341
- ],
342
- },
343
- {
344
- value: 'shanghai',
345
- label: '上海市',
346
- children: [
347
- {
348
- value: 'pudong',
349
- label: '浦东新区',
350
- },
351
- ],
352
- },
353
- ],
354
- },
355
- },
356
- {
357
- key: 'department',
358
- label: '部门选择',
359
- value: ['company'],
360
- component: ElCascader,
361
- params: {
362
- props: {
363
- value: 'code',
364
- label: 'name',
365
- children: 'subDepartments',
366
- showPrefix: false,
367
- checkStrictly: true,
368
- checkOnClickNode: true,
369
- },
370
- separator: ',',
371
- options: [
372
- {
373
- code: 'company',
374
- name: '公司总部',
375
- subDepartments: [
376
- {
377
- code: 'tech',
378
- name: '技术部',
379
- subDepartments: [
380
- {
381
- code: 'frontend',
382
- name: '前端组',
383
- },
384
- {
385
- code: 'backend',
386
- name: '后端组',
387
- },
388
- ],
389
- },
390
- {
391
- code: 'sales',
392
- name: '销售部',
393
- },
394
- ],
395
- },
396
- ],
397
- },
398
- },
399
- ],
400
- [
401
- {
402
- key: 'single_level_cascader',
403
- label: '单层级联',
404
- value: 'beijing',
405
- component: ElCascader,
406
- params: {
407
- options: [
408
- {
409
- value: 'beijing',
410
- label: '北京市',
411
- },
412
- {
413
- value: 'shanghai',
414
- label: '上海市',
415
- },
416
- {
417
- value: 'guangzhou',
418
- label: '广州市',
419
- },
420
- ],
421
- },
422
- },
423
- {
424
- value: ' ',
425
- },
426
- ],
427
- ],
428
- })
429
-
430
- function detAreaModeChange(value: any) {
431
- debugger
432
- if (state.rows3?.length && state.rows3[state.rows3.length - 1]?.[0]?.key === 'det_area_json') {
433
- state.rows3.pop()
434
- }
435
- if (value === 'abnormal') {
436
- state.rows3.push([
437
- {
438
- key: 'det_area_json',
439
- label: '感兴趣区域',
440
- value: '',
441
- readOnlyUseComponent: true,
442
- component: CustomUIs,
443
- span: 6,
444
- events: {
445
- change: (value) => getAreasHandler(value),
446
- },
447
- },
448
- { value: ' ' },
449
- ])
450
- }
451
- }
452
-
453
- function CustomUIs() {
454
- return h('div', {style:'color: red', class:"xx"}, 'xxx')
455
- }
456
-
457
- function getAreasHandler(value: any) {
458
- state.rows3[state.rows3.length - 1][0].value = value
459
- }
460
-
461
- /**
462
- * 保存
463
- */
464
- async function getFormData() {
465
- try {
466
- await formRef.value.validate()
467
- } catch (error: any) {
468
- console.log(error)
469
- ElMessage.error('表单校验失败')
470
- state.formData = {}
471
- return false
472
- }
473
- const data1 = row1Ref.value?.getFormKvData?.()
474
- const data2 = row2Ref.value?.getFormKvData?.()
475
- const data3 = row3Ref.value?.getFormKvData?.()
476
- const data4 = row4Ref.value?.getFormKvData?.()
477
- const data = { ...data1, ...data2, ...data3, ...data4 }
478
- state.formData = data
479
- ElMessage.success('表单校验成功')
480
- return data
481
- }
482
-
483
- /**
484
- * 重置表单
485
- */
486
- async function resetFormData() {
487
- // 使用组件内置的 resetForm 方法
488
- row1Ref.value?.resetForm?.()
489
- row2Ref.value?.resetForm?.()
490
- row3Ref.value?.resetForm?.()
491
- row4Ref.value?.resetForm?.()
492
- setTimeout(()=>{
493
- // 重置表单验证状态
494
- formRef.value?.clearValidate?.()
495
- // 清空结果显示
496
- state.formData = {}
497
- ElMessage.success('表单重置成功')
498
- }, 0)
499
- }
500
-
501
- async function getDetail() {
502
- setTimeout(()=>{
503
- const res = {
504
- "isEnable": true,
505
- "confidence": "aaa1",
506
- "iou": "1",
507
- "timeInterval": "2",
508
- "stuck_threshold": "3",
509
- "max_retries": "4",
510
- "save_video": true,
511
- "pre_buffer_second": "5",
512
- "det_area_mode": "abnormal",
513
- "det_area_json": "6",
514
- "region": ["beijing", "haidian"],
515
- "department": ["company","tech","frontend"],
516
- "single_level_cascader": "shanghai"
517
- }
518
-
519
- row1Ref.value?.setFormData?.(res,false)
520
- row2Ref.value?.setFormData?.(res,false)
521
- row3Ref.value?.setFormData?.(res,false)
522
- row4Ref.value?.setFormData?.(res,false)
523
- // 特殊处理
524
- detAreaModeChange('abnormal')
525
-
526
- setTimeout(()=>{
527
- const res = {
528
- "isEnable": true,
529
- "confidence": "aaa1",
530
- "iou": "1",
531
- "timeInterval": "2",
532
- "stuck_threshold": "3",
533
- "max_retries": "4",
534
- "save_video": true,
535
- "pre_buffer_second": "5",
536
- "det_area_mode": "normal",
537
- "det_area_json": "6",
538
- "region": ["beijing", "haidian"],
539
- "department": ["company","tech","frontend"],
540
- "single_level_cascader": "shanghai"
541
- }
542
-
543
- row1Ref.value?.setFormData?.(res,false)
544
- row2Ref.value?.setFormData?.(res,false)
545
- row3Ref.value?.setFormData?.(res,false)
546
- row4Ref.value?.setFormData?.(res,false)
547
- detAreaModeChange('normal')
548
-
549
- }, 2000)
550
- }, 2000)
551
- }
552
-
553
- onMounted(() => {
554
- getDetail()
555
- })
556
-
557
- </script>
558
-
559
- <style lang="scss" scoped>
560
- .demo-container {
561
- padding: 20px;
562
- max-width: 1400px;
563
- margin: 0 auto;
564
- }
565
-
566
- .control-panel {
567
- background: #f5f5f5;
568
- padding: 20px;
569
- border-radius: 8px;
570
- margin-bottom: 20px;
571
-
572
- h3 {
573
- margin: 0 0 20px 0;
574
- color: #333;
575
- }
576
-
577
- h4 {
578
- margin: 15px 0 10px 0;
579
- color: #666;
580
- font-size: 14px;
581
- }
582
- }
583
-
584
- .config-section,
585
- .upload-section,
586
- .action-section {
587
- margin-bottom: 20px;
588
- padding: 15px;
589
- background: white;
590
- border-radius: 6px;
591
- border: 1px solid #e0e0e0;
592
-
593
- .config-select {
594
- width: 300px;
595
- margin-right: 10px;
596
- }
597
-
598
- input[type='file'] {
599
- margin-right: 10px;
600
- }
601
-
602
- .el-button {
603
- margin-right: 10px;
604
- margin-bottom: 5px;
605
- }
606
- }
607
-
608
- .form-container {
609
- background: white;
610
- padding: 20px;
611
- border-radius: 8px;
612
- border: 1px solid #e0e0e0;
613
- margin-bottom: 20px;
614
- }
615
-
616
- .empty-state {
617
- text-align: center;
618
- padding: 60px 20px;
619
- background: white;
620
- border-radius: 8px;
621
- border: 1px solid #e0e0e0;
622
- }
623
-
624
- .data-card {
625
- margin-top: 20px;
626
-
627
- .card-header {
628
- display: flex;
629
- justify-content: space-between;
630
- align-items: center;
631
- }
632
-
633
- .form-data-display {
634
- background-color: #f5f7fa;
635
- padding: 15px;
636
- border-radius: 4px;
637
- font-size: 12px;
638
- line-height: 1.5;
639
- max-height: 400px;
640
- overflow-y: auto;
641
- }
642
- }
643
-
644
- @media (max-width: 768px) {
645
- .config-select {
646
- width: 100% !important;
647
- margin-bottom: 10px;
648
- }
649
-
650
- .el-button {
651
- width: 100%;
652
- margin-bottom: 10px;
653
- }
654
- }
655
- </style>
656
-