matrix_components 2.0.402 → 2.0.404

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