<template>
    <div class="content">
        <e-row :gutter="24">
            <!-- 基本用法 -->
            <e-col :span="24" class="box-card">
                <e-card shadow="always">
                    <div slot="header" class="clearfix">
                        <span>基本用法</span>
                    </div>
                    <div>
                        <e-checkbox v-model="checked">备选项</e-checkbox>
                    </div>
                </e-card>
            </e-col>
            <!-- 禁用状态 -->
            <e-col :span="24" class="box-card">
                <e-card shadow="always">
                    <div slot="header" class="clearfix">
                        <span>禁用状态</span>
                    </div>
                    <div>
                        <e-checkbox v-model="checked1" disabled>备选项1</e-checkbox>
                        <e-checkbox v-model="checked2" disabled>备选项</e-checkbox>
                    </div>
                </e-card>
            </e-col>
            <!-- 多选框组 -->
            <e-col :span="24" class="box-card">
                <e-card shadow="always">
                    <div slot="header" class="clearfix">
                        <span>多选框组</span>
                    </div>
                    <div>
                        <e-checkbox-group v-model="checkList">
                            <e-checkbox label="复选框 A"></e-checkbox>
                            <e-checkbox label="复选框 B"></e-checkbox>
                            <e-checkbox label="复选框 C"></e-checkbox>
                            <e-checkbox label="禁用" disabled></e-checkbox>
                            <e-checkbox label="选中且禁用" disabled></e-checkbox>
                        </e-checkbox-group>
                    </div>
                </e-card>
            </e-col>
            <e-col :span="24" class="box-card">
                <e-card shadow="always">
                    <div slot="header" class="clearfix">
                        <span>indeterminate 状态</span>
                    </div>
                    <div>
                        <e-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全选</e-checkbox>
                        <div style="margin: 15px 0;"></div>
                        <e-checkbox-group v-model="checkedCities" @change="handleCheckedCitiesChange">
                            <e-checkbox v-for="city in cities" :label="city" :key="city">{{city}}</e-checkbox>
                        </e-checkbox-group>
                    </div>
                </e-card>
            </e-col>
            <e-col :span="24" class="box-card">
                <e-card shadow="always">
                    <div slot="header" class="clearfix">
                        <span>可选项目数量的限制</span>
                    </div>
                    <div>
                        <e-checkbox-group 
                        v-model="checkedCities1"
                        :min="1"
                        :max="2">
                        <e-checkbox v-for="city in cities1" :label="city" :key="city">{{city}}</e-checkbox>
                    </e-checkbox-group>
                    </div>
                </e-card>
            </e-col>
            <e-col :span="24" class="box-card">
                <e-card shadow="always">
                    <div slot="header" class="clearfix">
                        <span>按钮样式</span>
                    </div>
                    <div>
                        <div>
                            <e-checkbox-group v-model="checkboxGroup1">
                            <e-checkbox-button v-for="city in cities2" :label="city" :key="city">{{city}}</e-checkbox-button>
                            </e-checkbox-group>
                        </div>
                        <div style="margin-top: 20px">
                            <e-checkbox-group v-model="checkboxGroup2" size="medium">
                            <e-checkbox-button v-for="city in cities2" :label="city" :key="city">{{city}}</e-checkbox-button>
                            </e-checkbox-group>
                        </div>
                        <div style="margin-top: 20px">
                            <e-checkbox-group v-model="checkboxGroup3" size="small">
                            <e-checkbox-button v-for="city in cities2" :label="city" :disabled="city === '北京'" :key="city">{{city}}</e-checkbox-button>
                            </e-checkbox-group>
                        </div>
                        <div style="margin-top: 20px">
                            <e-checkbox-group v-model="checkboxGroup4" size="mini" disabled>
                            <e-checkbox-button v-for="city in cities2" :label="city" :key="city">{{city}}</e-checkbox-button>
                            </e-checkbox-group>
                        </div>
                    </div>
                </e-card>
            </e-col>
            <e-col :span="24" class="box-card">
                <e-card shadow="always">
                    <div slot="header" class="clearfix">
                        <span>带边框</span>
                    </div>
                    <div>
                        <div>
                            <e-checkbox v-model="checked2" label="备选项1" border></e-checkbox>
                            <e-checkbox v-model="checked3" label="备选项2" border></e-checkbox>
                        </div>
                        <div style="margin-top: 20px">
                            <e-checkbox v-model="checked4" label="备选项1" border size="medium"></e-checkbox>
                            <e-checkbox v-model="checked5" label="备选项2" border size="medium"></e-checkbox>
                        </div>
                        <div style="margin-top: 20px">
                            <e-checkbox-group v-model="checkboxGroup2" size="small">
                            <e-checkbox label="备选项1" border></e-checkbox>
                            <e-checkbox label="备选项2" border disabled></e-checkbox>
                            </e-checkbox-group>
                        </div>
                        <div style="margin-top: 20px">
                            <e-checkbox-group v-model="checkboxGroup3" size="mini" disabled>
                            <e-checkbox label="备选项1" border></e-checkbox>
                            <e-checkbox label="备选项2" border></e-checkbox>
                            </e-checkbox-group>
                        </div>
                    </div>
                </e-card>
            </e-col>
        </e-row>
    </div>
</template>
<script>
const cityOptions = ['上海', '北京', '广州', '深圳'];
export default {
    components: {},
    data() {
        return {
            checked: true,
            checked1: false,
            checked2: true,
            checkList: ['选中且禁用','复选框 A'],
            checkAll: false,
            checkedCities: ['上海', '北京'],
            cities: cityOptions,
            isIndeterminate: true,
            checkedCities1: ['上海', '北京'],
            cities1: cityOptions,
            checkboxGroup1: ['上海'],
            checkboxGroup2: ['上海'],
            checkboxGroup3: ['上海'],
            checkboxGroup4: ['上海'],
            cities2: cityOptions,
            checked1: true,
            checked3: false,
            checked4: false,
            checked5: true,
            checkboxGroup2: [],
            checkboxGroup3: []
        }
    },
    mounted() {
    },
    methods: {
        handleCheckAllChange(val) {
        this.checkedCities = val ? cityOptions : [];
        this.isIndeterminate = false;
        },
        handleCheckedCitiesChange(value) {
            let checkedCount = value.length;
            this.checkAll = checkedCount === this.cities.length;
            this.isIndeterminate = checkedCount > 0 && checkedCount < this.cities.length;
        }
    }
}
</script>
  
<style>
.marginLeft {
    margin-left: 10px
}
.content {
    height: 100%;
    padding: 30px;
    background:#fff;
}

.block {
    display: inline-block;
    margin-left: 10px;
}

.box-card .el-col{
    margin-bottom:10px;
}
  </style>
