<template>
  <div class="top-panel" v-show="!appStore.mobile">
    <div class="top-panel__left">
      <div class="search-group">
        <el-input v-model="search" class="search-input" placeholder="请输入关键词" />
      </div>
    </div>
    <div class="top-panel__center">
      <!-- <div class="data_item">
        <span class="data_item__title">手持设备</span>
        <span class="data_item__value">{{ handDetectorCount }}</span>
        <span class="data_item__unit">台</span>
      </div> -->
      <div class="data_item">
        <span class="data_item__title">在线</span>
        <span class="data_item__value">{{ onlineCount }} / {{ handDetectorCount }}</span>
        <span class="data_item__unit">台</span>
      </div>
    </div>
  </div>
  <div class="top-right">
    <div class="normal-legend" :class="{'is-active': selectStatus.includes('normal')}" @click="toggleStatus('normal')">正常状态</div>
    <div class="fence-legend" :class="{'is-active': selectStatus.includes('fence')}" @click="toggleStatus('fence')">围栏报警</div>
    <div class="alarm-legend" :class="{'is-active': selectStatus.includes('alarm')}" @click="toggleStatus('alarm')">气体报警</div>
    <div class="offline-legend" :class="{'is-active': selectStatus.includes('offline')}" @click="toggleStatus('offline')">离线状态</div>
  </div>
</template>
<script lang="ts" setup>
import { ref, computed,defineModel } from 'vue'
import { useAppStore } from '@/store/modules/app'
const appStore = useAppStore()
var props = defineProps({
  handDetectorCount: {
    type: Number,
    default: 0
  },
  onlineCount: {
    type: Number,
    default: 0
  }
})
var search = defineModel('search',{
  type: String,
  default: ''
})
const selectStatus=defineModel('selectStatus',{
  type: Array,
  default: () => ['normal', 'offline', 'fence', 'alarm']
})
// var selectStatus = ref(['normal', 'offline'])
function toggleStatus(status: string) {
  if (selectStatus.value.includes(status)) {
    selectStatus.value = selectStatus.value.filter((item) => item !== status)
  } else {
    selectStatus.value.push(status)
  }
}
</script>
<style scoped lang="scss">
/* 顶部面板样式 */
.top-panel {
  position: absolute;
  top: 0px;
  left: 50px;

  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: space-between;
  // gap: 12px;
  padding: 6px 0px;
  flex-wrap: wrap;

  box-sizing: border-box;

  .top-panel__left {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 10px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
    height: 100%;
    width: 240px;
    margin-right: 12px;
    padding: 10px;
  }

  .top-panel__center {
    flex: 1 1 auto;
    display: flex;
    align-items: center;

    .data_item {
      box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
      // width: 200px;
      background: rgba(255, 255, 255, 0.9);
      border: 1px solid rgba(0, 0, 0, 0.06);
      border-radius: 8px;
      padding: 12px 20px;
      margin-right: 12px;

      .data_item__title {
        font-size: 14px;
        color: #3f3f3f;
        vertical-align: middle;
      }

      .data_item__value {
        display: inline-block;
        padding: 0 10px;
        font-size: 18px;
        font-weight: 600;
        color: #3399ff;
        vertical-align: middle;
      }
      .data_item__unit {
        font-size: 14px;
        color: #3f3f3f;
        vertical-align: middle;
      }
    }
  }
}
.top-right {
  position: absolute;
  top: 10px;
  right: 10px;

  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.06);
  padding: 8px 12px;
  border-radius: 8px;
  white-space: nowrap;

 
  .normal-legend,
  .fence-legend,
  .alarm-legend, .offline-legend  {
    position: relative;
    padding: 4px 8px;
    border-radius: 999px;
    color: #fff;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    user-select: none;
  }

  .normal-legend {
    background: #67c23a;
  }

  .fence-legend {
    background: #e6a23c;
  }

  .alarm-legend {
    background: #f56c6c;
  }
  .offline-legend {
    background: #909399;
    color: #fff;
  }
  .is-active::after{
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    font-size: 0;
    padding: 2px 2px 1px 2px;
    box-sizing: content-box;
    top: -2px;
    left: -3px;
    border-radius: 999px; 
    // border: 1px solid rgba(0, 0, 0, 0.5);
  }
  .normal-legend.is-active::after{
    border: 1px solid #67c23a;
  }
  .fence-legend.is-active::after{
    border: 1px solid #e6a23c;
  }
  .alarm-legend.is-active::after{
    border: 1px solid #f56c6c;
  }
  .offline-legend.is-active::after{
    border: 1px solid #909399;
  }
}
</style>
