<template>
  <div class="list_box" @click="onGoDetail()">
    <div class="time_box">
      <span>
        <van-icon name="clock-o" />
        &ensp;{{ item.yjFssj }}
      </span>
      <span v-if="item.yjJrcs">
        今日预警<span class="count_size">{{ item.yjJrcs }}</span>次
      </span>
      <span v-if="item.yjJb">
        <van-tag type="danger" style="padding: 0.3vw 5vw; border-radius: 3vw" v-if="item.yjJb == '10'">红色</van-tag>
        <van-tag type="warning" style="padding: 0.3vw 5vw; border-radius: 3vw" v-else-if="item.yjJb == '20'">橙色
        </van-tag>
        <van-tag color="#ffcc40" style="padding: 0.3vw 5vw; border-radius: 3vw" v-else-if="item.yjJb == '30'">黄色
        </van-tag>
        <van-tag type="primary" style="padding: 0.3vw 5vw; border-radius: 3vw"
          v-else-if="item.yjJb == '40'">蓝色</van-tag>
      </span>
    </div>
    <div class="detail_box">
      <van-image width="80px" height="85px" :src="baseUrl" style="flex: 1" @click.stop="ImagePreview([baseUrl])"
        v-if="baseUrl">
        <template v-slot:loading>
          <van-loading type="spinner" size="20" />
        </template>
      </van-image>
      <div class="detail_item">
        <div class="item user_info">
          <span v-if="item.yjClcph">{{ item.yjClcph }}</span>
          <span>{{ item.yjRyxm }}</span>
          <span v-if="item.mz">{{ item.mz }}</span>
          <span>{{ item.yjRysfzh }}</span>
          <span v-if="item.yjLx == '5'">{{ item.yjBt }}</span>
        </div>
        <div class="item">
          <van-tag type="primary" style="padding: 0 2vw; margin-right: 2vw" plain>{{
            item.yjbqmc ? item.yjbqmc : setDict(item.yjLx, dict.D_BZ_YJLX)
          }}</van-tag>
        </div>
        <div class="item">地址：{{ item.yjDz || item.yjGzymc }}</div>
        <div class="item">管辖派出所：{{ item.ssbm }}</div>
      </div>
      <img src="../assets/images/zwzl.png" class="zwzl_box" v-if="item.sfFszl > 0" />
    </div>
  </div>
</template>

<script setup>
import router from "../router/index.js";
import { getBase64 } from "../utils/tools.js";
import { defineProps, ref, onMounted, watch } from "vue";
import { getDictList, setDict } from "../utils/dict";
import { ImagePreview } from "vant";
// const { D_BZ_YJLX, D_BZ_TYJB } = getDictList("D_BZ_YJLX", "D_BZ_TYJB"); //字典信息
const props = defineProps({
  item: Object, //列表内容
  path: String, //跳转详情的路由
  dict: {
    type: Object,
    default: {
      D_BZ_YJLX: [],
      D_BZ_TYJB: [],
    },
  },
});
watch(
  () => props.item,
  (newValue) => {
    if (Object.keys(newValue).length > 0) _getBase64(newValue);
  },
  { immediate: true, deep: true }
);
const baseUrl = ref("");
//跳转

function onGoDetail() {
  try {
    router.push(props.path);
  } catch (error) { }
}
//获取base64地址
function _getBase64(item) {
  getBase64((res) => {
    baseUrl.value = res;
  }, item.yjTp);
}
</script>
<style lang="scss" scoped>
@import "../assets/styles/mixin.scss";

.list_box {
  @include font_size($font_medium_s);
  @include font_color($font-color-theme);
  margin: 0vw 2vw 2vw 2vw;
  padding: 2vw 1vw;
  @include item_bottom_color($bottom-border-top-clore-theme);

  .time_box {
    display: flex;
    justify-content: space-between;
    align-items: center;

    .count_size {
      font-size: 5vw;
      display: inline-block;
      margin: 0 1vw;
      color: red;
    }
  }
}

.list_box:nth-child(1) {
  border-top: none !important;
}

.detail_box {
  margin-top: 1vw;
  display: flex;
  position: relative;

  .detail_item {
    flex: 3.5;
    margin-left: 2vw;

    .user_info {
      @include font_size($font_medium);
      font-weight: 600;
      color: #507ce9;

      &>span {
        display: inline-block;
        margin-right: 2vw;
      }
    }

    .item {
      line-height: 6vw;
    }
  }
}
</style>
