matrix_components 2.0.393 → 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,658 +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
- if (value === 'abnormal') {
432
- if (state.rows3?.length && state.rows3[state.rows3.length - 1]?.[0]?.key === 'det_area_json') {
433
- state.rows3.pop()
434
- }
435
- state.rows3.push([
436
- {
437
- key: 'det_area_json',
438
- label: '感兴趣区域',
439
- value: '',
440
- readOnlyUseComponent: true,
441
- component: CustomUIs,
442
- span: 6,
443
- events: {
444
- change: (value) => getAreasHandler(value),
445
- },
446
- },
447
- { value: ' ' },
448
- ])
449
- } else {
450
- state.rows3.pop()
451
- }
452
- }
453
-
454
- function CustomUIs() {
455
- return h('div', {style:'color: red', class:"xx"}, 'xxx')
456
- }
457
-
458
- function getAreasHandler(value: any) {
459
- state.rows3[state.rows3.length - 1][0].value = value
460
- }
461
-
462
- /**
463
- * 保存
464
- */
465
- async function getFormData() {
466
- try {
467
- await formRef.value.validate()
468
- } catch (error: any) {
469
- console.log(error)
470
- ElMessage.error('表单校验失败')
471
- state.formData = {}
472
- return false
473
- }
474
- const data1 = row1Ref.value?.getFormKvData?.()
475
- const data2 = row2Ref.value?.getFormKvData?.()
476
- const data3 = row3Ref.value?.getFormKvData?.()
477
- const data4 = row4Ref.value?.getFormKvData?.()
478
- const data = { ...data1, ...data2, ...data3, ...data4 }
479
- state.formData = data
480
- ElMessage.success('表单校验成功')
481
- return data
482
- }
483
-
484
- /**
485
- * 重置表单
486
- */
487
- async function resetFormData() {
488
- // 使用组件内置的 resetForm 方法
489
- row1Ref.value?.resetForm?.()
490
- row2Ref.value?.resetForm?.()
491
- row3Ref.value?.resetForm?.()
492
- row4Ref.value?.resetForm?.()
493
- setTimeout(()=>{
494
- // 重置表单验证状态
495
- formRef.value?.clearValidate?.()
496
- // 清空结果显示
497
- state.formData = {}
498
- ElMessage.success('表单重置成功')
499
- }, 0)
500
- }
501
-
502
- async function getDetail() {
503
- setTimeout(()=>{
504
- const res = {
505
- "isEnable": true,
506
- "confidence": "aaa1",
507
- "iou": "1",
508
- "timeInterval": "2",
509
- "stuck_threshold": "3",
510
- "max_retries": "4",
511
- "save_video": true,
512
- "pre_buffer_second": "5",
513
- "det_area_mode": "abnormal",
514
- "det_area_json": "6",
515
- "region": ["beijing", "haidian"],
516
- "department": ["company","tech","frontend"],
517
- "single_level_cascader": "shanghai"
518
- }
519
-
520
- row1Ref.value?.setFormData?.(res,true)
521
- row2Ref.value?.setFormData?.(res,true)
522
- row3Ref.value?.setFormData?.(res,true)
523
- row4Ref.value?.setFormData?.(res,true)
524
- // 特殊处理
525
- // if (res.det_area_mode === 'abnormal') {
526
- // detAreaModeChange('abnormal')
527
- // }
528
-
529
- setTimeout(()=>{
530
- const res = {
531
- "isEnable": true,
532
- "confidence": "aaa1",
533
- "iou": "1",
534
- "timeInterval": "2",
535
- "stuck_threshold": "3",
536
- "max_retries": "4",
537
- "save_video": true,
538
- "pre_buffer_second": "5",
539
- "det_area_mode": "normal",
540
- "det_area_json": "6",
541
- "region": ["beijing", "haidian"],
542
- "department": ["company","tech","frontend"],
543
- "single_level_cascader": "shanghai"
544
- }
545
-
546
- row1Ref.value?.setFormData?.(res,true)
547
- row2Ref.value?.setFormData?.(res,true)
548
- row3Ref.value?.setFormData?.(res,true)
549
- row4Ref.value?.setFormData?.(res,true)
550
- // 特殊处理
551
- }, 2000)
552
- }, 2000)
553
- }
554
-
555
- onMounted(() => {
556
- getDetail()
557
- })
558
-
559
- </script>
560
-
561
- <style lang="scss" scoped>
562
- .demo-container {
563
- padding: 20px;
564
- max-width: 1400px;
565
- margin: 0 auto;
566
- }
567
-
568
- .control-panel {
569
- background: #f5f5f5;
570
- padding: 20px;
571
- border-radius: 8px;
572
- margin-bottom: 20px;
573
-
574
- h3 {
575
- margin: 0 0 20px 0;
576
- color: #333;
577
- }
578
-
579
- h4 {
580
- margin: 15px 0 10px 0;
581
- color: #666;
582
- font-size: 14px;
583
- }
584
- }
585
-
586
- .config-section,
587
- .upload-section,
588
- .action-section {
589
- margin-bottom: 20px;
590
- padding: 15px;
591
- background: white;
592
- border-radius: 6px;
593
- border: 1px solid #e0e0e0;
594
-
595
- .config-select {
596
- width: 300px;
597
- margin-right: 10px;
598
- }
599
-
600
- input[type='file'] {
601
- margin-right: 10px;
602
- }
603
-
604
- .el-button {
605
- margin-right: 10px;
606
- margin-bottom: 5px;
607
- }
608
- }
609
-
610
- .form-container {
611
- background: white;
612
- padding: 20px;
613
- border-radius: 8px;
614
- border: 1px solid #e0e0e0;
615
- margin-bottom: 20px;
616
- }
617
-
618
- .empty-state {
619
- text-align: center;
620
- padding: 60px 20px;
621
- background: white;
622
- border-radius: 8px;
623
- border: 1px solid #e0e0e0;
624
- }
625
-
626
- .data-card {
627
- margin-top: 20px;
628
-
629
- .card-header {
630
- display: flex;
631
- justify-content: space-between;
632
- align-items: center;
633
- }
634
-
635
- .form-data-display {
636
- background-color: #f5f7fa;
637
- padding: 15px;
638
- border-radius: 4px;
639
- font-size: 12px;
640
- line-height: 1.5;
641
- max-height: 400px;
642
- overflow-y: auto;
643
- }
644
- }
645
-
646
- @media (max-width: 768px) {
647
- .config-select {
648
- width: 100% !important;
649
- margin-bottom: 10px;
650
- }
651
-
652
- .el-button {
653
- width: 100%;
654
- margin-bottom: 10px;
655
- }
656
- }
657
- </style>
658
-