<template>
  <Card title="环境监测">
    <div class="container">
      <div class="left list">
        <div class="list-item" v-for="(item, key) in leftList" :key="key">
          <div
            class="label"
            :style="{ backgroundColor: item.labelColor, color: item.color, transform: 'rotate(-90deg) translateX(-16px) translateY(-18px)' }"
          >{{ item.label }}</div>
          <div class="value">
            <div class="number">{{ item.value }}</div>
            <span class="unit">{{ item.unit }}</span>
          </div>
        </div>
      </div>
      <div class="right list">
        <el-row class="list-item" type="flex" justify="space-between" align="middle" v-for="(item, key) in rightList" :key="key">
          <el-col :span="6">
            <img style="width: 16px; height: auto" :src="item.image" />
          </el-col>
          <el-col :span="8">
            <div class="label">{{ item.label }}</div>
          </el-col>
          <el-col :span="10">
            <el-row
              class="value"
              type="flex"
              justify="center"
              align="middle"
              :style="{ color: item.color, backgroundImage: `url('${item.valueBackgroundImage}')` }"
            >
              <span class="number">{{ item.value }}</span>
              <span class="unit">{{ item.unit }}</span>
            </el-row>
          </el-col>
        </el-row>
      </div>
    </div>
  </Card>
</template>

<script>
import Card from '../components/Card'
export default {
  components: { Card },
  data() {
    return {
      // 左边的列表
      leftList: {
        'PM2.5': { label: 'PM2.5', value: 68, unit: 'μg/m³', labelColor: '#434337', color: '#ffc300' },
        PM10: { label: 'PM10', value: 36, unit: 'μg/m³', labelColor: '#3f353d', color: '#f46927' },
        噪音: { label: '噪音', value: 13, unit: '%dB', labelColor: '#434c5d', color: '#c6c9ce' }
      },
      // 右边的列表
      rightList: {
        temperature: { label: '温度', value: 22, unit: '℃', image: require('../assets/images/command-center/icon-temperature.png') },
        humidity: { label: '湿度', value: 16, unit: 'RH', image: require('../assets/images/command-center/icon-humidity.png') },
        windSpeed: {
          label: '风速',
          value: 60,
          unit: 'km/h',
          image: require('../assets/images/command-center/icon-windSpeed.png'),
          color: '#f66629',
          valueBackgroundImage: require('../assets/images/command-center/block3.png')
        },
        windDirection: { label: '风向', value: '东南', unit: '风', image: require('../assets/images/command-center/icon-windDirection.png') },
        barometricPressure: { label: '大气压', value: 101, unit: 'KPa', image: require('../assets/images/command-center/icon-barometricPressure.png') }
      }
    }
  },
  methods: {}
}
</script>

<style lang="less" scoped>
.container {
  box-sizing: border-box;

  display: flex;

  padding: 16px;
  width: 100%;
  height: 100%;

  .left,
  .right {
    width: 50%;
    height: 100%;
  }

  .left.list {
    display: flex;
    flex-direction: column;
    justify-content: space-between;

    .list-item {
      display: flex;
      justify-content: space-between;

      height: calc(100% / 3.5);

      .label {
        box-sizing: border-box;

        display: grid;
        place-items: center;
        padding: 0 5px;
        width: 55px;
        height: 20px;
        box-sizing: border-box;
        letter-spacing: 1px;
      }

      .value {
        box-sizing: border-box;
        padding-right: 20px;

        flex: 1;
        display: flex;
        justify-content: space-between;
        align-items: center;

        .number {
          display: grid;
          place-items: center;

          width: 77px;
          height: 44px;
          font-size: 30px;
          background-image: url('../assets/images/command-center/block2.png');
        }

        .unit {
          font-size: 18px;
          color: #b2b4be;
          font-weight: bold;
        }
      }
    }
  }

  .right.list {
    display: flex;
    flex-direction: column;
    justify-content: space-between;

    .el-row.value {
      width: 65px;
      height: 21px;
      .number {
        margin-right: 5px;
      }
    }
  }
}

::v-deep .el-col {
  display: grid;
  place-items: center;
}
</style>
