matrix_components 2.0.403 → 2.0.405

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