<template>
  <div>
    <template v-if="showPage === 'history'">
      <a-tabs type="card">
        <a-tab-pane key="historyData">
          <span slot="tab">
            <a-icon type="file-text" />
            历史数据
          </span>
          <!-- <interlock-history-index></interlock-history-index> -->
          <div class="iotmenu-content">
            <u-equipment-tree-drag treeTitle="装置系统" @select="selectEquipment" :hasHandleBtn="false">
              <interlock-history-list ref="summaryList" @click="historyListClick"></interlock-history-list>
              <!-- :selectData="selectData"  -->
            </u-equipment-tree-drag>
          </div>
        </a-tab-pane>
        <a-tab-pane key="timedReport">
          <span slot="tab">
            <a-icon type="file-text" />
            定时报表
          </span>
          <div class="iotmenu-content">
            <interlock-timed-report></interlock-timed-report>
          </div>
        </a-tab-pane>
      </a-tabs>
    </template>
    <!-- 详情 -->
    <interlock-detail-list v-if="showPage === 'detail'" @click="showPage='history'" ref="summaryDetailRef" :currentData="currentData"></interlock-detail-list>
  </div>
</template>

<script>
  import InterlockHistoryList from './InterlockHistoryList.vue'
  import InterlockTimedReport from '../interlockTimedReport/InterlockTimedReportList.vue';
  import InterlockDetailList from '../interlockHistoryDetail/InterlockHistoryDetailList.vue';
  export default {
    name: '',
    components: {
      InterlockHistoryList,
      InterlockTimedReport,
      InterlockDetailList,
    },
    data () {
      return {
        showPage: 'history',
        // selectData: {},
        currentData: {}
      }
    },
    created () {
      this.$store.commit('SET_CLICKSYSTEMNODE', {});
      this.$store.commit('SET_TREESELECTKEYS', []);
      this.$store.commit('SET_TREEEXPANDEKEYS', []);
    },
    mounted () {
    },
    // beforeDestroy() {
    //   this.$store.commit('SET_CLICKSYSTEMNODE', {});
    //   this.$store.commit('SET_TREESELECTKEYS', []);
    //   this.$store.commit('SET_TREEEXPANDEKEYS', []);
    //   console.log('s2222222', this.$store.getters.treeExpandedKeys)
    // },
    methods: {
      selectEquipment(selectedKeys,e){
        // if (selectedKeys.length <= 0) {
        //   // 左侧树重置
        //   this.selectData.interlockType = null
        //   this.selectData.pid = null
        //   this.selectData.id = null
        // } else {
        //   let interlockChooseData = e.selectedNodes[0].data.props
        //   this.selectData.interlockType = interlockChooseData.interlockType
        //   this.selectData.pid = interlockChooseData.pid
        //   this.selectData.id = interlockChooseData.id
        // }
        this.$refs.summaryList.loadData();
      },
      historyListClick(data){
        this.showPage = 'detail'
        this.currentData = data
      },
    }
  }
</script>

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