<template>
  <div class="uav-list" :class="{ collapse: collapseFlag }">
    <img
      @click="collapseFlagfn"
      v-if="collapseFlag"
      style="transform: rotate(180deg)"
      src="./assets/images/hs.png"
      class="icon-collapse uav-list_btn"
    />
    <img
      @click="collapseFlagfn"
      v-else
      src="./assets/images/collapse.png"
      class="icon-collapse uav-list_btn"
    />
    <div class="uav-list-header">
      <img class="uav-list-header__icon" src="./assets/images/uav_list_header.png" />
      <span class="uav-list-header__text">无人机列表</span>
    </div>
    <div class="uav-search">
      <el-input
        class="uav-search__input"
        clearable
        placeholder="请输入无人机名称/机构名称"
        v-model="uavSearchContent"
        v-on:keyup.enter.native="onUavSearch"
      >
        <i
          slot="suffix"
          class="el-input__icon el-icon-search"
          style="color: rgba(123, 181, 213, 1)"
        ></i>
      </el-input>
      <el-button class="uav-search__btn" @click="onUavSearch">搜索</el-button>
    </div>
    <List
      class="uav-list-main"
      @exit
      :containerStyle="{
          width: '400PX',
          height: '275px',
        }"
      :list="uavList"
      @refresh="onUavSearch"
    />
    <div></div>
  </div>
</template>

<script>
import { Control_API } from "../../../../api";
import List from "./components/list";
import data from "./data.json";

export default {
  components: {
    List,
  },
  data() {
    return {
      uavList: [], // 无人机列表
      collapseFlag: false, // 收起列表按钮
      uavSearchContent: "", // 无人机搜索内容
    };
  },
  mounted() {
    // this.uavList = data.data;
    this.initList();
  },
  methods: {
    async initList() {
      let res = await Control_API.getUavTree({ name: this.uavSearchContent });
      this.uavList = res.data;
    },
    collapseFlagfn() {
      this.collapseFlag = !this.collapseFlag;
    },
    /**
     * 无人机搜索
     */
    onUavSearch() {
      this.initList();
    },
  },
};
</script>

<style lang="scss" scoped>
.collapse {
  transform: translateX(-100%);
  transition: 0.3s;
}

.uav-list {
  display: flex;
  flex-direction: column;
  padding-bottom: 10px;
  position: absolute;
  width: 460px;
  height: 85%;
  left: 0;
  top: 60px;
  // height: 86vh;
  z-index: 99;
  transition: 0.3s;
  background: rgba(9, 32, 87, 0.7);
  border-radius: 10px 10px 0px 0px;
  // border: 1px solid #70daf9;
  .uav-list_btn {
    position: absolute;
    cursor: pointer;
    right: -22px;
    top: 50%;
    transform: translate(0, -50%);
    z-index: 99;
  }
}

.uav-list-header {
  flex-shrink: 0;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  width: 460px;
  height: 33px;
  background: linear-gradient(
    180deg,
    #9198ff 0%,
    rgba(45, 81, 153, 0.45) 40%,
    #05091a 100%
  );
  box-shadow: inset 0px 0px 10px 2px #3f9dff;
  border-radius: 10px 10px 0px 0px;
  border: 1px solid #427dff;

  .uav-list-header__text {
    font-size: 20px;
    font-family: YouSheBiaoTiHei;
    color: #14faff;
    line-height: 26px;
    text-shadow: 0px 1px 1px rgba(2, 32, 56, 0.2);
    background: linear-gradient(
      135deg,
      #f7b67d 38%,
      #f9eacb 58%,
      #f5d2a6 79%,
      #f59743 100%
    );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }

  .uav-list-header__icon {
    width: 26px;
    margin-left: 9px;
  }
}

::v-deep .uav-search {
  flex-shrink: 0;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  // margin-bottom: 7px;
  margin-top: 14px;

  .uav-search__input {
    width: 317px;
    height: 32px;
    box-shadow: 0px 2px 4px 0px rgba(28, 94, 124, 0.5),
      inset 0px 0px 3px 0px #00b6ff;
    border-radius: 4px;

    .el-input__icon {
      line-height: 32px;
    }

    input {
      height: 32px;
      background: #02173d;
      color: #43deff;
      border: 1px solid #315ec7;

      &::placeholder {
        font-size: 12px;
        color: #7bb5d5;
      }
    }
  }

  .uav-search__btn {
    padding: 7px 25px 6px 26px;
    // background: rgba(38, 71, 238, 0.71);
    background: url("./assets/images/twobg.png");
    border-radius: 4px;
    border: 1px solid;
    font-size: 14px;
    color: #fff;
  }
}

.uav-list-main {
  margin-top: 20px;

  /* 滚动条整体样式 */
  &::-webkit-scrollbar {
    width: 10px; /* 滚动条宽度 */
  }

  /* 滚动条滑块样式 */
  &::-webkit-scrollbar-thumb {
    background-color: #02173d; /* 滑块颜色 */
  }

  /* 滚动条滑块悬停样式 */
  &::-webkit-scrollbar-thumb:hover {
    background-color: #112d5b; /* 悬停时滑块颜色 */
  }

  &::-webkit-scrollbar-track-piece {
    /* background-color: #182F5C; */
  }

  &::-webkit-scrollbar-track {
    background-color: #182f5c;
  }
}
</style>