<template>
  <div v-if="isShow.showYj">
    <div class="comom-title" v-if="isShow.showYj">
      <div class="title">预警数据</div>
      <div class="expand-btn">
        <el-icon  size="20"><Close @click="closeWindow"/></el-icon>
      </div>
    </div>
    <div class="zdryBox">
      <div v-if="list.Info_YJ.length > 0" class="ryBox">
        <div v-for="(item, index) in list.Info_YJ" :key="index" @click="handleClick(item)">
          <DeployControlItem :item="item" :dict="{ D_BZ_HPZL }" />
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import emitter from "@/utils/eventBus.js";
import { ref, onMounted, onUnmounted, reactive, getCurrentInstance } from 'vue';
import DeployControlItem from "@/views/home/components/deployControlItem.vue";
const { proxy } = getCurrentInstance();
const { D_BZ_HPZL } = proxy.$dict('D_BZ_HPZL')
const isShow = ref({
  showYj: false, //预警弹窗
  showWarning: false
});
const ORDIMG = 'https://89.40.7.122:38496/image'
const IMGYM = 'https://sg.lz.dsj.xz/dhimage'
const list = reactive({
  Info_YJ: [], //预警数据
  Info_Warning: [],
});

onMounted(() => {
  emitter.on("yjShow", (res) => {
    isShow.value.showYj = res ? true : false;
    if (res) list.Info_YJ = res.map(item => {
      return {
        ...item,
        yjtp:item.yjtp.replace(ORDIMG, IMGYM),
        yjlx: '01'
      }
    });
  });
});

const handleClick = (val) => {
  emitter.emit("yjDetail", val);
}
onUnmounted(() => {
  emitter.off("yjShow");
});
const closeWindow = () => {
  isShow.value.showYj = false;
}

</script>

<style>
.el-loading-mask {
  background: rgba(0, 0, 0, 0.5);
}
</style>

<style lang="scss" scoped>
@import "@/assets/css/homeScreen.scss";

.zdryBox {
  background: #052249;
  min-height: 0;
 max-height:  300px;

  .ryBox {
 max-height:  300px;
    overflow: hidden;
    overflow-y: auto;
  }
}

::v-deep .el-checkbox {
  margin-right: 10px;
}



::-webkit-scrollbar {
  background-color: #263b70;
}

::-webkit-scrollbar-thumb {
  background-color: #146bbe;
}

::-webkit-scrollbar-track {
  background-color: #263b70;
}

::-webkit-scrollbar-corner {
  background-color: #142141;
}

::v-deep .el-checkbox__label {
  color: #fff;
}

::v-deep .el-checkbox__input.is-checked+.el-checkbox__label {
  color: #00FFFF;
}

::v-deep .el-checkbox__inner {
  background: rgba(0, 144, 255, 0.2);
  border: 1px solid #0072FF;
}

::v-deep .el-checkbox__input.is-checked .el-checkbox__inner {
  background-color: #00FFFF;
  border-color: #00FFFF;
}

::v-deep .el-checkbox__input.is-indeterminate .el-checkbox__inner {
  background-color: #00FFFF;
  border-color: #00FFFF;
}

::v-deep .el-checkbox__inner::after {
  border: 2px solid #000;
  border-left: 0;
  border-top: 0;
  left: 3px;
  top: 0px;
}

::v-deep .el-checkbox__input.is-indeterminate .el-checkbox__inner::before {
  background: #000;
}

.comom-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.expand-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  // background: linear-gradient(135deg, #0072FF 0%, #00B4FF 100%);
  // border-radius: 50%;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 114, 255, 0.3);
}

.expand-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 114, 255, 0.5);
}

.expand-btn:active {
  transform: scale(0.95);
}
</style>
