<template>
  <div class="history-container">
    <div class="flex top">
      <div class="flex width200">
        <span> 系统选择：</span>
        <el-select v-model="value1" placeholder="请选择" size="mini">
          <el-option
            v-for="item in fxOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </div>
      <div class="date">
        <Date />
      </div>
    </div>
    <div v-for="(item, index) of listData" :key="index" class="middle">
      <BarEchart :echartData="item" class="echartDiv100" />
    </div>
    <div class="bottom">
      <!-- <el-table :data="tableData" style="width: 100%" border="1" height="360" class="table-left-header">
        <el-table-column v-for="item in tableHeader" :prop="item.prop" :label="item.label" />
      </el-table> -->
      <table border="1">
        <thead>
          <tr>
            <th>项目</th>
            <th colspan="17">降雨量(mm/s)</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>序号</td>
            <td v-for="(item, index) in tableHeader" :key="index">
              {{ item.label }}
            </td>
          </tr>
          <tr>
            <td>时间</td>
            <td v-for="(item, index) in tableHeader" :key="index">
              {{ item.time }}
            </td>
          </tr>
          <tr>
            <td>数值</td>
            <td v-for="(item, index) in tableHeader" :key="index">
              {{ item.value }}
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</template>

<script>
import { onMounted, reactive, ref, toRefs } from "vue";
import { ElMessage } from "element-plus";
import myApi from "@/api/myApi.js";
import BarEchart from "./BarEchart.vue";
import Process from "./Process.vue";
import Date from "@/components/Date.vue";
export default {
  name: "History",
  components: {
    BarEchart,
    Process,
    Date,
  },
  setup() {
    const state = reactive({
      listData: [
      {
          id: "echart0",
          title: "降水量-柱状图",
          legend: ["降水量"],
          color: ["#6fdbce"],
        },
        {
          id: "echart1",
          title: "降水量-柱状图",
          legend: ["降水量"],
          color: ["#6fdbce"],
        }
      ],
      fxOptions: [
        {
          value: "0",
          label: "降水量",
        },
        {
          value: "1",
          label: "系统A",
        },
        {
          value: "2",
          label: "系统B",
        },
        {
          value: "3",
          label: "系统C",
        },
        {
          value: "4",
          label: "系统D",
        },
        {
          value: "5",
          label: "系统E",
        },
      ],
      value1: "降水量",
      tableHeader: [
        {
          label: 1,
          time: "00:00",
          value: 78,
        },
        {
          label: 2,
          time: "01:00",
          value: 56,
        },
        {
          label: 3,
          time: "02:00",
          value: 45,
        },
        {
          label: 4,
          time: "03:00",
          value: 66,
        },
        {
          label: 5,
          time: "04:00",
          value: 86,
        },
        {
          label: 6,
          time: "05:00",
          value: 11,
        },
        {
          label: 7,
          time: "06:00",
          value: 13,
        },
        {
          label: 8,
          time: "07:00",
          value: 55,
        },
        {
          label: 9,
          time: "08:00",
          value: 76,
        },
        {
          label: 10,
          time: "09:00",
          value: 65,
        },
        {
          label: 11,
          time: "10:00",
          value: 80,
        },
        {
          label: 12,
          time: "11:00",
          value: 90,
        },
        {
          label: 13,
          time: "12:00",
          value: 34,
        },
        {
          label: 14,
          time: "13:00",
          value: 89,
        },
        {
          label: 15,
          time: "14:00",
          value: 34,
        },
        {
          label: 16,
          time: "15:00",
          value: 90,
        },
         {
          label: 17,
          time: "16:00",
          value: 45,
        },
      ],
    });
    onMounted(async () => {});

    return {
      ...toRefs(state),
    };
  },
};
</script>

<style lang="scss" scoped>
.history-container {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: space-between;
  flex-direction: column;
  padding: 10px;
  .top {
    width: 100%;
    height: 50px;
  }
  .middle {
    width: 100%;
    height: 400px;
    // border: 1px solid red;s
    .echartDiv100 {
      width: 100%;
      height: 100%;
      margin: 0 auto;
    }
  }
  .bottom {
    height: calc(100% - 520px);
    // border: 1px solid red;
  }
  .date {
    width: 100%;
    display: flex;
    justify-content: end;
    height: 50%;
  }
  .width200 {
    width: 200px;
    > span {
      display: inline-block;
      width: 180px;
    }
  }
  table {
    border-collapse: collapse;
    width: 100%;
    height: 200px;
    td {
      text-align: center;
    }
    th {
      height: 50px;
    }
    th:first-child {
      background: #ddd;
    }
    tr {
      td:first-child {
        background: #ddd;
      }
    }
  }
}
</style>
