<template>
  <MapPopup ref="MapPopup" :id="id" :mapContainerId="'cesiumContainer'">
    <!-- <div class="popup-container">
      <div class="popup-title">
        <div class="title_content">（污水）[YYSK12]-[YYSK11]</div>
        <div class="page-btn">
          <span class="page-control el-icon-caret-left" @click="prePage()"></span>
          <span>{{page}}</span>
          <span class="page-control el-icon-caret-right" @click="nextPage()"></span>
        </div>
      </div>
      <div class="content_base">
        <span>等级：--</span>
        <span>管径：--</span>
        <span>管道长度：--</span>
        <span>材质：--</span>
      </div>
      <div class="content_info">
        <p>缺陷类型：<span style="font-weight:600">污水直排</span></p>
        <p>告警监测点：监测点1（管网水质监测仪）<span class="iconfont iconqidian1 location-btn"></span></p>
        <p>监测点距离管线：2.36km（位于管网下游）</p>
        <p>最近告警日期：2021-07-14</p>
        <p class="cause">告警原因，告警原因告警原因</p>
      </div>
    </div> -->
    <div class="popup-container">
      <div class="popup-title">
        <div class="title_content">（{{currentPage.drainageType||'未知'}}）{{currentPage.pipeNo}}</div>
        <div class="page-btn">
          <span class="page-control el-icon-caret-left" @click="prePage()" :style="{color:currentIndex==0?'#dadada':''}"></span>
          <span>{{page}}</span>
          <span class="page-control el-icon-caret-right" @click="nextPage()" :style="{color:currentIndex==(data.length-1)?'#dadada':''}"></span>
        </div>
      </div>
      <div class="content_base">
        <span>等级：{{currentPage.pipeDiameter||'--'}}</span>
        <span>管径：{{currentPage.pipeDiameter||'--'}}</span>
        <span>管道长度：{{currentPage.pipeLength||'--'}}m</span>
        <span>材质：{{currentPage.texture||'--'}}</span>
      </div>
      <div class="content_info">
        <p>缺陷类型：<span style="font-weight:600">{{currentPage.hiddenDangerType||'--'}}</span></p>
        <p>告警监测点：{{currentPage.siteName||'--'}}（{{currentPage.deviceTypeName||'--'}}）
          <span class="iconfont iconqidian1 location-btn"></span></p>
        <p>监测点距离管线：{{currentPage.monitorLocation||'--'}}</p>
        <p>最近告警日期：{{currentPage.monitorDate||'--'}}</p>
        <p class="cause">告警原因：{{currentPage.warningCause||'--'}}</p>
      </div>
    </div>
  </MapPopup>
</template>

<script lang="ts">
import MapPopup from '@/components/ComPopup/index.vue'
import { Vue, Component, Prop, Watch } from 'vue-property-decorator'
//属性查看
@Component({ name: 'serachInfo', components: { MapPopup } })
export default class serachInfo extends Vue {
  position: Array<any> = []
  id = 'hhh'
  data: Array<any> = []
  // 当前值索引
  currentIndex: any = 0
  //分页情况
  page: String = ''
  // 当前页数据
  currentPage: Object = {}

  @Watch('currentIndex')
  showApplyChange(val) {
    this.page = `${val + 1}/${this.data.length}`
    this.currentPage = this.data[val]
  }

  mounted() {
    console.log('》》》》',this.position);
    
    this.initInfoPop(this.position)
    this.page = `${1}/${this.data.length}`
    this.currentPage = this.data[this.currentIndex]
  }

  initInfoPop(position) {
    ;(this.$refs['MapPopup'] as any).initBox()
    ;(this.$refs['MapPopup'] as any).setPosition(position)
  }

  remove() {
    ;(this.$refs['MapPopup'] as any).remove()
  }
  /**
   * 上一页
   */
  prePage() {
    if (this.currentIndex == 0) return
    else this.currentIndex -= 1
  }
  /**
   * 下一页
   */
  nextPage() {
    if (this.currentIndex == this.data.length) return
    else this.currentIndex += 1
  }
  /**
   *
   */
}
</script>

<style lang='scss' scoped>
.popup-container {
  width: 420px;
  height: 240px;
  background-color: #ffffff;
  z-index: 99999;
  box-shadow: 0 1px 8px 0 rgba(32, 33, 36, 0.2);
  border-radius: 3px;
  padding: 10px;
  position: relative;
  .popup-title {
    width: 100%;
    height: 30px;
    line-height: 30px;
    .title_content {
      width: calc(100% - 100px);
      height: 100%;
      float: left;
      font-weight: 600;
      color: #616367;
      font-size: 18px;
    }
    .page-btn {
      width: 100px;
      height: 100%;
      float: left;
      color: #b3b4b4;
      text-align: center;
      > span {
        &:nth-child(2) {
          color: #333333;
        }
        &.page-control {
          cursor: pointer;
        }
      }
    }
  }
  .content_base {
    width: 100%;
    height: 30px;
    line-height: 30px;
    color: #6a6f74;
    > span {
      &:nth-child(n + 1) {
        margin-left: 5px;
      }
    }
  }
  .content_info {
    > p {
      margin-top: 10px;
      color: #6d6971;
      &.cause {
        line-height: 24px;
      }
      .location-btn {
        color: #2d74e7;
        cursor: pointer;
      }
    }
  }
  &::before {
    display: block;
    content: '';
    border-style: solid;
    border-color: transparent;
    border-width: 16px 14px 16px 14px;
    border-top-color: #ffffff;
    position: absolute;
    left: 50%;
    bottom: -27px;
    -webkit-filter: drop-shadow(-3px 0px 2px rgba(0, 0, 0, 0.2));
    filter: drop-shadow(0px 5px 3px rgba(0, 0, 0, 0.1));
    transform: translateX(-50%);
  }
}
</style>