<template>
  <div class="top-box">
    <el-form
      :model="form"
      label-width="auto"
      :inline="true"
      class="demo-form-inline"
    >
      <el-form-item label="除尘器名称">
        <el-select
          v-model="form.dustName"
          placeholder="请选择除尘器"
          style="width: 240px"
        >
        </el-select>
      </el-form-item>
      <el-form-item label="分析时间">
        <el-date-picker
          v-model="form.dateValue"
          type="datetimerange"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          format="YYYY-MM-DD HH:mm:ss"
          date-format="YYYY/MM/DD ddd"
          time-format="A hh:mm:ss"
        />
      </el-form-item>
    </el-form>
  </div>
  <div class="layout1">
    <div class="left-box">
      <div class="part1">
        <div class="chart-box" v-for="(item, index) in chartData" :key="item">
          <div :id="'chart' + index" class="chart-item"></div>
        </div>
      </div>
      <div class="warn-info"></div>
    </div>
    <div class="right-box">
      <div class="part1"></div>
      <div class="part2">
        <div class="dust-title">2号窑尾除尘器</div>
        <div class="dust-info">
            <div class="info-item" v-for="item in dustInfo" :key="item.label">
                <span class="lable">{{ item.label }}</span>
                <span class="value">{{ item.value }}</span>
                <span class="unit">{{ item.unit }}</span>
            </div>
        </div>
      </div>
      <div class="warn-info"></div>
    </div>
  </div>
</template>
<script setup>
import { ref, reactive, onMounted } from "vue";
import * as echarts from "echarts";
const form = reactive({
  dustName: "",
  dateValue: [],
});
const option = {
  xAxis: {
    type: "category",
    data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
  },
  yAxis: {
    type: "value",
  },
  series: [
    {
      data: [820, 932, 901, 934, 1290, 1330, 1320],
      type: "line",
      smooth: true,
    },
  ],
};
const chartInstance = reactive([]);
const chartData = reactive([{}, {}, {}]);
const initChart = () => {
  chartData.forEach((item, index) => {
    if (chartInstance[index] && chartInstance[index].dispose) {
      chartInstance[index].dispose();
    }
    chartInstance[index] = echarts.init(
      document.getElementById("chart" + index)
    );
    console.log(chartInstance[index]);
    chartInstance[index].setOption(option);
  });
};
const dustInfo = reactive([
    {label: '压差', value: '0.0', unit: 'KPa'},
    {label: '粉尘浓度', value: '0.0', unit: 'KPa'},
])
onMounted(() => {
  initChart();
});
</script>
<style lang="scss" scoped>
.top-box {
}
.left-box {
  width: 45%;
  .part1 {
    border-radius: 15px;
    background-color: #fff;
    width: 100%;
    height: 100%;
    height: 70vh;
    .chart-box {
      width: 100%;
      height: 31%;
      .chart-item {
        width: 100%;
        height: 100%;
      }
    }
  }
}
.right-box {
  width: 45%;
  .part1 {
    width: 100%;
    height: 10vh;
    border-radius: 15px;
    background-color: #fff;
  }
  .part2 {
    margin-top: 20px;
    width: 100%;
    height: calc(60vh - 20px);
    border-radius: 15px;
    background-color: #fff;
    .dust-title {
        text-align: center;
        font-size: 20px;
        font-weight: 600;
        padding: 10px;
        border: 1px solid #ebeef5;
    }
    .dust-info {
        padding: 0 20px;
    }
    .info-item {
        padding: 3px 0;
        span {
            display: inline-block;
        }
        .lable {
            width: 40%;
        }
        .value {
            width: 50%;
        }
        .unit {
            width: 10%;
        }
    }
  }
}
.warn-info {
  margin-top: 10px;
  height: 15vh;
  border-radius: 15px;
  background-color: #fff;
}
.layout1 {
  display: flex;
  justify-content: space-between;
}
</style>
