<template>
  <div class="ws-container">
    <el-scrollbar style="height: 100%; width: 100%">
      <dv-decoration-2 style="width: 90%; height: 5px" />
      <div v-for="key in Object.keys(deviceData ?? {})" :key="key">
        <div class="ws-title">
          {{ key }}
        </div>
        <div class="workshop-row">
          <div v-for="device in deviceData[key]" :key="device.id">
            <svg-icon
              :color="getColorByStauts(device.state + '')"
              icon-class="shebei"
              :size="bigScreenData.fontSize * 15"
            />
            <div
              :style="{ color: getColorByStauts(device.state + '') }"
              class="chanliang"
            >
              {{ device?.deviceName }}
            </div>
          </div>
        </div>
        <dv-decoration-2 style="width: 95%; height: 5px" />
      </div>
    </el-scrollbar>
  </div>
</template>

<script lang="ts" setup>
const colors = ["#4caf50", "#ffc107", "#b61945", "#607d8b"];
const bigScreenData: any = inject("bigScreenData");
const props = defineProps({
  deviceData: {
    type: Object || null,
    required: true,
  },
});

const getColorByStauts = (state: string) => {
  let status = state === "0" ? "on" : "off";
  switch (status) {
    case "on":
      return colors[0];
    case "off":
      return colors[1];
    case "warning":
      return colors[2];
    case "error":
      return colors[3];
    default:
      return "#fff";
  }
};
</script>

<style lang="scss" scoped>
.ws-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: start;
  justify-content: start;
  //padding: 5px 20px;
}

.ws-title {
  font-size: 2.2vh;
  color: #fff;
  margin-top: 5px;
}

.workshop-row {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: start;
  align-items: center;

  .chanliang {
    width: 100%;
    text-align: center;
    margin-bottom: 10px;
    font-size: 2.2vh;
  }
}
</style>
