Преглед изворни кода

[Mod 0000] 表格表单默认设置为打开状态

houzekong пре 3 месеци
родитељ
комит
c026a17376
1 измењених фајлова са 13 додато и 5 уклоњено
  1. 13 5
      src/components/Form/src/components/FormGroup.vue

+ 13 - 5
src/components/Form/src/components/FormGroup.vue

@@ -1,6 +1,3 @@
-<!--
- * @Description:It is troublesome to implement radio button group in the form. So it is extracted independently as a separate component
--->
 <template>
   <Space v-bind="attrs">
     <template v-for="(item, i) in groups" :key="`fmgrp${i}`">
@@ -13,12 +10,13 @@
   </Space>
 </template>
 <script lang="ts">
-  import { defineComponent, PropType } from 'vue';
+  import { defineComponent, PropType, watch } from 'vue';
   import { Space, Button } from 'ant-design-vue';
   import { useAttrs } from '/@/hooks/core/useAttrs';
+  import { first } from 'lodash';
 
   export default defineComponent({
-    name: 'RadioButtonGroup',
+    name: 'FormGroup',
     components: {
       Space,
       AButton: Button,
@@ -46,6 +44,16 @@
         }
       }
 
+      watch(
+        () => props.groups,
+        (nv) => {
+          !props.value && handleClick(first(nv));
+        },
+        {
+          immediate: true,
+        }
+      );
+
       return { attrs, handleClick };
     },
   });