<template>
  <PathMap :resultItem="resultItem" :layersData="layersData" />
  <PathHeader />
  <PathLeftEcharts @changeLeftMenuShow="changeLeftMenuShow" />
  <PathLayers @changeMapLayers="changeMapLayers" />

  <div class="inpbox" :class="!btnVisible?'':'active'">
    <a-input-search
      v-model:value="searchValue"
      placeholder="请输入编号或名称搜索"
      enter-button
      @search="onSearch"
    />
  </div>
  <!-- 搜索结果 -->
  <div class="flex searchresultbox column" :class="!btnVisible?'':'active'" v-if="resultVisible">
    <div class="flex title ai-c jc-sb">
      <span>搜索结果</span>
      <CloseCircleOutlined style="fontSize: 20px;color:#fff;cursor:pointer" @click="closeResultModel" />
    </div>
    <div class="resultbox">
      <div v-for="(item,index) in resulteDataArr" @click="resultClick(item)">
        <div class="flex libox">
          <span class="span">{{ index + 1 }}</span>
          <div>
            <div class="name textbox">{{ item.syrmc }}</div>
            <div class="textbox">{{ item.djqmc + item.djzqmc }}</div>
            <div class="textbox">建筑物名称：{{ item.jzwmc }}</div>
            <div class="textbox">土地性质：{{ item.tdxz }}</div>
            <div class="textbox">法人：{{ item.frdb }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
  
</template>
<script lang="ts" setup>
  import { ref, watch, onMounted, computed } from 'vue';
  import { PathMap, PathHeader, PathLeftEcharts, PathLayers } from './index';
  import { CloseCircleOutlined } from '@ant-design/icons-vue';
  import { GetTaxBuildingInfo, GetTaxZongdiInfo } from '@/api/ziranziyuan/index';

  const btnVisible = ref(true)
  const resultVisible = ref(false)
  const searchValue = ref()
  const resulteDataArr = ref()
  const resultItem = ref()
  const layersData = ref()
  
  function changeLeftMenuShow(e) {
      btnVisible.value = e
  }
  function closeResultModel(){
    resultVisible.value = false
  }
  function onSearch(){
    GetTaxBuildingInfo({name: searchValue.value}).then(res =>{
      resulteDataArr.value = res
      resultVisible.value = true
    })
  }
  function resultClick(e){
    resultItem.value = e
  }
  function changeMapLayers(e){
    layersData.value = e
  }
                     
</script>
<style scoped>
.flex{
  display: flex;
}
.column{
  flex-direction: column;
}
.ai-c{
  align-items: center;
}
.jc-c{
  justify-content: center;
}
.jc-sb{
  justify-content: space-between;
}
.js-sa{
  justify-content: space-around
}
.searchresultbox{
  width: 280px;
  height: 600px;
  padding: 0 20px;
  background: rgba(0,0,0,0.6);
  position: absolute;
  top: 200px;
  left: 50px;
  .title{
    height: 50px;
    color: #fff;
    font-size: 14px;
    border-bottom: 1px dashed #E9F1F8;
  }
  .resultbox{
    height: calc(100% - 70px);
    margin-top: 10px;
    overflow: auto;
    .libox{
      height: 150px;
      color: #fff;
      font-size: 14px;
      .span{
        background: #f00;       
        font-size: 12px;
        width: 25px;
        height: 25px;
        border-radius: 25px;
        text-align: center;
        line-height: 25px;
        margin-right: 8px;
      }
      .name{
        color: #2A7F6F;   
        font-size: 16px;  
        font-weight: bold;
      }
      .textbox{
        line-height: 25px;
      }
    }
  }
}
.searchresultbox.active{
  left: 400px;
}
.inpbox{
  width: 280px;
  height: 30px;
  position: absolute;
  top: 100px;
  left: 50px;
}
.inpbox.active{
  left: 400px;
}
</style>