forked from drone/command-center-dashboard

chenyao
2025-04-09 cc1aacf766bc902001f460fdfce20a9ec2ea097d
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<!-- 机巢概况 -->
<template>
  <common-title title="机巢概况" :style="{ marginLeft: pxToRem(14) }" @details="detailsFun"></common-title>
  <div class="overview-next">
    <MachineNestTotal @searchNickName="handleSearch" />
    <div class="table-list">
      <div class="table-header">
        <div class="name">机巢名称</div>
        <div class="status">机巢状态</div>
      </div>
      <div class="table-body" v-if="tableList.length > 0"
        infinite-scroll-distance="6"
        v-infinite-scroll="loadMore"
        :infinite-scroll-disabled="busy"
        infinite-scroll-immediate="true">
        <div class="table-item" v-for="item in tableList">
          <div class="name">
            <!-- <img class="yjzx-img" width="10" height="10" src="@/assets/images/home/homeLeft/table-zx.png" alt="" /> -->
            <img width="13" height="15" src="../../../assets/images/home/homeLeft/table-icon.png" alt="" />
            {{ item.nickname }}
          </div>
          <div class="status" :class="item.status==='WORKING'?'atcive':''" @click="signMachineNestClick(item)">
            {{ item.status==='OFFLINE'?'离线中':(item.status==='WORKING'?'作业中':'空闲中') }}
          </div>
        </div>
      </div>
      <el-empty class="custom-empty" v-else>
        <template #description>
          <span class="custom-text">暂无数据</span>
        </template>
      </el-empty>
    </div>
  </div>
</template>
<script setup>
import CommonTitle from '@/components/CommonTitle.vue';
import MachineNestTotal from './components/MachineNestTotal.vue';
import { selectDevicePage } from '@/api/home/machineNest.js'
import { useStore } from 'vuex';
 
const store = useStore();
 
const isMore = ref(true);
// 控制加载状态
const busy = ref(false);
const searchText = ref('');
// 分页参数
const pageParams = ref({
  current: 1,
  size: 5,
  total: 0
});
// 机巢列表
const tableList = ref([]);
// 机巢列表数据
const getTableList = () => {
  const params = {
    nickname: searchText.value,
    is_execute: true,
    current: pageParams.value.current,
    size: pageParams.value.size
  };
  selectDevicePage(params).then((res) => {
    if (res.data.code !== 0) return;
    if (res.data.data.records.length === 0) return (isMore.value = false);
    pageParams.value.current += 1;
    tableList.value = [...tableList.value, ...res.data.data.records];
    busy.value = false;
  });
}
 
// 加载更多数据
const loadMore = async () => {
    busy.value = true;
    if (!isMore.value) return;
    getTableList();
};
 
// 搜索数据
const handleSearch = (name) => {
  searchText.value = name;
  pageParams.value.current = 1;
  tableList.value = [];
  isMore.value = true
  getTableList();
}
 
// 单个机巢详情
const signMachineNestClick = (item) => {
  store.commit('setSingleUavHome', item);
}
 
const detailsFun = () => {
  store.commit('setMachineNestDetail', true);
};
 
onMounted(() => {
  getTableList();
});
</script>
<style scoped lang="scss">
.overview-next {
  font-family: YouSheBiaoTiHei, YouSheBiaoTiHei;
  margin-left: 29px;
  padding: 16px 16px;
  width: 390px;
  height: 414px;
  background: linear-gradient(
    270deg,
    rgba(31, 62, 122, 0) 0%,
    rgba(31, 62, 122, 0.35) 21%,
    #1f3e7a 100%
  );
  border-radius: 0px 0px 0px 0px;
  opacity: 0.85;
  margin-bottom: 10px;
 
  .table-list {
    font-family: Source Han Sans CN, Source Han Sans CN;
    margin: 16px;
    font-weight: 500;
    font-size: 16px;
    height: 220px;
    .table-header,
    .table-item {
      display: flex;
      justify-content: space-between;
      height: 36px;
      line-height: 36px;
      padding: 0 20px;
    }
    .table-header {
      background: linear-gradient( 90deg, rgba(12,45,92,1) 0%, #0C3B78 50%, rgba(12,45,92,1) 100%), linear-gradient( 90deg, rgba(12,45,92,1) 0%, rgba(12,45,92,1) 50%, rgba(12,45,92,1) 100%);
      border-radius: 0px 0px 0px 0px;
      // border: 1px solid;
    }
    .table-body {
      height: 190px;
      overflow: auto;
      &::-webkit-scrollbar {
        width: 0;
        display: none;
      }
      -ms-overflow-style: none;  /* IE and Edge */
      scrollbar-width: none;  /* Firefox */
    }
    .table-item {
      position: relative;
      .yjzx-img {
        position: absolute;
        top: 14px;
        left: 10px;
      }
      .status {
        color: #6fc3ff;
        cursor: pointer;
      }
      .atcive {
        color: #04f020;
        background: linear-gradient( 90deg, rgba(12,45,92,1) 0%, #154671 50%, rgba(12,45,92,1) 100%), linear-gradient( 90deg, rgba(12,45,92,1) 0%, rgba(12,45,92,1) 50%, rgba(12,45,92,1) 100%);
      }
    }
    .custom-empty {
      margin: 16px 0;
      padding: 0;
      :deep(.el-empty__image) {
        width: 100px;
        height: 100px;
      }
    }
  }
}
</style>