forked from drone/command-center-dashboard

罗广辉
2025-04-21 2800fa4f32f3900509cb4d6eefaf2bfaf54efdd7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!-- 任务统计 -->
<template>
  <div class="task-total">
    <div class="total">
      <div class="txt">总任务数</div>
      <div class="num">{{ total }}</div>
      <img src="@/assets/images/task/total.png" alt="">
    </div>
    <div class="other-total">
      <div class="total" v-for="item in list">
        <div class="value" :style="{ color:item.color }">{{ item.value }}</div>
        <div class="name">{{ item.name }}</div>
      </div>
    </div>
  </div>
</template>
 
<script setup>
import { pxToRem } from '@/utils/rem';
import { totalJobNum, jobStatistics  } from "@/api/home/task";
 
const total = ref(0);
const list = ref([
  { name: '计划执行', value: '0', color: '#FFFFFF'},
  { name: '执行中', value: '0', color: '#FFA768'},
  { name: '待执行', value: '0', color: '#FFE17E'},
  { name: '已执行', value: '0', color: '#8EFFAC'},
  { name: '执行失败', value: '0', color: '#FF8E8E'},
]);
 
// 获取任务统计总数
const getTotalJobNum = () => {
  totalJobNum().then((res) => {
    if (res.data.code !== 0) returen;
    total.value = res.data.data;
  });
};
// 获取其他任务统计
const getJobStatistics = () => {
  jobStatistics().then((res) => {
    if (res.data.code !== 0) returen;
    list.value[1].value = res.data.data.planned_executions;
    list.value[2].value = res.data.data.running_num;
    list.value[3].value = res.data.data.pending_executions;
    list.value[4].value = res.data.data.executed;
    // list.value[5].value = res.data.data.failed_executions;
  });
};
 
onMounted(() => {
  getTotalJobNum();
  getJobStatistics();
});
</script>
 
<style lang="scss" scoped>
.task-total {
  font-family: YouSheBiaoTiHei, YouSheBiaoTiHei;
  display: flex;
  justify-content: space-between;
  color: #ffffff;
  .total {
    position: relative;
    text-align: center;
    left: 18px;
    .txt {
      font-size: 16px;
      margin-bottom: 14px;
      margin-top: 40px;
    }
    img { width: 160px; height: 110px;}
    .num {
      width: 100px;
      position: absolute;
      font-size: 32px;
      top: 90px;
      left: 24px;
    }
  }
  .other-total {
    width: 256px;
    height: 188px;
    background: url('@/assets/images/task/other-total.png') no-repeat center / 100% 100%;
    margin-top: 22px;
    padding: 20px;
    display: flex;
    flex-wrap: wrap;
    align-content: space-around;
    .total {
      position: static;
      width: 30%;
      text-align: center;
      left: 0;
      .name {
        font-size: 14px;
      }
      .value {
        font-size: 26px;
      }
    }
  }
}
</style>