<script setup lang="ts">
import { computed, PropType } from "vue";
import { model_OCR, model_mark, model_colour } from "./static";

defineOptions({
  name: "ModelCard"
});

interface CardProductType {
  isEnabled: boolean;
  state: string;
  description: string;
  deviceSort: string;
  type: number;
}

const props = defineProps({
  device: {
    type: Object as PropType<CardProductType>
  }
});

const cardClass = computed(() => [
  "model-card",
  { "model-card_offline": props.device?.state === "离线" }
]);

// const stateClass = computed(() => [
//   "model-state",
//   { "model-state_offline": props.device?.state === "离线" }
// ]);
</script>

<template>
  <div :class="cardClass">
    <div class="model-header">
      <div class="model-name">{{ device?.deviceSort }}</div>
      <div class="model-icon">
        <img :src="model_OCR" alt="" v-if="device?.type === 1" />
        <img :src="model_mark" alt="" v-else-if="device?.type === 2" />
        <img :src="model_colour" alt="" v-else />
      </div>
    </div>
    <div class="model-content">
      <div class="model-version">
        <i class="iconfont icon-banben model-content-icon" />
        版本: <span>{{ "V1.6.25" }}</span>
      </div>
      <div class="model-provider">
        <i class="iconfont icon-tigongfang model-content-icon" />
        提供方: <span>{{ "苏胜天" }}</span>
      </div>
      <div class="model-updateTime">
        <i class="iconfont icon-shijian model-content-icon" />
        更新时间: <span>{{ "2023.09.10" }}</span>
      </div>
      <div class="model-introduction">
        模型简介:
        <span>{{
          "针对企业人员是否有违章违规的问题，首先采用高性能的深度学习目标检测算法对图像中的人员进行定位等。"
        }}</span>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.model-card {
  box-sizing: border-box;
  width: 100%;
  height: 278px;
  border-radius: 8px;
  box-shadow: 0 8px 16px 0 rgb(0 0 0 / 10%);

  .model-header {
    position: relative;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    height: 88px;
    padding: 16px;
    font-size: 16px;
    font-weight: 700;
    color: #154ddd;
    background-image: url("../../../assets/model_header.png");
    background-repeat: no-repeat;
    background-position: 100% 100%;
    background-size: cover;
    border-radius: 8px 8px 0 0;

    .model-icon {
      position: absolute;
      top: 8px;
      right: 16px;
    }
  }

  .model-content {
    box-sizing: border-box;
    width: 100%;
    height: 190px;
    padding: 16px;

    .model-version,
    .model-provider,
    .model-updateTime {
      display: flex;
      align-items: center;
      justify-content: flex-start;
      margin-bottom: 8px;
      font-size: 14px;
      font-weight: 400;
      color: #666;

      .model-content-icon {
        margin-right: 8px;
        color: #154ddd;
      }

      span {
        color: #333;
      }
    }

    .model-introduction {
      font-size: 14px;
      font-weight: 400;
      color: #666;

      span {
        color: #333;
      }
    }
  }
}
</style>
