shj
2022-08-01 00d4082a1709e7c32e7fdefc815266a58d87bf8e
src/views/facilityManagement/EquipmentStatistics/index.vue
@@ -7,10 +7,36 @@
<script lang="ts">
import { defineComponent, onMounted, ref } from 'vue';
import * as echarts from 'echarts';
import { ElMessage } from 'element-plus';
import { facilityManagementApi } from '/@/api/facilityManagement';
export default defineComponent({
   setup() {
      const listApi = () => {
         facilityManagementApi()
            .getequipmentInfoStatistics()
            .then((res) => {
               if (res.data.code == 200) {
                  let arr=[]
                  arr=res.data.data
                  let date=[]
                  for (let i = 0; i < arr.length; i++) {
                     date.push(arr[i].count)
                  }
                  init(date);
               } else {
                  ElMessage({
                     showClose: true,
                     message: res.data.msg,
                     type: 'error',
                  });
               }
            });
      };
      onMounted(() => {
         listApi();
      });
      const main = ref();
      const init = () => {
      const init = (data:any) => {
         var myChart = echarts.init(main.value);
         var option = {
            tooltip: {},
@@ -35,7 +61,7 @@
            color: ['#6394f9'],
            series: [
               {
                  data: [120, 200, 150, 80, 70, 110, 130],
                  data: data,
                  type: 'bar',
               },
            ],
@@ -43,13 +69,11 @@
         myChart.setOption(option);
      };
      onMounted(() => {
         init();
      });
      return {
         init,
         onMounted,
         main,
         listApi,
      };
   },
});
@@ -57,7 +81,7 @@
<style scoped>
.box {
   background-color: #fff;
    box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
   box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
}
.title {
   font-size: 16px;