<template>
  <div class="device-summary">
    <div class="left">
      <div class="title">{{ title }}</div>
      <img class="device-img" :src="leftImage" alt="" />
    </div>
    <div class="right">
      <div v-for="item in list" :key="item.label" class="row">
        <div class="label">{{ item.label }}</div>
        <div class="bar">
          <div class="fill" :style="{ width: item.percent + '%' }"></div>
        </div>
        <div class="value">{{ item.value }}</div>
      </div>
    </div>
  </div>
</template>

<script>
import leftImage from "@/assets/index/b.png";

export default {
  name: "DeviceSummary",
  props: {
    title: {
      type: String,
      default: "阀门井",
    },
    list: {
      type: Array,
      default() {
        return [
          { label: "在线设备", value: 230, percent: 80 },
          { label: "离线设备", value: 30, percent: 20 },
          { label: "报警设备", value: 3, percent: 10 },
          { label: "故障设备", value: 3, percent: 10 },
        ];
      },
    },
  },
  data() {
    return {
      leftImage,
    };
  },
};
</script>

<style lang="scss" scoped>
.device-summary {
  display: flex;
  align-items: center;
  background: #000;
  color: #fff;
  font-size: 14px;
  width: 500px;
}

.left {
  position: relative;
  width: 230px;
  height: 210px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  margin-right: 18px;
}

.title {
  position: absolute;
  top: 18px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: #a9ddff;
}

.device-img {
  width: 220px;
  height: 200px;
  object-fit: contain;
}

.right {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row {
  display: flex;
  align-items: center;
  height: 28px;
  background: rgba(12, 135, 220, 0.9);
  padding: 0 10px;
}

.label {
  width: 70px;
  color: #e7f6ff;
}

.bar {
  flex: 1;
  height: 10px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  margin: 0 10px;
  overflow: hidden;
}

.fill {
  height: 100%;
  background: linear-gradient(90deg, #0bd6ff 0%, #27a0ff 100%);
}

.value {
  width: 36px;
  text-align: right;
  font-weight: 600;
}
</style>
