matrix_components 2.0.367 → 2.0.369

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.
@@ -59,7 +59,7 @@
59
59
 
60
60
  <script setup lang="ts">
61
61
  import { ElInput, ElMessage, ElRadioGroup } from 'element-plus'
62
- import { reactive, ref } from 'vue'
62
+ import { onMounted, reactive, ref } from 'vue'
63
63
  import { cloneDeep } from 'lodash-es'
64
64
  import { nextTick } from 'vue'
65
65
 
@@ -83,7 +83,6 @@
83
83
  formData: {},
84
84
  readOnly: props.readOnly,
85
85
  model: props.readOnly ? '' : 'vertical',
86
- // 使用 cloneDeep 进行深拷贝,保留函数
87
86
  rows: [
88
87
  [
89
88
  {
@@ -315,9 +314,9 @@
315
314
  state.formData = {}
316
315
  return false
317
316
  }
318
- const data1 = row1Ref.value?.getKeyValuePairs?.(state.rows)
319
- const data2 = row2Ref.value?.getKeyValuePairs?.(state.rows2)
320
- const data3 = row3Ref.value?.getKeyValuePairs?.(state.rows3)
317
+ const data1 = row1Ref.value?.getFormKvData?.()
318
+ const data2 = row2Ref.value?.getFormKvData?.()
319
+ const data3 = row3Ref.value?.getFormKvData?.()
321
320
  const data = { ...data1, ...data2, ...data3 }
322
321
  state.formData = data
323
322
  ElMessage.success('表单校验成功')
@@ -341,123 +340,35 @@
341
340
  }, 0)
342
341
  }
343
342
 
344
- /**
345
- * 重置表单数据到指定值或默认值
346
- * @param targetRows 要重置的rows数据
347
- * @param defaultValues 默认值对象,key为字段key,value为默认值
348
- */
349
- function resetFormToDefaults(targetRows: any[], defaultValues: Record<string, any> = {}) {
350
- for (let rowIndex = 0; rowIndex < targetRows.length; rowIndex++) {
351
- const row = targetRows[rowIndex]
352
- for (let colIndex = 0; colIndex < row.length; colIndex++) {
353
- const item = row[colIndex]
354
- if (item.key) {
355
- // 如果提供了默认值,使用默认值,否则根据组件类型重置
356
- if (defaultValues.hasOwnProperty(item.key)) {
357
- item.value = cloneDeep(defaultValues[item.key])
358
- } else {
359
- // 根据组件类型或当前值类型设置默认值
360
- if (Array.isArray(item.value)) {
361
- item.value = []
362
- } else if (typeof item.value === 'number') {
363
- item.value = 0
364
- } else if (typeof item.value === 'boolean') {
365
- item.value = false
366
- } else {
367
- item.value = ''
368
- }
369
- }
370
-
371
- // 重置删除的文件列表
372
- if (item.delValue !== undefined) {
373
- item.delValue = defaultValues[`${item.key}_delValue`]
374
- ? cloneDeep(defaultValues[`${item.key}_delValue`])
375
- : []
376
- }
343
+
344
+ async function getDetail() {
345
+ // 模拟获取详情数据
346
+ setTimeout(()=>{
347
+ const res = { "confidence": "aaa1", "iou": "1", "timeInterval": "2", "stuck_threshold": "3", "max_retries": "4", "save_video": "0", "pre_buffer_second": "5", "det_area_mode": "abnormal", "det_area_json": "6" }
348
+ for (const [k, v] of Object.entries(res)) {
349
+ let rows1 = getAllFormNodeByKey(state.rows,k);
350
+ if(rows1) {
351
+ rows1.value = v;
377
352
  }
378
-
379
- // 检查子项
380
- if (item.children && Array.isArray(item.children)) {
381
- for (let childIndex = 0; childIndex < item.children.length; childIndex++) {
382
- const child = item.children[childIndex]
383
- if (child.key) {
384
- // 重置子项
385
- if (defaultValues.hasOwnProperty(child.key)) {
386
- child.value = cloneDeep(defaultValues[child.key])
387
- } else {
388
- if (Array.isArray(child.value)) {
389
- child.value = []
390
- } else if (typeof child.value === 'number') {
391
- child.value = 0
392
- } else if (typeof child.value === 'boolean') {
393
- child.value = false
394
- } else {
395
- child.value = ''
396
- }
397
- }
398
-
399
- // 重置子项删除的文件列表
400
- if (child.delValue !== undefined) {
401
- child.delValue = defaultValues[`${child.key}_delValue`]
402
- ? cloneDeep(defaultValues[`${child.key}_delValue`])
403
- : []
404
- }
405
- }
406
- }
353
+ let rows2 = getAllFormNodeByKey(state.rows2,k);
354
+ if(rows2) {
355
+ rows2.value = v;
407
356
  }
408
- }
409
- }
410
- }
411
-
412
- /**
413
- * 批量设置表单值
414
- * @param targetRows 要设置的rows数据
415
- * @param values 值对象,key为字段key,value为要设置的值
416
- */
417
- function setFormValues(targetRows: any[], values: Record<string, any> = {}) {
418
- for (let rowIndex = 0; rowIndex < targetRows.length; rowIndex++) {
419
- const row = targetRows[rowIndex]
420
- for (let colIndex = 0; colIndex < row.length; colIndex++) {
421
- const item = row[colIndex]
422
- if (item.key && values.hasOwnProperty(item.key)) {
423
- item.value = cloneDeep(values[item.key])
424
- }
425
-
426
- // 检查子项
427
- if (item.children && Array.isArray(item.children)) {
428
- for (let childIndex = 0; childIndex < item.children.length; childIndex++) {
429
- const child = item.children[childIndex]
430
- if (child.key && values.hasOwnProperty(child.key)) {
431
- child.value = cloneDeep(values[child.key])
357
+ let rows3 = getAllFormNodeByKey(state.rows3,k);
358
+ if(rows3) {
359
+ rows3.value = v;
360
+ if(k === 'det_area_mode'){
361
+ detAreaModeChange(v)
432
362
  }
433
- }
434
363
  }
435
- }
436
364
  }
365
+ }, 1000)
437
366
  }
438
-
439
- /**
440
- * 重置所有表单到默认值(新的重置方法)
441
- * @param customDefaults 自定义默认值
442
- */
443
- function resetAllFormsToDefaults(customDefaults: Record<string, any> = {}) {
444
- // 重置第一个表单
445
- resetFormToDefaults(state.rows, customDefaults)
446
-
447
- // 重置第二个表单
448
- resetFormToDefaults(state.rows2, customDefaults)
449
-
450
- // 重置第三个表单
451
- resetFormToDefaults(state.rows3, customDefaults)
452
-
453
- // 重置表单验证状态
454
- formRef.value?.clearValidate?.()
455
-
456
- // 清空结果显示
457
- state.formData = {}
458
-
459
- ElMessage.success('表单重置到默认值成功')
460
- }
367
+
368
+ onMounted(() => {
369
+ getDetail()
370
+ })
371
+
461
372
  </script>
462
373
 
463
374
  <style lang="scss" scoped>