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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<!-- 机巢头部统计 -->
<template>
  <div class="machine-nest-total">
    <div class="next-num">
      <div class="total">
        <div class="value">{{ total }}</div>
        <div class="name">机巢总数</div>
      </div>
      <div class="status">
        <div class="item" v-for="(item, index) in listNum" >
          <div>
            <div :style="{ color: item.color }" class="value">{{ item.value }}</div>
            <div class="name">{{ item.name }}</div>
          </div>
          <div class="right-line" v-if="index !== listNum.length - 1"></div>
        </div>
      </div>
    </div>
    <div class="search-box">
      <el-input v-model="searchNameText" placeholder="请输入机巢名称" class="input-with-select">
        <template #append>
          <el-button :icon="Search" @click="searchNickName"/>
        </template>
      </el-input>
    </div>
  </div>
</template>
 
<script setup>
import { Search } from '@element-plus/icons-vue';
import { getDeviceInfoNum } from '@/api/home/machineNest.js'
 
// 统计机巢总数
let total = ref(0);
// 机巢统计
let listNum = ref([
  { name: '空闲中', value: 0, color: '#8EFFAC' },
  { name: '作业中', value: 0, color: '#FFA768' },
  { name: '离线中', value: 0, color: '#FFFFFF' },
  // { name: '异常', value: 10, color: '#FF8E8E' },
]);
// 获取机巢列表
const getList = () => {
  getDeviceInfoNum().then((res) => {
    if (res.data.code !== 0) return;
    let result = res.data.data;
    listNum.value[0].value = result.leisure_num;
    listNum.value[1].value = result.ex_num;
    listNum.value[2].value = result.offline_num;
    total.value = result.device_num;
  });
}
 
// 机巢搜索名称
let searchNameText = ref('');
 
const emit = defineEmits(['searchNickName']);
// 搜索事件
const searchNickName = () => {
  emit('searchNickName', searchNameText.value);
};
 
onMounted(() => {
  getList();
});
</script>
 
<style scoped lang="scss">
.machine-nest-total {
  .next-num {
    width: 358px;
    height: 92px;
    background: url(@/assets/images/home/homeLeft/next-num.png) no-repeat center / 100% 100%;
    position: relative;
    .total {
      position: absolute;
      left: 22px;
      top: 28px;
      font-weight: 500;
      font-size: 14px;
      color: #ffffff;
      font-family: Source Han Sans CN, Source Han Sans CN;
      line-height: 19px;
      .value {
        font-family: YouSheBiaoTiHei, YouSheBiaoTiHei;
        font-size: 26px;
        text-align: center;
      }
    }
    .status {
      position: absolute;
      top: 16px;
      right: 30px;
      width: 200px;
      display: flex;
      justify-content: space-between;
      line-height: 30px;
      .item {
        display: flex;
        align-items: center;
      }
      .right-line {
        width: 0px;
        height: 36px;
        border-radius: 0px 0px 0px 0px;
        border: 1px solid;
        border-image: linear-gradient(180deg, rgba(27, 148, 255, 0), rgba(27, 148, 255, 1), rgba(27, 148, 255, 0)) 1 1;
        margin-left: 10px;
      }
      .name {
        text-align: center;
        width: 42px;
        font-family: Source Han Sans CN, Source Han Sans CN;
        font-weight: 400;
        font-size: 14px;
        color: #ffffff;
      }
      .value {
        text-align: center;
        width: 42px;
        font-weight: 400;
        font-size: 26px;
      }
    }
  }
  .search-box {
    margin-top: 19px;
    margin-right: 16px;
    :deep(.el-input__wrapper) {
      background-color: rgba(0, 112, 255, 0.1);
      background: rgba(0, 15, 34, 0.5);
      box-shadow: 0 0 0 1px #0070ff inset;
    }
 
    :deep(.el-input-group__append) {
      background: rgba(0, 112, 255, 0.38);
      .el-button {
        background-color: transparent;
        border: 1px solid #0070ff;
        border-left: none;
        color: #fff;
      }
    }
 
    :deep(.el-input__inner) {
      color: #fff;
      &::placeholder {
        color: rgba(255, 255, 255, 0.6);
      }
    }
  }
}
</style>