<template>
    <!-- 下拉单选 -->
    <el-select
        v-model="checked"
        :placeholder="listItem.placeholder"
        @change="change"
    >
        <el-option
            v-for="item in listItem.option.list"
            :key="item.value"
            :label="item.name"
            :value="item.value"
        ></el-option>
    </el-select>
</template>

<script>
import mixin from '../mixin.js'
export default {
    name: 'FormRadio',
    props: {
        subform: { type: Object, default: () => ({}) },
        listItem: { type: Object, default: () => ({}) },
        formItem: { type: Object, default: () => ({}) }
    },
    mixins: [mixin],
    data () {
        return {
            checked: this.listItem.option.checked
        }
    },
    methods: {
        // 切换选项同步 value，并改变关联项的隐藏
        change (checked) {
            this.formItem.value = this.listItem.option.list.find(item => item.value === checked).name
            this.radioHide(this.subform, this.listItem.option.list, checked) // mixin
        }
    }
}
</script>

<style lang="less" scoped>
</style>
