index.vue 1.24 KB
<!--
 * @Description: 
 * @Autor: renchao
 * @LastEditTime: 2023-07-04 13:48:00
-->
<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: {
      getDjlxtotal () {
        return new Promise(async (resolve) => {
          try {
            let p = {
              DJLX: "",
              QLLX: "",
              XZQDM: "",
            };
            let res = await work.getDjlxtotal(p);
            res.result.map((item) => {
              return (
                this.cdata.category.push(item.AREACODE),
                this.cdata.lineData.push(item.ywtotal)
              );
            });
          } catch (error) {
            this.$refs.msg.messageShow();
          }
        });
      }
    },
    destroyed () {
      clearInterval(this.timer)
    }
  };
</script>
<style lang="scss" scoped>
</style>