<template>
  <div class="box">
    <div class="wrap">
      <div class="img">
        <!-- <img :src="data.image" alt /> -->
        <el-image :src="data.image" fit="fill"></el-image>
      </div>
      <div class="content">
        <div class="tit">
          <span style="cursor: pointer" @click="handleDetail(data.id)"
            >姓名：{{ data.name }}</span
          >
          <!-- <div>
            <span style="vertical-align: middle">匹配度</span>
            <el-rate
              style="display: inline-block"
              v-model="state.val"
              disabled
            ></el-rate>
          </div> -->
        </div>
        <!-- <div class="labelList">
                    <div v-for="item in data.industrys">{{ item }}</div>
                </div>-->
        <div v-if="data.industrys" class="line" style="overflow: hidden">
          <el-col>所属领域：</el-col>
          <el-col
            :title="data.industrys[data.industrys.length - 1]"
            style="display: inline-block; width: calc(100% - 86px)"
          >
            <span
              style="
                display: inline-block;
                width: 100%;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
              "
              >{{ data.industrys[data.industrys.length - 1] }}</span
            >
          </el-col>
        </div>
        <div class="line">
          所在机构：
          <span>{{ data.research_name }}</span>
        </div>
        <div
          v-if="data.patent_title"
          class="line"
          v-for="(patent_title, index) in data.patent_title"
          :key="index"
        >
          {{ patent_title }}
        </div>
      </div>
      <div class="keywordsWrap">
        <div class="keywords">
          <wordcloud
            v-if="data.keywords"
            :data="createdData(data.keywords)"
          ></wordcloud>
        </div>
      </div>
    </div>
    <slot></slot>
  </div>
</template>

<script setup>
import wordcloud from "./wordcloud.vue";
import collectAndVisit from "./collectAndVisit.vue";
import { useRouter } from "vue-router";
const router = useRouter();
const props = defineProps({
  data: {
    type: Object,
    required: true,
  },
});

function handleDetail(id) {
  let routeData = router.resolve({ path: `/searchList/4/detail/${id}` });
  window.open(routeData.href, "_blank");
}

const state = reactive({
  val: 3,
});

function createdData(arr) {
  let l = [];
  let snap = JSON.parse(JSON.stringify(arr));
  snap.map((e) => {
    l.push({ name: e, value: 30 });
    return { name: e, value: 30 };
  });
  return l;
}
</script>

<style lang="scss" scoped>
.box {
  width: 100%;
  background: #ffffff;
  padding: 20px;
  box-sizing: border-box;
  .wrap {
    display: flex;
    flex-direction: row;
    .img {
      width: 90px;
      margin-right: 12px;
      margin-right: 10px;
      display: flex;
      align-items: center;
      justify-content: center;
      .el-image {
        width: 90px;
        height: 90px;
        border-radius: 50%;
      }
    }
    .keywordsWrap {
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .keywords {
      width: 129px;
      height: 129px;
    }
    .content {
      flex: 1;
      overflow: hidden;

      .labelList {
        overflow: hidden;
        div {
          padding: 2px 4px;
          float: left;
          background: #0054ff;
          border-radius: 4px;
          margin-right: 5px;
          margin-bottom: 5px;
          font-size: 14px;
          font-family: Source Han Sans CN;
          font-weight: 400;
          color: #ffffff;
        }
      }

      .line {
        font-size: 16px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #666666;
        margin: 10px 0;
        span {
          font-size: 16px;
          font-family: Source Han Sans CN;
          font-weight: 500;
          color: #333;
        }
      }
      .tit {
        overflow: hidden;

        display: flex;
        & > span {
          flex: 1;
          text-overflow: ellipsis;
          white-space: nowrap;
          font-size: 20px;
          font-family: Source Han Sans CN;
          font-weight: bold;
          color: #333333;
          overflow: hidden;
        }
        & > div {
          width: 175px;
          vertical-align: middle;
        }
      }
    }
  }
}
</style>
