|
|
@@ -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 };
|
|
|
},
|
|
|
});
|