forked from drone/command-center-dashboard

罗广辉
2025-04-07 da2a4e58ecc7c5da0a3ec726708a16c21e7f60e3
src/views/Home/HomeLeft/OverviewNext.vue
@@ -2,25 +2,7 @@
<template>
  <common-title :style="{ marginLeft: pxToRem(14) }" @details="detailsFun"></common-title>
  <div class="overview-next">
    <div class="next-num">
      <div class="total">
        <div class="value">{{ total }}</div>
        <div class="name">机巢总数</div>
      </div>
      <div class="status">
        <div v-for="item in listNum">
          <div :style="{ color: item.color }" class="value">{{ item.value }}</div>
          <div class="name">{{ item.name }}</div>
        </div>
      </div>
    </div>
    <div class="search-box">
      <el-input v-model="searchText" placeholder="请输入机巢名称" class="input-with-select">
        <template #append>
          <el-button :icon="Search" @click="searchNickName"/>
        </template>
      </el-input>
    </div>
    <MachineNestTotal @searchNickName="handleSearch" />
    <div class="table-list">
      <div class="table-header">
        <div class="name">机巢名称</div>
@@ -51,39 +33,17 @@
  </div>
</template>
<script setup>
import { Search } from '@element-plus/icons-vue';
import CommonTitle from '@/components/CommonTitle.vue';
import { getDeviceInfoNum, selectDevicePage } from '@/api/home/machineNest.js'
import MachineNestTotal from './components/MachineNestTotal.vue';
import { selectDevicePage } from '@/api/home/machineNest.js'
import { useStore } from 'vuex';
const store = useStore();
// 统计机巢总数
let total = ref(0);
// 机巢统计
let listNum = ref([
  { name: '空闲中', value: 89, color: '#FFA768' },
  { name: '作业中', value: 100, color: '#8EFFAC' },
  { name: '离线中', value: 66, 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.ex_num;
    listNum.value[1].value = result.leisure_num;
    listNum.value[2].value = result.offline_num;
    total.value = result.device_num;
  });
}
const isMore = ref(true);
// 控制加载状态
const busy = ref(false);
// 机巢搜索名称
let searchText = ref('')
const searchText = ref('');
// 分页参数
const pageParams = ref({
  current: 1,
@@ -96,13 +56,12 @@
const getTableList = () => {
  const params = {
    nickname: searchText.value,
    is_execute: false,
    type: 1,
    is_execute: true,
    current: pageParams.value.current,
    size: pageParams.value.size
  };
  selectDevicePage(params).then((res) => {
    // if (res.data.code !== 0) return;
    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];
@@ -118,7 +77,8 @@
};
// 搜索数据
const searchNickName = () => {
const handleSearch = (name) => {
  searchText.value = name;
  pageParams.value.current = 1;
  tableList.value = [];
  isMore.value = true
@@ -131,11 +91,10 @@
}
const detailsFun = () => {
  console.log('details');
  store.commit('setMachineNestDetail', true);
};
onMounted(() => {
  getList();
  getTableList();
});
</script>
@@ -155,72 +114,7 @@
  border-radius: 0px 0px 0px 0px;
  opacity: 0.85;
  margin-bottom: 10px;
  .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;
      .name {
        font-family: Source Han Sans CN, Source Han Sans CN;
        font-weight: 400;
        font-size: 14px;
        color: #ffffff;
      }
      .value {
        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);
      }
    }
  }
  .table-list {
    font-family: Source Han Sans CN, Source Han Sans CN;
    margin: 16px;