<template>
  <div class="box">
    <div class="condition">
      <div class="header">
        <el-button style="float:left;" size="small" type="default" icon="el-icon-back" @click="goBack"></el-button>
        <span>{{params.name||''}}</span>
      </div>
      <el-row class="spaceTypes">
        <div class="types">
          <el-tabs v-model="activeTab" type='card'>
            <template v-for="(item,index) in tabsList">
              <el-tab-pane :name="item.Code" :key="index" :label="item.Name"></el-tab-pane>
            </template>
          </el-tabs>
        </div>
        <div class="deleBtn">
          <el-button size="small" @click="deleteCenote">删除竖井</el-button>
        </div>
      </el-row>
      <!-- 竖井内的设备 -->
      <device-table v-if="activeTab=='device'" :params="params" :type="activeTab"></device-table>
      <!-- 连通的其他竖井 -->
      <cenote-table v-else-if="activeTab=='cenote'" :params="params" :type="activeTab"></cenote-table>
      <!-- 竖井内系统 -->
      <system-table v-else-if="activeTab=='system'" :params="params" :type="activeTab"></system-table>
    </div>
  </div>
</template>

<script>
import { mapGetters } from "vuex"
import { deleteCenoteTableData } from '@/api/scan/request'
import cenoteTable from '@/components/ledger/cenote/table/cenoteTable'
import deviceTable from '@/components/ledger/cenote/table/deviceTable'
import systemTable from '@/components/ledger/cenote/table/systemTable'
export default {
  data() {
    return {
      params: {},
      tabsList: [
        { Code: 'device', Name: '竖井内的设备' },
        { Code: 'cenote', Name: '连通的其它竖井' },
        { Code: 'system', Name: '竖井内系统' },
      ], //tab页
      activeTab: 'device' //当前选中的tab
    }
  },
  computed: {
    ...mapGetters("layout", ["projectId", "userId", "secret"])
  },
  components: {
    cenoteTable,
    deviceTable,
    systemTable
  },
  created() {
    this.params = this.$route.query;
  },
  mounted() { },
  watch: {
    projectId() { }
  },
  methods: {
    // 返回
    goBack() {
      this.$router.push({ name: "cenotelist" })
    },
    // 删除业务空间
    deleteCenote() {
      this.$confirm("此操作将删除竖井，是否继续？", "提示", {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        deleteCenoteTableData([{ShaftID: this.params.ShaftID}], res => {
          this.$message.success('删除成功')
          this.goBack()
        })
      }).catch(() => {
        this.$message("取消删除")
      })
    }
  }
};
</script>

<style scoped lang='less'>
.box {
  .condition {
    padding: 10px;
    display: flex;
    height: 100%;
    flex-direction: column;
    border: 1px solid #dfe6ec;
    background: #fff;
    margin-bottom: 10px;
    .header {
      padding-bottom: 10px;
      span {
        line-height: 33px;
        margin-left: 15px;
      }
    }
    .spaceTypes {
      .types {
        float: left;
        width: calc(100% - 200px);
        /deep/ .el-tabs__item.is-top {
          border-top: 2px solid transparent;
          &.is-active {
            border-top: 2px solid #409eff;
          }
        }
      }
      .deleBtn {
        float: left;
        width: 200px;
        text-align: right;
        height: 40px;
        border-bottom: 1px solid #e4e7ed;
      }
    }
    .main {
      margin-top: 10px;
      height: calc(100% - 96px);
    }
    .footer {
      margin-bottom: 10px;
    }
  }
}
</style>

<style lang="less">
.el-table th {
  background-color: #d9d9d9;
  color: #000;
}
</style>

