forked from drone/command-center-dashboard

罗广辉
2025-03-31 4f40148798c944eaddceb3539cfe0ecc1dab5266
src/views/Home/components/HomeLeft/InspectionRaskDetails.vue
@@ -1,10 +1,6 @@
<!-- 巡检任务详情 -->
<template>
  <common-title
    title="巡检任务情况"
    :style="{ marginLeft: pxToRem(14) }"
    @details="detailsFun"
  >
  <common-title title="巡检任务情况" :style="{ marginLeft: pxToRem(14) }" @details="detailsFun">
  </common-title>
  <div class="inspection-rask-details">
    <div class="inspection-num">
@@ -19,7 +15,7 @@
        </div>
      </div>
    </div>
    <CommonDateTime :style="{ top: pxToRem(19) }"></CommonDateTime>
    <CommonDateTime :style="{ top: pxToRem(19) }" v-model="newTime" @change="dateChange" />
    <div class="chart-container" ref="chartRef"></div>
  </div>
</template>
@@ -30,6 +26,10 @@
import CommonTitle from '@/components/CommonTitle.vue';
import CommonDateTime from '@/components/CommonDateTime.vue';
import { getJobNumBar, getJobStatistics, getTotalJobNum } from '@/api/home';
import dayjs from 'dayjs';
const currenDate = dayjs().format('YYYY-MM-DD');
const newTime = ref([currenDate, currenDate]);
const list = ref([
  { name: '计划执行', value: 89, color: '#FFFFFF',field:'planned_executions' },
@@ -121,11 +121,10 @@
      },
    },
  },
  series: [
    {
  series: {
      data: [
        10, 15, 8, 20, 12, 18, 15, 22, 16, 19, 14, 17, 21, 13, 16, 18, 15, 20, 17, 22, 19, 16, 14,
        18, 21, 15, 17, 20, 16, 18,
      10, 15, 8, 20, 12, 18, 15, 22, 16, 19, 14, 17, 21, 13, 16, 18, 15, 20, 17, 22, 19, 16, 14, 18,
      21, 15, 17, 20, 16, 18,
      ],
      type: 'bar',
      barWidth: '60%',
@@ -136,39 +135,53 @@
        ]),
      },
    },
  ],
};
const detailsFun = () => {
  console.log('details');
};
const dateChange = value => {
  newTime.value = value;
  getData();
};
let chart = null;
const getData = () => {
  const params = {
    date_enum: 'TODAY',
    // start_date: newTime.value[0],
    // end_date: newTime.value[1]
  };
  getJobStatistics(params).then(res => {
    jobStatistics.value = res.data?.data || {};
  });
  getJobNumBar(params).then(res => {
    option.xAxis.data = res.data?.data.map(item => item.name);
    option.series.data = res.data?.data.map(item => item.value);
    chart.setOption(option);
  });
};
const chartRef = ref(null);
const total = ref(0);
const jobStatistics = ref({
  "planned_executions": 0,
  "executed": 0,
  "running_num": 0,
  "failed_executions": 0,
  "pending_executions": 0
})
  planned_executions: 0,
  executed: 0,
  running_num: 0,
  failed_executions: 0,
  pending_executions: 0,
});
onMounted(() => {
  getTotalJobNum().then(res => {
    total.value = res.data?.data || 0
  })
  getJobStatistics().then(res => {
    jobStatistics.value = res.data?.data || {}
  })
  getJobNumBar().then(res => {
    console.log(res.data.data);
  })
  const chart = echarts.init(chartRef.value);
  chart.setOption(option);
  chart = echarts.init(chartRef.value);
  // 监听窗口大小变化
  window.addEventListener('resize', () => {
    chart.resize();
  });
  getTotalJobNum().then(res => {
    total.value = res.data?.data || 0;
  });
  getData();
});
</script>
@@ -186,11 +199,13 @@
  );
  border-radius: 0px 0px 0px 0px;
  opacity: 0.85;
  .inspection-num {
    background: url('@/assets/images/home/homeLeft/inspection-num.png') no-repeat center / 100% 100%;
    width: 360px;
    height: 118px;
    position: relative;
    .total {
      position: absolute;
      left: 34px;
@@ -201,12 +216,14 @@
      text-align: center;
      font-family: Source Han Sans CN, Source Han Sans CN;
      line-height: 19px;
      .value {
        font-family: YouSheBiaoTiHei, YouSheBiaoTiHei;
        margin-left: 8px;
        font-size: 26px;
      }
    }
    .status {
      position: absolute;
      top: 8px;
@@ -218,12 +235,14 @@
      justify-content: flex-start;
      line-height: 22px;
      padding: 0 10px 10px 0;
      .name {
        font-family: Source Han Sans CN, Source Han Sans CN;
        font-weight: 400;
        font-size: 14px;
        color: #ffffff;
      }
      .value {
        font-family: YouSheBiaoTiHei, YouSheBiaoTiHei;
        font-weight: 400;
@@ -231,6 +250,7 @@
      }
    }
  }
  .chart-container {
    width: 100%;
    height: 200px;