<template>
  <section class="stage-wrapper">
    <section class="left" :style="{ width: lfBoxWid }">
      <div class="title">
        <div style="display: flex; align-items: center">
          <div style="padding-top: 5px; margin-right: 5px">
            <el-icon style="color: var(--el-color-primary) !important">
              <List />
            </el-icon>
          </div>
          <span class="zzjgxx" v-if="iconChange">组织机构信息</span>
        </div>
        <el-icon @click="handleCollapse" v-show="iconChange">
          <DArrowLeft />
        </el-icon>
        <el-icon @click="handleCollapse" v-show="!iconChange">
          <DArrowRight />
        </el-icon>
      </div>
      <div class="treeBox" :style="{ height: 'calc(100% - 70px)' }">
        <MOSTY.DepartmentTree width="100%" placeholder="管理部门ID" clearable filterable :searchType="'03'"
          @getdeptData="getdeptId" />
      </div>
    </section>
    <section class="right" :style="{ width: rgBoxWid }">
      <div class="header">
        <div class="topper">
          <span class="base">
            <el-icon>
              <WarningFilled />
            </el-icon>{{ tabTitle }}</span>
        </div>
        <div class="bottom">
          <el-tabs v-model="activeTab" type="card">
            <el-tab-pane :label="item.label" :name="item.value" v-for="(item, i) in tabs" :key="i" />
          </el-tabs>
          <!-- <div class="toggle" :class="{ active: !isOpen }" @click="onToggle">
            <span>{{ isOpen ? "收起" : "展开" }}</span>
            <el-icon>
              <DArrowLeft />
            </el-icon>
          </div> -->
        </div>
      </div>
      <div class="content">
        <div class="box" style="flex-grow: 0" v-if="isOpen">
          <Ccsstz v-if="activeTab == '1'" />
        </div>
        <div class="box" style="flex: 1">
          <CcsstzTable ref="ccsstzTableRef" v-if="activeTab == '1'" :isOpen="isOpen" :id="tabValue"
            :orgCode="orgCode" />
        </div>
      </div>
    </section>
  </section>
</template>

<script setup>
import { onMounted, ref, reactive, defineAsyncComponent, computed, provide } from "vue"
import Ccsstz from "./components/Ccsstz.vue"
import CcsstzTable from "./components/CcsstzTable.vue"
import * as MOSTY from "@/components/MyComponents/index"
// import { getApi } from "@/api/tobAcco_api.js";
const tabs = [
  {
    label: "三同时管理",
    ywId: "16",
    value: "1"
  }
]
const activeTab = ref("1")
const isOpen = ref(false)
const orgCode = ref("")
const tabTitle = computed(() => {
  return tabs.find(v => v.value == activeTab.value).label
})
const iconChange = ref(true)
const lfBoxWid = ref("300px")
const rgBoxWid = ref("calc(100% - 300px)")
const tabValue = computed(() => {
  return tabs.find(v => v.value == activeTab.value).ywId
})
const ccsstzTableRef = ref(null)
provide("ywId", tabValue)

const onToggle = () => {
  isOpen.value = !isOpen.value
}
const handleCollapse = () => {
  iconChange.value = !iconChange.value
  if (iconChange.value) {
    lfBoxWid.value = "330px"
    rgBoxWid.value = "calc(100% - 330px)"
  } else {
    lfBoxWid.value = "40px"
    rgBoxWid.value = "calc(100% - 40px)"
  }
}
const getdeptId = val => {
  orgCode.value = val.id
}
</script>

<style lang="scss" scoped>
.stage-wrapper {
  height: calc(100vh - 145px);
}

.stage-wrapper .header .topper {
  display: flex;
  align-items: center;

  >span {
    display: flex;
    align-items: center;
  }

  .base .el-icon {
    margin-right: 4px;
  }
}

.stage-wrapper .tip .el-icon {
  margin-top: 0;
}

.stage-wrapper .content {
  height: 100%;
  display: flex;
  flex-direction: column;

  .box {
    padding-top: 2px;
  }
}

.stage-wrapper .header .bottom .toggle .el-icon {
  margin-top: 0;
}

.stage-wrapper .header .bottom {
  display: flex;
  justify-content: space-between;
  padding-right: 10px;

  .toggle {
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;

    .el-icon {
      transform: rotate(90deg);
      transition: all 0.25s ease;
    }

    &.active {
      .el-icon {
        transform: rotate(-90deg);
      }
    }
  }
}

.stage-wrapper {
  display: flex;
  flex-direction: row;
}

.left {
  width: 300px;
  overflow: auto;
  background: #ffffff;
  box-shadow: 0px 2px 10px 0px rgba(107, 107, 107, 0.1);
  border-radius: 0px 0px 0px 0px;
  opacity: 1;

  .title {
    height: 60px;
    line-height: 60px;
    font-size: 18px;
    color: #0f3916;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .el-icon {
      cursor: pointer;
    }
  }

  .treeBox {
    overflow: auto;
  }
}

.right {
  padding-right: 10px;
  box-sizing: border-box;
  margin-left: 14px;
  background: #fff;
  width: 83%;
}
</style>
