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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<!-- 机巢详情列表 -->
<template>
  <common-title text="返回" :style="{ marginLeft: pxToRem(14) }" @details="detailsFun"></common-title>
  <div class="machine-nest-list">
    <MachineNestTotal @searchNickName="handleSearch" />
    <div class="content-wrapper">
      <div class="table-list">
        <div class="table-item" v-for="item in tableList">
          <img src="" alt="">
          <div class="middle">
            <div class="title">{{ item.nickname }}</div>
            <div class="number">飞行次数:{{ item.fly_count }}次 飞行里程:{{ item.flight_mileage }}km</div>
            <div class="result">任务成果:{{ item.accumulate_data }}个 飞行时长:{{ item.hour }}h</div>
          </div>
          <div class="right" :class="item.status==='WORKING'?'atcive':''" @click="signMachineNestClick(item)">
            {{ item.status==='OFFLINE'?'离线中':(item.status==='WORKING'?'作业中':'空闲中') }}
          </div>
        </div>
      </div>
      <div class="pagination-container">
        <el-pagination
          v-model:current-page="pageParams.current"
          v-model:page-size="pageParams.size"
          :total="pageParams.total"
          :page-sizes="[5, 10, 20]"
          layout="total, prev, pager, next"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          background
        />
      </div>
    </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 searchText = ref('');
// 分页参数
const pageParams = ref({
  current: 1,
  size: 8,
  total: 0
});
 
// 机巢列表
const tableList = ref([]);
// 机巢列表数据
const getTableList = () => {
  const params = {
    nickname: searchText.value,
    current: pageParams.value.current,
    size: pageParams.value.size
  };
  selectDevicePage(params).then((res) => {
    if (res.data.code !== 0) return;
    tableList.value = res.data.data.records;
    pageParams.value.total = res.data.data.total;
  });
};
 
// 搜索数据
const handleSearch = (name) => {
  searchText.value = name;
  pageParams.value.current = 1;
  tableList.value = [];
  getTableList();
}
 
// 分页方法
const handleSizeChange = (val) => {
  pageParams.value.size = val;
  pageParams.value.current = 1;
  getTableList();
};
 
const handleCurrentChange = (val) => {
  pageParams.value.current = val;
  getTableList();
};
 
// 单个机巢详情
const signMachineNestClick = (item) => {
  store.commit('setSingleUavHome', item);
}
 
// 返回
const detailsFun = () => {
  store.commit('setMachineNestDetail', false);
};
 
onMounted(() => {
  getTableList();
});
</script>
 
<style scoped lang="scss">
.machine-nest-list {
  font-family: YouSheBiaoTiHei, YouSheBiaoTiHei;
  margin-left: 29px;
  padding: 16px 16px;
  width: 390px;
  height: 838px;
  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;
  .content-wrapper {
    position: relative;
    height: calc(100% - 130px);
    .table-list {
      height: calc(100% - 50px);
      overflow-y: auto;
      font-family: Source Han Sans CN, Source Han Sans CN;
      font-weight: 500;
      font-size: 16px;
      color: #fff;
      .table-item {
        display: flex;
        justify-content: space-between;
        justify-items: center;
        align-items: center;
        margin-top: 10px;
        img {
          width: 48px;
          height: 48px;
        }
        .middle {
          .number,
          .result {
            font-size: 12px;
          }
        }
        .right {
          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%);
        }
      }
    }
    .pagination-container {
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      margin-top: 20px;
      display: flex;
      justify-content: center;
      
      :deep(.el-pagination) {
        --el-pagination-bg-color: transparent;
        --el-pagination-text-color: #fff;
        --el-pagination-button-color: #fff;
        --el-pagination-hover-color: #409eff;
        
        .el-pagination__total {
          color: #fff;
        }
        
        .btn-prev,
        .btn-next,
        .number {
          background-color: transparent;
          color: #fff;
          
          &:hover {
            color: #409eff;
          }
        }
        
        .is-active {
          color: #409eff;
        }
      }
    }
  }
}
</style>