index.vue 1.21 KB
<!--
 * @Description:
 * @Autor: renchao
 * @LastEditTime: 2023-07-04 13:54:34
-->
<template>
  <!-- 登记类型总量 -->
  <Chart :cdata="cdata" />
</template>
<script>
  import Chart from "./Chart";
  import work from "@/api/work";
  export default {
    data () {
      return {
        cdata: {
          timer: null,
          category: [],
          lineData: []
        }
      }
    },
    components: {
      Chart
    },
    mounted () {
      this.getDjlxtotal()
      this.timer = setInterval(() => {
        this.getDjlxtotal()
      }, 10000) // 10s
    },
    methods: {
      /**
       * @description: getDjlxtotal
       * @author: renchao
       */
      getDjlxtotal () {
        return new Promise(async (resolve) => {
          try {
            let p = {
              DJLX: "",
              QLLX: "",
              XZQDM: "",
            };
            let res = await work.getDjlxtotal(p)
            this.cdata.category = res.result.map(item => item.AREACODE)
            this.cdata.lineData = res.result.map(item => item.ywtotal)
          } catch (error) {
            this.$refs.msg.messageShow()
          }
        })
      }
    },
    destroyed () {
      clearInterval(this.timer)
    }
  };
</script>