<template>
  <div class="manage-container">
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane :label="$t('sensor.dqsj')" name="first">
        <current-data ref="current"></current-data>
      </el-tab-pane>
      <el-tab-pane :label="$t('sensor.lssj')" name="second">
        <history-data ref="history"></history-data>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import currentData from './currentData';
import historyData from './historyData';
export default {
  components: {
    currentData,
    historyData,
  },
  data() {
    return {
      activeName: 'first',
      dataKey: '',
      startDate: '',
      queryForm: {
        page: 1,
        size: 200,
        dataKey: '',
        deviceCode: '',
        start: '',
        end: '',
      },
    };
  },
  computed: {
    height() {
      return 500;
    },
  },
  created() {
    this.queryForm.dataKey = this.$route.query.dataKey;
    this.queryForm.deviceCode = this.$route.query.deviceCode;
  },
  methods: {
    handleClick(tab, event) {
      console.log(tab, event);
      if (tab.paneName == 'second') {
        this.$refs['history'].showData({
          dataKey: this.queryForm.dataKey,
          deviceCode: this.queryForm.deviceCode,
        });
      } else {
        this.$refs['current'].showData({
          dataKey: this.queryForm.dataKey,
          deviceCode: this.queryForm.deviceCode,
        });
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.manage-container {
  width: 100%;
  .el-form-item {
    width: 360px;
  }
}
</style>
