<!--
 * @Author: your name
 * @Date: 2021-10-16 14:56:13
 * @LastEditTime: 2021-11-12 14:47:54
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /data-show/src/views/BrandComparison/tailTOPMedia/index.vue
-->

<template>
    <div class="ttm-outter">
        <v-label-div title="尾翼TOP媒体" :showLine="false" :eStyle="{'border-style': 'none'}" />
        <div class="ttm-inner">
            <div class="ttm-item" v-for="(item,index) in list" :key="index">
                <span class="s1" :style="{color: colors[index]}">{{item.name}}</span>
                <div class="d1">
                    <v-echarts :opt="item.drawOpt"></v-echarts>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import {getSourceTopCount0528C} from "@/api/ModelComparison"
import {createSingleColumnar} from "@/utils/gol/singleColumnar"
export default {
    name: "tailTOPMedia",
    data() {
        return {
            form: {
                token: "",
                sBrand: "",
                sSeriesName: "",
                iContrastType: 2,
            },
            colors: ['#3373CC', '#63AECC', '#54BF93', '#CC9D12', '#CC7733', '#CC5B41'],
            list: [],
          
        };
    },
    created() {
        this.initData();
    },
    methods: {
        initData() {
            this.form.token = this.getToken;
            let arr = this.getMComparison || [];
            let brands = [];
            let models = [];
            arr.forEach((ele) => {
                brands.push(ele.brand);
                models.push(ele.model);
            });
            this.form.sBrand = brands.toString();
            this.form.sSeriesName = models.toString();
            this.getData();
        },
        getData() {
            let obj = Object.assign({}, this.getCtime2, this.form);
            getSourceTopCount0528C(obj).then(res => {
                let data = res.data || [];
                let arr = [];
                data.forEach((ele,index) => {
                    let val = ele.value || [];
                    let dx = [];
                    let ds = [];
                    val.forEach(e => {
                        dx.push(e.key);
                        ds.push(e.value);
                    })
                    let o = {
                        name: ele.key,
                        drawOpt: createSingleColumnar(dx,ds, this.colors[index])
                    }
                   arr.push(o) 
                })
                this.list = arr;
            })
        }
    }
};
</script>

<style lang="less" scoped>
.ttm-outter {
    width: 100%;
    height: auto;
    .ttm-inner {
        width: 100%;
        height: auto;
        display: flex;
        justify-content: flex-start;
        flex-wrap: wrap;
        .ttm-item {
            width: 628px;
            height: 380px;
            .s1 {
                padding-left: 16px;
                width: 100%;
                height: 40px;
                line-height: 40px;
                font-size: 16px;
                color: #fff;
            }
            .d1 {
                width: 100%;
                height: calc(100% - 40px);
            }
        }
    }
}
</style>
