<template>
  <div style="padding-top: 13vw">
    <TopNav navTitle="人员列表" :showRight="false" :showLeft="true" />
    <ul class="people-box">
      <li class="people-item boxItem" v-for="(item, index) in dataList" @click="lookDetail(item)" :key="index">
        <div class="text">相似度{{ item.xsd }}%</div>
        <div class="item-left">
          <van-image @click.stop="ImagePreview([item.baseUrl])" :src="item.baseUrl">
            <template v-slot:loading>
              <van-loading type="spinner" size="20" />
            </template>
          </van-image>
        </div>
        <div class="item-right">
          <div class="info">姓名 ：{{ item.xm }}</div>
          <div class="info">性别 ：{{ item.xbdm == "1" ? "男" : "女" }}</div>
          <div class="info">出生日期 ：{{ item.csrq }}</div>
          <div class="info">身份证号 ：{{ item.sfzh }}</div>
        </div>
      </li>
    </ul>
  </div>
</template>
<script>
export default {
  name: "peopleList",
};
</script>
<script setup>
import TopNav from "../../../components/topNav.vue";
import { onMounted, ref } from "vue";
import { useRouter, useRoute } from "vue-router";
import { selectRx } from "../../../api/common.js";
import { ImagePreview } from "vant";
import { hintToast, getBase64 } from "../../../utils/tools.js";
const router = useRouter();
const route = useRoute();
const dataList = ref([]);
onMounted(() => {
  let str = route.query.info;
  let data = new FormData();
  data.append("base64Str", str);
  selectRx(data).then((res) => {
    if (res && res.length > 0) {
      dataList.value = res.slice(0, 10);
      dataList.value.forEach((item) => {
        getBase64((url) => {
          item.baseUrl = url;
        }, item.url);
      });
    } else {
      hintToast("未查到人员信息");
    }
  });
});
//获取base64地址
function _getBase64(item) {
  getBase64((res) => {
    item.baseUrl = res;
  }, item.url);
}
// 查看详情
function lookDetail(item) {
  router.push({
    path: "/quarantinePersonnel",
    query: { sfzh: item.sfzh, pcsrlx: "5" },
  });
}
</script>

<style lang="scss" scoped>
.people-box {
  padding: 4vw;
  box-sizing: border-box;

  .people-item {
    display: flex;
    border: 1px solid #e9e9e9;
    padding: 2vw;
    border-radius: 1vw;
    margin-bottom: 2vw;
    position: relative;
    overflow: hidden;

    .text {
      position: absolute;
      right: -21px;
      top: 17px;
      width: 106px;
      text-align: center;
      height: 22px;
      line-height: 24px;
      background: red;
      font-size: 12px;
      color: #fff;
      transform: rotate(42deg);
    }

    .item-left {
      width: 22vw;
      margin-right: 2vw;
      text-align: center;

      ::v-deep .van-image {
        width: 22vw;
        max-height: 27vw;

        img {
          width: 22vw;
          max-height: 27vw;
        }
      }

    }

    .item-right {
      flex: 1;

      .info {
        line-height: 7vw;
      }
    }
  }
}
</style>