<template>
  <div
    class="dialogBox"
    :style="`left:${elLeft}px;top:${elTop}px`"
    draggable="true"
    ref="dialogBoxYpfx"
    @dragstart="dragstart($event)"
    @dragend="dragend($event)"
  >
    <div class="title">
      <span class="mc">{{ props.data.jzMc ? props.data.jzMc : props.data.fzrXm + "巡组" }}</span>
      <span @click="close" class="close">
        <el-icon><Close /></el-icon>
      </span>
    </div>
    <div class="info-Big-Box noScollLine">
      <div class="infoBox">
        <div class="xlStatus" :class="props.data.xfzt == 1 ? 'lineing' : props.data.xfzt == 2 ? 'unline': 'line'">
          {{props.data.xfzt == 1? "处警中": props.data.xfzt == 2? "离线": "巡逻中"}}
        </div>
        <div class="text">
          负责人：<span class="tag mj">民警</span>
          <el-tooltip :content=" '身份证号： ' + props.data.fzrSfzh  " placement="bottom">
            <span class="name">{{ props.data.fzrXm }} ({{ props.data.fzrLxdh }})</span>
          </el-tooltip>
        </div>
        <div class="text">
          开始时间：<span class="name">{{ props.data.bbkssj }}</span>
        </div>
        <div class="time">
          (计划 ( {{ props.data.kssj }} ~ {{ props.data.jssj }} )
        </div>
        <div class="text">
          组员：
          <span v-for="(item, index) in props.data.pbmj" :key="index" class="jc_box">
            <span class="tag mj">民警</span>
            <span class="name">{{ item.jlxm }}</span>
          </span>
          <span v-for="(item, index) in props.data.pbfj" :key="index" class="jc_box">
            <span class="tag fj">辅警</span>
            <span class="name">{{ item.jlxm }}</span>
          </span>
        </div>
        <div class="text">
          单位：<span class="name">{{ props.data.ssbm }}</span>
        </div>
        <div class="text zblist" v-if="props.data.txzb.length <= 0">
          通讯装备：<span>暂无数据</span>
        </div>

        <div class="text zblist" v-else>
          <el-collapse v-model="props.data.openTxzb">
            <el-collapse-item title="通讯装备：" name="1">
              <span class="zb-item" v-for="(item, index) in props.data.txzb" :key="index">
                <span class="sbinfo">{{ item.sbmc }}</span>
                <el-tooltip :content="'呼叫(' + item.hh + ')'" placement="bottom">
                  <img style="width: 22px"  @click="getZFJLY(item)"/>
                </el-tooltip>
              </span>
            </el-collapse-item>
          </el-collapse>
        </div>

        <div class="text zblist" v-if="props.data.jyqx.length <= 0">
          常用装备：<span>暂无数据</span>
        </div>

        <div class="text zblist" v-else>
          <el-collapse v-model="props.data.openJyqx">
            <el-collapse-item title="常用装备：" name="1">
              <span class="zb-item" v-for="(item, index) in props.data.jyqx" :key="index">
                <span class="qxinfo">{{ item.qxmc }}（{{ item.qxsl }}）个</span>
              </span>
            </el-collapse-item>
          </el-collapse>
        </div>
        <div class="text zblist">
          警用车辆：
          <span class="zb-item" v-for="(item, index) in props.data.pbcl" :key="index">
            <span class="qxinfo">{{ item.jdchphm }}</span>
          </span>
          <span v-if="props.data.pbcl.length <= 0">暂无</span>
        </div>
        <div class="text" v-if="props.data.bz != ''">
          备注： <span class="name">{{ props.data.bz }}</span>
        </div>
      </div>
    </div>
    <el-popover placement="bottom" :visible="visible" :width="476" :append-to-body="false">
        <template #reference>
          <div class="btnBox">
            <button class="dp-default small" @click="onClickZbyj">周边预警</button>
            <button class="dp-default small" @click="onClickSpsd">视频随动</button>
          </div>
        </template>
    </el-popover>
  </div>
</template>

<script setup>
import Axios from "axios";
import { qcckPost,qcckGet} from "@/api/qcckApi.js";
import { ref, onMounted, onUnmounted, defineProps, getCurrentInstance, watch } from "vue";
import { timeValidate } from "@/utils/time.js";
import emitter from "@/utils/eventBus.js";
import { ElMessage } from "element-plus";
import { useRouter } from "vue-router";
import { all } from "ol/events/condition";
const { proxy } = getCurrentInstance();
const props = defineProps({
  data: {
    type: Object,
    default: {}
  }
});
const visible = ref(false);
const dialogBoxYpfx = ref();
const initWidth = ref(0); //父元素宽度
const initHeight = ref(0); //父元素高度
const startClientX = ref(0); //元素拖拽前距离浏览器X轴位置
const startClientY = ref(0); //元素拖拽前距离浏览器Y轴位置
const elLeft = ref(400); //元素左偏移量
const elTop = ref(120); //元素右偏移量
watch(
  () => props.data,
  (val) => {
    visible.value = false;
  },{
    immediate:true,
    deep:true
  }
);
onMounted(() => {
  initBodySize();
});


//初始化
const initBodySize = () => {
  initWidth.value = dialogBoxYpfx.value.clientWidth;
  initHeight.value = dialogBoxYpfx.value.clientHeight;
};
//拖拽开始
const dragstart = (e) => {
  startClientX.value = e.clientX;
  startClientY.value = e.clientY;
};
//拖拽结束
const dragend = (e) => {
  let x = e.clientX - startClientX.value;
  let y = e.clientY - startClientY.value;
  elLeft.value += x;
  elTop.value += y;
};

//关闭弹窗
function close() {
  visible.value = false;
}


</script>

<style lang="scss" scoped>
@import "@/assets/css/homeScreen.scss";
.dialogBox {
  position: absolute;
  padding: 0;
  width: 484px !important;
  .title {
    border-bottom: 1px solid #275288;
    margin-bottom: 6px;
    .mc {
      margin-left: 10px;
    }
  }
  .info-Big-Box {
    max-height: 70vh;
    overflow: hidden;
    overflow: auto;
    padding: 4px 10px;
    box-sizing: border-box;
  }
  .infoBox {
    position: relative;
    padding: 10px !important;
    .text {
      color: #00bfff;
      line-height: 26px;
    }
    .tag {
      margin: 0 4px;
    }
    .name {
      color: #fff;
    }
    .time {
      color: #3ad2d4;
    }
    .jc_box {
      margin: 0 4px;
    }
    .zblist {
      display: flex;
      flex-wrap: wrap;
      .zb-item {
        margin-right: 10px;
        .sbinfo {
          color: yellow;
        }
        img {
          margin-left: 4px;
          cursor: pointer;
        }
        .qxinfo {
          color: rgb(127, 177, 217);
          padding: 2px 4px;
          border: 1px solid rgb(61, 116, 219);
          border-radius: 4px;
          display: inline;
          white-space: nowrap;
        }
      }
    }
  }
}
.all-dialog .dialogBox > .btnBox {
  padding-top: 0;
  padding-bottom: 0;
}
.timeBox{
  width: 100%;
  display: flex;
  align-items: center;
  .time1{
    margin: 0 10px;
    text-align: center;
    color: #fff;
  }
}

::v-deep .el-collapse{
  width: 100%;
  --el-collapse-header-height:auto;
  --el-collapse-header-bg-color:transparent;
  --el-collapse-border-color:transparent;
}
::v-deep .el-collapse-item__header{
  color: #00bfff;
}
::v-deep .el-collapse-item__wrap{
  background-color:transparent;
}
::v-deep .el-collapse-item__content {
  color: #fff;
  padding-bottom: 0;
}
.null{
  text-align: center;
}

</style>
