<script setup lang="ts">
import { PropType } from 'vue';

interface VersionType {
  name: string;
  currentVersion: string;
  type: string;
  id?: string;
}
const props = defineProps({
  versionList: {
    required: true,
    type: Array as PropType<VersionType[]>,
    default: () => [],
  },
  title: {
    required: true,
    type: String,
    default: () => '',
  },
});
</script>
<template>
  <div v-if="versionList.length > 0" class="card">
    <div class="title">
      <span>{{ title }}</span>
    </div>
    <div class="firm-ware-version">
      <el-form label-width="auto" label-position="left">
        <el-form-item v-for="item in versionList" :key="item.name" :label="item.name">
          <span :id="item.id || item.name" class="label-width" :title="item.currentVersion">{{ item.currentVersion }}</span>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<style lang="scss" scoped>
.card {
  background: var(--o-bg-color-light);
  border-radius: 4px;
  width: calc((100% - 64px) / 4);
  min-width: 300px;
  margin-right: 16px;
  margin-bottom: 16px;
}
.title {
  width: 100%;
  height: 56px;
  background: var(--o-bg-color-light);
  box-shadow: inset 0 -1px 0 0 #dfe5ef;
  border-radius: 4px 4px 0 0;
  padding: 16px;

  span {
    line-height: 24px;
    font-size: 16px;
    color: var(--o-text-color-primary);
    font-weight: bolder;
    margin-left: 8px;
    vertical-align: super;
  }
}

.firm-ware-version {
  background: var(--o-bg-color-light);
  border-radius: var(--o-border-radius);
  padding: 24px;

  :deep(.el-form-item) {
    height: 16px;
    margin-bottom: 8px;
    &:nth-last-child(1) {
      margin: 0;
    }
  }

  :deep(.el-form-item__label) {
    padding-top: 0;
    padding-bottom: 0;
  }

  :deep(.el-form-item__content) {
    line-height: normal;
    color: #000000;
  }
  .label-width{
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
</style>
