wangzhibo
2026-07-16 b57020623cf0c946706573bf102e548c3a544423
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<template>
    <!--【很重要】直接绑定status,或者使用 form[prop!] -->
    <el-radio-group v-model="form.status">
        <el-radio v-for="(item, index) in list" :key="index" :value="item.value">
            {{ item.label }}
        </el-radio>
    </el-radio-group>
</template>
 
<!--【很重要】必须要有name,避免注册后和其他冲突 -->
<script setup lang="ts">
defineOptions({
    name: 'select-status'
});
 
import { useForm } from '@cool-vue/crud';
import { computed, ref } from 'vue';
 
const props = defineProps({
    scope: null, // 表单值
    prop: String // 表单项配置的 prop
});
 
// 使用 useForm,能直接获取到上级的表单实例,
// 比如操作表单的 Form.value?.submit、Form.value?.close等
// 获取表单值,Form.value?.form
const Form = useForm();
 
// 表单值,包一层不会太难受
const form = computed(() => Form.value?.form || {});
 
// 选项列表
const list = ref<{ label: string; value: number }[]>([
    {
        label: '很好',
        value: 1
    },
    {
        label: '不舒服',
        value: 2
    },
    {
        label: '要嘎了',
        value: 3
    }
]);
</script>