<template>
  <div>
    <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
      <div class="nav">
        <div v-for="(item, index) in navtopData" :key="index" :class="{ 'nav-item-active': activeNav == index }"
          @click="clickNav(index)" class="nav-item" style="font-size: 12px;">
          {{ item.name }}
        </div>
      </div>
      <div class="mostHead" v-if="activeName == 'first' && activeNav == 0">
        <h2 style="display: inline-block;margin-right: 2px;font-size: 20px;">CID文件一次性检测</h2>
        <el-button type="primary" plain>结果导出Excel</el-button>
        <span class="closeX" @click="closeX">×</span>
      </div>
      <el-tab-pane label="网络结构图" name="first">
        <net-work v-if="activeName == 'first' && activeNav == null"></net-work>
        <div class="disappear" v-if="activeName == 'first' && activeNav == 0">
          <!-- 左侧树形数据 -->
          <div style="width: 15%;">
            <CidTree @treeBack="treeBack"></CidTree>
          </div>
          <!-- 右侧展示图 -->
          <div style="width: 85%; height: calc(100vh - 280px);position: relative;">
            <div class="abBox">
              <div>
                <span style="border-right: 1px solid black;padding-right: 300px;font-size: 12px;">
                  基准文件:asfsdgagdgf.cid
                </span>
              </div>
              <div>
                <span style="font-size: 12px;">
                  对比文件:asfsdgagdgf.cid
                </span>
              </div>
              <div class="uploadBox">
                <el-upload ref="upload" class="upload-demo" :http-request="nowUpload" :limit="1"
                  element-loading-text="上传中..." element-loading-background="rgba(255, 255, 255, 0.8)"
                  :on-remove="handleRemove" :on-change="fileSuccess" :show-file-list="false">
                  <template #trigger>
                    <el-button style="border-bottom: 1px solid #7BBAFD;" type="text" plain>上传CID</el-button>
                  </template>
                </el-upload>
              </div>
            </div>
            <Gsix :activeName="activeName" :activeNav="activeNav" :backName="backName" :mustVal="mustVal"></Gsix>
          </div>
        </div>
      </el-tab-pane>
      <el-tab-pane label="SCD可视化" name="second">Config</el-tab-pane>
    </el-tabs>
  </div>
</template>
  

<script setup>
import { ref } from "vue";
import netWork from "./components/netWork";
import CidTree from "./components/CidTree.vue";
import Gsix from "./components/Gsix.vue";
import { useRoute } from 'vue-router';
import cid from "@/api/cid/cid";
const activeName = ref("first");//默认展示网络结构图
const navtopData = ref([
  { name: "CID一致性校核" },
  { name: "SCD文件一致性校核" },
  { name: "SCL文件校核" },
  { name: "CRC校核" },
  { name: "虚端子关系图" },
]);
const activeNav = ref(null);
const backName = ref('')//树组件返回名称
let mustVal = ref(false)
let fileWater = ref({})//文件流
const clickNav = (navIndex) => {  //点击导航栏事件
  activeNav.value = navIndex;
}
const handleClick = (val) => {
  if (val.props.name == 'first') {
    activeNav.value = null
    activeName.value = val.props.name
  }
}
const treeBack = (data) => {
  backName.value = data
}
const closeX = () => {
  activeName.value = 'first'
  activeNav.value = null
}
const nowUpload = (file, e) => {
  console.log(file.file, '上传');
  fileWater.value = file.file
  cid.fileUpload({ station_id: 1, file: file.file }).then(res => {
    console.log(res, '文件上传');
  })
}
const handleRemove = (file, e) => {
  console.log(file, e, '删除');
}
const fileSuccess = (file, e) => {
  mustVal.value = true

}
</script>

<style scoped lang="scss">
$height: 40px;

@mixin mid-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

:deep(.el-tabs__item) {
  margin: 16px 0 0 32px;
  font-size: 18px;
}

:deep(.el-tabs__item:last-child) {
  margin-left: 0;
}

:deep(.el-tabs__nav-wrap::after) {
  --el-border-color-light: none;
}

:deep(.el-tabs__item.is-active),
:deep(.el-tabs__active-bar) {
  color: #255ce7;
}

:deep(.el-tabs__active-bar) {
  background-color: #255ce7;
}

//设置导航栏样式
.nav {
  @include mid-center;

  .nav-item {
    width: 144px;
    height: $height;
    @include mid-center;
    margin-right: 8px;
    cursor: pointer;
    background: #fff url("~@/assets/image/instruct/navtop.png") no-repeat center;
    background-size: 144px $height;
  }

  .nav-item-active {
    background: #fff url("~@/assets/image/instruct/navtop_active.png") no-repeat center;
    background-size: 144px $height;
  }
}

//最外层的滚动条不要
:deep(.el-main) {
  // overflow: hidden;
}

//ied的高度
:deep(.network-wrap) {
  height: 70vh;
  overflow: auto;
}

// 头部导出excel
.mostHead {
  width: 97%;
  height: auto;
  border-bottom: 1px solid #A3ADE0;
  margin: 0px auto;
  position: relative;
}

.closeX {
  font-size: 30px;
  position: absolute;
  top: 20px;
  right: 0px;
  cursor: pointer;
}

// CID显示
.disappear {
  width: 97%;
  height: calc(100vh - 260px);
  margin: 0 auto;
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

.abBox {
  width: 90%;
  height: 5%;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background-color: white;
  margin-left: 10px;
  position: relative;
}

.uploadBox {
  position: absolute;
  top: 0px;
  right: -100px;
}
</style>