<template>
  <div class="container">
    <div class="page-title">
      检索记录
    </div>

    <div class="card" v-for="item in lists" :key="item.id">
      <div>
        {{ tipsType[item.type] }}
      </div>
      <div class="name name1">
        <div class="text2">
          {{ item.createdAt }}
        </div>
        <div>
          {{ item.value ? "是" : "否" }}
        </div>
      </div>
      <div class="content">
        {{ item.content }}
      </div>

      <div class="imgs">
        <van-image
          style="margin-right:3px"
          :src="img"
          v-for="(img, imgIndex) in item.img"
          :key="imgIndex"
          fit="contain"
          @click="preview(imgIndex, item.img)"
        />
      </div>
    </div>
    <div class="card" v-for="item in list" :key="item.id">
      <div class="name">
        <div class="text1">
          其他
        </div>
        <div class="text2">
          {{ item.createdAt }}
        </div>
      </div>
      <div class="content">
        {{ item.content }}
      </div>

      <div class="imgs">
        <van-image
          :src="img"
          v-for="(img, imgIndex) in item.file"
          :key="imgIndex"
          fit="contain"
          @click="preview(imgIndex, item.file)"
        />
      </div>
    </div>

    <van-empty v-if="empty" description="暂无检索记录" />

    <div class="btn" v-if="lists.length < 1">
      <van-button
        :color="$colors.prim"
        block
        round
        @click="$router.push('recordAdd?recordId=' + recordId)"
        >添加检索记录</van-button
      >
    </div>
  </div>
</template>

<script>
import { ImagePreview } from "vant";
export default {
  metaInfo() {
    return {
      title: "检索记录"
    };
  },
  data() {
    return {
      recordId: "",
      list: [],
      lists: [],
      empty: false,
      tipsType: {
        examOrganization: "是否履行考前备案手续（此项为否，不再检查下面内容）",
        examSite: "是否在考场明显位置张贴《考级简章》",
        examRoom: "考场服务设施是否完善（候考室、指示标记、安全设施等）",
        environment: "考级时间与网上平台考前备案的考级时间是否一致",
        safetyq: "考场内有无相关专业考官且佩戴考官证",
        safetyw: "是否现场对考生艺术水平作出评定（美术专业除外）",
        safetye: "考级内容是否是所属考级机构教材确定的考级内容",
        safetyr:
          "是否在考场明显位置张贴《恢复开展社会艺术水平考级现场考级活动疫情防控措施指南》海报",
        safetyt: "考点是否配备测量体温设施设备，并有专人值守",
        safetys: "考级现场是否实施预约限流措施"
      }
    };
  },
  mounted() {
    this.recordId = this.$route.query.recordId;
    this.$http
      .post(
        "/recordCheck/all",
        {
          query: {
            recordId: this.recordId
          }
        },
        { body: "json" }
      )
      .then(res => {
        console.log(res);
        this.list = res.content;
        this.empty = res.empty;
      });
    this.$http
      .post(
        "recordExpertAudit/all",
        {
          query: {
            recordId: this.recordId
          }
        },
        { body: "json" }
      )
      .then(res => {
        console.log(res);
        this.lists = res.content;
        // this.empty = res.empty;
      });
  },
  methods: {
    preview(index, imgs) {
      ImagePreview({
        images: imgs,
        startPosition: index,
        closeable: true
      });
    }
  }
};
</script>

<style lang="less" scoped>
.btn {
  position: fixed;
  bottom: 0;
  padding: 6px 47px;
  left: 0;
  right: 0;
  z-index: 20;
  background: #fff;
}
.container {
  padding: 10px 20px 100px;
}
.page-title {
  font-size: 20px;
  font-weight: bold;
  color: #313233;
  line-height: 28px;
  padding: 16px;
  background: #ffffff;
  border-radius: 12px;
}

.card {
  background: #ffffff;
  border-radius: 12px;
  padding: 20px;
  margin-top: 12px;

  .name {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    .text1 {
      font-size: 16px;
      font-weight: bold;
      color: #313233;
      line-height: 28px;
    }

    .text2 {
      font-size: 12px;
      color: #969799;
      line-height: 17px;
    }
  }

  .content {
    font-size: 13px;
    color: #939599;
    line-height: 22px;
  }

  .imgs {
    display: flex;
    margin-top: 16px;

    .van-image {
      width: 72px;
      height: 72px;
      border-radius: 8px;
      overflow: hidden;
    }
  }
}
</style>
