<script setup lang='ts'>
import { TypeMap } from "~/pages/detail/util";
import Img from "~/assets/icon-no-data.png";

let fromZlb = localStorage.getItem('fromZlb') === '1'
const router = useRouter();
const route = useRoute();
let tmk_id = route.query.tmk_id;
let kcDetailData = $ref({});
let exam_list = $ref([]);

getDetail();
function getDetail() {
  request({
    url: "/txwx/mszy_kc/detail",
    data: {
      tmk_id,
    },
  }).then((res) => {
    if (res.code == "1") {
      kcDetailData = res.data.one_info;
      exam_list = kcDetailData.txwx_exam;
    }
  });
}
function showDetail(item) {
  router.push({
    path: "/exam/testQuestions",
    query: { tmk_id, te_id: item.te_id, tq_id: item.tq_ids },
  });
}
</script>

<template>
  <van-nav-bar :left-arrow="!fromZlb" title="检测" @click-left="() => router.back()" />
  <div>
    <ul v-if="exam_list.length > 0" class="res-list">
      <li v-for="item in exam_list" :key="item"  v-show="item.te_open == '1'">
        <h3 class="ml-10px flex-1 text-14px text-overflow color-171721">
          {{ item.te_name }}
        </h3>
        <button
          type="button"
          class="ml-10px file-btn"
          @click="showDetail(item)"
        >
          查看
        </button>
      </li>
    </ul>
    <div v-else class="py-40px text-center">
      <div>
        <img :src="Img" width="138" class="block m-0-auto" alt="" />
        <h3 class="text-18px color-050026 mt-20px">暂无数据，敬请期待！</h3>
      </div>
    </div>
  </div>
</template>
<style lang="scss" scoped>
.res-list {
  width: 100%;
  padding-top: 20px;
  li {
    display: flex;
    padding: 10px 20px;
    align-items: center;

    & + li {
      border-top: 1px dashed rgba(110, 88, 197, 0.5);
    }

    .file-btn {
      width: 58px;
      height: 24px;
      border: 1px solid #1259a1;
      border-radius: 12px;
      font-size: 12px;
      color: #1259a1;
      text-align: center;
    }
  }
}
</style>
