<template>
  <el-dialog title="参数预警" :visible.sync="dialogVisible" width="90%" :before-close="handleClose">
    <el-container>
      <el-aside width="600px">
        <warn-left
          ref="warnLeft"
          :geprDayList="geprDayList"
          :startDate="startDate"
          :endDate="endDate"
          @closeDis="closeDis"
        ></warn-left>
      </el-aside>
      <el-main style="padding: 0px">
        <warn-right
          ref="warnRight"
          :geprDayList="geprDayList"
          :startDate="startDate"
          :endDate="endDate"
          style="padding: 0px"
        ></warn-right>
      </el-main>
    </el-container>
    <!-- <div class="page">
      <div class="left">
       
      </div>
      <div class="right">
        
      </div>
    </div> -->
    <span slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">关 闭</el-button>
    </span>
  </el-dialog>
</template>

<script>
import warnLeft from './warn_left.vue'
import warnRight from './warn_right.vue'
import vueBusEvents from '@/utils/vueBusEvents'
import events from '@/views/top/events'
import vue from 'vue'
const lsJhKey = 'TOPLEFT_JH_SELECTED'
import { TOP_WELL_CHOOSEN } from '@/store/mutation-types'
import moment from 'moment'
import newWarnApi from '@/api/newWarnApi.js'
export default {
  components: {
    warnLeft,
    warnRight
  },
  data() {
    return {
      dialogVisible: false,
      geprDayList: [],
      startDate: '',
      endDate: ''
    }
  },
  methods: {
    init() {
      this.dialogVisible = true
      this.getGroupDate()
    },
    handleClose() {
      this.dialogVisible = false
    },
    closeDis(record) {
      console.log('被调用', record)
      this.$bus.emit(vueBusEvents.closeGCYJ)
      this.selectedJh = record.JH
      this.$store.commit('serchJhSet', record.JH)
      vue.ls.set(lsJhKey, record)
      this.$store.commit(TOP_WELL_CHOOSEN, record)
      events.$emit('jhSelected', { jh: record.JH, record, tid: moment().unix() })
      this.$bus.emit(vueBusEvents.closeSideBar)
      this.dialogVisible = false
      // 202211
      this.timeRange = 1
      this.$router.push({ name: 'top', query: { jh: this.selectedJh } })
    },
    getGroupDate() {
      newWarnApi.groupData().then(res => {
        console.log(res)
        this.geprDayList = res.result
        this.startDate = res.result[(res.result.length - 1)]
        this.endDate = res.result[0]
      })
    },
  }
}
</script>

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