<template>
    <div class="header">
        <div class="leftheader">
            <div class="item" v-for="(item, index) in categorylist" :key="item.id" @click="clickcategory(item, index)"
                :class="index == categoryindex ? 'selectitem' : ''">
                <div class="name">
                    {{ item.title }}
                </div>
            </div>
        </div>
        <div class="rightheader">
            <div id="main"></div>
        </div>
    </div>
</template>
<script>
import * as echarts from 'echarts';

export default {
    name: "visitRecords",
    data() {
        return {
            pickerOptions: {
                disabledDate(time) {
                    return time.getTime() > Date.now(); //禁止选择今天以后的时间
                },
            },
            //选择时间区间
            datePickerStart: "",
            datePickerEnd: "",
            //右侧标题选中
            recordindex: 0,
            //左侧类型选中
            categoryindex: 0,
            //左侧选中的item
            categoryItem: {},
            //左侧list
            categorylist: [{
                id: 1,
                title: '冠状动脉粥样硬化性心脏病',
            }, {
                id: 2,
                title: '冠状动脉粥样硬化性心脏病冠状动脉粥样硬化性心脏病',
            }]
        };
    },
    created() {
        this.categoryItem = this.categorylist[0]
    },
    mounted() {
        this.info();
    },
    methods: {
        clickcategory(item, index) {
            this.categoryindex = index
            this.categoryItem = item
        },
        info() {
            // 基于准备好的dom，初始化echarts实例
            var myChart = echarts.init(document.getElementById('main'));
            // 绘制图表
            myChart.setOption({
                title: {
                    text: '运动监测'
                },
                tooltip: {},
                xAxis: {
                    data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子', '衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子']
                },
                yAxis: {},
                series: [
                    {
                        name: '销量',
                        type: 'bar',
                        data: [5, 20, 36, 10, 10, 20, 5, 20, 36, 10, 10, 20]
                    }
                ]
            });
        },
    }
};
</script>
<style lang="scss" scoped>
.header {
    background-color: #fff !important;
    padding: 0 !important;
    display: flex;

    .rightheader {
        width: 75%;
        padding-top: 20px;
        border-left: 3px solid #DFE4ED;

        #main {
            width: 1000px;
            height: 450px;
            margin: 0 auto;
        }
    }

    .leftheader {
        width: 20%;
        margin-top: 20px;
        height: 450px;
        overflow: scroll;
        // 隐藏表头的滚动条
        overflow-x: hidden !important;

        .selectitem {
            background-color: #D2E9FC;
            border-left: 2px solid #1890ff !important;
            border-bottom: 1px solid #fff !important;
        }

        .item {
            padding: 25px 10px;
            position: relative;
            border-left: 2px solid #fff;
            border-bottom: 1px solid #E7E7E7;

            .name {
                font-size: 18px;
                font-weight: 600;
            }
        }
    }
}
</style>
  