<template>
  <div class="main-content" style="position: absolute; left: 80px; z-index: 1">
    <!--<div class="left-box left" style="background-color: white;" v-if="searchList && searchList.length > 0">-->
    <div
      :id="searchId"
      class="left-box left"
      style="background-color: white"
      v-if="searchList && searchList.length > 0"
    >
      <!-- 搜索列表 有搜索结果时-->
      <!-- v-if="searchList && searchList.length > 0"  v-infinite-scroll="loadMore" :infinite-scroll-disabled="busy"-->
      <div
        class="search-list-wrap"
        infinite-scroll-distance="5"
        infinite-scroll-immediate-check="false"
      >
        <ul class="search-list">
          <li
            v-for="(searchLi, index) in searchList"
            @mousedown="handleSearchLiClick(searchLi)"
            :key="index"
          >
            <div class="left">
              <p class="disease-name" v-html="searchLi.name"></p>
              <div class="one-line">
                <p class="alias" v-html="searchLi.alias"></p>
                <p class="sign" v-if="searchLi.alias">|</p>
                <p class="code">{{ searchLi.hospitalName }}</p>
              </div>
            </div>
            <!--<div class="right" v-if="isSearchLiSelected(searchLi)"><i class="el-icon-check"></i></div>-->
          </li>
          <!--<p v-if="busy" class="loading">加载中...</p>-->
          <!--<p v-if="noMore" class="loading">没有更多了...</p>-->
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
import { $on, $off, $once, $emit } from '../../../utils/gogocodeTransfer'
let vm = null
export default {
  name: 'search-doctor',
  components: {},
  props: {
    searchList: {
      type: Array,
      default: [],
    },
    searchId: {
      type: Number | String,
      default: 100,
    },
  },
  created() {
    vm = this

    // $("#" + this.searchId).show();
  },
  data() {
    return {}
  },
  mounted() {
    // document.querySelector("#" + this.searchId).style.display = 'block';
  },
  methods: {
    handleSearchLiClick(searchLi) {
      console.log(this.searchId)
      $emit(this, 'handleSearchLiClick', {
        name: searchLi.name,
        mobilePhone: searchLi.mobilePhone,
      })
    },
  },
  emits: ['handleSearchLiClick'],
}
</script>

<style lang="scss">
.main-content {
  overflow: hidden;
  .left {
    float: left;
  }
  .left-box {
    width: 270px;
    height: 300px;
    .common-diagnose {
      width: 100%;
      height: 300px;
      .title {
        color: #303133;
        font-size: 16px;
        line-height: 40px;
        margin-top: 10px;
        .no-result {
          font-size: 14px;
          color: #e6a23c;
          margin-left: 28px;
        }
      }
      .list {
        width: 100%;
        height: 250px;
        overflow: hidden;
        overflow-y: scroll;
        /*.scroll-bar;*/
        padding: 10px;
        border: 1px solid #dcdfe6;
        li {
          height: 35px;
          line-height: 35px;
          padding: 0 15px;
          background: #fff;
          border: 1px solid #dcdfe6;
          color: #606266;
          cursor: pointer;
          font-size: 12px;
          &.active {
            color: #fff;
            background: #409eff;
            border-color: #409eff;
          }
          display: inline-block;
          margin: 0 10px 10px 0;
          border-radius: 4px;
          max-width: 350px;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
      }
    }
    .search-list-wrap {
      width: 100%;
      height: 290px;
      margin-top: 10px;
      border: 1px solid #dcdfe6;
      overflow: hidden;
      overflow-y: scroll;
      /*.scroll-bar;*/
      .search-list {
        border-radius: 4px;
        width: 100%;
        padding: 10px;
        li {
          position: relative;
          line-height: 30px;
          overflow: hidden;
          cursor: pointer;
          font-size: 12px;
          &:hover {
            background: #eee;
          }
          .left {
            width: 310px;
            float: left;
            span {
              color: #ff8429;
            }
            .disease-name {
              font-size: 14px;
            }
            .one-line {
              width: 100%;
              overflow: hidden;
              font-size: 12px;
              color: #aaa;
              .alias {
                float: left;
              }
              .sign {
                float: left;
                margin: 0 5px;
              }
              .code {
                float: left;
              }
            }
          }
          .right {
            position: absolute;
            right: 0;
            top: 50%;
            margin-top: -13px;
            // width: 0px;
            // float: left;
            display: inline-block;
            vertical-align: middle;
            i {
              font-size: 24px;
              color: #449284;
              font-weight: 700;
            }
          }
          .code {
            line-height: 30px;
          }
        }
        .loading {
          color: #ccc;
          text-align: center;
          margin: 0;
          font-size: 12px;
          margin-top: 5px;
        }
      }
    }
  }
  .choosed-list-wrap {
    width: 450px;
    height: 300px;
    margin-left: 30px;
    .title {
      color: #303133;
      font-size: 16px;
      line-height: 40px;
      margin-top: 10px;
    }
    .choosed-list {
      overflow: hidden;
      overflow-y: scroll;
      width: 450px;
      height: 250px;
      padding: 10px;
      border: 1px solid #dcdfe6;
      /*.scroll-bar;*/
      .el-tag {
        margin: 0 10px 10px 0;
        .text {
          display: inline-block;
          max-width: 342px;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
        .el-tag__close {
          top: -12px;
        }
      }
    }
  }
}
</style>
