index.vue 1001 Bytes
<template>
  <Chart :cdata="cdata" />
</template>

<script>
import Chart from "./Chart";
import work from "@/api/work";
export default {
  data() {
    return {
      cdata: {
        category: [],
        lineData: [],
        barData: [],
      },
    };
  },
  components: {
    Chart,
  },
  mounted() {
    window.addEventListener("resize", () => {
      this.submitViews();
    });
    this.submitViews();
  },
  methods: {
    async submitViews() {
      try {
        let { result: res } = await work.submitViews("A20");
        this.cdata.category = [];
        this.cdata.barData = [];
        this.cdata.lineData = [];
        res.map((item) => {
          return (
            this.cdata.category.push(item.areaName),
            this.cdata.barData.push(item.successCount),
            this.cdata.lineData.push(item.failureCount)
          );
        });
      } catch (error) {
        // this.$refs.msg.messageShow();
      }
    },
  },
};
</script>

<style lang="scss" scoped></style>