<template>
  <div>
    <Chart :cdata="cdata" />
  </div>
</template>

<script>
import Chart from './chart.vue';
import {getAction} from "@api/manage";
export default {
  data () {
    return {
      cdata: {
        // xData: ["data1", "data2", "data3", "data4", "data5"],
        seriesData: [
          { value: 10, name: "data1" },
          { value: 5, name: "data2" },
          { value: 15, name: "data3" },
          { value: 25, name: "data4" },
          { value: 20, name: "data5" }
        ]
      },
      url: {
        queryDevice: "/device/buDevice/queryDevice",
      },
    }
  },
  components: {
    Chart,
  },
  methods: {
    get(){
      setTimeout(() => {
        let param = {};
        getAction(this.url.queryDevice, param, 'get').then((res) => {
          const { cdata } = this
          this.cdata.seriesData = res.result
          this.cdata = { ...this.cdata }
        })
      }, 500)
    }
  },
  mounted () {
    let that = this
    that.get()
    // 定时请求数据
    this.timer = setInterval(this.get, 1000 * 60 * 30)
  },
  beforeDestroy () {
    clearInterval(this.timer)
  }
}
</script>

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