<template>
  <div class="container">
    <el-row :gutter="20">
      <el-col :span="12">
        <el-card>
          <template #header>
            实时水位（米）
          </template>
        </el-card>
        <el-card style="margin-top: 10px;">
          <template #header>
            当日累计雨量（毫米）
          </template>
        </el-card>
      </el-col>
      <el-col :span="12">
        <el-card>
          <template #header>
            闸门开度/堰闸顶高（米）
          </template>
        </el-card>
        <el-card style="margin-top: 10px;">
          <template #header>
            机组实时状态
          </template>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { info, weather, infoStatics } from "@/api/other";
import { index, save } from "@/api/system/baseForm";

export default {
  data() {
    return {
      weather: {},
    }
  },
  methods: {
    async getWeatherInfo () {
      let infoObj = {
        weather: '',
        water: '',
        rain: '',
        prevent: '',
        early_warning: ''
      }
      const weatherInfo = await weather()
      infoObj.weather = `${weatherInfo.weather},${weatherInfo.wD}${weatherInfo.wS},${weatherInfo.sendibleTemp}-${weatherInfo.temp}°C`
      const info = await infoStatics()
      console.log(info)
    },

    async getWeather () {
      const res = (await index({
        table_name: 'waters',
        filter: [
          {
            key: 'date',
            op: 'eq',
            value: this.$moment().format('YYYY-MM-DD')
          }
        ]
      },false)).data[0]

      if (!res) {
        await this.getWeatherInfo()
      } else {
        this.weather = res
      }
    }
  },
  computed: {},
  created() {
    //this.getWeather()
    this.getWeatherInfo()
  }
}
</script>

<style scoped lang="scss">
</style>
