<!--
 * @Author: your name
 * @Date: 2021-10-15 15:34:26
 * @LastEditTime: 2021-11-11 14:27:39
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /data-show/src/views/BrandComparison/keyMediaCommunicationComparison/index.vue
-->
<template>
    <div class="kmcc-outter" v-loading="load">
        <v-label-div title="重点媒体传播对比"> </v-label-div>
        <div class="kmcc-inner">
            <v-echarts :opt="opt"></v-echarts>
        </div>
    </div>
</template>

<script>
import createOpt from "./opt";
import { getSourceCount0528C } from "@/api/BrandComparison";
export default {
    name: "kmcc-outter",
    data() {
        return {
            load: false,
            form: {
                token: "",
                sBrand: "",
                sSeriesName: "",
                iContrastType: 2,
            },
            opt: {},
        };
    },
    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;
            getSourceCount0528C(obj).then((res) => {
                let data = res.data;
                let dx = [];
                let ds = [];
                data.forEach((ele) => {
                    let key = ele.key;
                    let value = ele.value;
                    dx.push(key);
                    ds.push(value);
                });
                this.opt = createOpt(dx, ds);
                this.load = false;
            });
        },
    },
};
</script>

<style lang="less" scoped>
.kmcc-outter {
    width: 936px;
    height: 460px;
    border: 2px solid #0f2a4d;
    margin-left: 16px;
    .kmcc-inner {
        width: 100%;
        height: calc(100% - 48px);
    }
}
</style>
