RadioGroup.san 1.1 KB
Newer Older
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
<template>
    <div class="sm-form-item">
        <label class="label">{{label}}</label>
        <div class="group-box">
            <san-radio
                on-change="handleChange($event)"
                san-for="item in items"
                label="{{item.name}}"
                value="{{item.value}}"
                disabled="{{item.disabled}}"
                checked="{=value=}"
            ></san-radio>
        </div>
    </div>
</template>
<script>
    import Radio from 'san-mui/Radio';
    import {DataTypes} from 'san';
    export default {
        components: {
            'san-radio': Radio
        },
        dataTypes: {
            items: DataTypes.array,
            value: DataTypes.string
        },
        initData() {
            return {
                items: {},
                value: [],
                label: ''
            };
        },
        attached(value) {
            this.watch('value', val => {
                this.dispatch('UI:form-item-change', val);
            });
        },
        handleChange(val) {
            this.fire('valueChange', val);
        }
    };
</script>