<!--
 * @Author: your name
 * @Date: 2021-10-16 14:47:23
 * @LastEditTime: 2021-10-16 14:54:34
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /data-show/src/views/BrandComparison/informationVolumeByChannel/index.vue
-->
<template>
  <div class="ivb-outter" v-loading="load">
    <v-label-div
      title="分渠道信息量"
      :showLine="false"
      :eStyle="{ 'border-style': 'none' }"
    />
    <div class="ivb-inner">
      <v-echarts :opt="opt"></v-echarts>
    </div>
  </div>
</template>

<script>
import { getSourcetypeC } from "@/api/ThemeComparisonRear";
import createOpt from "./opt";
export default {
  name: "informationVolumeByChannel",
  data() {
    return {
      opt: {},
      load: false,
      form: {
        token: "",
        sGuid: "",
        sTimeType: 3
      },
    };
  },
  created() {
    this.initData();
  },
  methods: {
    initData() {
      this.form.token = this.getToken;
      let arr = this.getTComparison;
      let sGuid = [];
      arr.forEach((ele) => {
          sGuid.push(ele.guids);
      });
      this.form.sGuid = sGuid.toString();
      this.getData();
    },
    getData() {
      return new Promise((resolve, reject) => {
        let obj = Object.assign({}, this.getCtime2, this.form);
        this.load = true;
        getSourcetypeC(obj)
          .then((res) => {
            let data = res.data || [];
            let brandList = [];
            let dx = [];
            data.forEach((e) => {
              let ab = e.Data || {};
              for (let key in ab) {
                if (!dx.includes(key)) {
                  dx.push(key);
                }
              }
              brandList.push(e.Name);
            });
            this.opt = createOpt(data, dx, brandList);
            this.load = false;
            resolve(data);
          })
          .catch(() => {
            reject(false);
          });
      });
    },
  },
};
</script>

<style lang="less" scoped>
.ivb-outter {
  width: 944px;
  height: 412px;
  .ivb-inner {
    width: 100%;
    height: calc(100% - 48px);
  }
}
</style>
