<!--
 * @Author: your name
 * @Date: 2021-10-16 13:57:58
 * @LastEditTime: 2021-11-12 14:25:38
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /data-show/src/views/BrandComparison/comparisonOfPositiveTopicsInTheForum/index.vue
-->
<template>
    <div class="cpt-outter" v-loading="load">
        <v-label-div title="论坛正面话题对比" :showLine="false" :eStyle="{'border-style': 'none'}"/>
        <div class="cpt-inner">
            <div class="cpt-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 { getTopicPosAndTopicNeg0528C } from "@/api/ModelComparison";
import {createSideSingleColumn} from "@/utils/gol/sideSingleColumn"
export default {
    name: "comparisonOfPositiveTopicsInTheForum",
    data() {
        return {
            load: false,
            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);
            this.load = true;
            getTopicPosAndTopicNeg0528C(obj).then((res) => {
                let data = res.data || [];
                let arr = [];
                data.forEach((ele) => {
                    let z = ele.value[0].value || [];
                    let dx = [];
                    let ds = [];
                    z.forEach((e) => {
                        dx.push(e.key);
                        ds.push(e.value);
                    });
                    let obj = {
                        name: ele.key,
                        drawOpt: createSideSingleColumn(dx, ds, "#3373CC"),
                    };
                    arr.push(obj);
                });
                this.list = arr;
                this.load = false;
            });
        },
    },
}
</script>

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